You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A model that takes outputs of another model as inputs is called a soft-coupled model. There is nothing to do on the modeler side to declare a soft-dependency. The detection is done automatically by PlantSimEngine using the inputs and outputs of the models.
62
+
A model that takes outputs of another model as inputs is called a soft-coupled model. There is nothing to do on the modeler side to declare a soft-dependency. The detection is done automatically by PlantSimEngine using the inputs and outputs of the models.
63
+
64
+
## Handling dependencies in a multiscale context
65
+
66
+
If a model requires some input variable that is computed at another scale, providing the appropriate mapping will resolve name conflicts and enable proper use of that variable and there will be no extra steps for the user or the modeler.
67
+
68
+
In the case of a hard dependency that operates at a different scale from its parent, the same principle applies and there are also no extra steps on the user-side.
69
+
70
+
On the other hand, modelers need to bear in mind a couple of subtleties when developing models that possess hard dependencies that operate at a different organ level from their parent :
71
+
72
+
The parent model directly handles the call to its hard dependency model(s), meaning they are not explicitely managed by the dependency graph.
73
+
Therefore only the owning model of that dependency is visible in the graph, and its hard dependency nodes are internal.
74
+
75
+
When the caller (or any downstream model that requires some variables from the hard dependency) operates at the same scale, variables are easily accessible, and no mapping is required.
76
+
77
+
If an inner model operates at a different scale/organ level, a modeler must declare hard dependencies with their respective organ level, similarly to the way the user provides a mapping.
The model's constructor provides convenient default names for the scale corresponding to the reproductive organs. A user may override that if their naming schemes or MTG attributes differ.
But how does a model M calling a hard dependency H provide H's variables when calling H's `run!` function ? The status the user provides M operates at M's organ level, so if used to call H's run! function any required variable for H will be missing.
126
+
127
+
PlantSimEngine provides what are called Status Templates in the simulation graph. Each organ level has its own Status template listing the available variables at that scale.
128
+
So when a model M calls a hard dependency H's `run!` function, any required variables can be accessed through the status template of H's organ level.
129
+
130
+
Using the same example in XPalm :
131
+
132
+
```julia
133
+
# Note that the function's 'status' parameter does NOT contain the variables required by the hard dependencies as the calling model's organ level is "Phytomer", not "Male" or "Female"
134
+
135
+
function PlantSimEngine.run!(m::ReproductiveOrganEmission, models, status, meteo, constants, sim_object)
136
+
...
137
+
status.graph_node_count +=1
138
+
139
+
# Create the new organ as a child of the phytomer:
140
+
st_repro_organ =add_organ!(
141
+
status.node[1], # The phytomer's internode is its first child
142
+
sim_object, # The simulation object, so we can add the new status
0 commit comments