# An extra mortality that grows with the total biomass in the community.
# Like any custom rate function it has to live in the global environment
# or in a package, so that mizer can find it by name.
crowdingMort <- function(params, n, n_pp, n_other, t, component, ...) {
biomass <- sum(n %*% (params@w * params@dw))
# Same dimensions as the mortality rate: species x size
0 * params@mu_b + 1e-14 * biomass
}
params <- NS_params
other_mort(params)[["crowding"]] <- "crowdingMort"
other_mort(params)
# The contribution is included in the mortality rate
range(getMort(params) - getMort(NS_params))
# and can be removed again
other_mort(params)[["crowding"]] <- NULL
other_mort(params)
Run the code above in your browser using DataLab