diff --git a/NAMESPACE b/NAMESPACE index aebaadca..287e0ee7 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -120,6 +120,7 @@ S3method(compute_terms,cohort) S3method(compute_terms,human) S3method(compute_terms,na) S3method(compute_terms,xde) +S3method(dEIPdt,static) S3method(dHdt,numeric) S3method(dHdt,static) S3method(dLdt,basic) @@ -314,6 +315,7 @@ export(compute_kappa_ty) export(compute_local_frac) export(compute_terms) export(compute_terms_steady) +export(dEIPdt) export(dHdt) export(dLdt) export(dMYZdt) diff --git a/R/adult-GeRM.R b/R/adult-GeRM.R index dd1839ff..0cac2fae 100644 --- a/R/adult-GeRM.R +++ b/R/adult-GeRM.R @@ -109,7 +109,7 @@ dMYZdt.GeRM_dde <- function(t, y, pars, Lambda, kappa) { dGdt <- f*(M - G) - nu*G - (Omega %*% G) dYdt <- f*q*kappa*(M - Y) - (Omega %*% Y) dZdt <- Upsilon %*% diag(f_eip*q_eip*kappa_eip, nPatches) %*% (M_eip - Y_eip) - (Omega %*% Z) - dUdt <- as.vector((Omega_eip - Omega) %*% Upsilon) + dUdt <- as.vector(((1-dEIPdt(t,pars))*Omega_eip - Omega) %*% Upsilon) return(c(dMdt, dGdt, dYdt, dZdt, dUdt, kappa, f, q, g, sigma)) }) diff --git a/R/adult-RM.R b/R/adult-RM.R index 20c6357e..bc927f2b 100644 --- a/R/adult-RM.R +++ b/R/adult-RM.R @@ -105,7 +105,7 @@ dMYZdt.RM_dde <- function(t, y, pars, Lambda, kappa) { dPdt <- f*(M - P) - (Omega %*% P) dYdt <- f*q*kappa*(M - Y) - (Omega %*% Y) dZdt <- Upsilon %*% (fqkappa_eip * (M_eip - Y_eip)) - (Omega %*% Z) - dUdt <- as.vector((Omega_eip - Omega) %*% Upsilon) + dUdt <- as.vector(((1-dEIPdt(t,pars))*Omega_eip - Omega) %*% Upsilon) return(c(dMdt, dPdt, dYdt, dZdt, dUdt, f*q*kappa, g, sigma)) }) diff --git a/R/eip.R b/R/eip.R index 98cbccb0..5c0f4b19 100644 --- a/R/eip.R +++ b/R/eip.R @@ -10,6 +10,16 @@ EIP <- function(t, pars) { UseMethod("EIP", pars$EIPmod) } +#' @title Compute the derivative of the EIP as a function of time +#' @description This method dispatches on the type of `pars$EIPmod`. +#' @param t current simulation time +#' @param pars a [list] +#' @return [numeric] +#' @export +dEIPdt <- function(t, pars) { + UseMethod("dEIPdt", pars$EIPmod) +} + #' @title Modify parameters due to exogenous forcing by all kinds of control #' @description Implements [EIP] for the static model (the EIP is constant) #' @inheritParams EIP @@ -17,6 +27,13 @@ EIP <- function(t, pars) { #' @export EIP.static <- function(t, pars) {pars} +#' @title This function computes the negative derivative of the EIP as a function of time +#' @description Implements [EIP] for the static model (the dEIPdt=0) +#' @inheritParams EIP +#' @return [numeric] +#' @export +dEIPdt.static <- function(t, pars){0} + #' @title Set up the static model for control forcing (do nothing) #' @param pars a [list] #' @return [list] diff --git a/R/utils.R b/R/utils.R index 583700a1..20cbb0a6 100644 --- a/R/utils.R +++ b/R/utils.R @@ -73,18 +73,20 @@ get_inits <- function(pars){ #' @export parse_deout <- function(deout, pars){ varslist = list() - varslist$time = deout[,1] if ('Lpar' %in% names(pars)) { varslist$L = parse_deout_L(deout, pars) + varslist$L$time = deout[,1] } if ('MYZpar' %in% names(pars)) { varslist$MYZ = parse_deout_MYZ(deout, pars) + varslist$MYZ$time = deout[,1] } if ('Xpar' %in% names(pars)) { varslist$XH = parse_deout_X(deout, pars) + varslist$XH$time = deout[,1] } varslist$terms = compute_terms(varslist, deout, pars) - varslist$terms$time = varslist$time + varslist$terms$time = deout[,1] varslist$deout = deout return(varslist) } diff --git a/_pkgdown.yml b/_pkgdown.yml index cfcc5965..a346b457 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -93,6 +93,8 @@ reference: contents: - EIP - EIP.static + - dEIPdt + - dEIPdt.static - setup_eip_static - subtitle: Ztrace desc: | diff --git a/man/dEIPdt.Rd b/man/dEIPdt.Rd new file mode 100644 index 00000000..25de2557 --- /dev/null +++ b/man/dEIPdt.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/eip.R +\name{dEIPdt} +\alias{dEIPdt} +\title{Compute the derivative of the EIP as a function of time} +\usage{ +dEIPdt(t, pars) +} +\arguments{ +\item{t}{current simulation time} + +\item{pars}{a \link{list}} +} +\value{ +\link{numeric} +} +\description{ +This method dispatches on the type of \code{pars$EIPmod}. +} diff --git a/man/dEIPdt.static.Rd b/man/dEIPdt.static.Rd new file mode 100644 index 00000000..2d5114cc --- /dev/null +++ b/man/dEIPdt.static.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/eip.R +\name{dEIPdt.static} +\alias{dEIPdt.static} +\title{This function computes the negative derivative of the EIP as a function of time} +\usage{ +\method{dEIPdt}{static}(t, pars) +} +\arguments{ +\item{t}{current simulation time} + +\item{pars}{a \link{list}} +} +\value{ +\link{numeric} +} +\description{ +Implements \link{EIP} for the static model (the dEIPdt=0) +}