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.

Four panels. Top left, the frozen-noise agent: its epistemic curve is flat, so the minimum of its objective sits on the economic optimum. Top right, the DP meter: its epistemic curve rises away from the surge line and holds the agent off the optimum on the safe side. Bottom left, the Coriolis meter: its epistemic curve rises toward the surge line and the minimum lands past it. Bottom right, where the DP agent aims and settles as its meter worsens, a flat line for the frozen-noise agent at the setpoint, and a single diamond for the Coriolis meter just below the surge line.

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

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 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.