R/checkSolution.R

Defines functions checkSolution

Documented in checkSolution

#' Checks whether the solution generated by the ODE solver contains negative values
#' 
#' @param soln Matrix from ode solver out$solution
#' @param tol tolerance
#' @export

checkSolution = function(soln, tol = -0.1) {

    stateVarNames=colnames(soln)
    for (v in 2:length(stateVarNames)) {
        var = stateVarNames[v]
        if (any(soln[, var] < tol,na.rm=TRUE)) {
            warning(paste("MICROPOP WARNING: There are negative values for", var))
        }
        
    }
}

Try the microPop package in your browser

Any scripts or data that you put into this service are public.

microPop documentation built on Feb. 3, 2022, 5:07 p.m.