Anti-surge control: the flow meter picks the side
An active-inference agent holding a compressor's surge margin drifts toward the flows its meter reads best. A DP meter keeps it off the surge line. A Coriolis meter of the same accuracy settles it past the line.
TL;DR: A linear-Gaussian cpomdp agent, with Kalman-filter perception and actions chosen by expected free energy, holds an illustrative compressor’s surge margin at +5% of design flow. Its flow meter’s noise variance R(Q) depends on the flow. The epistemic term then varies across actions and pulls the agent toward flows where R is small, and the sign of its offset from the setpoint is the sign of −d log R/dm, where m is the margin. A DP meter (Q = k√ΔP with flat transmitter error) gives R ∝ 1/Q², so the pull runs away from surge and the agent settles at +7.14%. A Coriolis meter of the same 0.2% accuracy at design flow gives R ∝ Q², which reverses the pull. It settles at −0.38%, past the line. With R frozen at the operating point the epistemic term is the same for every action and the agent settles on its setpoint. The meter’s error model is part of the controller, and surge protection belongs in the setpoint or a hard limit.
The result
Based on the work by Sathish, Khader, Sayma and Shah I took the opportunity to point cpomdp at a real world industrial application. Doing some quick research and then math derivations revealed that the R(x) paper would yet again prove useful in helping us understand the mechanics of how to build one of these sensors in the linear Gaussian regime without being reduced to a Kalman filter.
Previous work by Sathish et al., briefly summarised, looked at designing a natural gas centrifugal compressor that is prone to surge and simulating it in an Aspen HYSYS dynamic model, with active inference put forward as an alternative to PID and model predictive control when the conditions get noisy and uncertain.
I haven’t had access to the full paper, only its abstract, so this is only a partial reflection of their work. My work here was inspired by theirs, and it can’t stand for or against any of their claims until I’ve read the full paper. I’ll come back and adapt this page once I have.
What the abstract doesn’t get into is the flow meter. They make the case that active inference copes well with noisy and uncertain conditions, and the uncertainty they focus on is the gas arriving at the compressor, with suction conditions that shift over a reservoir’s life. The noise in the flow reading itself, and how that noise changes as the flow moves, doesn’t come up. That turns out to matter. An active inference agent should be curious, and it will happily drift toward wherever its meter reads best, even when that’s past the surge line.
Here I wanted to take cpomdp and fill in the gaps. Setting a cpomdp agent to hold a centrifugal compressor’s flow at a 5% margin above the surge line, in percent of design flow, I then changed its flow meter and nothing else. Each meter is 0.2% accurate at design flow. Only the shape of its error changes.
| Flow meter | First step | Settles at |
|---|---|---|
| DP, with its noise frozen at the operating point | +5.03% | +5.00% |
| Orifice plate or venturi (differential pressure) | +12.30% | +7.14% |
| Coriolis | −4.98% | −0.38% |
The setpoint is +5%. A negative margin is past the surge line. “Settles at” is cpomdp’s
own Agent run in closed loop, with no noise.
The DP agent stands off on the safe side. The Coriolis agent aims past the surge line on its first step. It settles there too.
Why the meter decides
The agent’s objective has an information term. It rewards a reading by how much the reading would teach, and quiet(low noise) readings teach most. So the agent drifts toward the flows its own meter reads best.
A DP element reads flow through a square root, and its transmitter error is roughly flat in pressure. Its flow noise is worst at low flow, near surge. A Coriolis meter’s error is a fixed share of the reading so its noise is lowest at low flow meaning the sign flips. The term that holds the DP agent off surge pulls the Coriolis agent in. The cpomdp docs derive both noise models and a closed-form law for where the agent stands.
If you run compressors
- The information term is not a safety factor. With a DP meter it looks like caution. It is appetite for information, and here it happens to point away from surge.
- Surge protection belongs in the setpoint or a hard limit. Real surge margin prices the cost of being wrong. Curiosity cannot stand in for that.
- Coordinates decide whether the term does any work. Many anti-surge controllers work in reduced ΔP coordinates. A linear-Gaussian model with additive control, written there, has constant noise. Its information term then takes the same value for every action, and the agent becomes a plain controller.
- The meter’s error model is part of the controller. An active-inference controller needs it. Above all it needs the sign of its slope.
What this is not
A showcase on an illustrative compressor. It has no surge dynamics and no compressor map, and its operating point describes no real machine.
- The DP noise model comes from ISO 5167, which excludes pulsating flow. Surge is pulsating flow. The model describes the meter on the approach to surge.
- The Coriolis meter has no zero-stability term. A real one has a fixed error near zero flow, which would weaken its pull toward low flow.
- It is not a controller benchmark. The baseline is the same agent with frozen noise.
- The setpoint’s weight is a policy choice and sets the size of every offset above. The direction is the result.
The application follows Sathish, Khader, Sayma and Shah, who propose active inference for anti-surge control in GT2024-124905 (ASME Turbo Expo 2024). The modelling here is mine.
Run it
git clone https://github.com/inferogenesis/cpomdp
cd cpomdp
git checkout 6a2e89d
uv run python examples/surge_margin.py --check
It prints every number above. It also checks eleven claims about them.