PlantBiophysics.jlPlantBiophysics.jl

First Leaf Simulation​#

This is the shortest path to a coupled leaf energy-balance simulation.

julia
using PlantBiophysics, PlantSimEngine, PlantMeteo, Dates, DataFrames

meteo = Weather([
    Atmosphere(
        T=20.0 + hour / 10,
        Wind=1.0,
        P=101.3,
        Rh=0.65,
        duration=Hour(1),
    )
    for hour in 1:3
])

scene = CompositeModel(
    Monteith(),
    Fvcb(),
    Medlyn(0.03, 12.0);
    status=Status(
        Ra_SW_f=13.747,
        sky_fraction=1.0,
        aPPFD=1500.0,
        d=0.03,
    ),
    environment=meteo,
)

simulation = run!(scene; steps=3, outputs=:all)

outputs=:all retains the simulated values at each timestep. Display the net radiation (Rn), sensible heat flux (H), latent heat flux (λE), leaf temperature (Tₗ), net CO₂ assimilation (A), and stomatal conductance to CO₂ (Gₛ) together, with one row per timestep:

julia
rows = collect_outputs(simulation; sink=DataFrame)
leaf_rows = subset(
    rows,
    :application_id => ByRow(==(:energy_balance)),
    :variable => ByRow(in((:Rn, :H, :λE, :Tₗ, :A, :Gₛ))),
)
outputs = unstack(
    select(leaf_rows, :timestep, :variable, :value),
    :timestep, :variable, :value,
)
select(outputs, :timestep, :Rn, :H, :λE, :Tₗ, :A, :Gₛ)
3×7 DataFrame
RowtimestepRnHλETₗAGₛ
Int64Float64?Float64?Float64?Float64?Float64?Float64?
1121.4544-124.393145.84717.705132.331.68187
2221.4995-124.893146.39317.795432.39491.68238
3321.5447-125.394146.93917.885732.45951.68288

Rn, H, and λE are in W m⁻²; Tₗ is in °C; A is in µmol CO₂ m⁻² s⁻¹; and Gₛ is in mol CO₂ m⁻² s⁻¹.

The latest state remains available on the leaf object:

julia
leaf = only(model_objects(scene))
(
    Rn=leaf.status.Rn, H=leaf.status.H, λE=leaf.status.λE,
    Tₗ=leaf.status.Tₗ, A=leaf.status.A, Gₛ=leaf.status.Gₛ,
)
(Rn = 21.54474457541152, H = -125.39389682386889, λE = 146.9386413992804, Tₗ = 17.885685843905282, A = 32.459511329420295, Gₛ = 1.6828752896516088)

Continue with Design to understand how the models fit together, or First simulation for a step-by-step explanation.