From a99df2388164c47396d5162215b6f2355de7f1f7 Mon Sep 17 00:00:00 2001 From: Gustav Delius Date: Tue, 6 Aug 2024 13:39:23 +0100 Subject: [PATCH] `steadySingleSpecies()` now checks that species grow at least to maturity. --- R/steadySingleSpecies.R | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/R/steadySingleSpecies.R b/R/steadySingleSpecies.R index 89ed09b3..1a229106 100644 --- a/R/steadySingleSpecies.R +++ b/R/steadySingleSpecies.R @@ -43,6 +43,12 @@ steadySingleSpecies <- function(params, species = NULL, w_max_idx <- sum(params@w <= params@species_params[sp, "w_max"]) idx <- w_min_idx:(w_max_idx - 1) + # Check that species can grow to maturity at least + w_mat_idx <- sum(params@w <= params@species_params[sp, "w_mat"]) + if (any(growth[w_min_idx:w_mat_idx] == 0)) { + stop(sp, " cannot grow to maturity") + } + # Keep egg density constant n0 <- params@initial_n[sp, w_min_idx] # Steady state solution of the upwind-difference scheme used in project