Skip to main content

ode

Macro ode 

ode!() { /* proc-macro */ }
Expand description

Define an ODE (ordinary differential equation) model.

This is the primary entry point for building pharmacometric ODE models. The macro generates and validates an ODE model and automatically generates its metadata (parameter names, state labels, output labels, route declarations).

§Fields

FieldRequiredDescription
nameyesModel name ("my_model")
paramsyesParameter identifiers [ka, ke, v]
covariatesnoCovariate identifiers [wt, age]
statesyesState identifiers [gut, central]
outputsyesOutput identifiers [cp]
routesnoRoute declarations [bolus(oral) -> gut, infusion(iv) -> central]
diffeqyesClosure |x, p, t, dx, cov| { … } writing derivatives into dx
lagnoClosure returning route‑specific lag times via lag! { route => expr }
fanoClosure returning bioavailability fractions
initnoClosure setting initial state values
outyesClosure |x, p, t, cov, y| { … } mapping states to outputs

§Example

let model = ode! {
    name: "one_cmt_iv",
    params: [ke, v],
    states: [central],
    outputs: [cp],
    routes: [infusion(iv) -> central],
    diffeq: |x, _p, _t, dx, _cov| {
        dx[central] = -ke * x[central];
    },
    out: |x, _p, _t, _cov, y| {
        y[cp] = x[central] / v;
    },
};