Multi-rate circuits¶
A case with two [[circuit]] blocks runs its pipes on two drivers at once: the
explicit circuit, where acoustics matter, at its own CFL step, and the
quasi_steady circuit at its macro step. The two meet at plain plenums. Why it
is built this way, its order, its stability limit and the measurements are in
Numerics, "Multi-rate circuits"; the
contracts of every function below are in their docstrings (the standard is
Function contracts and flow charts).
Load and dispatch¶
What enters: a case whose [[circuit]] blocks name a solver and the pipe ids
of each circuit. validate_case checks them at load (_validate_circuits), and
dispatch_advance sends the case to _advance_multirate.
flowchart TD
IN["[[circuit]] blocks"] --> PC{"_parse_circuit"}
PC -- "solver not explicit or quasi_steady, pipes not a list, no id" --> X1["CaseParseError naming the entry"]
PC --> VC{"_validate_circuits"}
VC -- "not one explicit and one quasi_steady; a pipe in two or none; an unknown pipe" --> X2["CaseValidationError"]
VC -- "[case] solver not explicit, rk not ssp_rk2 or ssp_rk3, qs_steady_energy off" --> X2
VC -- "explicit cfl outside [0, 1]; no dt_max and no qs_dt_max; a step on the wrong circuit" --> X2
VC -- "a joint across the circuits not a plenum; EHR, neck, LODI, cylinder, turbo, BC kind, Python closure, real gas, condensation on a quasi-steady pipe" --> X2
VC --> DA["dispatch_advance: circuits declared"]
DA --> AM{"_advance_multirate"}
AM -- "header the circuits contradict; a surface catalyst its driver cannot run" --> X3["ValueError"]
AM --> SP{"split_circuits"}
SP -- "unknown pipe; a spanning joint that is not a plain Junction; a quasi-steady port with a neck, LODI or Python BC; species that differ across the plenum" --> X4["ValueError, before any plenum is touched"]
SP --> NET["MultirateNetwork: each circuit's pipes, components, far BCs, thermal couplings; one PlenumInterface per coupling plenum"]
split_circuits takes each coupling plenum's quasi-steady ports off its port
list for the run (restore_ports puts them back on the way out, also on a
raise) and gives each quasi-steady end a PlenumInterfaceBC instead: the
quasi-steady connectivity reads it as a live pressure (("p_live", bc)), and
it fills the end's ghost and feed from the plenum as a port would.
One macro step¶
flowchart TD
T{"t < t_end?"} -- "no, or a live-control stop" --> OUT["final time; ports restored; sent and received totals on each interface"]
T -- "max_steps spent" --> X5["RuntimeError"]
T -- yes --> FULL{"state.full?"}
FULL -- "yes: the first step, or the last prediction missed" --> QS["_qs_macro_flow: size dt, solve the quasi-steady flow at t + dt, each plenum at its pressure p0"]
QS --> LIN["_linearise: per end, the flow and its rates per unit flow; _probe_slopes: one more solve per plenum at p0 (1 + 1e-3)"]
FULL -- "no: a light step" --> SZ["_qs_macro_size: size dt on the last solved flow"]
SZ --> PRED["_linearise: the base flow predicted, the last mean-pressure solve's flow plus the last slopes times the plenums' move; no solve"]
PRED --> SRC
LIN -- "a probe refused on both sides" --> W1["RuntimeWarning; that plenum's flow held over the step"]
LIN --> SRC["each plenum's ExternalRates: delivering ends' rates, drawn flow, slopes, plus the remainder owed / dt"]
W1 --> SRC
SRC --> EX["_advance_explicit_span: advance_network from t to t + dt on the explicit circuit"]
EX -- "after each explicit step but the last" --> OS["on_step(t')"]
EX --> ACC["each stage: Junction.accumulate_rates adds ExternalRates.now() at the stage pressures, the drawn flow at the plenum's own h and Y; each step: apply_fuel_step tallies the stage-weighted mean into received and received_pdt"]
ACC -- "the sub-run stops short of t + dt" --> X6["RuntimeError"]
ACC --> MEAN["_solve_at_mean_pressure: the quasi-steady flow again, each plenum at its mean pressure over the span"]
MEAN --> CHK["_next_step_full: the prediction against that solve; a miss over 1 % makes the next step full"]
CHK --> MARCH["_qs_macro_march: the slow states on that flow"]
MARCH --> EXC["exchange, per interface: _qs_end_rates summed over its ends, dt times them added to sent"]
EXC --> NX["t += dt, on_step(t)"]
NX --> T
T -- "loop done" --> BOOK["_book_remainder, per interface: the last remainder to the plenum; sent equals received"]
The quasi-steady flow is solved first, with each plenum as it stood at t,
and probed for its slope against each plenum's pressure. The explicit circuit
then carries the quasi-steady through-flow over the same span, linear in the
plenum pressures of each stage, and the quasi-steady circuit marches on the
flow at the plenums' mean pressure over the span, which is the flow the source
delivered. A quasi-steady end that draws from the plenum records the
quasi-steady march's own inlet face flux (ṁ times the ghost's total enthalpy
and the feed composition); one that delivers into it records its outlet cell
at the end of the step. What the record and the plenum still differ by is
carried into the next step's source, and the last of it booked when the run
ends. Most steps are light: they predict the start-of-step solve from the last
mean-pressure solve and the last slopes, and a prediction that misses by more
than 1 % makes the next step full. Until 2026-11-17 the flow was held constant over the span, which bound
the macro step below twice the plenum's relaxation time. Live control is polled between macro steps only, so a
stop never leaves the circuits at different times; the explicit sub-runs get
none. Since 2026-11-17 they get the header's heat-release cap, its lagged limit
carried from one sub-run to the next (hrr_carry), and on_step fires after
every explicit step: during a span the quasi-steady circuit shows its
start-of-step solve (the probes put it back), and the sub-run's last step is
left to the macro loop, which fires it once the quasi-steady circuit has
marched to the same time.
Functions¶
src/aeolus1d/io/parsers.py::_parse_circuitsrc/aeolus1d/io/validate.py::_validate_circuitssrc/aeolus1d/io/validate.py::_circuit_structure_issuessrc/aeolus1d/io/validate.py::_circuit_step_issuessrc/aeolus1d/io/validate.py::_circuit_qs_element_issuessrc/aeolus1d/io/case.py::_advance_multiratesrc/aeolus1d/io/case.py::_qs_transient_configsrc/aeolus1d/solver/multirate.py::split_circuitssrc/aeolus1d/solver/multirate.py::_check_interfacesrc/aeolus1d/solver/multirate.py::_species_namessrc/aeolus1d/solver/multirate.py::restore_portssrc/aeolus1d/solver/multirate.py::PlenumInterfaceBC.__call__src/aeolus1d/solver/multirate.py::PlenumInterfaceBC.qs_p_nowsrc/aeolus1d/solver/multirate.py::advance_network_multiratesrc/aeolus1d/solver/multirate.py::exchangesrc/aeolus1d/solver/multirate.py::_qs_end_ratessrc/aeolus1d/solver/multirate.py::_advance_explicit_spansrc/aeolus1d/solver/multirate.py::_linearisesrc/aeolus1d/solver/multirate.py::_probe_slopessrc/aeolus1d/solver/multirate.py::_probe_eachsrc/aeolus1d/solver/multirate.py::_qs_statesrc/aeolus1d/solver/multirate.py::_qs_restoresrc/aeolus1d/solver/multirate.py::_end_flowsrc/aeolus1d/solver/multirate.py::_solve_at_mean_pressuresrc/aeolus1d/solver/multirate.py::_book_remaindersrc/aeolus1d/solver/multirate.py::_next_step_fullsrc/aeolus1d/solver/quasi_steady_network.py::_qs_macro_sizesrc/aeolus1d/solver/quasi_steady_network.py::_qs_macro_stepsrc/aeolus1d/solver/quasi_steady_network.py::_qs_macro_flowsrc/aeolus1d/solver/quasi_steady_network.py::_qs_macro_marchsrc/aeolus1d/solver/quasi_steady_network.py::_build_connectivitysrc/aeolus1d/solver/quasi_steady_network.py::_eval_connsrc/aeolus1d/solver/network_timeloop.py::advance_networksrc/aeolus1d/components/junction.py::ExternalRates.nowsrc/aeolus1d/components/junction.py::Junction.accumulate_ratessrc/aeolus1d/components/junction.py::Junction.apply_fuel_stepsrc/aeolus1d/components/junction.py::Junction.write_inflow_composition