Fri, 06/01/2012 - 09:07 — Youjia Chen
I followed the 'water flow in different layers' example in 'help' of the software to do my simulation (attachment see transmission.sml). My expected result is the flow was transported between instances in each time step (attachment see wantedresult.jpg), but the real result shows time-step lags between instances (attachment see realresult.jpg).
I think the problem is probably because in the example, the outflow was defined as initial values. But in my work, the outflow depends on the 'inflow' flow and 'growth' flow. But I can not define outflow value before simulation in my work.
How could I do to get my expected result?
Thanks in advance for any help!
Youjia Chen
Attachment | Size |
---|---|
transmission.sml | 109.1 KB |
realresult.jpg | 26.52 KB |
wantedresult.jpg | 12.35 KB |
Forums:
It will take a few steps to
It will take a few steps to get the model to give the results you want.
Firstly, each outflow should be calculated from the value of the pool after the other flows have been applied to it. Simile does not normally do this -- it first updates all the compartment values, then evaluates all the other model components -- so you have to add this explicitly to your model. To do this, add influences from the inflow and growth flows to the outflow flow, and change outflow's equation to 'pool+inflow-growth'. This is the same as pool on the start of the next time step, provided the time step duration is 1 unit.
Now, if you try to run your model, Simile will produce a failure message: circular set of function evaluations. This is because the inflow, outflow and interflow values now form a loop all depending on each other, so Simile cannot evaluate them in any order. What we actually want to do is calculate the boundary condition (the inflow in instance 1) first, and all others depend on that. Now this is hard to arrange if the interflow is in an association submodel, so simplify the model by instead using an array variable for interflows. Delete the 'above' submodel and add in its place a variable called 'interflows' with an influence from 'outflow' and one to 'inflow'. The equation of 'interflows' is '[outflow]' so it has the values of the 4 outflows. The equation for 'inflow' becomes: 'if layer_number == 1 then 80 else element([interflows],layer_number-1)'.
At this point the model still has circular evaluations, but you can tell Simile to start with the inflow by editing the properties of the influence from interflows, and selecting 'use destination values made in same time step'. This means that values of inflow can use values of interflows derived by a sequence of evaluations from other values of inflow. Obviously the first inflow to be set is the boundary condition and does not need such a value, but subsequent ones do. The influence will now be shown dashed, indicating that the destination no longer needs to be calculated after the source).
After this the model will produce the results you expected. Attached is a copy of the model with the changes made. Note that the 'pool' compartments all stay at 0 because their flows in and out now always sum to zero.
thank you
Dear Jaspert,
It is amazing! Thanks so much for your quickly and nice explanation.
Youjia