Hi!
Attached is a simple model with a ramp and a pulse train function, producing the behavior shown in the figure. I was wondering how it could be possible to produce a step pattern, following the peaks of the pulse train behavior, like the one drawn in the figure.
Thank you in advance!
Step pattern
-
- Member
- Posts: 37
- Joined: Fri Dec 07, 2018 9:20 am
- Vensim version: DSS
Step pattern
- Attachments
-
- Screenshot.png (247.07 KiB) Viewed 1452 times
-
- test.mdl
- (1.31 KiB) Downloaded 143 times
-
- Super Administrator
- Posts: 4590
- Joined: Wed Mar 05, 2003 3:10 am
Re: Step pattern
You can use a level to give you the step pattern.
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
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Units are important!
http://www.bbc.co.uk/news/magazine-27509559
Re: Step pattern
In other words, use a level to integrate a PULSE TRAIN.
Another option would be to use the ramp, and feed it to the QUANTUM function to make steps. QUANTUM is like INTEGER but with an arbitrary step size.
Another option would be to use the ramp, and feed it to the QUANTUM function to make steps. QUANTUM is like INTEGER but with an arbitrary step size.
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
-
- Member
- Posts: 37
- Joined: Fri Dec 07, 2018 9:20 am
- Vensim version: DSS
Re: Step pattern
Hi, and thank you both for your answers! Much appreciated!
I wanted to mention also in my first post that the INTEG function / level is something that I already tried, but the steps do not eventually reach the pulse peaks, as shown in the attached figure. It seems that the pulse duration is so small (0 in this case) that the level does not have enough time to accumulate, at least this is how I understand it. Unless this is a Timestep issue (I am using 0.0625, but I also tried with other options without success) or something else.
The QUANTUM function is indeed a great alternative, thank you for the suggestion! Although I would like to understand why the INTEG function is not working in this case.
I wanted to mention also in my first post that the INTEG function / level is something that I already tried, but the steps do not eventually reach the pulse peaks, as shown in the attached figure. It seems that the pulse duration is so small (0 in this case) that the level does not have enough time to accumulate, at least this is how I understand it. Unless this is a Timestep issue (I am using 0.0625, but I also tried with other options without success) or something else.
The QUANTUM function is indeed a great alternative, thank you for the suggestion! Although I would like to understand why the INTEG function is not working in this case.
- Attachments
-
- test.mdl
- (1.45 KiB) Downloaded 138 times
-
- Screenshot.png (263.04 KiB) Viewed 1428 times
Re: Step pattern
Consider the following setup:
p = PULSE TRAIN( ... )
v = INTEG( p, 0 )
The discrete integration via Euler's method takes steps like:
v(time+time step) = v(time) + time step*p
This makes it easy to see why the steps are small when TIME STEP is small.
If instead you integrate:
v = INTEG( p/TIME STEP, 0 )
or you modify p:
p = PULSE TRAIN( ... )/TIME STEP
you'll get integer steps in v. (The second approach may be a little more conventional for stock/flow and unit notation.)
p = PULSE TRAIN( ... )
v = INTEG( p, 0 )
The discrete integration via Euler's method takes steps like:
v(time+time step) = v(time) + time step*p
This makes it easy to see why the steps are small when TIME STEP is small.
If instead you integrate:
v = INTEG( p/TIME STEP, 0 )
or you modify p:
p = PULSE TRAIN( ... )/TIME STEP
you'll get integer steps in v. (The second approach may be a little more conventional for stock/flow and unit notation.)
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
-
- Super Administrator
- Posts: 4590
- Joined: Wed Mar 05, 2003 3:10 am
Re: Step pattern
Also make sure you put units in your model. And that the model passes the units check.
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
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Units are important!
http://www.bbc.co.uk/news/magazine-27509559
-
- Member
- Posts: 37
- Joined: Fri Dec 07, 2018 9:20 am
- Vensim version: DSS
Re: Step pattern
Thank you both for your answers once again! This clarified a lot!
After using the PULSE TRAIN / TIME STEP approach for integration, the outcome was the behavior of the first screenshot. What happens essentially is that for every new pulse, the value of the previous pulse is retained and integrated with the value of the new pulse, whereas what I would like to see are steps of the current pulse only (i.e. add the value of the current pulse and discard the previous one).
As I was trying to find a solution, I added a flow for the level, so that the flow equation (i.e. PULSE TRAIN / TIME STEP) would not be 'hidden' in the level. So then I noticed that the flow pulses are eventually considerably higher than the auxiliary pulses (second screenshot). One one hand, this can be solved by using the PULSE TRAIN / TIME STEP function in the auxiliary variable, as suggested, and feed it directly to the flow, but then again the mismatch of high pulses and small steps remains.
I have also added units to the model (attached), which now passes the units check too.
Thank you again for your time!
After using the PULSE TRAIN / TIME STEP approach for integration, the outcome was the behavior of the first screenshot. What happens essentially is that for every new pulse, the value of the previous pulse is retained and integrated with the value of the new pulse, whereas what I would like to see are steps of the current pulse only (i.e. add the value of the current pulse and discard the previous one).
As I was trying to find a solution, I added a flow for the level, so that the flow equation (i.e. PULSE TRAIN / TIME STEP) would not be 'hidden' in the level. So then I noticed that the flow pulses are eventually considerably higher than the auxiliary pulses (second screenshot). One one hand, this can be solved by using the PULSE TRAIN / TIME STEP function in the auxiliary variable, as suggested, and feed it directly to the flow, but then again the mismatch of high pulses and small steps remains.
I have also added units to the model (attached), which now passes the units check too.
Thank you again for your time!
- Attachments
-
- test.mdl
- (1.89 KiB) Downloaded 137 times
-
- Screenshot 1.png (189.7 KiB) Viewed 1397 times
-
- Screenshot 2.png (283.53 KiB) Viewed 1397 times