pmcore::prelude

Type Alias Drift

pub type Drift = fn(_: &Matrix<f64, Dyn, Const<1>, VecStorage<f64, Dyn, Const<1>>>, _: &Matrix<f64, Dyn, Const<1>, VecStorage<f64, Dyn, Const<1>>>, _: f64, _: &mut Matrix<f64, Dyn, Const<1>, VecStorage<f64, Dyn, Const<1>>>, _: Matrix<f64, Dyn, Const<1>, VecStorage<f64, Dyn, Const<1>>>, _: &Covariates);
Expand description

This closure represents the drift term of the model: Params:

  • x: The state vector at time t
  • p: The parameters of the model; Use the [fetch_params!] macro to extract the parameters
  • t: The time at which the drift term is evaluated
  • dx: A mutable reference to the derivative of the state vector at time t
  • rateiv: A vector of infusion rates at time t
  • cov: A reference to the covariates at time t; Use the [fetch_cov!] macro to extract the covariates Example:
use pharmsol::*;
let drift = |x, p, t, dx, rateiv, cov| {
fetch_params!(p, mka, mke, v);
fetch_cov!(cov, t, wt);
ka = dx[2];
ke = dx[3];
dx[0] = -ka * x[0];
dx[1] = ka * x[0] - ke * x[1];
dx[2] = -dx[2] + mka; // Mean reverting to mka
dx[3] = -dx[3] + mke; // Mean reverting to mke
};