Configure the initial state - water depth, temperature and salinity
profile, and biogeochemical water-column pools - that build_aeme() writes
into each model's configuration. Values can be supplied once for every
model (depth, profile, wq) and/or overridden per model via
model_init (for example a GLM-AED-specific temperature profile).
Usage
set_initial_conditions(
aeme,
depth = NULL,
profile = NULL,
wq = NULL,
model_init = NULL,
model_controls = NULL,
from_obs = FALSE,
reset = FALSE
)Arguments
- aeme
Aeme object.
- depth
numeric(1); initial water depth (m), i.e. the height of the lake surface above the lowest point of the hypsograph.
NULL(default) leaves it unchanged.- profile
data.frame; initial profile with a
depthcolumn (positive-down, 0 = surface) and atemperaturecolumn (degC); asaltcolumn (ppt) is optional and defaults to 0.NULL(default) leaves the profile unchanged.- wq
named list; initial water-column values keyed by AEME variable name (e.g.
list(CHM_oxy = 300, NIT_amm = 0.5)). Each element is either a single number (constant with depth) or a data.frame withdepthandvaluecolumns. Names must be present inmodel_controls$var_aeme.NULL(default) leaves water-quality initial values unchanged.- model_init
named list; per-model overrides keyed by model name (
"dy_cd","glm_aed","gotm_wet","simstrat_aed2","simstrat_aed"). Each element is itself a list with any ofdepth,profileandwq, following the same rules as the generic arguments. These are merged over the generic specification when that model is built.NULL(default) leaves per-model overrides unchanged.- model_controls
data.frame; model configuration, typically loaded via
get_model_controls().- from_obs
logical; if
TRUE, seed the generic profile and water-quality values from lake observations viaupdate_init()before the explicit arguments are applied (the explicit arguments take precedence). DefaultFALSE.- reset
logical; if
TRUE, discard any existingconfiguration(aeme)$initial_conditionsbefore applying the arguments. DefaultFALSE, i.e. new values are merged into the existing specification.
Details
The structured specification is stored in
configuration(aeme)$initial_conditions as a list with a default entry
plus an optional entry per model, and is resolved at build time by merging
each model's overrides over the defaults. For backwards compatibility the
generic depth/profile are also written to input(aeme)$init_depth /
input(aeme)$init_profile, and scalar generic wq values into
configuration(aeme)$model_controls$initial_wc, so the generic controls
take effect immediately.
Examples
aeme_file <- system.file("extdata/aeme.rds", package = "AEME")
aeme <- readRDS(aeme_file)
# Generic profile for all models
prof <- data.frame(depth = c(0, 5, 10), temperature = c(18, 14, 11))
aeme <- set_initial_conditions(aeme, depth = 10, profile = prof)
#> ℹ `profile` has no salt column; using 0.
#> ✔ Initial conditions updated.
# GLM-AED-specific override
aeme <- set_initial_conditions(
aeme,
model_init = list(
glm_aed = list(profile = data.frame(depth = c(0, 10),
temperature = c(20, 12)))
)
)
#> ℹ `model_init$glm_aed$profile` has no salt column; using 0.
#> ✔ Initial conditions updated (1 model-specific override).
