calculate_nutrient_balance: Calculate nutrient balance (Mid-level - Main function)

View source: R/07-nutrient-regeneration.R

calculate_nutrient_balanceR Documentation

Calculate nutrient balance (Mid-level - Main function)

Description

Calculates daily nitrogen and phosphorus fluxes (ingestion, retention, excretion) for a fish using prey and predator elemental concentrations.

Usage

calculate_nutrient_balance(consumption, weight_gain, processed_nutrient_params)

Arguments

consumption

Vector of consumption by prey type (g/day)

weight_gain

Predator weight gain (g/day)

processed_nutrient_params

List with processed nutrient parameters

Value

A named list with three elements:

nitrogen

Named list with six numeric scalars describing daily nitrogen fluxes (g N/day): consumed, assimilated, growth, excretion, egestion, and assimilation_efficiency (dimensionless fraction, 0–1).

phosphorus

Same structure as nitrogen but for phosphorus (g P/day).

weight_gain

Numeric scalar. Predator weight gain (g/day), as supplied.

Experimental

Nutrient regeneration modelling is an **experimental feature** under active development. This function can be called directly to compute daily N and P fluxes for a single time step, but it is **not yet integrated** into the main 'run_fb4()' simulation loop. Full integration (automatic daily nutrient tracking, inclusion in 'fb4_result' objects, and TMB backend support) is planned for a future release. The API may change.

Examples

params <- list(
  prey_n_concentrations     = c(0.025, 0.030),
  prey_p_concentrations     = c(0.004, 0.005),
  predator_n_concentration  = 0.030,
  predator_p_concentration  = 0.004,
  n_assimilation_efficiency = c(0.80, 0.80),
  p_assimilation_efficiency = c(0.60, 0.60)
)
calculate_nutrient_balance(consumption = c(2.0, 1.0),
                           weight_gain = 0.5,
                           processed_nutrient_params = params)

fb4package documentation built on May 8, 2026, 1:07 a.m.