diff --git a/NEWS.md b/NEWS.md index fdb9ca3..163682e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,6 +5,7 @@ * Updated the *in-situ* examples in the README file * Cleaned the `theme_bw()` from README and set default `ggplot` theme with `ggdist::ggdist()` * Fixed the error in README example for plotting the in-situ velocity-acceleration profile +* Fixed error in the `find_optimal_FV_scalar()` function and all upper-level calling functions which happens when `resistance` parameter is below zero # shorts 3.1.0 diff --git a/R/optimal-functions.R b/R/optimal-functions.R index f804946..5e12976 100644 --- a/R/optimal-functions.R +++ b/R/optimal-functions.R @@ -80,8 +80,8 @@ find_optimal_FV_scalar <- function(distance, F0, V0, bodymass = 75, inertia = 0, par = 1, fn = opt_func, method = "Brent", - lower = 1 / min(100, F0 / resistance), - upper = min(100, F0 / resistance) + lower = 1 / min(100, F0 / ifelse(resistance < 0, 0, resistance)), + upper = min(100, F0 / ifelse(resistance < 0, 0, resistance)) ) }, error = function(cond) {