
Update body composition during simulation (Mid-level)
Source:R/05-body-composition.R
update_body_composition.RdUpdates body composition as fish grows or changes condition Used during simulation loops - assumes pre-validated inputs
Usage
update_body_composition(
old_weight,
new_weight,
old_composition = NULL,
processed_composition_params
)Value
A named list with the same 13 elements as
calculate_body_composition, describing the body composition
at new_weight. If old_composition is supplied, an additional
element changes is appended — a named list with five numeric
scalars: weight_change, water_change, protein_change,
fat_change, and energy_density_change (all in the same units
as the corresponding composition elements).
Examples
params <- list(water_fraction = 0.72, fat_energy = 36450,
protein_energy = 17990, max_fat_fraction = 0.30)
old <- calculate_body_composition(weight = 100,
processed_composition_params = params)
update_body_composition(old_weight = 100, new_weight = 110,
old_composition = old,
processed_composition_params = params)
#> $total_weight
#> [1] 110
#>
#> $water_g
#> [1] 79.2
#>
#> $protein_g
#> [1] 17.15258
#>
#> $ash_g
#> [1] 1.973042
#>
#> $fat_g
#> [1] 11.67437
#>
#> $water_fraction
#> [1] 0.72
#>
#> $protein_fraction
#> [1] 0.1559326
#>
#> $ash_fraction
#> [1] 0.01793674
#>
#> $fat_fraction
#> [1] 0.1061307
#>
#> $energy_density
#> [1] 6673.69
#>
#> $total_energy
#> [1] 734105.9
#>
#> $total_fraction
#> [1] 1
#>
#> $balanced
#> [1] TRUE
#>
#> $changes
#> $changes$weight_change
#> [1] 10
#>
#> $changes$water_change
#> [1] 7.2
#>
#> $changes$protein_change
#> [1] 1.670393
#>
#> $changes$fat_change
#> [1] 0.9436867
#>
#> $changes$energy_density_change
#> [1] -22.89148
#>
#>