traitecoevo / plant

Trait-Driven Models of Ecology and Evolution :evergreen_tree:
https://traitecoevo.github.io/plant
53 stars 20 forks source link

Expand state variables available in output for FF16 #309

Closed dfalster closed 9 months ago

dfalster commented 2 years ago

This relates to #296

The role of previous plant plus object was to give access to more of the internals. We were reluctant to store all of them for sake of speed. The redesign of strategy internals means this can now be accomplished using just a single strategy object, with a switch (collect_all_auxillary) to store more or fewer of the internals.

I have two suggested pathways here. Arguably both would be good additions.

  1. Expand optional auxiliary variables collected in FF16_strategy.h (at https://github.com/traitecoevo/plant/blob/99c443f81b98e1284e14dcda4102a31108ca039c/inst/include/plant/models/ff16_strategy.h#L39 and https://github.com/traitecoevo/plant/blob/99c443f81b98e1284e14dcda4102a31108ca039c/src/ff16_strategy.cpp#L129) to enable collecting more variables. The option collect_all_auxillary in the constructor (see https://github.com/traitecoevo/plant/blob/99c443f81b98e1284e14dcda4102a31108ca039c/src/ff16_strategy.cpp#L10) can then be triggered only when running run_scm_collect
  2. Expose all the functions in strategy via R to enable more post-hoc calculations. Given height, we can calculate leaf area. Given leaf area, we can calculate root mass, etc.... Currently the way strategy is defined in RcppR6_classes.yml doesn't expose all the strategy functions. But it could. (would need to change from a list-like construct to something more like Canopy.
aornugent commented 2 years ago

The first step being implemented is to add ode_aux to Patch so that it can be queried from an SCM object. This will allow us to return the addtional state variables in run_scm_collect using a collect_aux flag.

Later we will address the second step by re-factoring the RcppR6 definition for *_Strategy objects to expose methods as well as attributes by switching from a list class to a constructor class (which isn't super well defined in the RcppR6 docs)

dfalster commented 9 months ago

This is achieved via commit referenced above, 65da50ab8550436ac32d50817b871903f86d469b