Skip to main content

analytical

Macro analytical 

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

Define an analytical (closed‑form) PK model.

Builds a model that uses a built‑in analytical solution. The macro validates that the declared parameters match the chosen analytical solution’s requirements and generates an Analytical value with full metadata.

§Fields

FieldRequiredDescription
nameyesModel name
paramsyesParameter identifiers
derivednoDerived parameter identifiers (computed in derive)
covariatesnoCovariate identifiers
statesyesState identifiers
outputsyesOutput identifiers
routesnoRoute declarations
structureyesBuilt‑in kernel name, e.g. one_compartment or one_compartment_with_absorption
derivenoClosure |t| { … } computing derived parameters from primaries and covariates
lagnoLag‑time closure
fanoBioavailability closure
initnoInitial‑state closure
outyesOutput mapping closure

§Example

let model = analytical! {
    name: "one_cmt_oral",
    params: [ka, ke, v],
    states: [gut, central],
    outputs: [cp],
    routes: [bolus(oral) -> gut],
    structure: one_compartment_with_absorption,
    out: |x, _t, y| {
        y[cp] = x[central] / v;
    },
};