ordering outflows

Use this forum to post Vensim related questions.
Post Reply
msc87
Junior Member
Posts: 9
Joined: Tue Jan 05, 2010 11:55 am

ordering outflows

Post by msc87 »

Hi dear friends
I want to have a outflow(outflow_2) from stock which should be ordered with another outflow(outflow_1).it means that the size of outflow_2 should be calculated remnant amount of stock after outflow_1 reduced the stock from.
formulation would be like this :

outflow_2= .5 * (stock0 - outflow_1+ inflow)

:D

[Edited on 1-5-2010 by msc87]
Administrator
Super Administrator
Posts: 4838
Joined: Wed Mar 05, 2003 3:10 am

Post by Administrator »

Can you create an aux variable, eg,

remaining stock = stock0 - outflow_1 * time step

outflow_2 = .5 * remaining stock
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

You can use that equation for outflow_2 - though it has units errors. The standard formulation to prevent a stock going negative would be

outflow 2 = MIN(target outflow 2,(stock + (inflow - outflow 1)*TIME STEP)/TIME STEP)

Note that this will only work with Euler/Diff integration techniques - generally it is much better practice to use formulations based only on the stock and choose TIME STEP small relative to those flow rates as in

outflow 2 = MIN(target outflow,stock/min stock processing time 2)

See the molecules for more discussion of this.
msc87
Junior Member
Posts: 9
Joined: Tue Jan 05, 2010 11:55 am

Post by msc87 »

Hi
I tried to use your recommendations but when i introduced Time Step parameter i faced with an error message saying that there is a parameter with this name.
so now what should I do?
how can i use time step? and another question:
As i know this time step depends on simulation time step of modeling but i don't know if i have to change this parameter manually in model or not, if I want to change time step in any running time?
Administrator
Super Administrator
Posts: 4838
Joined: Wed Mar 05, 2003 3:10 am

Post by Administrator »

Use the shadow tool to add TIME STEP to a model view. Or just type it in the equation, Vensim will add it to the sketch automatically.
msc87
Junior Member
Posts: 9
Joined: Tue Jan 05, 2010 11:55 am

Post by msc87 »

Originally posted by Administrator
Use the shadow tool to add TIME STEP to a model view. Or just type it in the equation, Vensim will add it to the sketch automatically.
i did it but it again showed an error message. I should introduce this variable to the model but when i want to use it as a auxiliary variable, an error message "the variable TIME STEP already exists" appears or when I write it directly in an equation, another message " unexpected variable" emerges.

if it is possible for yo, please give me a simple sample of your proposed model.

thanks a lot
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

The Ball.mdl model shows how to write auxiliary equations for Time Step.

If you are using Vensim PLE you will need to Add TIME STEP (which is a built in variable) to the sketch using the Shadow Variable tool (keyboard 8) then creating an arrow from that to your equation.
Post Reply