Choosing the "right" time step

Use this forum to discuss any issues relating to Systems Dynamics and Systems Thinking.
Post Reply
IanL
Junior Member
Posts: 2
Joined: Wed Aug 15, 2007 2:12 am

Choosing the "right" time step

Post by IanL »

Hi all

I have a simple (famous last words) question but first a digression to explain how I came to it.

I came across a paper by Sterman entitled "Reflections on becoming a systems scientist" which I found very interesting. I haven't managed to track down a copy of his book yet, but in this paper he refers to a bathtub model, which I decided to make a vensim model of. (the paper is available online http://web.mit.edu/jsterman/www/All_Mod ... _(SDR).pdf

This model is not difficult to develop. (For the record the model I made consisted of a stock for the bathtub water volume, a constant outflow, a lookup graph for the outflow over time, a <time> shadow variable, and the reference to these in the inflow.)

However I noticed a rather curious result when I run it. I initially had the time period defined as minutes and the time step as 1 and I noticed that the resulting sine curve of water volume in the bathtub is shifted up from what I would expect. It oscillates between 75 litres and 175 litres implying the average bathtub level is 125 litres.

This is fine, except it seems that over those 16 minutes the same quantity of water both entered and left the model so one would assume the average should be the starting volume of 100 litres.

I thought about this and tried calculating the values manually (which agreed with the model). It occurred to me that if I decreased the size of the time step I may change the results.

Sure enough reducing the time step to 1/4 minutes brought the sine curve down quite a bit to oscillating between 56.25 and 156.25, or an average of ~103 litres. Identical model except the frequency of calculation and yet quite a different result. In fact it seemed as the time step tends towards zero the model tends towards the anticipated result.

Now with some further thought I can see exactly why this occurs. However it raises a rather big problem in my eyes if even such a simple model is subject to such inaccuracies entirely due to the structure of the model?

So, apologies for the long digression, but my actual question is how can SD modellers manage the issue of varying time steps influencing results in larger and more complex models? It seems to me in a complex model this problem could go completely unnoticed, and given small changes in models can have rather large impacts on outcomes, it is surely a rather big issue?

Any thoughts, strategies to deal with this or obvious things I have missed that mean it isn't a problem (!) would be very much appreciated.

Cheers
Ian
LAUJJL
Senior Member
Posts: 1427
Joined: Fri May 23, 2003 10:09 am
Vensim version: DSS

choosing the right time step

Post by LAUJJL »

Hi

Beyond the technical problem that you explain, choosing the
right time step is sometimes conceptually difficult.
One must choose the time step that is at the same time
appropriate to the problem studied and to the available data.
So it is a problem of common sense and experience and expecting to find the solution in books is illusory.
About the problem you mention, posting your model would be a good idea.
Did you try some other integration method, besides Euler?
For instance Runge-Kutta?
Regards.
JJ
Monte
Senior Member
Posts: 133
Joined: Sat Aug 13, 2005 4:18 am
Vensim version: PLE+

Post by Monte »

Hi Ian,

Have you already pressed "Ctrl+T" to check the validity of your model syntax?
For another thing, the time step should be set based on the smallest time constant in your model. Try setting it between one-fourth and one-tenth the size of the smallest time constant in the model. Anyway, changing the integration method is also a good idea, as noted by JJ.
IanL
Junior Member
Posts: 2
Joined: Wed Aug 15, 2007 2:12 am

Post by IanL »

Thanks for the replies, appreciated!

Some thoughts:

I don't think the integration technique in this simple model should make any difference - the results can be calculated by hand very easily (and the same problem arises). Analytically this model is fairly simple to solve but that isn't really the point.

I think choosing the time step is a very important conceptual idea in general as you mention JJ - and I think extensive sensitivity analysis is perhaps the best solution. Still it concerns me that even in such a simple model the impact can be so large.

I have tried to attach the model - hopefully that works...

Cheers
Ian
Attachments
Bath Model.mdl
(1.93 KiB) Downloaded 352 times
LAUJJL
Senior Member
Posts: 1427
Joined: Fri May 23, 2003 10:09 am
Vensim version: DSS

setting the right time step

Post by LAUJJL »

Hi

It seems that the problem is the method of integration.
When you use Runge-Kutta method there is no more difference.
Joined a model, slightly modified to correct dimension errors.
When run with a time step of 0.125,0.25,0.5 it shows differences with Euler integration and no difference with Runge-Kutta.
Regards.
JJ
Attachments
Bath Model_1.mdl
(2.38 KiB) Downloaded 363 times
Monte
Senior Member
Posts: 133
Joined: Sat Aug 13, 2005 4:18 am
Vensim version: PLE+

Post by Monte »

Problematic is likely to be the use of Euler, if not the use of the rate formulation that way. The cause of this problem remains to be seen.
Post Reply