Examples#
Every example is a committed, executed notebook — the outputs on these pages are real runs. Read them in order: the first-order system is the tutorial, the Hicks-Ray family walks one model through each piece of the package, and the flowsheet examples scale the same workflow up to unmodified IDAES models.
Start here
First-order system — the smallest complete workflow, and why the infinite horizon beats a long finite one.
Hicks-Ray CSTR: the infinite horizon — the canonical nonlinear CSTR, short horizon plus terminal segment against a long-horizon baseline.
One model, every piece (the Hicks-Ray family)
The terminal segment — what
drto.infinite_horizonbuilds and how to tune it.Dynamic optimization — the assembly: profiles, objective, solve.
Forward integration —
drto.dynamic_simulationas the plant.The steady-state branch — the reduction and the equilibrium at held controls.
Initializing from the steady state —
drto.initialize_steady_state, solve-based and broadcast flat.Three NMPC loops compared:
drto.ideal_nmpc,drto.asnmpc, anddrto.nonideal_nmpcon the same reactor, without disturbances and under process noise. With the delay at 90% of the sampling interval and under noise, the nonideal loop’s squared distance to the targets is 4.8% larger than the ideal loop’s and the advanced-step loop’s is 0.2% larger.
More systems
Quadruple tank — a multivariable benchmark.
Cart-pole — stabilizing an unstable equilibrium.
Double column — a larger flowsheet, infinite versus finite horizon.
IDAES flowsheets
An IDAES flowsheet under drto — the saponification CSTR straight from
idaes.models.unit_models: member-subset states, a Port-declared control, the setpoint from the steady reduction, and the infinite-horizon controller, every solve throughdrto.scaled_solve.Cold start on the IDAES CSTR —
drto.cold_start_dynamicworking the full algebraic cascade, linear and exponential profiles through the same solve, with the solver logs.Warm start on the IDAES CSTR — one loop iteration on one persistent model: the solution shifts one sampling time forward, tail included with zero fills, and the warm-started solve lands in single digits against the cold seventeen.
Advanced step on the IDAES CSTR — solve at a prediction, correct at the measurement without re-solving: the implemented moves within a percent of the warm re-solve, an order of magnitude faster.
Checking the DAE index — the pendulum’s index ladder and the solvent extraction stage posed with extents and on the reaction invariants: the higher-index forms fail with the offending variables named, the index-one forms pass.
Ideal NMPC on the IDAES CSTR — the closed loop in one call: measure, solve, implement, simulate, the cold start then warm-started re-solves under measured factors, the hot start driven onto the setpoint in three samples.
Advanced-step NMPC on the IDAES CSTR: the same loop with the horizon solve moved between samples and corrected to each measurement by a backsolve. Without noise it implements the ideal loop’s moves, and under the ideal page’s noise it stays within 600 W of the ideal loop’s duty on a 4 MW range.
NMPC with the solve time on the IDAES CSTR: the same loop with each move taking effect one delay after its measurement. At the solve times the solver reports, about a third of the interval here, the holdups differ from the ideal loop’s by up to 2.4 mol on a 20 mol range.
The Klatt-Engell CSTR — the van de Vusse reactor of Lueken, Brandner & Lucia (2023) posed on drto’s terminal segment: the setpoints the reactor cannot hold, the equilibrium a steady solve selects instead, and one horizon solve with the first action’s derivatives read off its factorization.
Approximate NMPC on the Klatt-Engell CSTR — the online solve replaced by a fitted network: Sobol sampling into a labeled dataset, Sobolev training against the stored derivatives, the parity of the fit, and the policy run closed loop against the horizon solves at the same states.
The infinite horizon on the PrOMMiS mixer-settler — rare earth solvent extraction, posed on PrOMMiS’s chemistry as an index-one model: the states are the inventories the reactions cannot change, the setpoint comes from the model’s own steady reduction, and the assigned scaling factors are what make the solve possible.