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 = ModelMapping(
        Monteith(),
        Fvcb(),
        Medlyn(0.03, 12.0),
        status = (Ra_SW_f = 13.747, sky_fraction = 1.0, aPPFD = 1500.0, d = 0.03)
    )

leaf2 = ModelMapping(
        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_fraction, :d, :Tₗ, :Rn, :Ra_LW_f, :H, :λE, :Cₛ, :Cᵢ, :A, :Gₛ, :Gbₕ, :Dₗ, :Gbc, :iter, :aPPFD), Tuple{Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Int64}, Base.RefValue{Float64}}}}((:Ra_SW_f, :sky_fraction, :d, :Tₗ, :Rn, :Ra_LW_f, :H, :λE, :Cₛ, :Cᵢ, :A, :Gₛ, :Gbₕ, :Dₗ, :Gbc, :iter, :aPPFD), NamedTuple(), Status{(:Ra_SW_f, :sky_fraction, :d, :Tₗ, :Rn, :Ra_LW_f, :H, :λE, :Cₛ, :Cᵢ, :A, :Gₛ, :Gbₕ, :Dₗ, :Gbc, :iter, :aPPFD), Tuple{Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Int64}, Base.RefValue{Float64}}}[Status(Ra_SW_f = 13.747, sky_fraction = 1.0, d = 0.03, Tₗ = 17.997367149395565, Rn = 26.312709644906413, Ra_LW_f = 12.565709644906415, H = -198.47860467447032, λE = 224.79131431937674, Cₛ = 350.02226579363736, Cᵢ = 312.07368512991275, A = 32.00581672793857, Gₛ = 1.3446766301139093, Gbₕ = 0.020472103924321854, Dₗ = 0.879389285329452, Gbc = 0.6404015155185633, iter = 1, aPPFD = 1500.0)], Base.RefValue{Union{Nothing, Tables.Schema}}(Tables.Schema:
 :Ra_SW_f       Float64
 :sky_fraction  Float64
 :d             Float64
 :Tₗ            Float64
 :Rn            Float64
 :Ra_LW_f       Float64
 :H             Float64
 :λE            Float64
 :Cₛ            Float64
 :Cᵢ            Float64
 :A             Float64
 :Gₛ            Float64
 :Gbₕ           Float64
 :Dₗ            Float64
 :Gbc           Float64
 :iter          Int64
 :aPPFD         Float64), Base.RefValue{Bool}(true))
 TimeStepTable{Status{(:Ra_SW_f, :sky_fraction, :d, :Tₗ, :Rn, :Ra_LW_f, :H, :λE, :Cₛ, :Cᵢ, :A, :Gₛ, :Gbₕ, :Dₗ, :Gbc, :iter, :aPPFD), Tuple{Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Int64}, Base.RefValue{Float64}}}}((:Ra_SW_f, :sky_fraction, :d, :Tₗ, :Rn, :Ra_LW_f, :H, :λE, :Cₛ, :Cᵢ, :A, :Gₛ, :Gbₕ, :Dₗ, :Gbc, :iter, :aPPFD), NamedTuple(), Status{(:Ra_SW_f, :sky_fraction, :d, :Tₗ, :Rn, :Ra_LW_f, :H, :λE, :Cₛ, :Cᵢ, :A, :Gₛ, :Gbₕ, :Dₗ, :Gbc, :iter, :aPPFD), Tuple{Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Int64}, Base.RefValue{Float64}}}[Status(Ra_SW_f = 10.0, sky_fraction = 1.0, d = 0.02, Tₗ = 18.113063204352787, Rn = 22.20969063162897, Ra_LW_f = 12.20969063162897, H = -230.62330528919128, λE = 252.83299592082025, Cₛ = 358.43440219710857, Cᵢ = 332.89322108297375, A = 31.836564493004904, Gₛ = 1.2457212823313566, Gbₕ = 0.024485123117510294, Dₗ = 0.8945075679317125, Gbc = 0.7659354412265967, iter = 3, aPPFD = 1250.0)], Base.RefValue{Union{Nothing, Tables.Schema}}(Tables.Schema:
 :Ra_SW_f       Float64
 :sky_fraction  Float64
 :d             Float64
 :Tₗ            Float64
 :Rn            Float64
 :Ra_LW_f       Float64
 :H             Float64
 :λE            Float64
 :Cₛ            Float64
 :Cᵢ            Float64
 :A             Float64
 :Gₛ            Float64
 :Gbₕ           Float64
 :Dₗ            Float64
 :Gbc           Float64
 :iter          Int64
 :aPPFD         Float64), Base.RefValue{Bool}(true))

Providing an array of ModelMapping object to the run! function returns an array of output data in the same order the ModelMapping 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 = ModelMapping(
        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 = ModelMapping(
        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_fraction, :d, :Tₗ, :Rn, :Ra_LW_f, :H, :λE, :Cₛ, :Cᵢ, :A, :Gₛ, :Gbₕ, :Dₗ, :Gbc, :iter, :aPPFD), Tuple{Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Int64}, Base.RefValue{Float64}}}}((:Ra_SW_f, :sky_fraction, :d, :Tₗ, :Rn, :Ra_LW_f, :H, :λE, :Cₛ, :Cᵢ, :A, :Gₛ, :Gbₕ, :Dₗ, :Gbc, :iter, :aPPFD), NamedTuple(), Status{(:Ra_SW_f, :sky_fraction, :d, :Tₗ, :Rn, :Ra_LW_f, :H, :λE, :Cₛ, :Cᵢ, :A, :Gₛ, :Gbₕ, :Dₗ, :Gbc, :iter, :aPPFD), Tuple{Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Int64}, Base.RefValue{Float64}}}[Status(Ra_SW_f = 5.0, sky_fraction = 1.0, d = 0.03, Tₗ = 21.83573153084025, Rn = 15.965283680361527, Ra_LW_f = 10.965283680361527, H = -165.13291928522207, λE = 181.09820296558362, Cₛ = 343.2102259282796, Cᵢ = 321.31043893452926, A = 24.830906670516264, Gₛ = 1.1254592707750168, Gbₕ = 0.02179553879423706, Dₗ = 0.7193502294172813, Gbc = 0.6749404500856484, iter = 2, aPPFD = 500.0), Status(Ra_SW_f = 10.0, sky_fraction = 1.0, d = 0.03, Tₗ = 22.84020211068735, Rn = 21.198501685131703, Ra_LW_f = 11.198501685131705, H = -193.86349456634008, λE = 215.06199625147178, Cₛ = 339.04379384844833, Cᵢ = 317.5976064559233, A = 32.50283493340968, Gₛ = 1.4992103985745588, Gbₕ = 0.025713303035379057, Dₗ = 0.7006386368513509, Gbc = 0.7935997492819119, iter = 2, aPPFD = 1000.0), Status(Ra_SW_f = 20.0, sky_fraction = 1.0, d = 0.03, Tₗ = 21.940135631873805, Rn = 31.639376277185356, Ra_LW_f = 11.639376277185358, H = -206.85399277211323, λE = 238.49336904929856, Cₛ = 336.54038618415206, Cᵢ = 314.38038349280896, A = 34.63853849836, Gₛ = 1.5423228111285296, Gbₕ = 0.025763960160421828, Dₗ = 0.7665023514958125, Gbc = 0.7970282167056153, iter = 2, aPPFD = 1500.0)], Base.RefValue{Union{Nothing, Tables.Schema}}(Tables.Schema:
 :Ra_SW_f       Float64
 :sky_fraction  Float64
 :d             Float64
 :Tₗ            Float64
 :Rn            Float64
 :Ra_LW_f       Float64
 :H             Float64
 :λE            Float64
 :Cₛ            Float64
 :Cᵢ            Float64
 :A             Float64
 :Gₛ            Float64
 :Gbₕ           Float64
 :Dₗ            Float64
 :Gbc           Float64
 :iter          Int64
 :aPPFD         Float64), Base.RefValue{Bool}(true))
 TimeStepTable{Status{(:Ra_SW_f, :sky_fraction, :d, :Tₗ, :Rn, :Ra_LW_f, :H, :λE, :Cₛ, :Cᵢ, :A, :Gₛ, :Gbₕ, :Dₗ, :Gbc, :iter, :aPPFD), Tuple{Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Int64}, Base.RefValue{Float64}}}}((:Ra_SW_f, :sky_fraction, :d, :Tₗ, :Rn, :Ra_LW_f, :H, :λE, :Cₛ, :Cᵢ, :A, :Gₛ, :Gbₕ, :Dₗ, :Gbc, :iter, :aPPFD), NamedTuple(), Status{(:Ra_SW_f, :sky_fraction, :d, :Tₗ, :Rn, :Ra_LW_f, :H, :λE, :Cₛ, :Cᵢ, :A, :Gₛ, :Gbₕ, :Dₗ, :Gbc, :iter, :aPPFD), Tuple{Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Int64}, Base.RefValue{Float64}}}[Status(Ra_SW_f = 3.0, sky_fraction = 1.0, d = 0.03, Tₗ = 21.905180236999048, Rn = 13.72837418527546, Ra_LW_f = 10.72837418527546, H = -161.39640111743302, λE = 175.12477530270849, Cₛ = 347.52067885419683, Cᵢ = 325.22283717660844, A = 21.896705442954676, Gₛ = 0.9773562588613921, Gbₕ = 0.02177077981441629, Dₗ = 0.7305134302240728, Gbc = 0.6741737410291917, iter = 2, aPPFD = 400.0), Status(Ra_SW_f = 7.0, sky_fraction = 1.0, d = 0.03, Tₗ = 22.856541089871975, Rn = 18.141509752971267, Ra_LW_f = 11.141509752971267, H = -192.88111783193096, λE = 211.0226275849022, Cₛ = 341.549183682953, Cᵢ = 319.88642214871663, A = 30.507641140236963, Gₛ = 1.3966042731695492, Gbₕ = 0.025707474336594975, Dₗ = 0.7034052887994511, Gbc = 0.7934198558669229, iter = 2, aPPFD = 800.0), Status(Ra_SW_f = 16.0, sky_fraction = 1.0, d = 0.03, Tₗ = 21.933366243216966, Rn = 27.662429536710544, Ra_LW_f = 11.662429536710544, H = -207.33873986071112, λE = 235.00116939742165, Cₛ = 338.1020812862871, Cᵢ = 315.83436451983005, A = 33.39679220907404, Gₛ = 1.4825119047979523, Gbₕ = 0.025766250624393847, Dₗ = 0.7654103783222683, Gbc = 0.7970990739963298, iter = 2, aPPFD = 1200.0)], Base.RefValue{Union{Nothing, Tables.Schema}}(Tables.Schema:
 :Ra_SW_f       Float64
 :sky_fraction  Float64
 :d             Float64
 :Tₗ            Float64
 :Rn            Float64
 :Ra_LW_f       Float64
 :H             Float64
 :λE            Float64
 :Cₛ            Float64
 :Cᵢ            Float64
 :A             Float64
 :Gₛ            Float64
 :Gbₕ           Float64
 :Dₗ            Float64
 :Gbc           Float64
 :iter          Int64
 :aPPFD         Float64), Base.RefValue{Bool}(true))