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
RowRa_SW_fsky_fractiondTₗRnRa_LW_fHλECₛCᵢAGₛGbₕDₗGbciteraPPFDtimestepcomponent
Float64Float64Float64Float64Float64Float64Float64Float64Float64Float64Float64Float64Float64Float64Float64Int64Float64Int64String
113.7471.00.0317.997426.312712.5657-198.479224.791350.022312.07432.00581.344680.02047210.8793890.64040211500.01leaf1
210.01.00.0218.113122.209712.2097-230.623252.833358.434332.89331.83661.245720.02448510.8945080.76593531250.01leaf2

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
RowRa_SW_fsky_fractiondTₗRnRa_LW_fHλECₛCᵢAGₛGbₕDₗGbciteraPPFDtimestepcomponent
Float64Float64Float64Float64Float64Float64Float64Float64Float64Float64Float64Float64Float64Float64Float64Int64Float64Int64String
15.01.00.0321.835715.965310.9653-165.133181.098343.21321.3124.83091.125460.02179550.719350.674942500.01leaf1
210.01.00.0322.840221.198511.1985-193.863215.062339.044317.59832.50281.499210.02571330.7006390.793621000.02leaf1
320.01.00.0321.940131.639411.6394-206.854238.493336.54314.3834.63851.542320.0257640.7665020.79702821500.03leaf1
43.01.00.0321.905213.728410.7284-161.396175.125347.521325.22321.89670.9773560.02177080.7305130.6741742400.01leaf2
57.01.00.0322.856518.141511.1415-192.881211.023341.549319.88630.50761.39660.02570750.7034050.793422800.02leaf2
616.01.00.0321.933427.662411.6624-207.339235.001338.102315.83433.39681.482510.02576630.765410.79709921200.03leaf2