Time Steps and If then else

Use this forum to post Vensim related questions.
Post Reply
ABridle
Junior Member
Posts: 4
Joined: Fri Aug 20, 2004 2:53 pm

Time Steps and If then else

Post by ABridle »

I'm using an 'if then else' statement to convert items of one type to another after a certain time. When I use different time steps, not all the items convert when the time hits 12 (works OK with 1, but not with 0.5 or 0.125).

Can anybody explain why they don't convert or what I'm doing wrong - model is attached.

Thanks,

Andrea
Attachments
Random_checks.mdl
(2.12 KiB) Downloaded 815 times
Administrator
Super Administrator
Posts: 4832
Joined: Wed Mar 05, 2003 3:10 am

Post by Administrator »

I don't quite understand the question here. The model is working exactly as it should, you do the conversion when time >12, so at t=12, the conversion has not been done yet.

If you want the conversion to happen at t=12, drop the <= and use < instead.

type1 to type2 =
IF THEN ELSE ( Time < 12 , 0.01 , 1 )

Or have I misunderstood something?

Tony.
ABridle
Junior Member
Posts: 4
Joined: Fri Aug 20, 2004 2:53 pm

Post by ABridle »

At time 14, when running with time step 1, all items have converted from type 1 to type 2.

However when running with a smaller time step, there are still type 1 items (when they should have been converted to type 2).

Hope that makes sense.
Administrator
Super Administrator
Posts: 4832
Joined: Wed Mar 05, 2003 3:10 am

Post by Administrator »

I understand.

have a look at
http://www.vensim.com/documentation/html/23395.htm

This explains Euler integration.
LEVELTime+TIME STEP = LEVELTime + TIME STEP * RATETime

As you have a time step of 1, everything is happening as you expect it to. Your "Conversion" parameter is not a rate (not time dependant), so when the time step changes, the calculation in the level changes as well.

Change your "conversion" parameter to be a rate, eg
conversion[TYPE1] = ( TYPE 2 TO TYPE 1 * Number[TYPE2] - type1 to type2 * Number[TYPE1] ) / TIME STEP

and that should have the desired effect.

I would also suggest putting units in for your parameters, a units check would have told you that "conversion" needed to be dmnl/month and not dmnl.

Hope this makes sense.

Tony.
ABridle
Junior Member
Posts: 4
Joined: Fri Aug 20, 2004 2:53 pm

Post by ABridle »

Is there any way of having the change from type 1 to type 2 as a constant per month?

When I put the units as dmsl/month (and change the units of conversion), I get the problem that not all the items convert from one type to the other at the specified time for different time steps.

(Model adjusted and attached)
Attachments
Random_checks.mdl
(2.39 KiB) Downloaded 763 times
Pruyn
Senior Member
Posts: 80
Joined: Fri Mar 05, 2004 2:34 pm

Post by Pruyn »

If you want to instantly change the amount, make sure you divede this by time step. This way it will all be done during one time step and not one time period (e.g. month or day). See also Tony's comment.
I changed the if then else construction a bit so it will work. The first part is time step independent, the second part isn't. See adjusted mdl.

Jeroen
Attachments
Random_checks_JP.mdl
(2.53 KiB) Downloaded 697 times
Post Reply