Somebody help me please!! ramp and pulse train combination

Use this forum to post Vensim related questions.
mongjie88
Junior Member
Posts: 4
Joined: Fri Jan 20, 2017 11:13 am
Vensim version: PLE

Somebody help me please!! ramp and pulse train combination

Post by mongjie88 »

Hi there!!

I started to use Vensim PLE (the free version) just a couple of weeks ago, so I have still a long way to go. I would like to ask the following questions:

1- How can I ovecome the problem 'simulataneous equations' using the Vensim PLE? is there any trick there? The built in functions in Vensim PLE are very scarce.

2. I would like to generate a signal that is a mixture between a ramp and a pulse train, something like this ___/I___/l___/l__, those anyone knows how to do that??

I would really appreaciate, if someone can help me out!

Thanks in advance!

cheers
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: Somebody help me please!! ramp and pulse train combination

Post by tomfid »

1 - Every feedback loop must have a stock in it. This is not only a PLE limitation, it's also reality. A simultaneous equation loop might be a workaround for some "stiff model" situation, like a rapid market-clearing process embedded in a model with slow dynamics, but more often it's a conceptual mistake. To say more, we'd have to understand your specific instance.

2 - One easy option would be to use a lookup. Another possibility would be something like

x = MODULO( time/peak interval, 1 )

This will give a sawtooth, which you can then stretch or clip as needed to get the shape you're after.
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Somebody help me please!! ramp and pulse train combination

Post by Administrator »

mongjie88 wrote:1- How can I ovecome the problem 'simulataneous equations' using the Vensim PLE? is there any trick there? The built in functions in Vensim PLE are very scarce.
Can you post the model here so we can take a look? Simultaneous equations are common, and usually easily fixed with an adjustment to the logic used in the model.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
mongjie88
Junior Member
Posts: 4
Joined: Fri Jan 20, 2017 11:13 am
Vensim version: PLE

Re: Somebody help me please!! ramp and pulse train combination

Post by mongjie88 »

tomfid wrote:1 - Every feedback loop must have a stock in it. This is not only a PLE limitation, it's also reality. A simultaneous equation loop might be a workaround for some "stiff model" situation, like a rapid market-clearing process embedded in a model with slow dynamics, but more often it's a conceptual mistake. To say more, we'd have to understand your specific instance.

2 - One easy option would be to use a lookup. Another possibility would be something like

x = MODULO( time/peak interval, 1 )

This will give a sawtooth, which you can then stretch or clip as needed to get the shape you're after.
@Tomfid

Thanks a lot for ur reply!

However, I know how to use Lookup as a customized function, but I dont understand how to use it to produce the signal that I want. The same as with MODULO. I think Modulo is to give u the remainder of a division. Could you explain to me how please??
I would really appreciate if could take some of your time in providing me with one concrete example, using either way.

cheers!
mongjie88
Junior Member
Posts: 4
Joined: Fri Jan 20, 2017 11:13 am
Vensim version: PLE

Re: Somebody help me please!! ramp and pulse train combination

Post by mongjie88 »

Administrator wrote:
mongjie88 wrote:1- How can I ovecome the problem 'simulataneous equations' using the Vensim PLE? is there any trick there? The built in functions in Vensim PLE are very scarce.
Can you post the model here so we can take a look? Simultaneous equations are common, and usually easily fixed with an adjustment to the logic used in the model.

I will post it soon!!
Thank U!!!
mongjie88
Junior Member
Posts: 4
Joined: Fri Jan 20, 2017 11:13 am
Vensim version: PLE

Re: Somebody help me please!! ramp and pulse train combination

Post by mongjie88 »

mongjie88 wrote:
Administrator wrote:
mongjie88 wrote:1- How can I ovecome the problem 'simulataneous equations' using the Vensim PLE? is there any trick there? The built in functions in Vensim PLE are very scarce.
Can you post the model here so we can take a look? Simultaneous equations are common, and usually easily fixed with an adjustment to the logic used in the model.

btw

do you know how to produce a signal that is the combination of a ramp and a train impulse?? it has to look like this ___/l___/l____/l___/l___
I would appreciate every suggestions...
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Somebody help me please!! ramp and pulse train combination

Post by Administrator »

This does it. Might be better if you explain what you are trying to do though.
demo.mdl
(2.77 KiB) Downloaded 302 times
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: Somebody help me please!! ramp and pulse train combination

Post by tomfid »

The MODULO function is simpler - you might try it.

You can pass the sawtooth from MODULO through a lookup if you want to get a complex shape for the pulse train.

I think if we knew what you were doing, we could make better suggestions.
RWTH_FCN
Senior Member
Posts: 148
Joined: Wed Feb 08, 2017 9:10 am
Vensim version: DSS

Re: Somebody help me please!! ramp and pulse train combination

Post by RWTH_FCN »

Hi,
What kind of mistakes can cause a failure in PULSE TRAIN. I am using a PULSE TRAIN in a large-scale model but it produces nothing, although all 4 inputs of this fuction seems to be correct.
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: Somebody help me please!! ramp and pulse train combination

Post by tomfid »

Hard to say. I'd recommend copy-pasting your equation into a standalone model for testing. Be sure the time bounds are the same as the original. Also, be sure SAVEPER=TIME STEP; otherwise you might not see the pulses in the output.
RWTH_FCN
Senior Member
Posts: 148
Joined: Wed Feb 08, 2017 9:10 am
Vensim version: DSS

Re: Somebody help me please!! ramp and pulse train combination

Post by RWTH_FCN »

tomfid wrote: Fri Jul 19, 2019 1:15 pm Hard to say. I'd recommend copy-pasting your equation into a standalone model for testing. Be sure the time bounds are the same as the original. Also, be sure SAVEPER=TIME STEP; otherwise you might not see the pulses in the output.
I checked all your suggestions. When I open another vensim file and use this formula it is fine, but even a simple PULSE TRAIN with numerical input like PULSE TRAIN(1, 1 , 10 , 200 ) does not work properly in my large-sclae model. Can using C compiler cause this problem?
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: Somebody help me please!! ramp and pulse train combination

Post by tomfid »

That seems extremely unlikely. What happens if you run your small test model compiled?
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: Somebody help me please!! ramp and pulse train combination

Post by tomfid »

Any chance the variable type is set to INITIAL?
RWTH_FCN
Senior Member
Posts: 148
Joined: Wed Feb 08, 2017 9:10 am
Vensim version: DSS

Re: Somebody help me please!! ramp and pulse train combination

Post by RWTH_FCN »

tomfid wrote: Fri Jul 19, 2019 8:21 pm Any chance the variable type is set to INITIAL?
Changing variable type to initial does not help. It works well when I use a PULSE TRAIN function in a compiled small test model but it still does not work in my large scale model.
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: Somebody help me please!! ramp and pulse train combination

Post by tomfid »

Can you post or email the model?
RWTH_FCN
Senior Member
Posts: 148
Joined: Wed Feb 08, 2017 9:10 am
Vensim version: DSS

Re: Somebody help me please!! ramp and pulse train combination

Post by RWTH_FCN »

tomfid wrote: Sat Jul 20, 2019 6:40 pm Can you post or email the model?
Unfortunately, I cannot send the model, it has also huge input files and external files which make sending hard.
Attached you can find my time setting and formula for repeat time of PULSE TRAIN. The rest of variable for this function are as simple as repeat time.
Attachments
PULSE TRAIN.jpg
PULSE TRAIN.jpg (117.45 KiB) Viewed 10077 times
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Somebody help me please!! ramp and pulse train combination

Post by Administrator »

Can you copy the parameters "pulse", "eeg start", "eeg repeat time", "eeg duration" and "eeg end time" and paste them into a blank model?
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
RWTH_FCN
Senior Member
Posts: 148
Joined: Wed Feb 08, 2017 9:10 am
Vensim version: DSS

Re: Somebody help me please!! ramp and pulse train combination

Post by RWTH_FCN »

Administrator wrote: Sat Jul 20, 2019 7:08 pm Can you copy the parameters "pulse", "eeg start", "eeg repeat time", "eeg duration" and "eeg end time" and paste them into a blank model?
I have attached the equations of the function. As you can see I have used very simple equations and they work in such test model but when I use them in my large scale model I got zero for them.
Attachments
pulse function.mdl
(1.46 KiB) Downloaded 207 times
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: Somebody help me please!! ramp and pulse train combination

Post by tomfid »

Do they work in the large model if it's not compiled? (Note that if you've previously compiled it, you either have to change the model or delete the .dlls to run interpreted.)
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: Somebody help me please!! ramp and pulse train combination

Post by tomfid »

For debugging we really need the exact variables in the big model copy-pasted into a test model, with exactly the same time settings. Otherwise there are too many possible causes of variation. (However, if the copy-pasted version works for you, this probably won't help us diagnose.)

Other things too look at:
- pulse interval is non constant
- .cin file overriding one of the parameters with something that doesn't work
- PULSE TRAIN is in an initial
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: Somebody help me please!! ramp and pulse train combination

Post by tomfid »

A possible workaround would be to create a macro that implements a pulse train.
RWTH_FCN
Senior Member
Posts: 148
Joined: Wed Feb 08, 2017 9:10 am
Vensim version: DSS

Re: Somebody help me please!! ramp and pulse train combination

Post by RWTH_FCN »

tomfid wrote: Sat Jul 20, 2019 8:46 pm Do they work in the large model if it's not compiled? (Note that if you've previously compiled it, you either have to change the model or delete the .dlls to run interpreted.)
No, it is not related to compilation because it does not work with or without compilation. I was just wondering which time setting of model might cause this failure.
RWTH_FCN
Senior Member
Posts: 148
Joined: Wed Feb 08, 2017 9:10 am
Vensim version: DSS

Re: Somebody help me please!! ramp and pulse train combination

Post by RWTH_FCN »

tomfid wrote: Sat Jul 20, 2019 8:49 pm For debugging we really need the exact variables in the big model copy-pasted into a test model, with exactly the same time settings. Otherwise there are too many possible causes of variation. (However, if the copy-pasted version works for you, this probably won't help us diagnose.)

Other things too look at:
- pulse interval is non constant
- .cin file overriding one of the parameters with something that doesn't work
- PULSE TRAIN is in an initial
Thanks, I looked at your suggestions. One progress is that it produces always 1 instead of zero but still I do not see any pulse pattern in it.
RWTH_FCN
Senior Member
Posts: 148
Joined: Wed Feb 08, 2017 9:10 am
Vensim version: DSS

Re: Somebody help me please!! ramp and pulse train combination

Post by RWTH_FCN »

tomfid wrote: Sat Jul 20, 2019 8:52 pm A possible workaround would be to create a macro that implements a pulse train.
Can you describe it a little bit
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: Somebody help me please!! ramp and pulse train combination

Post by tomfid »

Here's a simple structure that generates pulses. There are a couple limitations - width=TIME STEP, and it wouldn't work with RK4 integration. I'm guessing it would work for your case though.
PULSE TRAIN alternative 1.mdl
(2.02 KiB) Downloaded 227 times
Post Reply