-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Sometimes we just want to traverse the graph to get the value of a variable, because we want e.g. the biomass of the leaf of that phytomer. We can do that already, but the problem is that we have no clean way of telling this to the dependency graph computation, because the inputs are considered for the current scale only. So currently we cannot guaranty that the model will run after the model at the other scale, which means we may use the variable before it was computed.
You can take a look at the LeafGeometryModel.jl
in VPalm for a good example. The only way we can account for that in the dependency graph is to map the inputs from the other scale, but this way we have the values for all other organs, when we really only want the one.
We should propose a new API for "declaring" that we will use a variable existing at another scale. This new API could be a function that we pass to the mapping, and that function would be called to get the variable.
For example:
MultiScaleModel(
model=LeafGeometryModel(),
mapping=[:biomass_leaf => ["Leaf" => (x -> x[1]) => :biomass], ],
)
Note the new function call (x -> x[1])
, which could be anything that traverses the graph and return a node. Then PlantSimEngine would run this traversal everytime we want to get the variable :biomass_leaf
, and would extract the value of :biomass
in the status of the node. We would support the same syntax as the normal mapping for expecting one value or a vector of values.
This would help implement multiple plants/species, see #119.