library(plant)
library(plantpress)
library(dplyr)
library(tidyr)
library(ggplot2)
library(patchwork)Example analysis
example
This worked example follows a complete analysis from model setup to figures. We will create two TF24 strategies, run them together in one patch, turn the size distributions into patch totals, and interpolate the output to requested times and heights.
TF24 soil-water environment
The TF24 model couples plant growth to a multi-layer soil-water balance. Environment("TF24") already provides five soil layers, an initial moisture state, and constant rainfall. The helper below shows how to replace those defaults with 15 layers and seasonal rainfall.
TF24’s hydraulic calculations make long runs expensive, so this example stops at a patch age of 25 years. Choose a lifetime appropriate to your scientific question for a production analysis.
Set up the analysis
Define the shortened patch lifetime and a function that constructs the same custom environment every time the model is run:
max_patch_lifetime <- 25
make_tf24_env <- function(max_patch_lifetime, n_layers = 15, theta0 = 0.2) {
env <- Environment("TF24")
env$set_soil_number_of_depths(n_layers)
env$set_soil_water_state(rep(theta0, n_layers))
# seasonal rainfall around a mean of 1.0
x <- seq(0, max_patch_lifetime, length.out = 1000)
y <- 0.25 * sin(2 * pi * x) + 1.0
env$extrinsic_drivers_set_variable("rainfall", x = x, y = y)
env
}Run the smallest version
A minimal run needs base parameters, at least one strategy, and an environment. The first call refines the node-introduction schedule; the second runs the patch and collects its state:
p0 <- base_parameters("TF24", "TF24_Env")
p0$hyperpar <- fieldtrial::tradeoffs("TF24")
p0$max_patch_lifetime <- max_patch_lifetime
traits <- trait_matrix(c(0.07), c("lma"))
p1 <- add_strategies(p0, traits)
env <- make_tf24_env(max_patch_lifetime)
results <- run(p1, env = env, refine_schedule = TRUE)$scenario$p
results <- tidy(run(results, env = env, record = "steps"))For repeated analyses, helper functions keep assumptions in one place. The first helper starts from TF24 defaults and changes four strategy parameters:
my_base_parameters <- function() {
p0 <- base_parameters("TF24", "TF24_Env")
p0$max_patch_lifetime <- max_patch_lifetime
p0$strategy_default$pars$hmat <- 15
p0$strategy_default$pars$rho <- 700
p0$strategy_default$pars$a_l1 <- 2.17
p0$strategy_default$pars$a_l2 <- 0.5
p0
}The run helper below combines two kinds of input:
- biological choices: traits, birth rates, and
B_lf1, a coefficient of the TF24 trade-offs that thefieldtrialpackage supplies; - a numerical choice: whether to refine the node-introduction schedule.
run_mypatch <- function(
traits = trait_matrix(c(0.07), c("lma")),
birth_rate = 10,
B_lf1 = 0.009,
p0 = my_base_parameters(),
optimise_schedule = FALSE
) {
p0$hyperpar <- fieldtrial::tradeoffs("TF24",
coefficients = list(B_lf1 = B_lf1))
birth_rate <- rep_len(birth_rate, nrow(traits))
p1 <- add_strategies(p0, traits, birth_rate = birth_rate)
env <- make_tf24_env(p0$max_patch_lifetime)
if(optimise_schedule)
result <- run(p1, env = env, refine_schedule = TRUE)$scenario$p
else
result <- p1
# gather outputs at each time step
tidy(run(result, env = env, record = "steps"))
}Run two strategies together
Run a patch for two strategies. Here, we provide two LMA values, representing thin leaves (0.07) and thicker leaves (0.24). To run one species, supply a one-row trait matrix; add_strategies() requires at least one strategy before the patch can be simulated.
results <-
run_mypatch(traits=trait_matrix(c(0.07, 0.24), c("lma")))Because run_mypatch() returns tidy() of a run with record = "steps", its result is already organised for analysis. The species table has one row per node at each recorded step; steps and env describe patch time and environment.
results_tidy <- results
results_tidy$steps
# A tibble: 102 × 3
step time patch_density
<int> <dbl> <dbl>
1 1 0 0.140
2 2 0.00001 0.140
3 3 0.00002 0.140
4 4 0.00003 0.140
5 5 0.00004 0.140
6 6 0.00005 0.140
7 7 0.00006 0.140
8 8 0.00007 0.140
9 9 0.00008 0.140
10 10 0.0000953 0.140
# ℹ 92 more rows
$n_spp
[1] 2
$species
# A tibble: 10,506 × 33
species time step patch_density node density log_density height mortality
<chr> <dbl> <int> <dbl> <int> <dbl> <dbl> <dbl> <dbl>
1 1 0 1 0.140 1 21.4 3.07 0.0351 0
2 1 1e-5 2 0.140 1 21.4 3.07 0.0351 1.00e-7
3 1 1e-5 2 0.140 2 21.4 3.07 0.0351 0
4 1 2e-5 3 0.140 1 21.4 3.07 0.0351 6.47e-4
5 1 2e-5 3 0.140 2 21.4 3.07 0.0351 1.00e-7
6 1 2e-5 3 0.140 3 21.4 3.07 0.0351 0
7 1 3e-5 4 0.140 1 21.4 3.06 0.0351 6.47e-4
8 1 3e-5 4 0.140 2 21.4 3.06 0.0351 6.46e-4
9 1 3e-5 4 0.140 3 21.4 3.06 0.0351 1.00e-7
10 1 3e-5 4 0.140 4 21.4 3.07 0.0351 0
# ℹ 10,496 more rows
# ℹ 24 more variables: fecundity <dbl>, area_heartwood <dbl>,
# mass_heartwood <dbl>, storage <dbl>, log_area_leaf_departure <dbl>,
# log_area_sapwood_departure <dbl>, leaf_marginal_return_tracked <dbl>,
# offspring_produced_survival_weighted <dbl>, competition_effect <dbl>,
# height_inverse <dbl>, net_mass_production_dt <dbl>, root_mass <dbl>,
# opt_psi_leaf <dbl>, opt_root_psi <dbl>, transpiration <dbl>, E_up_ <dbl>, …
$env
$env$light_availability
# A tibble: 6,630 × 6
time step patch_density height light_availability slope
<dbl> <int> <dbl> <dbl> <dbl> <dbl>
1 0 1 0.140 0 1 0
2 0 1 0.140 0.000548 1 0
3 0 1 0.140 0.00110 1 0
4 0 1 0.140 0.00164 1 0
5 0 1 0.140 0.00219 1 0
6 0 1 0.140 0.00274 1 0
7 0 1 0.140 0.00329 1 0
8 0 1 0.140 0.00384 1 0
9 0 1 0.140 0.00438 1 0
10 0 1 0.140 0.00493 1 0
# ℹ 6,620 more rows
$env$soil_moist
# A tibble: 1,530 × 4
time step patch_density soil_moist
<dbl> <int> <dbl> <dbl>
1 0 1 0.140 0.2
2 0 1 0.140 0.2
3 0 1 0.140 0.2
4 0 1 0.140 0.2
5 0 1 0.140 0.2
6 0 1 0.140 0.2
7 0 1 0.140 0.2
8 0 1 0.140 0.2
9 0 1 0.140 0.2
10 0 1 0.140 0.2
# ℹ 1,520 more rows
$env$soil_psi
# A tibble: 1,530 × 4
time step patch_density soil_psi
<dbl> <int> <dbl> <dbl>
1 0 1 0.140 0.264
2 0 1 0.140 0.264
3 0 1 0.140 0.264
4 0 1 0.140 0.264
5 0 1 0.140 0.264
6 0 1 0.140 0.264
7 0 1 0.140 0.264
8 0 1 0.140 0.264
9 0 1 0.140 0.264
10 0 1 0.140 0.264
# ℹ 1,520 more rows
$env$soil_depth
# A tibble: 1,530 × 4
time step patch_density soil_depth
<dbl> <int> <dbl> <dbl>
1 0 1 0.140 0.1
2 0 1 0.140 0.2
3 0 1 0.140 0.3
4 0 1 0.140 0.4
5 0 1 0.140 0.5
6 0 1 0.140 0.6
7 0 1 0.140 0.7
8 0 1 0.140 0.8
9 0 1 0.140 0.9
10 0 1 0.140 1
# ℹ 1,520 more rows
$env$soil_layer_width
# A tibble: 1,530 × 4
time step patch_density soil_layer_width
<dbl> <int> <dbl> <dbl>
1 0 1 0.140 0.1
2 0 1 0.140 0.1
3 0 1 0.140 0.1
4 0 1 0.140 0.1
5 0 1 0.140 0.1
6 0 1 0.140 0.1
7 0 1 0.140 0.1
8 0 1 0.140 0.1
9 0 1 0.140 0.1
10 0 1 0.140 0.1
# ℹ 1,520 more rows
$env$soil_moist_cumulative_flux
# A tibble: 102 × 8
time step patch_density sum_rainfall sum_infiltration sum_drainage
<dbl> <int> <dbl> <dbl> <dbl> <dbl>
1 0 1 0.140 0 0 0
2 0.00001 2 0.140 0.0000100 0.00000998 0.00000000758
3 0.00002 3 0.140 0.0000200 0.0000200 0.0000000152
4 0.00003 4 0.140 0.0000300 0.0000299 0.0000000227
5 0.00004 5 0.140 0.0000400 0.0000399 0.0000000303
6 0.00005 6 0.140 0.0000500 0.0000499 0.0000000379
7 0.00006 7 0.140 0.0000600 0.0000599 0.0000000455
8 0.00007 8 0.140 0.0000700 0.0000698 0.0000000530
9 0.00008 9 0.140 0.0000800 0.0000798 0.0000000606
10 0.0000953 10 0.140 0.0000953 0.0000950 0.0000000722
# ℹ 92 more rows
# ℹ 2 more variables: sum_resource_depletion <dbl>, sum_pulse_runoff <dbl>
$offspring_production
[1] 5.102273e+01 2.332343e-21
$net_reproduction_ratios
[1] 5.102273e+00 2.332343e-22
$p
$patch_area
[1] 1
$n_patches
[1] 1
$fitness_weighting
[1] "patch_age"
$max_patch_lifetime
[1] 25
$fitness_window_start
[1] 0
$fitness_window_end
[1] 0
$fitness_window_weight_x
numeric(0)
$fitness_window_weight_y
numeric(0)
$strategies
$strategies[[1]]
$pars
$lma
[1] 0.07
$rho
[1] 700
$hmat
[1] 15
$omega
[1] 3.8e-05
$eta
[1] 12
$theta
[1] 0.0002141786
$a_l1
[1] 2.17
$a_l2
[1] 0.5
$a_r1
[1] 0.07
$a_cr1
[1] 0
$a_b1
[1] 0.17
$r_s
[1] 5.731429
$r_b
[1] 11.46286
$r_r
[1] 217
$r_cr
[1] 6.598684
$r_l
[1] 640.9011
$a_y
[1] 0.7
$a_bio
[1] 0.0245
$k_l
[1] 2.699283
$k_b
[1] 0.2
$k_s
[1] 0.2
$k_r
[1] 1
$k_cr
[1] 0.2
$a_f3
[1] 0.000114
$a_f1
[1] 1
$a_f2
[1] 50
$S_D
[1] 0.25
$a_d0
[1] 0.1
$d_I
[1] 0.01
$a_dG1
[1] 5.5
$a_dG2
[1] 20
$a_st1
[1] 0.1
$a_st2
[1] 0.1
$a_st3
[1] 0.8
$storage_relaxation_offset
[1] 0.01917808
$a_pl0
[1] 0
$a_pl1
[1] 0
$a_pl2
[1] 0.2
$a_pl3
[1] 0.05
$a_pl4
[1] 3
$a_sw
[1] 0
$k_I
[1] 0.5
$vcmax_25
[1] 96
$stem_P50
[1] 2.888726
$K_s
[1] 0.3357738
$stem_c
[1] 2.04
$stem_b
[1] 3.457268
$psi_crit
[1] 5.91988
$TF24_beta2
[1] 1.5
$TF24_cost_scale
[1] 7.5
$TF24_floor_lambda_o
[1] 0
$jmax_25
[1] 157.44
$phi_J
[1] 0.3529412
$curv_fact_elec_trans
[1] 0.7
$curv_fact_colim
[1] 0.99
$R_d_25
[1] 1.44
$root_depth_shape_eta
[1] 0.2
$root_c
[1] 2.680147
$root_P50
[1] 3.4
$root_b
[1] 3.898245
$root_psi_crit
[1] 5.870283
$rooting_depth_max
[1] 1.5
$D_c
[1] 0.2
$theta_c
[1] 0
$L_tip
[1] 0.02
$recruitment_decay
[1] 0
$use_energy_balance
[1] 0
$d
[1] 0.05
$alpha_PAR
[1] 0.85
$alpha_NIR
[1] 0.2
$L_crown
[1] 2
$g_min
[1] 0
attr(,"class")
[1] "TF24_Pars"
$control
$function_integration_rule
[1] 21
$shading_model
[1] ""
$ppa_layer_optical_depth
[1] 0.5
$ppa_layer_smoothing
[1] 0.3
$offspring_height_tol
[1] 1e-12
$node_gradient_eps
[1] 1e-06
$node_gradient_direction
[1] -1
$node_gradient_richardson
[1] FALSE
$node_gradient_richardson_depth
[1] 4
$node_density_coordinate
[1] "auto"
$absorb_epsilon
[1] 0
$ode_step_size_initial
[1] 1e-06
$ode_step_size_min
[1] 1e-06
$ode_step_size_max
[1] 5
$ode_tol_rel
[1] 1e-05
$ode_tol_abs
[1] 1e-05
$ode_a_y
[1] 1
$ode_a_dydt
[1] 0
$ode_soil_substep
[1] FALSE
$ode_soil_substep_tol
[1] 1e-09
$ode_tol_scale_soil
[1] 1
$fixed_time_step
[1] 0
$schedule_nsteps
[1] 20
$schedule_eps
[1] 0.02
$schedule_verbose
[1] FALSE
$gradient_curvature_floor
[1] 0.001
$GSS_tol_abs
[1] 0.001
$vulnerability_curve_ncontrol
[1] 800
$ci_abs_tol
[1] 0.001
$ci_niter
[1] 1000
$stochastic_death_interval
[1] 0.05
attr(,"class")
[1] "Control"
$collect_all_auxiliary
[1] FALSE
$birth_rate_x
numeric(0)
$birth_rate_y
[1] 10
$is_variable_birth_rate
[1] FALSE
attr(,"class")
[1] "TF24_Model"
$strategies[[2]]
$pars
$lma
[1] 0.24
$rho
[1] 700
$hmat
[1] 15
$omega
[1] 3.8e-05
$eta
[1] 12
$theta
[1] 0.0002141786
$a_l1
[1] 2.17
$a_l2
[1] 0.5
$a_r1
[1] 0.07
$a_cr1
[1] 0
$a_b1
[1] 0.17
$r_s
[1] 5.731429
$r_b
[1] 11.46286
$r_r
[1] 217
$r_cr
[1] 6.598684
$r_l
[1] 320.8045
$a_y
[1] 0.7
$a_bio
[1] 0.0245
$k_l
[1] 0.32825
$k_b
[1] 0.2
$k_s
[1] 0.2
$k_r
[1] 1
$k_cr
[1] 0.2
$a_f3
[1] 0.000114
$a_f1
[1] 1
$a_f2
[1] 50
$S_D
[1] 0.25
$a_d0
[1] 0.1
$d_I
[1] 0.01
$a_dG1
[1] 5.5
$a_dG2
[1] 20
$a_st1
[1] 0.1
$a_st2
[1] 0.1
$a_st3
[1] 0.8
$storage_relaxation_offset
[1] 0.01917808
$a_pl0
[1] 0
$a_pl1
[1] 0
$a_pl2
[1] 0.2
$a_pl3
[1] 0.05
$a_pl4
[1] 3
$a_sw
[1] 0
$k_I
[1] 0.5
$vcmax_25
[1] 96
$stem_P50
[1] 2.888726
$K_s
[1] 0.3357738
$stem_c
[1] 2.04
$stem_b
[1] 3.457268
$psi_crit
[1] 5.91988
$TF24_beta2
[1] 1.5
$TF24_cost_scale
[1] 7.5
$TF24_floor_lambda_o
[1] 0
$jmax_25
[1] 157.44
$phi_J
[1] 0.3529412
$curv_fact_elec_trans
[1] 0.7
$curv_fact_colim
[1] 0.99
$R_d_25
[1] 1.44
$root_depth_shape_eta
[1] 0.2
$root_c
[1] 2.680147
$root_P50
[1] 3.4
$root_b
[1] 3.898245
$root_psi_crit
[1] 5.870283
$rooting_depth_max
[1] 1.5
$D_c
[1] 0.2
$theta_c
[1] 0
$L_tip
[1] 0.02
$recruitment_decay
[1] 0
$use_energy_balance
[1] 0
$d
[1] 0.05
$alpha_PAR
[1] 0.85
$alpha_NIR
[1] 0.2
$L_crown
[1] 2
$g_min
[1] 0
attr(,"class")
[1] "TF24_Pars"
$control
$function_integration_rule
[1] 21
$shading_model
[1] ""
$ppa_layer_optical_depth
[1] 0.5
$ppa_layer_smoothing
[1] 0.3
$offspring_height_tol
[1] 1e-12
$node_gradient_eps
[1] 1e-06
$node_gradient_direction
[1] -1
$node_gradient_richardson
[1] FALSE
$node_gradient_richardson_depth
[1] 4
$node_density_coordinate
[1] "auto"
$absorb_epsilon
[1] 0
$ode_step_size_initial
[1] 1e-06
$ode_step_size_min
[1] 1e-06
$ode_step_size_max
[1] 5
$ode_tol_rel
[1] 1e-05
$ode_tol_abs
[1] 1e-05
$ode_a_y
[1] 1
$ode_a_dydt
[1] 0
$ode_soil_substep
[1] FALSE
$ode_soil_substep_tol
[1] 1e-09
$ode_tol_scale_soil
[1] 1
$fixed_time_step
[1] 0
$schedule_nsteps
[1] 20
$schedule_eps
[1] 0.02
$schedule_verbose
[1] FALSE
$gradient_curvature_floor
[1] 0.001
$GSS_tol_abs
[1] 0.001
$vulnerability_curve_ncontrol
[1] 800
$ci_abs_tol
[1] 0.001
$ci_niter
[1] 1000
$stochastic_death_interval
[1] 0.05
attr(,"class")
[1] "Control"
$collect_all_auxiliary
[1] FALSE
$birth_rate_x
numeric(0)
$birth_rate_y
[1] 10
$is_variable_birth_rate
[1] FALSE
attr(,"class")
[1] "TF24_Model"
$strategy_default
$pars
$lma
[1] 0.1978791
$rho
[1] 700
$hmat
[1] 15
$omega
[1] 3.8e-05
$eta
[1] 12
$theta
[1] 0.0002141786
$a_l1
[1] 2.17
$a_l2
[1] 0.5
$a_r1
[1] 0.07
$a_cr1
[1] 0
$a_b1
[1] 0.17
$r_s
[1] 6.598684
$r_b
[1] 13.19737
$r_r
[1] 217
$r_cr
[1] 6.598684
$r_l
[1] 198.4545
$a_y
[1] 0.7
$a_bio
[1] 0.0245
$k_l
[1] 0.4565855
$k_b
[1] 0.2
$k_s
[1] 0.2
$k_r
[1] 1
$k_cr
[1] 0.2
$a_f3
[1] 0.000114
$a_f1
[1] 1
$a_f2
[1] 50
$S_D
[1] 0.25
$a_d0
[1] 0.1
$d_I
[1] 0.01
$a_dG1
[1] 5.5
$a_dG2
[1] 20
$a_st1
[1] 0.1
$a_st2
[1] 0.1
$a_st3
[1] 0.8
$storage_relaxation_offset
[1] 0.01917808
$a_pl0
[1] 0
$a_pl1
[1] 0
$a_pl2
[1] 0.2
$a_pl3
[1] 0.05
$a_pl4
[1] 3
$a_sw
[1] 0
$k_I
[1] 0.5
$vcmax_25
[1] 96
$stem_P50
[1] 2.888726
$K_s
[1] 0.3357738
$stem_c
[1] 2.04
$stem_b
[1] 3.457268
$psi_crit
[1] 5.91988
$TF24_beta2
[1] 1.5
$TF24_cost_scale
[1] 7.5
$TF24_floor_lambda_o
[1] 0
$jmax_25
[1] 157.44
$phi_J
[1] 0.3529412
$curv_fact_elec_trans
[1] 0.7
$curv_fact_colim
[1] 0.99
$R_d_25
[1] 1.44
$root_depth_shape_eta
[1] 0.2
$root_c
[1] 2.680147
$root_P50
[1] 3.4
$root_b
[1] 3.898245
$root_psi_crit
[1] 5.870283
$rooting_depth_max
[1] 1.5
$D_c
[1] 0.2
$theta_c
[1] 0
$L_tip
[1] 0.02
$recruitment_decay
[1] 0
$use_energy_balance
[1] 0
$d
[1] 0.05
$alpha_PAR
[1] 0.85
$alpha_NIR
[1] 0.2
$L_crown
[1] 2
$g_min
[1] 0
attr(,"class")
[1] "TF24_Pars"
$control
$function_integration_rule
[1] 21
$shading_model
[1] ""
$ppa_layer_optical_depth
[1] 0.5
$ppa_layer_smoothing
[1] 0.3
$offspring_height_tol
[1] 1e-12
$node_gradient_eps
[1] 1e-06
$node_gradient_direction
[1] -1
$node_gradient_richardson
[1] FALSE
$node_gradient_richardson_depth
[1] 4
$node_density_coordinate
[1] "auto"
$absorb_epsilon
[1] 0
$ode_step_size_initial
[1] 1e-06
$ode_step_size_min
[1] 1e-06
$ode_step_size_max
[1] 5
$ode_tol_rel
[1] 1e-05
$ode_tol_abs
[1] 1e-05
$ode_a_y
[1] 1
$ode_a_dydt
[1] 0
$ode_soil_substep
[1] FALSE
$ode_soil_substep_tol
[1] 1e-09
$ode_tol_scale_soil
[1] 1
$fixed_time_step
[1] 0
$schedule_nsteps
[1] 20
$schedule_eps
[1] 0.02
$schedule_verbose
[1] FALSE
$gradient_curvature_floor
[1] 0.001
$GSS_tol_abs
[1] 0.001
$vulnerability_curve_ncontrol
[1] 800
$ci_abs_tol
[1] 0.001
$ci_niter
[1] 1000
$stochastic_death_interval
[1] 0.05
attr(,"class")
[1] "Control"
$collect_all_auxiliary
[1] FALSE
$birth_rate_x
numeric(0)
$birth_rate_y
[1] 1
$is_variable_birth_rate
[1] FALSE
attr(,"class")
[1] "TF24_Model"
$node_schedule_times_default
[1] 0.000000e+00 1.000000e-05 2.000000e-05 3.000000e-05 4.000000e-05
[6] 5.000000e-05 6.000000e-05 7.000000e-05 8.000000e-05 9.525879e-05
[11] 1.105176e-04 1.257764e-04 1.410352e-04 1.562939e-04 1.868115e-04
[16] 2.173291e-04 2.478467e-04 2.783643e-04 3.088818e-04 3.699170e-04
[21] 4.309521e-04 4.919873e-04 5.530225e-04 6.140576e-04 7.361279e-04
[26] 8.581982e-04 9.802686e-04 1.102339e-03 1.224409e-03 1.468550e-03
[31] 1.712690e-03 1.956831e-03 2.200972e-03 2.445112e-03 2.933394e-03
[36] 3.421675e-03 3.909956e-03 4.398237e-03 4.886519e-03 5.863081e-03
[41] 6.839644e-03 7.816206e-03 8.792769e-03 9.769331e-03 1.172246e-02
[46] 1.367558e-02 1.562871e-02 1.758183e-02 1.953496e-02 2.344121e-02
[51] 2.734746e-02 3.125371e-02 3.515996e-02 3.906621e-02 4.687871e-02
[56] 5.469121e-02 6.250371e-02 7.031621e-02 7.812871e-02 9.375371e-02
[61] 1.093787e-01 1.250037e-01 1.406287e-01 1.562537e-01 1.875037e-01
[66] 2.187537e-01 2.500037e-01 2.812537e-01 3.125037e-01 3.750037e-01
[71] 4.375037e-01 5.000037e-01 5.625037e-01 6.250037e-01 7.500037e-01
[76] 8.750037e-01 1.000004e+00 1.125004e+00 1.250004e+00 1.500004e+00
[81] 1.750004e+00 2.000004e+00 2.250004e+00 2.500004e+00 3.000004e+00
[86] 3.500004e+00 4.000004e+00 4.500004e+00 5.000004e+00 6.000004e+00
[91] 7.000004e+00 8.000004e+00 9.000004e+00 1.000000e+01 1.200000e+01
[96] 1.400000e+01 1.600000e+01 1.800000e+01 2.000000e+01 2.200000e+01
[101] 2.400000e+01
$node_schedule_times
$node_schedule_times[[1]]
[1] 0.000000e+00 1.000000e-05 2.000000e-05 3.000000e-05 4.000000e-05
[6] 5.000000e-05 6.000000e-05 7.000000e-05 8.000000e-05 9.525879e-05
[11] 1.105176e-04 1.257764e-04 1.410352e-04 1.562939e-04 1.868115e-04
[16] 2.173291e-04 2.478467e-04 2.783643e-04 3.088818e-04 3.699170e-04
[21] 4.309521e-04 4.919873e-04 5.530225e-04 6.140576e-04 7.361279e-04
[26] 8.581982e-04 9.802686e-04 1.102339e-03 1.224409e-03 1.468550e-03
[31] 1.712690e-03 1.956831e-03 2.200972e-03 2.445112e-03 2.933394e-03
[36] 3.421675e-03 3.909956e-03 4.398237e-03 4.886519e-03 5.863081e-03
[41] 6.839644e-03 7.816206e-03 8.792769e-03 9.769331e-03 1.172246e-02
[46] 1.367558e-02 1.562871e-02 1.758183e-02 1.953496e-02 2.344121e-02
[51] 2.734746e-02 3.125371e-02 3.515996e-02 3.906621e-02 4.687871e-02
[56] 5.469121e-02 6.250371e-02 7.031621e-02 7.812871e-02 9.375371e-02
[61] 1.093787e-01 1.250037e-01 1.406287e-01 1.562537e-01 1.875037e-01
[66] 2.187537e-01 2.500037e-01 2.812537e-01 3.125037e-01 3.750037e-01
[71] 4.375037e-01 5.000037e-01 5.625037e-01 6.250037e-01 7.500037e-01
[76] 8.750037e-01 1.000004e+00 1.125004e+00 1.250004e+00 1.500004e+00
[81] 1.750004e+00 2.000004e+00 2.250004e+00 2.500004e+00 3.000004e+00
[86] 3.500004e+00 4.000004e+00 4.500004e+00 5.000004e+00 6.000004e+00
[91] 7.000004e+00 8.000004e+00 9.000004e+00 1.000000e+01 1.200000e+01
[96] 1.400000e+01 1.600000e+01 1.800000e+01 2.000000e+01 2.200000e+01
[101] 2.400000e+01
$node_schedule_times[[2]]
[1] 0.000000e+00 1.000000e-05 2.000000e-05 3.000000e-05 4.000000e-05
[6] 5.000000e-05 6.000000e-05 7.000000e-05 8.000000e-05 9.525879e-05
[11] 1.105176e-04 1.257764e-04 1.410352e-04 1.562939e-04 1.868115e-04
[16] 2.173291e-04 2.478467e-04 2.783643e-04 3.088818e-04 3.699170e-04
[21] 4.309521e-04 4.919873e-04 5.530225e-04 6.140576e-04 7.361279e-04
[26] 8.581982e-04 9.802686e-04 1.102339e-03 1.224409e-03 1.468550e-03
[31] 1.712690e-03 1.956831e-03 2.200972e-03 2.445112e-03 2.933394e-03
[36] 3.421675e-03 3.909956e-03 4.398237e-03 4.886519e-03 5.863081e-03
[41] 6.839644e-03 7.816206e-03 8.792769e-03 9.769331e-03 1.172246e-02
[46] 1.367558e-02 1.562871e-02 1.758183e-02 1.953496e-02 2.344121e-02
[51] 2.734746e-02 3.125371e-02 3.515996e-02 3.906621e-02 4.687871e-02
[56] 5.469121e-02 6.250371e-02 7.031621e-02 7.812871e-02 9.375371e-02
[61] 1.093787e-01 1.250037e-01 1.406287e-01 1.562537e-01 1.875037e-01
[66] 2.187537e-01 2.500037e-01 2.812537e-01 3.125037e-01 3.750037e-01
[71] 4.375037e-01 5.000037e-01 5.625037e-01 6.250037e-01 7.500037e-01
[76] 8.750037e-01 1.000004e+00 1.125004e+00 1.250004e+00 1.500004e+00
[81] 1.750004e+00 2.000004e+00 2.250004e+00 2.500004e+00 3.000004e+00
[86] 3.500004e+00 4.000004e+00 4.500004e+00 5.000004e+00 6.000004e+00
[91] 7.000004e+00 8.000004e+00 9.000004e+00 1.000000e+01 1.200000e+01
[96] 1.400000e+01 1.600000e+01 1.800000e+01 2.000000e+01 2.200000e+01
[101] 2.400000e+01
$ode_times
numeric(0)
$ode_step_sizes
numeric(0)
$ode_soil_input_slopes
list()
$ode_soil_substep_ends
list()
$initial_state
numeric(0)
$n_initial_cohorts
numeric(0)
$initial_node_times
numeric(0)
$initial_patch_density
numeric(0)
$initial_pr_patch_survival
numeric(0)
$initial_time
[1] 0
$initial_established
[1] FALSE
$hyperpar
function (m, s, filter = TRUE)
{
lma <- trait_values(m, s, "lma")
rho <- trait_values(m, s, "rho")
omega <- trait_values(m, s, "omega")
K_s <- trait_values(m, s, "K_s")
vcmax_25 <- trait_values(m, s, "vcmax_25")
jmax_25 <- trait_values(m, s, "jmax_25")
econ <- economic_tradeoffs(lma, rho, omega, co)
TF24_cost_scale <- co$B_hks1 * (rho/co$rho_0)^(-co$B_hks2)
if (any(K_s <= 0, na.rm = TRUE)) {
stop("K_s must be > 0 for stem_P50 derivation", call. = FALSE)
}
stem_P50 <- 10^(co$B_Hv1 + co$B_Hv2 * log10(K_s))
stem_c <- co$B_c1 * exp(-co$B_c2 * stem_P50)
stem_b <- stem_P50/((-log(1 - 50/100))^(1/stem_c))
psi_crit <- stem_b * (log(1/0.05))^(1/stem_c)
narea_ls <- (co$a_lf1 + co$B_lf1 * lma * 1000)/1000
narea_lp <- (co$B_lf2 * vcmax_25 + co$B_lf3 * jmax_25)/1000
nmass_ls <- narea_ls/lma
nmass_lp <- narea_lp/lma
r_l <- co$B_lf4 * nmass_ls + co$B_lf5 * nmass_lp
extra <- cbind(k_l = econ$k_l, d_I = econ$d_I, TF24_cost_scale = TF24_cost_scale,
k_s = econ$k_s, r_s = econ$r_s, r_b = econ$r_b, a_f3 = econ$a_f3,
r_l = r_l, stem_c = stem_c, stem_P50 = stem_P50, stem_b = stem_b,
psi_crit = psi_crit)
append_derived(m, extra, s, filter)
}
<bytecode: 0x9c3ade270>
<environment: 0x9c74a87b0>
attr(,"model")
[1] "TF24"
attr(,"coefficients")
attr(,"coefficients")$lma_0
[1] 0.1978791
attr(,"coefficients")$B_kl1
[1] 0.4565855
attr(,"coefficients")$B_kl2
[1] 1.71
attr(,"coefficients")$rho_0
[1] 608
attr(,"coefficients")$B_dI1
[1] 0.01
attr(,"coefficients")$B_dI2
[1] 0
attr(,"coefficients")$B_hks1
[1] 7.5
attr(,"coefficients")$B_hks2
[1] 0
attr(,"coefficients")$B_ks1
[1] 0.2
attr(,"coefficients")$B_ks2
[1] 0
attr(,"coefficients")$B_rs1
[1] 4012
attr(,"coefficients")$B_rb1
[1] 8024
attr(,"coefficients")$B_f1
[1] 3
attr(,"coefficients")$a_lf1
[1] 0.535
attr(,"coefficients")$B_lf1
[1] 0.009
attr(,"coefficients")$B_lf2
[1] 0.004
attr(,"coefficients")$B_lf3
[1] 8e-04
attr(,"coefficients")$B_lf4
[1] 21000
attr(,"coefficients")$B_lf5
[1] 40000
attr(,"coefficients")$B_Hv1
[1] 0.3659157
attr(,"coefficients")$B_Hv2
[1] -0.2
attr(,"coefficients")$B_c1
[1] 2.04
attr(,"coefficients")$B_c2
[1] 0
attr(,"traits")
[1] "lma" "rho" "omega" "K_s" "vcmax_25" "jmax_25"
attr(,"class")
[1] "Parameters<TF24,TF24_Env>" "Parameters"
$events
$time
[1] 0.000000e+00 0.000000e+00 1.000000e-05 1.000000e-05 2.000000e-05
[6] 2.000000e-05 3.000000e-05 3.000000e-05 4.000000e-05 4.000000e-05
[11] 5.000000e-05 5.000000e-05 6.000000e-05 6.000000e-05 7.000000e-05
[16] 7.000000e-05 8.000000e-05 8.000000e-05 9.525879e-05 9.525879e-05
[21] 1.105176e-04 1.105176e-04 1.257764e-04 1.257764e-04 1.410352e-04
[26] 1.410352e-04 1.562939e-04 1.562939e-04 1.868115e-04 1.868115e-04
[31] 2.173291e-04 2.173291e-04 2.478467e-04 2.478467e-04 2.783643e-04
[36] 2.783643e-04 3.088818e-04 3.088818e-04 3.699170e-04 3.699170e-04
[41] 4.309521e-04 4.309521e-04 4.919873e-04 4.919873e-04 5.530225e-04
[46] 5.530225e-04 6.140576e-04 6.140576e-04 7.361279e-04 7.361279e-04
[51] 8.581982e-04 8.581982e-04 9.802686e-04 9.802686e-04 1.102339e-03
[56] 1.102339e-03 1.224409e-03 1.224409e-03 1.468550e-03 1.468550e-03
[61] 1.712690e-03 1.712690e-03 1.956831e-03 1.956831e-03 2.200972e-03
[66] 2.200972e-03 2.445112e-03 2.445112e-03 2.933394e-03 2.933394e-03
[71] 3.421675e-03 3.421675e-03 3.909956e-03 3.909956e-03 4.398237e-03
[76] 4.398237e-03 4.886519e-03 4.886519e-03 5.863081e-03 5.863081e-03
[81] 6.839644e-03 6.839644e-03 7.816206e-03 7.816206e-03 8.792769e-03
[86] 8.792769e-03 9.769331e-03 9.769331e-03 1.172246e-02 1.172246e-02
[91] 1.367558e-02 1.367558e-02 1.562871e-02 1.562871e-02 1.758183e-02
[96] 1.758183e-02 1.953496e-02 1.953496e-02 2.344121e-02 2.344121e-02
[101] 2.734746e-02 2.734746e-02 3.125371e-02 3.125371e-02 3.515996e-02
[106] 3.515996e-02 3.906621e-02 3.906621e-02 4.687871e-02 4.687871e-02
[111] 5.469121e-02 5.469121e-02 6.250371e-02 6.250371e-02 7.031621e-02
[116] 7.031621e-02 7.812871e-02 7.812871e-02 9.375371e-02 9.375371e-02
[121] 1.093787e-01 1.093787e-01 1.250037e-01 1.250037e-01 1.406287e-01
[126] 1.406287e-01 1.562537e-01 1.562537e-01 1.875037e-01 1.875037e-01
[131] 2.187537e-01 2.187537e-01 2.500037e-01 2.500037e-01 2.812537e-01
[136] 2.812537e-01 3.125037e-01 3.125037e-01 3.750037e-01 3.750037e-01
[141] 4.375037e-01 4.375037e-01 5.000037e-01 5.000037e-01 5.625037e-01
[146] 5.625037e-01 6.250037e-01 6.250037e-01 7.500037e-01 7.500037e-01
[151] 8.750037e-01 8.750037e-01 1.000004e+00 1.000004e+00 1.125004e+00
[156] 1.125004e+00 1.250004e+00 1.250004e+00 1.500004e+00 1.500004e+00
[161] 1.750004e+00 1.750004e+00 2.000004e+00 2.000004e+00 2.250004e+00
[166] 2.250004e+00 2.500004e+00 2.500004e+00 3.000004e+00 3.000004e+00
[171] 3.500004e+00 3.500004e+00 4.000004e+00 4.000004e+00 4.500004e+00
[176] 4.500004e+00 5.000004e+00 5.000004e+00 6.000004e+00 6.000004e+00
[181] 7.000004e+00 7.000004e+00 8.000004e+00 8.000004e+00 9.000004e+00
[186] 9.000004e+00 1.000000e+01 1.000000e+01 1.200000e+01 1.200000e+01
[191] 1.400000e+01 1.400000e+01 1.600000e+01 1.600000e+01 1.800000e+01
[196] 1.800000e+01 2.000000e+01 2.000000e+01 2.200000e+01 2.200000e+01
[201] 2.400000e+01 2.400000e+01
$type
[1] "node_introduction" "node_introduction" "node_introduction"
[4] "node_introduction" "node_introduction" "node_introduction"
[7] "node_introduction" "node_introduction" "node_introduction"
[10] "node_introduction" "node_introduction" "node_introduction"
[13] "node_introduction" "node_introduction" "node_introduction"
[16] "node_introduction" "node_introduction" "node_introduction"
[19] "node_introduction" "node_introduction" "node_introduction"
[22] "node_introduction" "node_introduction" "node_introduction"
[25] "node_introduction" "node_introduction" "node_introduction"
[28] "node_introduction" "node_introduction" "node_introduction"
[31] "node_introduction" "node_introduction" "node_introduction"
[34] "node_introduction" "node_introduction" "node_introduction"
[37] "node_introduction" "node_introduction" "node_introduction"
[40] "node_introduction" "node_introduction" "node_introduction"
[43] "node_introduction" "node_introduction" "node_introduction"
[46] "node_introduction" "node_introduction" "node_introduction"
[49] "node_introduction" "node_introduction" "node_introduction"
[52] "node_introduction" "node_introduction" "node_introduction"
[55] "node_introduction" "node_introduction" "node_introduction"
[58] "node_introduction" "node_introduction" "node_introduction"
[61] "node_introduction" "node_introduction" "node_introduction"
[64] "node_introduction" "node_introduction" "node_introduction"
[67] "node_introduction" "node_introduction" "node_introduction"
[70] "node_introduction" "node_introduction" "node_introduction"
[73] "node_introduction" "node_introduction" "node_introduction"
[76] "node_introduction" "node_introduction" "node_introduction"
[79] "node_introduction" "node_introduction" "node_introduction"
[82] "node_introduction" "node_introduction" "node_introduction"
[85] "node_introduction" "node_introduction" "node_introduction"
[88] "node_introduction" "node_introduction" "node_introduction"
[91] "node_introduction" "node_introduction" "node_introduction"
[94] "node_introduction" "node_introduction" "node_introduction"
[97] "node_introduction" "node_introduction" "node_introduction"
[100] "node_introduction" "node_introduction" "node_introduction"
[103] "node_introduction" "node_introduction" "node_introduction"
[106] "node_introduction" "node_introduction" "node_introduction"
[109] "node_introduction" "node_introduction" "node_introduction"
[112] "node_introduction" "node_introduction" "node_introduction"
[115] "node_introduction" "node_introduction" "node_introduction"
[118] "node_introduction" "node_introduction" "node_introduction"
[121] "node_introduction" "node_introduction" "node_introduction"
[124] "node_introduction" "node_introduction" "node_introduction"
[127] "node_introduction" "node_introduction" "node_introduction"
[130] "node_introduction" "node_introduction" "node_introduction"
[133] "node_introduction" "node_introduction" "node_introduction"
[136] "node_introduction" "node_introduction" "node_introduction"
[139] "node_introduction" "node_introduction" "node_introduction"
[142] "node_introduction" "node_introduction" "node_introduction"
[145] "node_introduction" "node_introduction" "node_introduction"
[148] "node_introduction" "node_introduction" "node_introduction"
[151] "node_introduction" "node_introduction" "node_introduction"
[154] "node_introduction" "node_introduction" "node_introduction"
[157] "node_introduction" "node_introduction" "node_introduction"
[160] "node_introduction" "node_introduction" "node_introduction"
[163] "node_introduction" "node_introduction" "node_introduction"
[166] "node_introduction" "node_introduction" "node_introduction"
[169] "node_introduction" "node_introduction" "node_introduction"
[172] "node_introduction" "node_introduction" "node_introduction"
[175] "node_introduction" "node_introduction" "node_introduction"
[178] "node_introduction" "node_introduction" "node_introduction"
[181] "node_introduction" "node_introduction" "node_introduction"
[184] "node_introduction" "node_introduction" "node_introduction"
[187] "node_introduction" "node_introduction" "node_introduction"
[190] "node_introduction" "node_introduction" "node_introduction"
[193] "node_introduction" "node_introduction" "node_introduction"
[196] "node_introduction" "node_introduction" "node_introduction"
[199] "node_introduction" "node_introduction" "node_introduction"
[202] "node_introduction"
$target
[1] "species" "species" "species" "species" "species" "species" "species"
[8] "species" "species" "species" "species" "species" "species" "species"
[15] "species" "species" "species" "species" "species" "species" "species"
[22] "species" "species" "species" "species" "species" "species" "species"
[29] "species" "species" "species" "species" "species" "species" "species"
[36] "species" "species" "species" "species" "species" "species" "species"
[43] "species" "species" "species" "species" "species" "species" "species"
[50] "species" "species" "species" "species" "species" "species" "species"
[57] "species" "species" "species" "species" "species" "species" "species"
[64] "species" "species" "species" "species" "species" "species" "species"
[71] "species" "species" "species" "species" "species" "species" "species"
[78] "species" "species" "species" "species" "species" "species" "species"
[85] "species" "species" "species" "species" "species" "species" "species"
[92] "species" "species" "species" "species" "species" "species" "species"
[99] "species" "species" "species" "species" "species" "species" "species"
[106] "species" "species" "species" "species" "species" "species" "species"
[113] "species" "species" "species" "species" "species" "species" "species"
[120] "species" "species" "species" "species" "species" "species" "species"
[127] "species" "species" "species" "species" "species" "species" "species"
[134] "species" "species" "species" "species" "species" "species" "species"
[141] "species" "species" "species" "species" "species" "species" "species"
[148] "species" "species" "species" "species" "species" "species" "species"
[155] "species" "species" "species" "species" "species" "species" "species"
[162] "species" "species" "species" "species" "species" "species" "species"
[169] "species" "species" "species" "species" "species" "species" "species"
[176] "species" "species" "species" "species" "species" "species" "species"
[183] "species" "species" "species" "species" "species" "species" "species"
[190] "species" "species" "species" "species" "species" "species" "species"
[197] "species" "species" "species" "species" "species" "species"
$target_index
[1] 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1
[38] 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2
[75] 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1
[112] 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2
[149] 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1
[186] 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2
$params
$params[[1]]
numeric(0)
$params[[2]]
numeric(0)
$params[[3]]
numeric(0)
$params[[4]]
numeric(0)
$params[[5]]
numeric(0)
$params[[6]]
numeric(0)
$params[[7]]
numeric(0)
$params[[8]]
numeric(0)
$params[[9]]
numeric(0)
$params[[10]]
numeric(0)
$params[[11]]
numeric(0)
$params[[12]]
numeric(0)
$params[[13]]
numeric(0)
$params[[14]]
numeric(0)
$params[[15]]
numeric(0)
$params[[16]]
numeric(0)
$params[[17]]
numeric(0)
$params[[18]]
numeric(0)
$params[[19]]
numeric(0)
$params[[20]]
numeric(0)
$params[[21]]
numeric(0)
$params[[22]]
numeric(0)
$params[[23]]
numeric(0)
$params[[24]]
numeric(0)
$params[[25]]
numeric(0)
$params[[26]]
numeric(0)
$params[[27]]
numeric(0)
$params[[28]]
numeric(0)
$params[[29]]
numeric(0)
$params[[30]]
numeric(0)
$params[[31]]
numeric(0)
$params[[32]]
numeric(0)
$params[[33]]
numeric(0)
$params[[34]]
numeric(0)
$params[[35]]
numeric(0)
$params[[36]]
numeric(0)
$params[[37]]
numeric(0)
$params[[38]]
numeric(0)
$params[[39]]
numeric(0)
$params[[40]]
numeric(0)
$params[[41]]
numeric(0)
$params[[42]]
numeric(0)
$params[[43]]
numeric(0)
$params[[44]]
numeric(0)
$params[[45]]
numeric(0)
$params[[46]]
numeric(0)
$params[[47]]
numeric(0)
$params[[48]]
numeric(0)
$params[[49]]
numeric(0)
$params[[50]]
numeric(0)
$params[[51]]
numeric(0)
$params[[52]]
numeric(0)
$params[[53]]
numeric(0)
$params[[54]]
numeric(0)
$params[[55]]
numeric(0)
$params[[56]]
numeric(0)
$params[[57]]
numeric(0)
$params[[58]]
numeric(0)
$params[[59]]
numeric(0)
$params[[60]]
numeric(0)
$params[[61]]
numeric(0)
$params[[62]]
numeric(0)
$params[[63]]
numeric(0)
$params[[64]]
numeric(0)
$params[[65]]
numeric(0)
$params[[66]]
numeric(0)
$params[[67]]
numeric(0)
$params[[68]]
numeric(0)
$params[[69]]
numeric(0)
$params[[70]]
numeric(0)
$params[[71]]
numeric(0)
$params[[72]]
numeric(0)
$params[[73]]
numeric(0)
$params[[74]]
numeric(0)
$params[[75]]
numeric(0)
$params[[76]]
numeric(0)
$params[[77]]
numeric(0)
$params[[78]]
numeric(0)
$params[[79]]
numeric(0)
$params[[80]]
numeric(0)
$params[[81]]
numeric(0)
$params[[82]]
numeric(0)
$params[[83]]
numeric(0)
$params[[84]]
numeric(0)
$params[[85]]
numeric(0)
$params[[86]]
numeric(0)
$params[[87]]
numeric(0)
$params[[88]]
numeric(0)
$params[[89]]
numeric(0)
$params[[90]]
numeric(0)
$params[[91]]
numeric(0)
$params[[92]]
numeric(0)
$params[[93]]
numeric(0)
$params[[94]]
numeric(0)
$params[[95]]
numeric(0)
$params[[96]]
numeric(0)
$params[[97]]
numeric(0)
$params[[98]]
numeric(0)
$params[[99]]
numeric(0)
$params[[100]]
numeric(0)
$params[[101]]
numeric(0)
$params[[102]]
numeric(0)
$params[[103]]
numeric(0)
$params[[104]]
numeric(0)
$params[[105]]
numeric(0)
$params[[106]]
numeric(0)
$params[[107]]
numeric(0)
$params[[108]]
numeric(0)
$params[[109]]
numeric(0)
$params[[110]]
numeric(0)
$params[[111]]
numeric(0)
$params[[112]]
numeric(0)
$params[[113]]
numeric(0)
$params[[114]]
numeric(0)
$params[[115]]
numeric(0)
$params[[116]]
numeric(0)
$params[[117]]
numeric(0)
$params[[118]]
numeric(0)
$params[[119]]
numeric(0)
$params[[120]]
numeric(0)
$params[[121]]
numeric(0)
$params[[122]]
numeric(0)
$params[[123]]
numeric(0)
$params[[124]]
numeric(0)
$params[[125]]
numeric(0)
$params[[126]]
numeric(0)
$params[[127]]
numeric(0)
$params[[128]]
numeric(0)
$params[[129]]
numeric(0)
$params[[130]]
numeric(0)
$params[[131]]
numeric(0)
$params[[132]]
numeric(0)
$params[[133]]
numeric(0)
$params[[134]]
numeric(0)
$params[[135]]
numeric(0)
$params[[136]]
numeric(0)
$params[[137]]
numeric(0)
$params[[138]]
numeric(0)
$params[[139]]
numeric(0)
$params[[140]]
numeric(0)
$params[[141]]
numeric(0)
$params[[142]]
numeric(0)
$params[[143]]
numeric(0)
$params[[144]]
numeric(0)
$params[[145]]
numeric(0)
$params[[146]]
numeric(0)
$params[[147]]
numeric(0)
$params[[148]]
numeric(0)
$params[[149]]
numeric(0)
$params[[150]]
numeric(0)
$params[[151]]
numeric(0)
$params[[152]]
numeric(0)
$params[[153]]
numeric(0)
$params[[154]]
numeric(0)
$params[[155]]
numeric(0)
$params[[156]]
numeric(0)
$params[[157]]
numeric(0)
$params[[158]]
numeric(0)
$params[[159]]
numeric(0)
$params[[160]]
numeric(0)
$params[[161]]
numeric(0)
$params[[162]]
numeric(0)
$params[[163]]
numeric(0)
$params[[164]]
numeric(0)
$params[[165]]
numeric(0)
$params[[166]]
numeric(0)
$params[[167]]
numeric(0)
$params[[168]]
numeric(0)
$params[[169]]
numeric(0)
$params[[170]]
numeric(0)
$params[[171]]
numeric(0)
$params[[172]]
numeric(0)
$params[[173]]
numeric(0)
$params[[174]]
numeric(0)
$params[[175]]
numeric(0)
$params[[176]]
numeric(0)
$params[[177]]
numeric(0)
$params[[178]]
numeric(0)
$params[[179]]
numeric(0)
$params[[180]]
numeric(0)
$params[[181]]
numeric(0)
$params[[182]]
numeric(0)
$params[[183]]
numeric(0)
$params[[184]]
numeric(0)
$params[[185]]
numeric(0)
$params[[186]]
numeric(0)
$params[[187]]
numeric(0)
$params[[188]]
numeric(0)
$params[[189]]
numeric(0)
$params[[190]]
numeric(0)
$params[[191]]
numeric(0)
$params[[192]]
numeric(0)
$params[[193]]
numeric(0)
$params[[194]]
numeric(0)
$params[[195]]
numeric(0)
$params[[196]]
numeric(0)
$params[[197]]
numeric(0)
$params[[198]]
numeric(0)
$params[[199]]
numeric(0)
$params[[200]]
numeric(0)
$params[[201]]
numeric(0)
$params[[202]]
numeric(0)
attr(,"class")
[1] "Events"
$event_log
$time
numeric(0)
$type
character(0)
$target
character(0)
$target_index
numeric(0)
$requested
list()
$applied
list()
attr(,"class")
[1] "EventLog"
$control
$function_integration_rule
[1] 21
$shading_model
[1] ""
$ppa_layer_optical_depth
[1] 0.5
$ppa_layer_smoothing
[1] 0.3
$offspring_height_tol
[1] 1e-12
$node_gradient_eps
[1] 1e-06
$node_gradient_direction
[1] -1
$node_gradient_richardson
[1] FALSE
$node_gradient_richardson_depth
[1] 4
$node_density_coordinate
[1] "auto"
$absorb_epsilon
[1] 0
$ode_step_size_initial
[1] 1e-06
$ode_step_size_min
[1] 1e-06
$ode_step_size_max
[1] 5
$ode_tol_rel
[1] 1e-05
$ode_tol_abs
[1] 1e-05
$ode_a_y
[1] 1
$ode_a_dydt
[1] 0
$ode_soil_substep
[1] FALSE
$ode_soil_substep_tol
[1] 1e-09
$ode_tol_scale_soil
[1] 1
$fixed_time_step
[1] 0
$schedule_nsteps
[1] 20
$schedule_eps
[1] 0.02
$schedule_verbose
[1] FALSE
$gradient_curvature_floor
[1] 0.001
$GSS_tol_abs
[1] 0.001
$vulnerability_curve_ncontrol
[1] 800
$ci_abs_tol
[1] 0.001
$ci_niter
[1] 1000
$stochastic_death_interval
[1] 0.05
attr(,"class")
[1] "Control"
Each line in the size-distribution plot follows one node through time. New nodes enter at times chosen by the node schedule, so a recorded step is not the same as one year. Line transparency represents node density: darker trajectories contribute more individuals to the patch.
results_tidy$species %>%
drop_na() %>%
plot_size_distribution()
Calculate patch totals for each strategy
Integration turns a size distribution into one patch-level value per strategy and time. For example, integrating node density over height gives the total number of individuals per square metre:
data_species_tot <-
results_tidy$species %>% integrate_over_size_distribution()
data_species_tot# A tibble: 202 × 33
step time patch_density species density min_height log_density height
<int> <dbl> <dbl> <chr> <dbl> <dbl> <dbl> <dbl>
1 2 0.00001 0.140 1 0.0000999 0.0351 0.000306 3.51e-6
2 2 0.00001 0.140 2 0.0000999 0.0239 0.000431 2.39e-6
3 3 0.00002 0.140 1 0.000200 0.0351 0.000613 7.01e-6
4 3 0.00002 0.140 2 0.000200 0.0239 0.000862 4.77e-6
5 4 0.00003 0.140 1 0.000300 0.0351 0.000919 1.05e-5
6 4 0.00003 0.140 2 0.000300 0.0239 0.00129 7.16e-6
7 5 0.00004 0.140 1 0.000400 0.0351 0.00123 1.40e-5
8 5 0.00004 0.140 2 0.000400 0.0239 0.00172 9.55e-6
9 6 0.00005 0.140 1 0.000500 0.0351 0.00153 1.75e-5
10 6 0.00005 0.140 2 0.000500 0.0239 0.00215 1.19e-5
# ℹ 192 more rows
# ℹ 25 more variables: mortality <dbl>, fecundity <dbl>, area_heartwood <dbl>,
# mass_heartwood <dbl>, storage <dbl>, log_area_leaf_departure <dbl>,
# log_area_sapwood_departure <dbl>, leaf_marginal_return_tracked <dbl>,
# offspring_produced_survival_weighted <dbl>, competition_effect <dbl>,
# height_inverse <dbl>, net_mass_production_dt <dbl>, root_mass <dbl>,
# opt_psi_leaf <dbl>, opt_root_psi <dbl>, transpiration <dbl>, E_up_ <dbl>, …
Plotting that total shows how stem density changes as the patch develops:
data_species_tot %>%
ggplot(aes(time, density, colour=species)) +
geom_line()
expand_state() derives additional quantities, including leaf area and tissue mass, from the states returned by the solver:
results_tidy_expand <- results_tidy %>% expand_state()
results_tidy_expand$species# A tibble: 10,506 × 46
species time step patch_density node density log_density height mortality
<chr> <dbl> <int> <dbl> <int> <dbl> <dbl> <dbl> <dbl>
1 1 0 1 0.140 1 21.4 3.07 0.0351 0
2 1 1e-5 2 0.140 1 21.4 3.07 0.0351 1.00e-7
3 1 1e-5 2 0.140 2 21.4 3.07 0.0351 0
4 1 2e-5 3 0.140 1 21.4 3.07 0.0351 6.47e-4
5 1 2e-5 3 0.140 2 21.4 3.07 0.0351 1.00e-7
6 1 2e-5 3 0.140 3 21.4 3.07 0.0351 0
7 1 3e-5 4 0.140 1 21.4 3.06 0.0351 6.47e-4
8 1 3e-5 4 0.140 2 21.4 3.06 0.0351 6.46e-4
9 1 3e-5 4 0.140 3 21.4 3.06 0.0351 1.00e-7
10 1 3e-5 4 0.140 4 21.4 3.07 0.0351 0
# ℹ 10,496 more rows
# ℹ 37 more variables: fecundity <dbl>, area_heartwood <dbl>,
# mass_heartwood <dbl>, storage <dbl>, log_area_leaf_departure <dbl>,
# log_area_sapwood_departure <dbl>, leaf_marginal_return_tracked <dbl>,
# offspring_produced_survival_weighted <dbl>, competition_effect <dbl>,
# height_inverse <dbl>, net_mass_production_dt <dbl>, root_mass <dbl>,
# opt_psi_leaf <dbl>, opt_root_psi <dbl>, transpiration <dbl>, E_up_ <dbl>, …
To obtain total leaf area, the helper weights individual leaf area by node density and integrates over height at each time:
data_species_tot <-
results_tidy_expand$species %>%
integrate_over_size_distribution()
data_species_tot %>%
ggplot(aes(time, area_leaf, colour = species)) +
geom_line()
In this run, the thin-leaved strategy initially deploys more total leaf area but is later overtaken by the thicker-leaved strategy.
The expanded totals also show how above-ground biomass is divided among leaf, bark, sapwood, and heartwood through time:
v <- c("mass_heartwood", "mass_sapwood", "mass_bark", "mass_leaf")
data_long <-
data_species_tot %>%
select(time,species, one_of(v)) %>%
pivot_longer(cols=starts_with("mass"), names_to = "tissue")
data_long$tissue <- factor(data_long$tissue, levels = v)
species_names <- tibble(species = unique(data_long$species),
species_name = c("Species_1","Species_2"))
data_long %>%
left_join(species_names) %>%
ggplot(aes(time, value, fill=tissue)) +
geom_area() +
labs(x = "Patch age (yr)", y = "Above ground mass (kg/m2)") +
theme_classic() +
xlim(c(0,100)) +
facet_wrap(~species_name)
Interpolate to specific times
The node-introduction schedule sets the times at which new characteristics enter the simulation. It can optionally be refined by the node-spacing algorithm. The recorded steps therefore may not fall at the exact times we want to query. interpolate_to_times() estimates the node states at 1, 5, and 10 years from the existing run:
times <- c(1, 5, 10)
tidy_species_data <- results_tidy$species
tidy_species_new <- interpolate_to_times(tidy_species_data, times)The returned rows contain the state variables at those requested times:
tidy_species_new %>% drop_na()# A tibble: 514 × 32
species node time patch_density density log_density height mortality
<chr> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 1 1 1 0.138 1.44 0.366 3.18 0.0121
2 1 1 5 0.0953 0.413 -0.884 8.31 0.0982
3 1 1 10 0.0298 0.113 -2.18 14.3 0.281
4 1 2 1 0.138 1.44 0.366 3.18 0.0121
5 1 2 5 0.0953 0.413 -0.885 8.31 0.0982
6 1 2 10 0.0298 0.113 -2.18 14.3 0.281
7 1 3 1 0.138 1.44 0.366 3.18 0.0121
8 1 3 5 0.0953 0.413 -0.885 8.30 0.0982
9 1 3 10 0.0298 0.112 -2.18 14.3 0.282
10 1 4 1 0.138 1.44 0.365 3.18 0.0121
# ℹ 504 more rows
# ℹ 24 more variables: fecundity <dbl>, area_heartwood <dbl>,
# mass_heartwood <dbl>, storage <dbl>, log_area_leaf_departure <dbl>,
# log_area_sapwood_departure <dbl>, leaf_marginal_return_tracked <dbl>,
# offspring_produced_survival_weighted <dbl>, competition_effect <dbl>,
# height_inverse <dbl>, net_mass_production_dt <dbl>, root_mass <dbl>,
# opt_psi_leaf <dbl>, opt_root_psi <dbl>, transpiration <dbl>, E_up_ <dbl>, …
To check the interpolation, combine the new rows with the recorded trajectories. The red points lie on the original curves, showing agreement at the requested times:
data_combined <-
tidy_species_data %>%
bind_rows(tidy_species_new) %>%
arrange(species, node, time) %>%
filter(node %in% seq(1, 101, by=20))
data_combined_long <-
data_combined %>%
select(node, time, step, density, height, species) %>%
pivot_longer(cols = c("density", "height"))
data_combined_long %>%
ggplot(aes(time, value, group=node,colour=node)) +
geom_line() +
geom_point(data = data_combined_long %>% filter(is.na(step)), col=2) +
scale_y_log10() +
xlim(c(0, 20)) +
facet_grid(name~species, scales="free") +
theme_classic()
Interpolate to specific heights
The complementary question is: what was the state at a particular height? interpolate_to_heights() estimates values across nodes at each recorded time:
heights <- c(1, 5, 10)
tidy_species_data <- results_tidy$species
tidy_species_new <- interpolate_to_heights(tidy_species_data, heights)These rows contain estimates at heights of 1, 5, and 10 metres:
tidy_species_new %>% drop_na()# A tibble: 278 × 32
species time step patch_density density log_density height mortality
<chr> <dbl> <int> <dbl> <dbl> <dbl> <dbl> <dbl>
1 1 0 1 0.140 21.4 3.07 0.0351 0
2 1 0.00001 2 0.140 21.4 3.07 0.0351 0.000000100
3 1 0.00002 3 0.140 21.4 3.07 0.0351 0.000647
4 1 0.00003 4 0.140 21.4 3.06 0.0351 0.000647
5 1 0.00004 5 0.140 21.4 3.06 0.0351 0.000647
6 1 0.00005 6 0.140 21.4 3.06 0.0351 0.000647
7 1 0.00006 7 0.140 21.4 3.06 0.0351 0.000647
8 1 0.00007 8 0.140 21.4 3.06 0.0351 0.000647
9 1 0.00008 9 0.140 21.4 3.06 0.0351 0.000647
10 1 0.0000953 10 0.140 21.4 3.06 0.0351 0.000647
# ℹ 268 more rows
# ℹ 24 more variables: fecundity <dbl>, area_heartwood <dbl>,
# mass_heartwood <dbl>, storage <dbl>, log_area_leaf_departure <dbl>,
# log_area_sapwood_departure <dbl>, leaf_marginal_return_tracked <dbl>,
# offspring_produced_survival_weighted <dbl>, competition_effect <dbl>,
# height_inverse <dbl>, net_mass_production_dt <dbl>, root_mass <dbl>,
# opt_psi_leaf <dbl>, opt_root_psi <dbl>, transpiration <dbl>, E_up_ <dbl>, …
Again, plotting the estimates as red points against the recorded profiles makes the interpolation easy to assess:
data_combined <-
tidy_species_data %>%
bind_rows(tidy_species_new) %>%
arrange(species, time, height) %>%
filter(step %in% unique(round(seq(min(step, na.rm = TRUE),
max(step, na.rm = TRUE), length.out = 2))))
data_combined_long <-
data_combined %>%
select(node, time, step, height, density, mortality, area_heartwood, species) %>%
pivot_longer(cols = c("density", "mortality", "area_heartwood"))
data_combined_long %>%
filter(!is.na(node)) %>%
ggplot() +
geom_line(aes(height, value, group=step, colour=step)) +
geom_point(data = data_combined_long %>% filter(is.na(node)), aes(x=height, y=value), col="red")+
facet_grid(name~species, scales="free") +
theme_classic()