Hey there,
im having a problem removing a proportion of compartment X via the outflow at time X
for example i have 100 in compartment X at time 100. I have been using the formula
if age (which is time(1)-init_time(1)) ==100 then 0.08*compX else 0
this is not working to take 8% of the compartment out via the flow and nothing else. i think it is taking nothing out.
So i tried to use the formula
if age>100 and age
this takes out too much.
What is the solution, seeing that removing it from the compartment via the outflow is what i want.
Ls
disregard, i worked it out
dont worry i overcame my stupidity by
if age>100 and age
and this takes out 8%
cheers
LS
removing a proportion of compX at time(x)
Yes, there is the problem of comparing floating point numbers for equality when any tiny rounding error will make the computed values not exactly the same so checking for a range of values is neccessary.
If your code works I think you must be using a timestep (dt) of 1. In general you must include the dt in your expression to calculate the desired outflow. I've taken the below from the help file.
For the help on dt see http://simulistics.com/help/equations/functions/dt.htm or the help in Simile.
A more general expression checking for the event time as well as calculating the desired outflow is (courtesy of Jasper):
else 0
if time()>=EventTime-dt()/2 and time()
Jonathan