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)
)
output_vector = run!([leaf1, leaf2], meteo)
2-element Vector{Any}:
TimeStepTable{Status{(:Ra_SW_f, :sky_fracti...}(1 x 17):
╭─────┬─────────┬──────────────┬─────────┬─────────┬─────────┬─────────┬────────
│ Row │ Ra_SW_f │ sky_fraction │ d │ Tₗ │ Rn │ Ra_LW_f │ ⋯
│ │ Float64 │ Float64 │ Float64 │ Float64 │ Float64 │ Float64 │ Floa ⋯
├─────┼─────────┼──────────────┼─────────┼─────────┼─────────┼─────────┼────────
│ 1 │ 13.747 │ 1.0 │ 0.03 │ 17.9974 │ 26.3127 │ 12.5657 │ -198. ⋯
╰─────┴─────────┴──────────────┴─────────┴─────────┴─────────┴─────────┴────────
11 columns omitted
TimeStepTable{Status{(:Ra_SW_f, :sky_fracti...}(1 x 17):
╭─────┬─────────┬──────────────┬─────────┬─────────┬─────────┬─────────┬────────
│ Row │ Ra_SW_f │ sky_fraction │ d │ Tₗ │ Rn │ Ra_LW_f │ ⋯
│ │ Float64 │ Float64 │ Float64 │ Float64 │ Float64 │ Float64 │ Floa ⋯
├─────┼─────────┼──────────────┼─────────┼─────────┼─────────┼─────────┼────────
│ 1 │ 10.0 │ 1.0 │ 0.02 │ 18.1131 │ 22.2097 │ 12.2097 │ -230. ⋯
╰─────┴─────────┴──────────────┴─────────┴─────────┴─────────┴─────────┴────────
11 columns omitted
Providing an array of ModelList
object to the run!
function returns an array of output data in the same order the ModelList
objects were provided. 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
)
)
output_vector = run!([leaf1, leaf2], meteo)
2-element Vector{Any}:
TimeStepTable{Status{(:Ra_SW_f, :sky_fracti...}(3 x 17):
╭─────┬─────────┬──────────────┬─────────┬─────────┬─────────┬─────────┬────────
│ Row │ Ra_SW_f │ sky_fraction │ d │ Tₗ │ Rn │ Ra_LW_f │ ⋯
│ │ Float64 │ Float64 │ Float64 │ Float64 │ Float64 │ Float64 │ Floa ⋯
├─────┼─────────┼──────────────┼─────────┼─────────┼─────────┼─────────┼────────
│ 1 │ 5.0 │ 1.0 │ 0.03 │ 21.8357 │ 15.9653 │ 10.9653 │ -165. ⋯
│ 2 │ 10.0 │ 1.0 │ 0.03 │ 22.8402 │ 21.1985 │ 11.1985 │ -193. ⋯
│ 3 │ 20.0 │ 1.0 │ 0.03 │ 21.9401 │ 31.6394 │ 11.6394 │ -206. ⋯
╰─────┴─────────┴──────────────┴─────────┴─────────┴─────────┴─────────┴────────
11 columns omitted
TimeStepTable{Status{(:Ra_SW_f, :sky_fracti...}(3 x 17):
╭─────┬─────────┬──────────────┬─────────┬─────────┬─────────┬─────────┬────────
│ Row │ Ra_SW_f │ sky_fraction │ d │ Tₗ │ Rn │ Ra_LW_f │ ⋯
│ │ Float64 │ Float64 │ Float64 │ Float64 │ Float64 │ Float64 │ Floa ⋯
├─────┼─────────┼──────────────┼─────────┼─────────┼─────────┼─────────┼────────
│ 1 │ 3.0 │ 1.0 │ 0.03 │ 21.9052 │ 13.7284 │ 10.7284 │ -161. ⋯
│ 2 │ 7.0 │ 1.0 │ 0.03 │ 22.8565 │ 18.1415 │ 11.1415 │ -192. ⋯
│ 3 │ 16.0 │ 1.0 │ 0.03 │ 21.9334 │ 27.6624 │ 11.6624 │ -207. ⋯
╰─────┴─────────┴──────────────┴─────────┴─────────┴─────────┴─────────┴────────
11 columns omitted