Page 1 of 1

ordering outflows

Posted: Tue Jan 05, 2010 12:15 pm
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]

Posted: Wed Jan 06, 2010 11:28 am
by Administrator
Can you create an aux variable, eg,

remaining stock = stock0 - outflow_1 * time step

outflow_2 = .5 * remaining stock

Posted: Wed Jan 06, 2010 11:31 am
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.

Posted: Wed Mar 10, 2010 12:09 pm
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?

Posted: Wed Mar 10, 2010 3:57 pm
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.

Posted: Fri Mar 26, 2010 10:46 pm
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

Posted: Sat Mar 27, 2010 10:06 am
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.