This is the shortest path to a coupled leaf energy-balance simulation.
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:
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ₛ)| Row | timestep | Rn | H | λE | Tₗ | A | Gₛ |
|---|---|---|---|---|---|---|---|
| Int64 | Float64? | Float64? | Float64? | Float64? | Float64? | Float64? | |
| 1 | 1 | 21.4544 | -124.393 | 145.847 | 17.7051 | 32.33 | 1.68187 |
| 2 | 2 | 21.4995 | -124.893 | 146.393 | 17.7954 | 32.3949 | 1.68238 |
| 3 | 3 | 21.5447 | -125.394 | 146.939 | 17.8857 | 32.4595 | 1.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:
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ₛ,
)Continue with Design to understand how the models fit together, or First simulation for a step-by-step explanation.