Build an appropriately refined schedule for node introduction.
build_schedule( p, env = make_environment(parameters = p), ctrl = scm_base_control() )
build_schedule( p, env = make_environment(parameters = p), ctrl = scm_base_control() )
p |
Parameters object |
env |
Environment object |
ctrl |
Control object |
There are control options (within the Parameters
object)
that affect how this function runs, in particular
schedule_nsteps
and schedule_eps
control how refined
the schedule will end up, and schedule_verbose
controls if
details are printed to the screen during construction.
A Parameters object, with schedule components set. The
output offspring produced is also available as an attribute
birth_rate
.
Rich FitzJohn
Control parameters that tune various aspects of the numerical solvers.
Control(..., values = list(...))
Control(..., values = list(...))
... , values
|
Values to initialise the struct with (either as variadic arguments, or as a list, but not both). |
Base class of representing patch disturbance
Disturbance_Regime()
Disturbance_Regime()
Make environment objects for a strategy
environment_type(type) make_environment(type = NULL, parameters = NULL, ...)
environment_type(type) make_environment(type = NULL, parameters = NULL, ...)
type |
Any strategy name as a string, e.g.: |
parameters |
a object |
... |
other arguments passed through |
The functions expand_parameters and mutant_parameters convert trait values into parametr objects for the model. By default, expand_parameters adds an extra strategy to existing.
expand_parameters( trait_matrix, p, hyperpar = param_hyperpar(p), birth_rate_list = 1, keep_existing_strategies = TRUE ) mutant_parameters(..., keep_existing_strategies = FALSE)
expand_parameters( trait_matrix, p, hyperpar = param_hyperpar(p), birth_rate_list = 1, keep_existing_strategies = TRUE ) mutant_parameters(..., keep_existing_strategies = FALSE)
trait_matrix |
A matrix of traits corresponding to the new types to introduce. |
p |
A |
hyperpar |
Hyperparameter function to use. By default links to standard function for this strategy type. |
birth_rate_list |
List object with birth rates for each species in |
keep_existing_strategies |
Should existing residents be retained
x. Birth rates can take the form of a scalar (constant) or a vector.
In either case birth rates are set as |
... |
Arguments to |
Rich FitzJohn
Sets reasonable defaults for fast numerical calculations
fast_control(base = Control())
fast_control(base = Control())
base |
An optional |
A Control object with parameters set.
Rich FitzJohn
Create an FF16_Environment object.
FF16_Environment( light_availability_spline_rescale_usually, soil_number_of_depths ) K93_Environment() TF24_Environment( light_availability_spline_rescale_usually, soil_number_of_depths )
FF16_Environment( light_availability_spline_rescale_usually, soil_number_of_depths ) K93_Environment() TF24_Environment( light_availability_spline_rescale_usually, soil_number_of_depths )
light_availability_spline_rescale_usually |
whether to rescale intervals when estimating light environment |
soil_number_of_depths |
Number of soil layers to include |
Add additional state variables to the species component in output of FF16 model.
FF16_expand_state(tidy_patch_results)
FF16_expand_state(tidy_patch_results)
tidy_patch_results |
from 'tidy_patch' |
similar format to input, but with additional columns for additional state variables
Construct a fixed environment for a model
Construct a fixed environment for FF16w strategy
FF16_fixed_environment(e = 1, height_max = 150, ...) FF16w_fixed_environment(e = 1, height_max = 150) K93_fixed_environment(e = 1, height_max = 300, ...) TF24_fixed_environment(e = 1, height_max = 150, ...)
FF16_fixed_environment(e = 1, height_max = 150, ...) FF16w_fixed_environment(e = 1, height_max = 150) K93_fixed_environment(e = 1, height_max = 300, ...) TF24_fixed_environment(e = 1, height_max = 150, ...)
e |
Value of environment (deafult = 1.0) |
height_max |
= 150.0 maximum possible height in environment |
... |
Additional parameters to be passed to |
Builds a detailed report on stand grown with FF16 strategy, based on the template Rmd file provided. The reports are rendered as html files and saved in the specified output folder.
FF16_generate_stand_report( results, output_file = "FF16_report.html", overwrite = FALSE, target_ages = NA, input_file = system.file("reports", "FF16_report.Rmd", package = "plant"), quiet = TRUE )
FF16_generate_stand_report( results, output_file = "FF16_report.html", overwrite = FALSE, target_ages = NA, input_file = system.file("reports", "FF16_report.Rmd", package = "plant"), quiet = TRUE )
results |
results of runnning |
output_file |
name of output file |
overwrite |
logical value to determine whether to overwrite existing report |
target_ages |
Patches ages at which to make plots |
input_file |
report script (.Rmd) file to build study report |
quiet |
An option to suppress printing during rendering from knitr, pandoc command line and others. |
html file of the rendered report located in the specified output folder.
Hyperparameter function for FF16 physiological model
FF16_hyperpar(m, s, filter = TRUE)
FF16_hyperpar(m, s, filter = TRUE)
m |
A matrix of trait values, as returned by |
s |
A strategy object |
filter |
A flag indicating whether to filter columns. If TRUE, any numbers that are within eps of the default strategy are not replaced. |
Create a FF16 Individual
FF16_Individual(s = FF16_Strategy())
FF16_Individual(s = FF16_Strategy())
s |
A |
pl <- FF16_Individual() pl$height
pl <- FF16_Individual() pl$height
create a model Environment object
FF16_make_environment( light_availability_spline_tol = 1e-04, light_availability_spline_nbase = 17, light_availability_spline_max_depth = 16, light_availability_spline_rescale_usually = TRUE ) FF16r_make_environment( light_availability_spline_tol = 1e-04, light_availability_spline_nbase = 17, light_availability_spline_max_depth = 16, light_availability_spline_rescale_usually = TRUE ) FF16w_make_environment( light_availability_spline_tol = 1e-04, light_availability_spline_nbase = 17, light_availability_spline_max_depth = 16, light_availability_spline_rescale_usually = TRUE, soil_number_of_depths = 1, soil_initial_state = 0, rainfall = 1 ) K93_make_environment( light_availability_spline_tol = 1e-04, light_availability_spline_nbase = 17, light_availability_spline_max_depth = 16, light_availability_spline_rescale_usually = TRUE ) TF24_make_environment( light_availability_spline_tol = 1e-04, light_availability_spline_nbase = 17, light_availability_spline_max_depth = 16, light_availability_spline_rescale_usually = TRUE )
FF16_make_environment( light_availability_spline_tol = 1e-04, light_availability_spline_nbase = 17, light_availability_spline_max_depth = 16, light_availability_spline_rescale_usually = TRUE ) FF16r_make_environment( light_availability_spline_tol = 1e-04, light_availability_spline_nbase = 17, light_availability_spline_max_depth = 16, light_availability_spline_rescale_usually = TRUE ) FF16w_make_environment( light_availability_spline_tol = 1e-04, light_availability_spline_nbase = 17, light_availability_spline_max_depth = 16, light_availability_spline_rescale_usually = TRUE, soil_number_of_depths = 1, soil_initial_state = 0, rainfall = 1 ) K93_make_environment( light_availability_spline_tol = 1e-04, light_availability_spline_nbase = 17, light_availability_spline_max_depth = 16, light_availability_spline_rescale_usually = TRUE ) TF24_make_environment( light_availability_spline_tol = 1e-04, light_availability_spline_nbase = 17, light_availability_spline_max_depth = 16, light_availability_spline_rescale_usually = TRUE )
light_availability_spline_tol |
Error tolerance of adpative spline method. Deafult is 1e-4. |
light_availability_spline_nbase |
Parameter used in adaptive spline method. Default is 17. |
light_availability_spline_max_depth |
Parameter used in adaptive spline method. Default is 16. |
light_availability_spline_rescale_usually |
whether to rescale intervals when estimating light environment |
soil_number_of_depths |
the number of soil layers |
soil_initial_state |
the initial state of the soil layers |
rainfall |
constant function value for rainfall driver, y = rainfall |
Setup an a model system with default or specified parameters. This function enables you initialize a model system. Use the model name to start different models.
FF16_Parameters(...) FF16r_Parameters() K93_Parameters() TF24_Parameters(...)
FF16_Parameters(...) FF16r_Parameters() K93_Parameters() TF24_Parameters(...)
... |
Arguments to be passed to the model constructor. These include *'patch_area': Area of idnividfual patch. Only relevant for stochastic model. Default is 1.0m2. *'max_patch_lifetime': The maximum time in years we want to simulate *'strategies': A list of stratgies to simulate. The default is an empty list. *'strategy_default': Values for the default startegy. The default values are those specified in the C++ code for the model. *'node_schedule_times_default': Default vector of times at which to introduce nodes. The default is chosen to have close spacing at the start of the simulation. *'node_schedule_times': A list with each element containing the vector of times we want to introduce nodes for each strategy. The default is an empty list. *'ode_times': A vector of patch ages we want the ode solver to stop at |
p1 <- FF16_Parameters() p2 <- FF16_Parameters(max_patch_lifetime = 10.0, patch_area = 1.0, strategies = list(FF16_Strategy()), strategy_default = FF16_Strategy(), node_schedule_times_default = node_schedule_times_default(10.0), node_schedule_times = list(node_schedule_times_default(10.0)), ode_times = c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) p1 <- TF24_Parameters() p2 <- TF24_Parameters(max_patch_lifetime = 10.0)
p1 <- FF16_Parameters() p2 <- FF16_Parameters(max_patch_lifetime = 10.0, patch_area = 1.0, strategies = list(FF16_Strategy()), strategy_default = FF16_Strategy(), node_schedule_times_default = node_schedule_times_default(10.0), node_schedule_times = list(node_schedule_times_default(10.0)), ode_times = c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) p1 <- TF24_Parameters() p2 <- TF24_Parameters(max_patch_lifetime = 10.0)
Strategy parameters that tune various aspects of the biological model.
FF16_Strategy(..., values = list(...))
FF16_Strategy(..., values = list(...))
... , values
|
Values to initialise the struct with (either as variadic arguments, or as a list, but not both). |
This makes a pretend light environment over the plant height, slightly concave up, whatever.
FF16_test_environment(height, n = 101, light_env = NULL, n_strategies = 1) FF16r_test_environment(height, n = 101, light_env = NULL, n_strategies = 1) FF16w_test_environment(height, n = 101, light_env = NULL, n_strategies = 1) K93_test_environment(height, n = 101, light_env = NULL, n_strategies = 1) TF24_test_environment(height, n = 101, light_env = NULL, n_strategies = 1)
FF16_test_environment(height, n = 101, light_env = NULL, n_strategies = 1) FF16r_test_environment(height, n = 101, light_env = NULL, n_strategies = 1) FF16w_test_environment(height, n = 101, light_env = NULL, n_strategies = 1) K93_test_environment(height, n = 101, light_env = NULL, n_strategies = 1) TF24_test_environment(height, n = 101, light_env = NULL, n_strategies = 1)
height |
top height of environment object |
n |
number of points |
light_env |
function for light environment in test object |
n_strategies |
number of strategies for test environment |
environment <- plant:::FF16_test_environment(10) environment <- plant:::FF16w_test_environment(10) environment <- plant:::K93_test_environment(10) environment <- plant:::TF24_test_environment(10)
environment <- plant:::FF16_test_environment(10) environment <- plant:::FF16w_test_environment(10) environment <- plant:::K93_test_environment(10) environment <- plant:::TF24_test_environment(10)
Hyperparameter function for FF16r physiological model
FF16r_hyperpar(m, s, filter = TRUE)
FF16r_hyperpar(m, s, filter = TRUE)
m |
A matrix of trait values, as returned by |
s |
A strategy object |
filter |
A flag indicating whether to filter columns. If TRUE, any numbers that are within eps of the default strategy are not replaced. |
Create a FF16r Plant or Node
FF16r_Individual(s = FF16r_Strategy())
FF16r_Individual(s = FF16r_Strategy())
s |
A |
pl <- FF16r_Individual() pl$height
pl <- FF16r_Individual() pl$height
Strategy parameters that tune various aspects of the biological model.
FF16r_Strategy(..., values = list(...))
FF16r_Strategy(..., values = list(...))
... , values
|
Values to initialise the struct with (either as variadic arguments, or as a list, but not both). |
Create a FF16w Plant or Node
FF16w_Individual(s = FF16w_Strategy()) FF16w_Parameters()
FF16w_Individual(s = FF16w_Strategy()) FF16w_Parameters()
s |
A |
pl <- FF16w_Individual() pl$height
pl <- FF16w_Individual() pl$height
Strategy parameters that tune various aspects of the biological model.
FF16w_Strategy(..., values = list(...))
FF16w_Strategy(..., values = list(...))
... , values
|
Values to initialise the struct with (either as variadic arguments, or as a list, but not both). |
Grow an individual up to particular sizes.
grow_individual_to_size( individual, sizes, size_name, env, time_max = Inf, warn = TRUE, filter = FALSE ) grow_individual_to_height(individual, heights, env, ...)
grow_individual_to_size( individual, sizes, size_name, env, time_max = Inf, warn = TRUE, filter = FALSE ) grow_individual_to_height(individual, heights, env, ...)
individual |
An |
sizes |
A vector of sizes to grow the plant to (increasing in size). |
size_name |
The name of the size variable within
|
env |
An |
time_max |
Time to run the ODE out for – only exists to prevent an infinite loop (say, on an unreachable size). |
warn |
Warn if requesting a plant that is too large? |
filter |
Filter individuals that are too large? |
heights |
Heights (when using |
... |
Additional parameters passed to
|
A list with elements time
(the time that a given
size was reached), state
(the ode state at these
times, as a matrix) and plant
a list of individuals grown to the
appropriate size. Note that if only a single size is given,
a list of length 1 is returned.
Grow a plant up for particular time lengths
grow_individual_to_time(individual, times, env)
grow_individual_to_time(individual, times, env)
individual |
An |
times |
A vector of times |
env |
An |
Individual object
Individual(T, E)
Individual(T, E)
T |
String containing class of plant strategy to create; |
E |
String containing class of environmnet to create; |
Integrate over the size distribution for each species at each time point, to give totals of each variable Integrations are performed using trapezium integration
integrate_over_size_distribution(tidy_species_data)
integrate_over_size_distribution(tidy_species_data)
tidy_species_data |
output of either 'tidy_patch' or 'tidy_species' |
a tibble whose columns provide metrics on integrated totals for each variable for each species at each time
Internals class holding vectors of states, thier associated rates and auxiliary (aux) state which is calculated from the state through running compute_rates
Internals(s_size, a_size)
Internals(s_size, a_size)
s_size |
??? |
a_size |
??? |
Interpolate data on size distributions for each species to specific heights at every time point
interpolate_to_heights(tidy_species_data, heights, method = "natural")
interpolate_to_heights(tidy_species_data, heights, method = "natural")
tidy_species_data |
output of either 'tidy_patch' or 'tidy_species' |
heights |
heights to interpolate to |
method |
Method for interpolation. For more info see help on stats::spline |
Returns a tibble of similar format to input, but with all outputs interpolated to specified hieghts.
Interpolate data on size distributions for each species to specific timer points, using specified interpolation method
interpolate_to_times(tidy_species_data, times, method = "natural")
interpolate_to_times(tidy_species_data, times, method = "natural")
tidy_species_data |
output of either 'tidy_patch' or 'tidy_species' |
times |
times to interpolate to |
method |
Method for interpolation. For more info see help on stats::spline |
Returns a tibble of similar format to input, but with all outputs interpolated to specified hieghts.
Hyperparameter function for K93 physiological model
K93_hyperpar(m, s, filter = TRUE)
K93_hyperpar(m, s, filter = TRUE)
m |
A matrix of trait values, as returned by |
s |
A strategy object |
filter |
A flag indicating whether to filter columns. If TRUE, any numbers that are within eps of the default strategy are not replaced. |
Create a K93 Individual or Node
K93_Individual(s = K93_Strategy())
K93_Individual(s = K93_Strategy())
s |
A |
pl <- K93_Individual() pl$height
pl <- K93_Individual() pl$height
Strategy parameters that tune various aspects of the biological model.
K93_Strategy(..., values = list(...))
K93_Strategy(..., values = list(...))
... , values
|
Values to initialise the struct with (either as variadic arguments, or as a list, but not both). |
Hyperparameters for FF16 physiological model
make_FF16_hyperpar( lma_0 = 0.1978791, B_kl1 = 0.4565855, B_kl2 = 1.71, rho_0 = 608, B_dI1 = 0.01, B_dI2 = 0, B_ks1 = 0.2, B_ks2 = 0, B_rs1 = 4012, B_rb1 = 2 * 4012, B_f1 = 3, narea = 0.00187, narea_0 = 0.00187, B_lf1 = 5120.738 * 0.00187 * 24 * 3600/1e+06, B_lf2 = 0.5, B_lf3 = 0.04, B_lf4 = 21000, B_lf5 = 1, k_I = 0.5, latitude = 0 )
make_FF16_hyperpar( lma_0 = 0.1978791, B_kl1 = 0.4565855, B_kl2 = 1.71, rho_0 = 608, B_dI1 = 0.01, B_dI2 = 0, B_ks1 = 0.2, B_ks2 = 0, B_rs1 = 4012, B_rb1 = 2 * 4012, B_f1 = 3, narea = 0.00187, narea_0 = 0.00187, B_lf1 = 5120.738 * 0.00187 * 24 * 3600/1e+06, B_lf2 = 0.5, B_lf3 = 0.04, B_lf4 = 21000, B_lf5 = 1, k_I = 0.5, latitude = 0 )
lma_0 |
Central (mean) value for leaf mass per area [kg /m2] |
B_kl1 |
Rate of leaf turnover at lma_0 [/yr] |
B_kl2 |
Scaling slope for phi in leaf turnover [dimensionless] |
rho_0 |
Central (mean) value for wood density [kg /m3] |
B_dI1 |
Rate of instantaneous mortality at rho_0 [/yr] |
B_dI2 |
Scaling slope for wood density in intrinsic mortality [dimensionless] |
B_ks1 |
Rate of sapwood turnover at rho_0 [/yr] |
B_ks2 |
Scaling slope for rho in sapwood turnover [dimensionless] |
B_rs1 |
CO_2 respiration per unit sapwood volume [mol / yr / m3 ] |
B_rb1 |
CO_2 respiration per unit sapwood volume [mol / yr / m3 ] |
B_f1 |
Cost of seed accessories per unit seed mass [dimensionless] |
narea |
nitrogen per leaf area [kg / m2] |
narea_0 |
central (mean) value for nitrogen per leaf area [kg / m2] |
B_lf1 |
Potential CO_2 photosynthesis at average leaf nitrogen [mol / d / m2] |
B_lf2 |
Curvature of leaf photosynthetic light response curve [dimensionless] |
B_lf3 |
Quantum yield of leaf photosynthetic light response curve [dimensionless] |
B_lf4 |
CO_2 respiration per unit leaf nitrogen [mol / yr / kg] |
B_lf5 |
Scaling exponent for leaf nitrogen in maximum leaf photosynthesis [dimensionless] |
k_I |
light extinction coefficient [dimensionless] |
latitude |
degrees from equator (0-90), used in solar model [deg] |
Hyperparameters for FF16r physiological model
make_FF16r_hyperpar( lma_0 = 0.1978791, B_kl1 = 0.4565855, B_kl2 = 1.71, rho_0 = 608, B_dI1 = 0.01, B_dI2 = 0, B_ks1 = 0.2, B_ks2 = 0, B_rs1 = 4012, B_rb1 = 2 * 4012, B_f1 = 3, narea = 0.00187, narea_0 = 0.00187, B_lf1 = 5120.738 * 0.00187 * 24 * 3600/1e+06, B_lf2 = 0.5, B_lf3 = 0.04, B_lf4 = 21000, B_lf5 = 1, k_I = 0.5, latitude = 0 )
make_FF16r_hyperpar( lma_0 = 0.1978791, B_kl1 = 0.4565855, B_kl2 = 1.71, rho_0 = 608, B_dI1 = 0.01, B_dI2 = 0, B_ks1 = 0.2, B_ks2 = 0, B_rs1 = 4012, B_rb1 = 2 * 4012, B_f1 = 3, narea = 0.00187, narea_0 = 0.00187, B_lf1 = 5120.738 * 0.00187 * 24 * 3600/1e+06, B_lf2 = 0.5, B_lf3 = 0.04, B_lf4 = 21000, B_lf5 = 1, k_I = 0.5, latitude = 0 )
lma_0 |
Central (mean) value for leaf mass per area [kg /m2] |
B_kl1 |
Rate of leaf turnover at lma_0 [/yr] |
B_kl2 |
Scaling slope for phi in leaf turnover [dimensionless] |
rho_0 |
Central (mean) value for wood density [kg /m3] |
B_dI1 |
Rate of instantaneous mortality at rho_0 [/yr] |
B_dI2 |
Scaling slope for wood density in intrinsic mortality [dimensionless] |
B_ks1 |
Rate of sapwood turnover at rho_0 [/yr] |
B_ks2 |
Scaling slope for rho in sapwood turnover [dimensionless] |
B_rs1 |
CO_2 respiration per unit sapwood volume [mol / yr / m3 ] |
B_rb1 |
CO_2 respiration per unit sapwood volume [mol / yr / m3 ] |
B_f1 |
Cost of seed accessories per unit seed mass [dimensionless] |
narea |
nitrogen per leaf area [kg / m2] |
narea_0 |
central (mean) value for nitrogen per leaf area [kg / m2] |
B_lf1 |
Potential CO_2 photosynthesis at average leaf nitrogen [mol / d / m2] |
B_lf2 |
Curvature of leaf photosynthetic light response curve [dimensionless] |
B_lf3 |
Quantum yield of leaf photosynthetic light response curve [dimensionless] |
B_lf4 |
CO_2 respiration per unit leaf nitrogen [mol / yr / kg] |
B_lf5 |
Scaling exponent for leaf nitrogen in maximum leaf photosynthesis [dimensionless] |
k_I |
light extinction coefficient [dimensionless] |
latitude |
degrees from equator (0-90), used in solar model [deg] |
Hyperparameters for FF16w physiological model
Hyperparameter function for FF16w physiological model
make_FF16w_hyperpar( lma_0 = 0.1978791, B_kl1 = 0.4565855, B_kl2 = 1.71, rho_0 = 608, B_dI1 = 0.01, B_dI2 = 0, B_ks1 = 0.2, B_ks2 = 0, B_rs1 = 4012, B_rb1 = 2 * 4012, B_f1 = 3, narea = 0.00187, narea_0 = 0.00187, B_lf1 = 5120.738 * 0.00187 * 24 * 3600/1e+06, B_lf2 = 0.5, B_lf3 = 0.04, B_lf4 = 21000, B_lf5 = 1, k_I = 0.5, latitude = 0 ) FF16w_hyperpar(m, s, filter = TRUE)
make_FF16w_hyperpar( lma_0 = 0.1978791, B_kl1 = 0.4565855, B_kl2 = 1.71, rho_0 = 608, B_dI1 = 0.01, B_dI2 = 0, B_ks1 = 0.2, B_ks2 = 0, B_rs1 = 4012, B_rb1 = 2 * 4012, B_f1 = 3, narea = 0.00187, narea_0 = 0.00187, B_lf1 = 5120.738 * 0.00187 * 24 * 3600/1e+06, B_lf2 = 0.5, B_lf3 = 0.04, B_lf4 = 21000, B_lf5 = 1, k_I = 0.5, latitude = 0 ) FF16w_hyperpar(m, s, filter = TRUE)
lma_0 |
Central (mean) value for leaf mass per area [kg /m2] |
B_kl1 |
Rate of leaf turnover at lma_0 [/yr] |
B_kl2 |
Scaling slope for phi in leaf turnover [dimensionless] |
rho_0 |
Central (mean) value for wood density [kg /m3] |
B_dI1 |
Rate of instantaneous mortality at rho_0 [/yr] |
B_dI2 |
Scaling slope for wood density in intrinsic mortality [dimensionless] |
B_ks1 |
Rate of sapwood turnover at rho_0 [/yr] |
B_ks2 |
Scaling slope for rho in sapwood turnover [dimensionless] |
B_rs1 |
CO_2 respiration per unit sapwood volume [mol / yr / m3 ] |
B_rb1 |
CO_2 respiration per unit sapwood volume [mol / yr / m3 ] |
B_f1 |
Cost of seed accessories per unit seed mass [dimensionless] |
narea |
nitrogen per leaf area [kg / m2] |
narea_0 |
central (mean) value for nitrogen per leaf area [kg / m2] |
B_lf1 |
Potential CO_2 photosynthesis at average leaf nitrogen [mol / d / m2] |
B_lf2 |
Curvature of leaf photosynthetic light response curve [dimensionless] |
B_lf3 |
Quantum yield of leaf photosynthetic light response curve [dimensionless] |
B_lf4 |
CO_2 respiration per unit leaf nitrogen [mol / yr / kg] |
B_lf5 |
Scaling exponent for leaf nitrogen in maximum leaf photosynthesis [dimensionless] |
k_I |
light extinction coefficient [dimensionless] |
latitude |
degrees from equator (0-90), used in solar model [deg] |
m |
A matrix of trait values, as returned by |
s |
A strategy object |
filter |
A flag indicating whether to filter columns. If TRUE, any numbers that are within eps of the default strategy are not replaced. |
Set a suitable hyperparameter function for chosen physiological model
make_hyperpar(type) param_hyperpar(parameters) hyperpar(type)
make_hyperpar(type) param_hyperpar(parameters) hyperpar(type)
type |
Any strategy name as a string, e.g.: |
parameters |
A parameters object |
Construct hyperparameter object for K93 physiological model
make_K93_hyperpar( b_0 = 0.059, b_1 = 0.012, b_2 = 0.00041, c_0 = 0.008, c_1 = 0.00044, d_0 = 0.00073, d_1 = 0.044, eta = 12, k_I = 0.01 )
make_K93_hyperpar( b_0 = 0.059, b_1 = 0.012, b_2 = 0.00041, c_0 = 0.008, c_1 = 0.00044, d_0 = 0.00073, d_1 = 0.044, eta = 12, k_I = 0.01 )
b_0 |
Growth intercept year-1 |
b_1 |
Growth asymptote year-1.(ln cm)-1 |
b_2 |
Growth suppression rate m2.cm-2.year-1 |
c_0 |
Mortality intercept year-1 |
c_1 |
Mortality suppression rate m2.cm-2.year-1 |
d_0 |
Recruitment rate (cm2.year-1) |
d_1 |
Recruitment suppression rate (m2.cm-2) |
eta |
Crown shape parameter |
k_I |
Extinction coefficient used when estimating competitive effect |
Functions for reconstructing a Patch from an SCM
make_patch( state, p, env = make_environment(parameters = p), ctrl = scm_base_control() ) scm_state(i, x) scm_patch(i, x)
make_patch( state, p, env = make_environment(parameters = p), ctrl = scm_base_control() ) scm_state(i, x) scm_patch(i, x)
state |
State object created by |
p |
Parameters object |
env |
Environment object (defaults to FF16_Environment) |
ctrl |
Control object |
i |
Index to extract from |
x |
Result of running |
Create a function that allows integrating aggregate properties of the SCM system.
make_scm_integrate(obj)
make_scm_integrate(obj)
obj |
An object from |
The workflow here is to run an SCM to create an SCM by running
run_scm
, or a set of data from run_scm_collect
and
then reconstitute all the intermediate bits of data so that an any
variable that PlantPlus
tracks can be integrated out.
Because the pre-processing step is reasonably slow, this function
returns a function that takes a variable name and integrates it.
Hyperparameters for TF24 physiological model
make_TF24_hyperpar( lma_0 = 0.1978791, B_kl1 = 0.4565855, B_kl2 = 1.71, rho_0 = 608, B_dI1 = 0.01, B_dI2 = 0, B_ks1 = 0.2, B_ks2 = 0, B_rs1 = 4012, B_rb1 = 2 * 4012, B_f1 = 3, narea = 0.00187, narea_0 = 0.00187, B_lf1 = 5120.738 * 0.00187 * 24 * 3600/1e+06, B_lf2 = 0.5, B_lf3 = 0.04, B_lf4 = 21000, B_lf5 = 1, k_I = 0.5, latitude = 0 )
make_TF24_hyperpar( lma_0 = 0.1978791, B_kl1 = 0.4565855, B_kl2 = 1.71, rho_0 = 608, B_dI1 = 0.01, B_dI2 = 0, B_ks1 = 0.2, B_ks2 = 0, B_rs1 = 4012, B_rb1 = 2 * 4012, B_f1 = 3, narea = 0.00187, narea_0 = 0.00187, B_lf1 = 5120.738 * 0.00187 * 24 * 3600/1e+06, B_lf2 = 0.5, B_lf3 = 0.04, B_lf4 = 21000, B_lf5 = 1, k_I = 0.5, latitude = 0 )
lma_0 |
Central (mean) value for leaf mass per area [kg /m2] |
B_kl1 |
Rate of leaf turnover at lma_0 [/yr] |
B_kl2 |
Scaling slope for phi in leaf turnover [dimensionless] |
rho_0 |
Central (mean) value for wood density [kg /m3] |
B_dI1 |
Rate of instantaneous mortality at rho_0 [/yr] |
B_dI2 |
Scaling slope for wood density in intrinsic mortality [dimensionless] |
B_ks1 |
Rate of sapwood turnover at rho_0 [/yr] |
B_ks2 |
Scaling slope for rho in sapwood turnover [dimensionless] |
B_rs1 |
CO_2 respiration per unit sapwood volume [mol / yr / m3 ] |
B_rb1 |
CO_2 respiration per unit sapwood volume [mol / yr / m3 ] |
B_f1 |
Cost of seed accessories per unit seed mass [dimensionless] |
narea |
nitrogen per leaf area [kg / m2] |
narea_0 |
central (mean) value for nitrogen per leaf area [kg / m2] |
B_lf1 |
Potential CO_2 photosynthesis at average leaf nitrogen [mol / d / m2] |
B_lf2 |
Curvature of leaf photosynthetic light response curve [dimensionless] |
B_lf3 |
Quantum yield of leaf photosynthetic light response curve [dimensionless] |
B_lf4 |
CO_2 respiration per unit leaf nitrogen [mol / yr / kg] |
B_lf5 |
Scaling exponent for leaf nitrogen in maximum leaf photosynthesis [dimensionless] |
k_I |
light extinction coefficient [dimensionless] |
latitude |
degrees from equator (0-90), used in solar model [deg] |
A disturbance-free regime for running individual patches
No_Disturbance()
No_Disturbance()
Generate a suitable set of default node introduction times, biased so that introductions are more closely packed at the beginning of time, become increasingly spread out.
node_schedule_times_default(max_time)
node_schedule_times_default(max_time)
max_time |
Time to generate introduction times up to (the
last introduction time will be at least |
The reason for the stepped distribution is to keep step sizes as series of doublings. Doing this limits the range of possible introduction times from an infinite set of possible values to a very limited subset of values (based on combinations of 1, 0.5, 0.25, 0.125 etc). The reason for doing this is to minimise the number of unique introduction times across all species. The ODE stepper needs to stop at each point where a node is introduced. If each species was selecting a bunch of points that was essentially unique (compared to those selected for all other species), the number of unique node introductions times could get very large, requiring more ODE steps.
Vector of introduction times.
Rich FitzJohn, adapted from original C++ code by Daniel S. Falster.
Schedule of node introduction times
NodeSchedule(n_species)
NodeSchedule(n_species)
n_species |
number of species |
Control parameters for the ode system
OdeControl(..., values = list(...))
OdeControl(..., values = list(...))
... , values
|
Values to initialise the struct with (either as variadic arguments, or as a list, but not both). |
The function 'optimise_individual_rate_at_height_by_trait' and 'optimise_individual_rate_at_size_by_trait' solve for the maximum of some rate (e.g. growth rate) at a specified height within the interval of the bounds of a given trait
optimise_individual_rate_at_size_by_trait( type = "FF16", bounds, log_scale = TRUE, tol = 0.001, size = 1, size_name = "height", rate = size_name, params = scm_base_parameters(type), env = make_environment(type), hyperpars = hyperpar(type), set_state_directly = FALSE ) optimise_individual_rate_at_height_by_trait(..., height = 1)
optimise_individual_rate_at_size_by_trait( type = "FF16", bounds, log_scale = TRUE, tol = 0.001, size = 1, size_name = "height", rate = size_name, params = scm_base_parameters(type), env = make_environment(type), hyperpars = hyperpar(type), set_state_directly = FALSE ) optimise_individual_rate_at_height_by_trait(..., height = 1)
type |
The type of model to use (e.g. "FF16"). Defaults to "FF16" |
bounds |
A vector giving the lower and upper bounds of the trait |
log_scale |
Should the trait be optimised on a log scale? Defaults to TRUE |
tol |
The tolerance for the optimisation |
size |
The size of the individual to optimise the rate at |
size_name |
The name of the size variable specified by |
rate |
The name of the rate to optimise. Defaults to |
params |
The parameters of the model |
env |
The environment of the model |
hyperpars |
The hyperparameter function of the model |
set_state_directly |
If TRUE, set the state directly to the size, otherwise grows the plant to that size. Defaults to FALSE |
... |
Additional parameters passed to |
height |
Heigh at which grow is optimsied. Defaults to 1 |
Isaac Towers, Daniel Falster and Andrew O'Reilly-Nugent
Activate logging with loggr
plant_log_console( file_name = "console", .message = FALSE, .warning = FALSE, .error = FALSE, ... )
plant_log_console( file_name = "console", .message = FALSE, .warning = FALSE, .error = FALSE, ... )
file_name |
File to save output (default = console) |
.message , .warning , .error
|
Include messages, warnings or
errors? By default (and in contrast to |
... |
Additional parameters passed to |
By default plant prints little information about its progress.
This can be modified by enabling logging. A formatter that is
different to the default loggr::log_file
formatter is
selected here; it will print additional information that plant's
internal logging functions record.
"Schedule" events (splitting) are sent to the DEBUG stream,
everything else is sent to INFO. All events have a "routine"
field added to them, which is useful if sent to a Redis server
(using loggr.redis
).
Title
plot_size_distribution(data_species)
plot_size_distribution(data_species)
data_species |
?? |
Gauss-Kronrod Quadrature
QK(rule)
QK(rule)
rule |
Degree of the rule; valid sizes are 15, 21, 31, 41, 51, 61. |
Compute the whole plant light compensation point for a single plant.
resource_compensation_point(p, ...)
resource_compensation_point(p, ...)
p |
A |
... |
Additional arguments that are ignored |
Rich FitzJohn
Check performance on current system using package bench
run_plant_benchmarks( strategy_types = list(FF16 = FF16_Strategy, FF16w = FF16w_Strategy, K93 = K93_Strategy), iterations = 1 )
run_plant_benchmarks( strategy_types = list(FF16 = FF16_Strategy, FF16w = FF16w_Strategy, K93 = K93_Strategy), iterations = 1 )
strategy_types |
A list of name strategy types to be tests |
iterations |
The number of iterations to be run |
A dataframe of results
Run the SCM, returning the SCM object for interrogation
run_scm( p, env = make_environment(parameters = p), ctrl = scm_base_control(), use_ode_times = FALSE )
run_scm( p, env = make_environment(parameters = p), ctrl = scm_base_control(), use_ode_times = FALSE )
p |
Parameters object |
env |
Environment object (defaults to FF16_Environment) |
ctrl |
Control object |
use_ode_times |
Should ODE times be used? |
This is the simplest way of using the SCM, probably.
A SCM
object.
Rich FitzJohn
Run the SCM model, given a Parameters and NodeSchedule
run_scm_collect( p, env = make_environment(parameters = p), ctrl = scm_base_control(), collect_auxiliary_variables = FALSE )
run_scm_collect( p, env = make_environment(parameters = p), ctrl = scm_base_control(), collect_auxiliary_variables = FALSE )
p |
A |
env |
Environment object (defaults to FF16_Environment) |
ctrl |
Control object |
collect_auxiliary_variables |
Return additional strategy variables (eg competition_effect) |
This is mostly a simple wrapper around some of the SCM functions. Not sure if this is how we will generally want to do this. Consider this function liable to change.
Rich FitzJohn
Run a stochastic simulation of a patch, given a Parameters
run_stochastic_collect( p, env = make_environment(parameters = p), ctrl = scm_base_control(), random_schedule = TRUE )
run_stochastic_collect( p, env = make_environment(parameters = p), ctrl = scm_base_control(), random_schedule = TRUE )
p |
A |
env |
Environment object |
ctrl |
Control object |
random_schedule |
setting to TRUE causes algorithm to generate a random schedule based on offspring arrival and area. |
This one might need to be made differently so that different schedules can be added easily. Not sure if this is how we will generally want to do this. Consider this function liable to change.
Rich FitzJohn
Hopefully sensible set of parameters for use with the SCM. Turns accuracy down a bunch, makes it noisy, sets up the hyperparameterisation that we most often use.
scm_base_control()
scm_base_control()
Rich FitzJohn
Basic default settings for a given strategy, environment only really used for templating initially and will be overloaded later by passing an environment to the SCM API (suggesting perhaps the template could be removed).
scm_base_parameters(type = NA, env = environment_type(type))
scm_base_parameters(type = NA, env = environment_type(type))
type |
Any strategy name as a string, e.g.: |
env |
And environment object |
Rich FitzJohn
Sequence in log space
seq_log(from, to, length.out) seq_log_range(r, length.out) seq_range(r, length.out)
seq_log(from, to, length.out) seq_log_range(r, length.out) seq_range(r, length.out)
from |
Starting point |
to |
Ending point |
length.out |
Number of points to generate |
r |
range (i.e., c(from, to) |
Unlike the billions of options for seq
, only
length.out
is supported here, and both from
and
to
must be provided. For completeness, seq_range
generates a range in non-log space.
Rich FitzJohn
Create a list of Strategies or Plants by varying a single trait.
strategy_list( x, parameters, hyperpar = param_hyperpar(parameters), birth_rate_list )
strategy_list( x, parameters, hyperpar = param_hyperpar(parameters), birth_rate_list )
x |
Values for the trait. This must be a matrix, with
column names corresponding to entries in |
parameters |
|
hyperpar |
Hyperparameter function to use. By default links to standard function for this strategy type. |
birth_rate_list |
List object with birth rates for each species in
x. Birth rates can take the form of a scalar (constant) or a vector.
In either case birth rates are set as |
Builds a detailed report on stand grown with TF24 strategy, based on the template Rmd file provided. The reports are rendered as html files and saved in the specified output folder.
TF24_generate_stand_report( results, output_file = "TF24_report.html", overwrite = FALSE, target_ages = NA, input_file = system.file("reports", "TF24_report.Rmd", package = "plant"), quiet = TRUE )
TF24_generate_stand_report( results, output_file = "TF24_report.html", overwrite = FALSE, target_ages = NA, input_file = system.file("reports", "TF24_report.Rmd", package = "plant"), quiet = TRUE )
results |
results of runnning |
output_file |
name of output file |
overwrite |
logical value to determine whether to overwrite existing report |
target_ages |
Patches ages at which to make plots |
input_file |
report script (.Rmd) file to build study report |
quiet |
An option to suppress printing during rendering from knitr, pandoc command line and others. |
html file of the rendered report located in the specified output folder.
Hyperparameter function for TF24 physiological model
TF24_hyperpar(m, s, filter = TRUE)
TF24_hyperpar(m, s, filter = TRUE)
m |
A matrix of trait values, as returned by |
s |
A strategy object |
filter |
A flag indicating whether to filter columns. If TRUE, any numbers that are within eps of the default strategy are not replaced. |
Create a TF24 Plant or Node
TF24_Individual(s = TF24_Strategy())
TF24_Individual(s = TF24_Strategy())
s |
A |
pl <- TF24_Individual() pl$height
pl <- TF24_Individual() pl$height
Strategy parameters that tune various aspects of the biological model.
TF24_Strategy(..., values = list(...))
TF24_Strategy(..., values = list(...))
... , values
|
Values to initialise the struct with (either as variadic arguments, or as a list, but not both). |
Turn 'env' component of solver output into a tidy data object
tidy_env(env)
tidy_env(env)
env |
a list, the 'env' component of solver output. |
a tibble describing the environment in a patch
Turn 'results' of plant solver, when solving individuals into a tidy data object
tidy_individual(results)
tidy_individual(results)
results |
plant solver output. |
a tibble whose columns provide metrics on each individual over time
Turns output of plant solver into a tidy data object
tidy_patch(results)
tidy_patch(results)
results |
output of run_scm_collect |
a list, containing outputs of plant solver in tidy format
Turn 'species' component of plant solver output into a tidy data object
tidy_species(data)
tidy_species(data)
data |
a list, the 'species' component of plant solver output. |
a tibble whose columns provide metrics on each breakpoint in species size distribution
Helper function to create trait matrices suitable for
strategy_list
.
trait_matrix(x, trait_name)
trait_matrix(x, trait_name)
x |
Values |
trait_name |
Name of a single trait |
Rich FitzJohn
Make colours transparent
util_colour_set_opacity(col, opacity = 0.5)
util_colour_set_opacity(col, opacity = 0.5)
col |
Vector of colours |
opacity |
Vector of opacities |
util_colour_set_opacity("red", seq(0, 1, length.out=6)) util_colour_set_opacity(c("red", "blue"), .5)
util_colour_set_opacity("red", seq(0, 1, length.out=6)) util_colour_set_opacity(c("red", "blue"), .5)
Weibull_Disturbance_Regime control object.
Weibull_Disturbance_Regime(max_patch_lifetime)
Weibull_Disturbance_Regime(max_patch_lifetime)
max_patch_lifetime |
Maximum lifetime of a patch, determines length of a simulation |