Thomas made the remark that it would be more simple for developers to be able to decorate a function they already have with some metadata to build a PlantSimEngine model rather than writing it from scratch as we currently require. It would be simpler because it would be only Julia code first, so simpler to develop, prototype and test. And then when we want to make a model out of it, we decorate the function with some macros to make a PSE model.
Here's an example interface we imagined:
@PSE_model AbstractTestModel function test_model(carbon_offer=-Inf, carbon_demand=-Inf, param1, Ri_Par_f, Δ)
@meteo Ri_Par_f # This macro helps us identify `Ri_Par_f` as a meteorology variable (i.e. meteo.Ri_Par_f)
@constant Δ # This macro identifies the constants (taken as constants.Δ)
@param param1 = 0.5
var1 = compute_var1(carbon_demand, param1) # This is just a regular function call, not flagged as a hard dependency
@hard_dependency carbon_offer = carbon_offer_model(carbon_demand, var1) # this is a hard dependency
trophic_state = carbon_offer / carbon_demand
carbon_allocation = minimum(carbon_offer, carbon_demand)
return @outputs (trophic_state = -Inf carbon_allocation = -Inf)
end
Note that the @PSE_model would automatically identify the inputs from the arguments of the function (and return an error if the inputs have no default value), and the other macros would identify meteo, constant, parameters, and output variables.
The combinations of the macros would write all the code needed for PSE to make a model:
- the model struct, using CamelCase based on the name of the function
- inputs, based on the arguments to the function that are not meteo, constant or parameters
- outputs based on the outputs macro
meteo. and status. prefix for the meteo and inputs/outputs variables
- replace the hard dependency code by the generic call used in PSE, i.e. get the model associated to the function (it has to be defined before this model to be available)
carbon_offer_model, get its process, and replace the line by the generic call PlantSimEngine.run!(models.carbon_offer, models, status, meteo, constants, extra)
- a method for the
run! function
This would simplify the development of models, and allow for testing more easily the base functions without coupling, i.e. we can use test_model as is, or use it from PSE using a modelList that would call the run! method.
Thomas made the remark that it would be more simple for developers to be able to decorate a function they already have with some metadata to build a PlantSimEngine model rather than writing it from scratch as we currently require. It would be simpler because it would be only Julia code first, so simpler to develop, prototype and test. And then when we want to make a model out of it, we decorate the function with some macros to make a PSE model.
Here's an example interface we imagined:
Note that the
@PSE_modelwould automatically identify the inputs from the arguments of the function (and return an error if the inputs have no default value), and the other macros would identify meteo, constant, parameters, and output variables.The combinations of the macros would write all the code needed for PSE to make a model:
meteo.andstatus.prefix for the meteo and inputs/outputs variablescarbon_offer_model, get its process, and replace the line by the generic callPlantSimEngine.run!(models.carbon_offer, models, status, meteo, constants, extra)run!functionThis would simplify the development of models, and allow for testing more easily the base functions without coupling, i.e. we can use
test_modelas is, or use it from PSE using a modelList that would call therun!method.