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
| Field | Required | Description |
|---|---|---|
name | yes | Model name |
params | yes | Parameter identifiers |
derived | no | Derived parameter identifiers (computed in derive) |
covariates | no | Covariate identifiers |
states | yes | State identifiers |
outputs | yes | Output identifiers |
routes | no | Route declarations |
structure | yes | Built‑in kernel name, e.g. one_compartment or one_compartment_with_absorption |
derive | no | Closure |t| { … } computing derived parameters from primaries and covariates |
lag | no | Lag‑time closure |
fa | no | Bioavailability closure |
init | no | Initial‑state closure |
out | yes | Output 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;
},
};