Public API#
This page is a task-oriented map of the aquakin API: it points you to the
right entry points for each job. A bare name is importable as aquakin.<name>
and has its full signature and docstring in the API reference.
A name written with its module, such as aquakin.plant.IFASUnit or
aquakin.study.run_study, lives only in that subpackage; the API reference
lists it under aquakin.plant or
aquakin.study. A name from a module below those, such
as aquakin.plant.bsm.build_bsm1, is not in the API reference; read its
docstring with help(). A name written as Plant.<method> is a method of
aquakin.Plant.
Tip
The guide pages — Getting started, Reactors, Plant-wide simulation, Sensitivity analysis, Calibration, Uncertainty and model comparison, Experiment design, Calibrating a plant and Worked example: designing an experiment — walk through these APIs with worked examples, and Key ideas explains the statistics behind the analysis tools. Start there; use this page and the API reference to look things up.
Everything not listed here (the concrete AST node classes, the compile context, the schema
models, the raw Diffrax solver objects) is internal and should not be imported
from aquakin directly. A rate function of your own subclasses the public
RateFunction, whose arguments are ASTNodes, the type of a parsed
sub-expression (see
Rate functions of your own). Reactors are stateless after construction —
solve() takes every variable input as an argument — which is what lets you
jax.vmap a reactor over an ensemble.
Loading and inspecting a model#
To… |
Use |
|---|---|
Load a shipped model by name |
|
Load a model from a YAML file |
|
Reset the model cache |
|
Work with a loaded model |
|
Add a rate function aquakin does not ship |
subclass |
Build a model from a spec, or parse one expression |
|
Conditions#
To… |
Use |
|---|---|
Set conditions for a single tank (0-D) |
|
Set spatially varying conditions (PFR/CFD) |
|
Reactors and solutions#
To… |
Use |
|---|---|
Integrate a well-mixed batch (0-D) |
|
Integrate a plug-flow profile (1-D) |
|
Integrate a non-ideal flow reactor in time (1-D) |
|
Fit a dispersion number or a number of tanks to a tracer test |
|
Integrate along a Lagrangian particle track |
|
Resolve a biofilm over depth (1-D) |
|
React inside a CFD operator split |
|
Handle pumps / dosing / phase switches |
|
Set a reactor’s tolerances, integrator and differentiation |
|
Solutions (BatchSolution, PFRSolution, TrackSolution, BiofilmSolution,
AxialFlowSolution)
share by-name accessors: C_named, C_named_many, final_named, final,
to_dataframe, to_csv, plot.
Plant-wide simulation#
To… |
Use |
|---|---|
Assemble a flowsheet |
|
More unit operations |
|
Control a unit with a law written as an expression |
|
Write a unit of your own |
|
Build the IWA benchmark plants |
|
Catch wiring mistakes |
|
Move water between units |
|
Read a plant result |
|
Save a run to a folder and read it back a slice at a time |
|
Chart a plant’s streams, from a solution or saved results |
|
Compare one channel across several runs |
|
Check a plant’s units before solving |
|
Select a temperature model |
|
Configure aeration |
|
Translate state between models (ASM↔ADM) |
|
Run to steady state |
|
Report progress from a long solve, or cancel it |
|
Flowsheet files#
To… |
Use |
|---|---|
Save a plant as a JSON/YAML file, and build one from it |
|
Read, write and check a flowsheet file |
|
Tell whether a flowsheet’s inputs have changed |
|
Run the same from a terminal |
|
Influent#
To… |
Use |
|---|---|
Split lab measurements into model states |
|
Read a time series from CSV |
|
Read or write an influent as a headed table |
|
Catch a solve that runs outside an influent record |
|
Describe an influent by expressions of time ( |
|
Sensitivity analysis#
To… |
Use |
|---|---|
Gradient of an output w.r.t. parameters/conditions |
|
Cap-free forward sensitivity through a stiff solve |
|
Global (Sobol-total-bound) sensitivity |
|
Variance-based (Sobol first-order and total) sensitivity |
|
Configure differentiation / integration |
|
Guard against silent non-finite gradients |
|
Sensitivities of a plant solve |
|
Gradients through a stiff solve by a chosen adjoint |
|
Uncertainty propagation and process design#
To… |
Use |
|---|---|
Propagate input uncertainty |
|
Compare named scenarios |
|
Optimize a constrained process design (a dose, a size) |
|
Run an ensemble of solves |
|
Calibration#
To… |
Use |
|---|---|
Point-estimate fit |
|
MAP fit + Laplace posterior |
|
Configure the fit |
|
Sample the posterior of a fit (MCMC) |
|
Profile-likelihood interval of one parameter or pool |
|
Identifiability report from a fit or a Fisher matrix |
|
Compare model structures fitted to the same data (AIC, AICc, BIC, Akaike weights) |
|
Save a fit to a folder and read it back |
|
Experiment design#
To… |
Use |
|---|---|
Fisher information of a design (before running it) |
|
Fisher information of any JAX observation function, optionally split by candidate measurement |
|
Score a design (D / A / E / modified-E) |
|
Choose between candidate experiments |
|
Choose the best set of measurements from a candidate pool under a budget |
|
Optimize sampling times and initial concentrations |
|
Design an experiment that tells two fitted models apart (Buzzi-Ferraris, Hunter-Reiner) |
|
Calibrating a plant#
To… |
Use |
|---|---|
MAP fit of plant parameters |
|
Sample the posterior of a plant fit |
|
Name what a plant sensor measures |
|
Fisher information and profile likelihood of plant parameters |
|
Choose plant sensors by the information they add |
|
Studies#
A study is a folder that keeps a simulation, calibration or analysis of a flowsheet together with its settings and its results, and knows when those results have gone stale.
To… |
Use |
|---|---|
Create, read and change a study |
|
Run it and read its results |
|
Draw its charts as SVG (what the flowsheet editor shows) |
|
Know how large a run’s results will be before it runs |
|
Choose the CSV style a project’s results are written in |
|
Check whether its results are up to date |
|
Pin it to a snapshot of the flowsheet, or release it |
|
Read and write result files |
|
Run the same from a terminal |
|
Model checks: units and conservation#
To… |
Use |
|---|---|
Dimensional consistency of rate expressions |
|
Compare or convert two unit strings, scale included |
|
Mass / electron balance of stoichiometry |
|
Composition tables |
|
Benchmark evaluation and reporting#
To… |
Use |
|---|---|
Score BSM1 / BSM2 performance |
|
Evaluate any plant: effluent, energy, sludge, limits |
|
Effluent quality / operating-cost indices |
|
Sludge and effluent statistics |
|
Lumped measurements from model states |
|
Greenhouse-gas footprint |
|
Monetized operating cost |
|
Compare KPIs across scenarios |
|
Design and sizing#
To… |
Use |
|---|---|
Size an activated-sludge process |
|
Aeration / blower energy |
|
Pumping / mixing / heating energy |
|
Disinfection sizing |
|
For the exact signatures, return types, and every remaining public symbol of
aquakin, aquakin.plant and aquakin.study, see the API reference.