Simulation over several components
Running the simulation
We saw in the previous sections how to run a simulation over one and several time-steps.
Now it is also very easy to run a simulation for different components by just providing an array of component instead:
using PlantBiophysics, PlantSimEngine, PlantMeteo
using Dates, DataFrames
meteo = Atmosphere(T = 22.0, Wind = 0.8333, P = 101.325, Rh = 0.4490995)
leaf1 = ModelList(
Monteith(),
Fvcb(),
Medlyn(0.03, 12.0),
status = (Ra_SW_f = 13.747, sky_fraction = 1.0, aPPFD = 1500.0, d = 0.03)
)
leaf2 = ModelList(
Monteith(),
Fvcb(),
Medlyn(0.03, 12.0),
status = (Ra_SW_f = 10., sky_fraction = 1.0, aPPFD = 1250.0, d = 0.02)
)
run!([leaf1, leaf2], meteo)
DataFrame(Dict("leaf1" => leaf1, "leaf2" => leaf2))
2×19 DataFrame
Row | Ra_SW_f | sky_fraction | d | Tₗ | Rn | Ra_LW_f | H | λE | Cₛ | Cᵢ | A | Gₛ | Gbₕ | Dₗ | Gbc | iter | aPPFD | timestep | component |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Int64 | Float64 | Int64 | String | |
1 | 13.747 | 1.0 | 0.03 | 17.9974 | 26.3127 | 12.5657 | -198.479 | 224.791 | 350.022 | 312.074 | 32.0058 | 1.34468 | 0.0204721 | 0.879389 | 0.640402 | 1 | 1500.0 | 1 | leaf1 |
2 | 10.0 | 1.0 | 0.02 | 18.1131 | 22.2097 | 12.2097 | -230.623 | 252.833 | 358.434 | 332.893 | 31.8366 | 1.24572 | 0.0244851 | 0.894508 | 0.765935 | 3 | 1250.0 | 1 | leaf2 |
Note that we use a Dict
of components in the call to DataFrame
because it allows to get a component
column to retrieve the component in the DataFrame
, but we could also just use an Array instead.
A simulation over different time-steps would give:
meteo =
read_weather(
joinpath(dirname(dirname(pathof(PlantMeteo))), "test", "data", "meteo.csv"),
:temperature => :T,
:relativeHumidity => (x -> x ./ 100) => :Rh,
:wind => :Wind,
:atmosphereCO2_ppm => :Cₐ,
date_format=DateFormat("yyyy/mm/dd")
)
leaf1 = ModelList(
Monteith(),
Fvcb(),
Medlyn(0.03, 12.0),
status = (
Ra_SW_f = [5., 10., 20.],
sky_fraction = 1.0,
aPPFD = [500., 1000., 1500.0],
d = 0.03
)
)
leaf2 = ModelList(
Monteith(),
Fvcb(),
Medlyn(0.03, 12.0),
status = (
Ra_SW_f = [3., 7., 16.],
sky_fraction = 1.0,
aPPFD = [400., 800., 1200.0],
d = 0.03
)
)
run!([leaf1, leaf2], meteo)
DataFrame(Dict("leaf1" => leaf1, "leaf2" => leaf2))
6×19 DataFrame
Row | Ra_SW_f | sky_fraction | d | Tₗ | Rn | Ra_LW_f | H | λE | Cₛ | Cᵢ | A | Gₛ | Gbₕ | Dₗ | Gbc | iter | aPPFD | timestep | component |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Int64 | Float64 | Int64 | String | |
1 | 5.0 | 1.0 | 0.03 | 21.8357 | 15.9653 | 10.9653 | -165.133 | 181.098 | 343.21 | 321.31 | 24.8309 | 1.12546 | 0.0217955 | 0.71935 | 0.67494 | 2 | 500.0 | 1 | leaf1 |
2 | 10.0 | 1.0 | 0.03 | 22.8402 | 21.1985 | 11.1985 | -193.863 | 215.062 | 339.044 | 317.598 | 32.5028 | 1.49921 | 0.0257133 | 0.700639 | 0.7936 | 2 | 1000.0 | 2 | leaf1 |
3 | 20.0 | 1.0 | 0.03 | 21.9401 | 31.6394 | 11.6394 | -206.854 | 238.493 | 336.54 | 314.38 | 34.6385 | 1.54232 | 0.025764 | 0.766502 | 0.797028 | 2 | 1500.0 | 3 | leaf1 |
4 | 3.0 | 1.0 | 0.03 | 21.9052 | 13.7284 | 10.7284 | -161.396 | 175.125 | 347.521 | 325.223 | 21.8967 | 0.977356 | 0.0217708 | 0.730513 | 0.674174 | 2 | 400.0 | 1 | leaf2 |
5 | 7.0 | 1.0 | 0.03 | 22.8565 | 18.1415 | 11.1415 | -192.881 | 211.023 | 341.549 | 319.886 | 30.5076 | 1.3966 | 0.0257075 | 0.703405 | 0.79342 | 2 | 800.0 | 2 | leaf2 |
6 | 16.0 | 1.0 | 0.03 | 21.9334 | 27.6624 | 11.6624 | -207.339 | 235.001 | 338.102 | 315.834 | 33.3968 | 1.48251 | 0.0257663 | 0.76541 | 0.797099 | 2 | 1200.0 | 3 | leaf2 |