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, Dates
using PlantSimEngine.Examples
meteo = Atmosphere(T = 20.0, Wind = 1.0, Rh = 0.65, Ri_PAR_f = 500.0)
leaf = ModelMapping(Beer(0.5), status = (LAI = 2.0,))
out = run!(leaf, meteo)
TimeStepTable{Status{(:LAI, :aPPFD), Tuple{...}(1 x 2):
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, Dates
using PlantSimEngine.Examples

meteo_day = read_weather(joinpath(pkgdir(PlantSimEngine), "examples/meteo_day.csv"), duration=Dates.Day)

models = ModelMapping(
    ToyLAIModel(),
    Beer(0.5),
    status=(TT_cu=cumsum(meteo_day.TT),),
)

outputs_coupled = run!(models, meteo_day)
outputs_coupled[1:3,:] # show the first 3 rows of the output
TimeStepTable{Status{(:TT_cu, :LAI, :aPPFD)...}(3 x 3):
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

Coupling the light interception and Leaf Area Index models with a biomass increment model

using PlantSimEngine
using PlantMeteo, Dates
using PlantSimEngine.Examples

meteo_day = read_weather(joinpath(pkgdir(PlantSimEngine), "examples/meteo_day.csv"), duration=Dates.Day)

models = ModelMapping(
    ToyLAIModel(),
    Beer(0.5),
    ToyRUEGrowthModel(0.2),
    status=(TT_cu=cumsum(meteo_day.TT),),
)

outputs_coupled = run!(models, meteo_day)
outputs_coupled[1:3,:] # show the first 3 rows of the output
TimeStepTable{Status{(:TT_cu, :LAI, :aPPFD,...}(3 x 5):
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

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 = ModelMapping(
        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)