# Specify weather data to use in these examples
ex_weather <- get_growing_season_climate(weather$'2005')
# Example 1: varying the thermal time values at which senescence starts for
# different organs in a simulation; here we set them to the following values
# instead of the defaults:
# - seneLeaf: 2000 degrees C * day
# - seneStem: 2100 degrees C * day
# - seneRoot: 2200 degrees C * day
# - seneRhizome: 2300 degrees C * day
senescence_simulation <- partial_run_biocro(
miscanthus_x_giganteus$initial_values,
miscanthus_x_giganteus$parameters,
ex_weather,
miscanthus_x_giganteus$direct_modules,
miscanthus_x_giganteus$differential_modules,
miscanthus_x_giganteus$ode_solver,
c('seneLeaf', 'seneStem', 'seneRoot', 'seneRhizome')
)
senescence_result <- senescence_simulation(c(2000, 2100, 2200, 2300))
# Example 2: a crude method for simulating the effects of climate change; here
# we increase the atmospheric CO2 concentration to 500 ppm and the temperature
# by 2 degrees C relative to 2005 temperatures. The commands below that call
# `temperature_simulation` all produce the same result.
temperature_simulation <- partial_run_biocro(
miscanthus_x_giganteus$initial_values,
miscanthus_x_giganteus$parameters,
ex_weather,
miscanthus_x_giganteus$direct_modules,
miscanthus_x_giganteus$differential_modules,
miscanthus_x_giganteus$ode_solver,
c("Catm", "temp")
)
hot_result_1 <- temperature_simulation(c(500, ex_weather$temp + 2.0))
hot_result_2 <- temperature_simulation(list(Catm = 500, temp = ex_weather$temp + 2.0))
hot_result_3 <- temperature_simulation(list(temp = ex_weather$temp + 2.0, Catm = 500))
# Note that these commands will both produce errors:
# hot_result_4 <- temperature_simulation(c(Catm = 500, temp = ex_weather$temp + 2.0))
# hot_result_5 <- temperature_simulation(stats::setNames(
# c(500, ex_weather$temp + 2.0),
# c("Catm", rep("temp", length(ex_weather$temp)))
# ))
# Note that this command will produce a strange result where the first
# temperature value will be incorrectly interpreted as a `Catm` value, and the
# `Catm` value will be interpreted as the final temperature value.
# hot_result_6 <- temperature_simulation(c(ex_weather$temp + 2.0, 500))
# Example 3: varying the base and air temperature inputs to the
# 'thermal_time_linear' module from the 'BioCro' module library. The commands
# below that call `thermal_time_rate` all produce the same result.
thermal_time_rate <- partial_evaluate_module(
'BioCro:thermal_time_linear',
within(miscanthus_x_giganteus$parameters, {fractional_doy = 1}),
c("temp", "tbase")
)
rate_result_1 <- thermal_time_rate(c(25, 10))
rate_result_2 <- thermal_time_rate(c(temp = 25, tbase = 10))
rate_result_3 <- thermal_time_rate(c(tbase = 10, temp = 25))
rate_result_4 <- thermal_time_rate(list(temp = 25, tbase = 10))
rate_result_5 <- thermal_time_rate(list(tbase = 10, temp = 25))
Run the code above in your browser using DataLab