Quick examples
This page is meant for people who have set up their environment and just want to copy-paste an example or two, see what the REPL returns and start tinkering.
If you are less comfortable with Julia, or need to set up an environment first, see this page : Getting started with Julia. If you wish for a more detailed rundown of the examples, you can instead have a look at the step by step section, which will go into more detail.
These examples are all for single-scale simulations. For multi-scale modelling tutorials and examples, refer to [this section][#multiscale]
You can find the implementation for all the example models, as well as other toy models in the examples folder.
Environment
These examples assume you have a working Julia environment with PlantSimengine added to it, as well as the other packages used in these examples. Details for getting to that point are provided on the Installing and running PlantSimEngine page.
Example with a single light interception model and a single weather timestep
using PlantSimEngine, PlantMeteo
using PlantSimEngine.Examples
meteo = Atmosphere(T = 20.0, Wind = 1.0, Rh = 0.65, Ri_PAR_f = 500.0)
leaf = ModelList(Beer(0.5), status = (LAI = 2.0,))
out = run!(leaf, meteo)
TimeStepTable{Status{(:LAI, :aPPFD), Tuple{...}(1 x 2):
╭─────┬─────────┬─────────╮
│ Row │ LAI │ aPPFD │
│ │ Float64 │ Float64 │
├─────┼─────────┼─────────┤
│ 1 │ 2.0 │ 1444.4 │
╰─────┴─────────┴─────────╯
Coupling the light interception model with a Leaf Area Index model
The weather data in this example contains data over 365 days, meaning the simulation will have as many timesteps.
using PlantSimEngine
using PlantMeteo, CSV, DataFrames
using PlantSimEngine.Examples
meteo_day = CSV.read(joinpath(pkgdir(PlantSimEngine), "examples/meteo_day.csv"), DataFrame, header=18)
models = ModelList(
ToyLAIModel(),
Beer(0.5),
status=(TT_cu=cumsum(meteo_day.TT),),
)
outputs_coupled = run!(models, meteo_day)
TimeStepTable{Status{(:TT_cu, :LAI, :aPPFD)...}(365 x 3):
╭─────┬──────────┬────────────┬───────────╮
│ Row │ TT_cu │ LAI │ aPPFD │
│ │ Float64 │ Float64 │ Float64 │
├─────┼──────────┼────────────┼───────────┤
│ 1 │ 0.0 │ 0.00554988 │ 0.0396961 │
│ 2 │ 0.0 │ 0.00554988 │ 0.02173 │
│ 3 │ 0.0 │ 0.00554988 │ 0.0314899 │
│ 4 │ 0.0 │ 0.00554988 │ 0.0390834 │
│ 5 │ 0.0 │ 0.00554988 │ 0.0454514 │
│ 6 │ 0.0 │ 0.00554988 │ 0.0472677 │
│ 7 │ 0.0 │ 0.00554988 │ 0.04346 │
│ 8 │ 0.0 │ 0.00554988 │ 0.0469832 │
│ 9 │ 0.0 │ 0.00554988 │ 0.0291703 │
│ 10 │ 0.0 │ 0.00554988 │ 0.0140052 │
│ 11 │ 0.0 │ 0.00554988 │ 0.0505283 │
│ 12 │ 0.0 │ 0.00554988 │ 0.0405277 │
│ 13 │ 0.5625 │ 0.00557831 │ 0.0297814 │
│ 14 │ 0.945833 │ 0.00559777 │ 0.0433269 │
│ 15 │ 0.979167 │ 0.00559946 │ 0.0470271 │
│ ⋮ │ ⋮ │ ⋮ │ ⋮ │
╰─────┴──────────┴────────────┴───────────╯
350 rows omitted
Coupling the light interception and Leaf Area Index models with a biomass increment model
using PlantSimEngine
using PlantMeteo, CSV, DataFrames
using PlantSimEngine.Examples
meteo_day = CSV.read(joinpath(pkgdir(PlantSimEngine), "examples/meteo_day.csv"), DataFrame, header=18)
models = ModelList(
ToyLAIModel(),
Beer(0.5),
ToyRUEGrowthModel(0.2),
status=(TT_cu=cumsum(meteo_day.TT),),
)
outputs_coupled = run!(models, meteo_day)
TimeStepTable{Status{(:TT_cu, :LAI, :aPPFD,...}(365 x 5):
╭─────┬──────────┬────────────┬───────────┬────────────┬───────────────────╮
│ Row │ TT_cu │ LAI │ aPPFD │ biomass │ biomass_increment │
│ │ Float64 │ Float64 │ Float64 │ Float64 │ Float64 │
├─────┼──────────┼────────────┼───────────┼────────────┼───────────────────┤
│ 1 │ 0.0 │ 0.00554988 │ 0.0396961 │ 0.00793922 │ 0.00793922 │
│ 2 │ 0.0 │ 0.00554988 │ 0.02173 │ 0.0122852 │ 0.004346 │
│ 3 │ 0.0 │ 0.00554988 │ 0.0314899 │ 0.0185832 │ 0.00629798 │
│ 4 │ 0.0 │ 0.00554988 │ 0.0390834 │ 0.0263999 │ 0.00781668 │
│ 5 │ 0.0 │ 0.00554988 │ 0.0454514 │ 0.0354902 │ 0.00909028 │
│ 6 │ 0.0 │ 0.00554988 │ 0.0472677 │ 0.0449437 │ 0.00945354 │
│ 7 │ 0.0 │ 0.00554988 │ 0.04346 │ 0.0536357 │ 0.00869201 │
│ 8 │ 0.0 │ 0.00554988 │ 0.0469832 │ 0.0630324 │ 0.00939665 │
│ 9 │ 0.0 │ 0.00554988 │ 0.0291703 │ 0.0688664 │ 0.00583406 │
│ 10 │ 0.0 │ 0.00554988 │ 0.0140052 │ 0.0716675 │ 0.00280105 │
│ 11 │ 0.0 │ 0.00554988 │ 0.0505283 │ 0.0817731 │ 0.0101057 │
│ 12 │ 0.0 │ 0.00554988 │ 0.0405277 │ 0.0898787 │ 0.00810554 │
│ 13 │ 0.5625 │ 0.00557831 │ 0.0297814 │ 0.095835 │ 0.00595629 │
│ 14 │ 0.945833 │ 0.00559777 │ 0.0433269 │ 0.1045 │ 0.00866538 │
│ 15 │ 0.979167 │ 0.00559946 │ 0.0470271 │ 0.113906 │ 0.00940542 │
│ ⋮ │ ⋮ │ ⋮ │ ⋮ │ ⋮ │ ⋮ │
╰─────┴──────────┴────────────┴───────────┴────────────┴───────────────────╯
350 rows omitted
Example using PlantBioPhysics
A companion package, PlantBioPhysics, uses PlantSimEngine, and contains other models used in ecophysiological simulations.
You can have a look at its documentation here
Several example simulations are provided there. Here's one taken from this page :
using PlantBiophysics, PlantSimEngine
meteo = Atmosphere(T = 22.0, Wind = 0.8333, P = 101.325, Rh = 0.4490995)
leaf = ModelList(
Monteith(),
Fvcb(),
Medlyn(0.03, 12.0),
status = (Ra_SW_f = 13.747, sky_fraction = 1.0, aPPFD = 1500.0, d = 0.03)
)
out = run!(leaf,meteo)