State Estimation and Digital Twins
Purpose
A multiphysics model predicts the internal evolution of a system from its initial state, parameters, inputs, and boundary conditions.
A digital twin must go further.
It must continuously reconcile model predictions with measurements from the physical system. This requires a state-estimation layer capable of inferring internal quantities that are not directly measurable during normal operation.
For PEM fuel-cell systems, examples include membrane hydration, accumulated water, gas inventories, and purge-related internal states.
This page focuses on that estimation layer and on its role within a digital twin.
For the physical model itself, see PEMFC Multiphysics Modelling.
Estimation problem
A nonlinear dynamical system can be written in discrete form as
where:
- is the internal state vector;
- contains known inputs;
- contains model parameters;
- contains measured outputs;
- represents process uncertainty;
- represents measurement uncertainty.
The estimation problem is to reconstruct from the sequence of inputs and measurements.
This is fundamentally different from simply simulating the model.
Why internal states matter
Several quantities that strongly affect PEMFC behaviour are difficult or impossible to measure directly online.
Examples include:
- membrane water content;
- internal gas composition;
- accumulated liquid water;
- local or effective reactant depletion;
- purge-related accumulation;
- internal thermal states;
- degradation-related quantities.
These states affect voltage, efficiency, stability, and operating limits, but only indirect measurements are usually available.
A state estimator provides a mathematically structured way to infer them.
Reduced estimated state
The complete multiphysics model may contain more states than should be estimated.
A reduced estimated state is preferable when only a subset of internal quantities is sufficiently observable.
A representative reduced vector may be written as
where:
- is temperature;
- is membrane hydration;
- is a purge-related accumulated quantity.
Other physical quantities, such as liquid-water saturation, may remain model states or operating variables without belonging to the estimated vector.
This distinction is deliberate.
Increasing the estimator state dimension does not automatically increase the information recovered from the measurements.
Observability
A state can only be estimated reliably if its influence on measured outputs is distinguishable from the influence of other states and parameters.
This is the practical meaning of observability.
For nonlinear PEMFC models, observability depends on:
- the selected state vector;
- available sensors;
- operating trajectory;
- excitation level;
- model structure;
- parameter uncertainty;
- measurement noise.
A state may be observable under one operating regime and weakly observable under another.
This is why state selection must be made together with the measurement model rather than from physical interest alone.
Identifiability and observability
State observability and parameter identifiability are related but distinct.
A model may contain two parameters whose effects on voltage are nearly indistinguishable. Attempting to estimate both online can make the problem ill-conditioned even when the state dynamics are otherwise well behaved.
Similarly, a state and a parameter can compensate for one another.
For this reason, a digital-twin estimator should avoid simultaneously estimating too many weakly distinguishable quantities.
Parameters should remain fixed unless the available measurements genuinely contain enough information to identify them.
Unscented Kalman Filter
The current nonlinear estimator is based on an Unscented Kalman Filter (UKF).
The UKF avoids explicit linearisation of the nonlinear model.
Instead, it propagates a set of deterministically chosen sigma points through the nonlinear transition and measurement functions.
For a state of dimension , the sigma points represent the current mean and covariance of the estimated state distribution.
At each iteration, the UKF performs two principal stages:
- prediction;
- measurement correction.
Prediction step
Starting from the current estimate and covariance the UKF constructs sigma points around the estimated mean. Each sigma point is propagated through the nonlinear state-transition model:
The predicted state mean and covariance are reconstructed from the propagated sigma points.
Process covariance is then added to account for model uncertainty.
Measurement update
The predicted sigma points are mapped into measurement space:
From these points, the filter computes:
- predicted measurement;
- innovation covariance;
- state-measurement cross-covariance.
The Kalman gain is then used to correct the predicted state according to the difference between predicted and measured outputs.
The correction therefore reflects both:
- the size of the measurement residual;
- the confidence assigned to model and sensors.
Process and measurement covariance
The matrices and are central to estimator behaviour. represents uncertainty in the state-transition model. Large values make the estimator trust the model less and adapt more strongly to measurements. represents measurement uncertainty. Large values make the estimator trust the measurements less. These matrices are not arbitrary numerical tuning knobs. Their values should reflect actual uncertainty sources as far as possible. Poor covariance selection can produce:
- slow convergence;
- noisy estimates;
- excessive correction;
- estimator lag;
- numerical instability;
- false confidence.
Initialisation
The UKF also requires an initial state estimate and covariance. Initialisation matters especially for slowly observable states. For example, membrane hydration may not be reconstructed immediately from a small voltage residual if several other states produce similar effects. A realistic initial covariance allows the estimator to converge while still representing uncertainty honestly. Overconfident initialisation can prevent useful correction.
Measurement selection
The information available to the estimator depends directly on sensor choice. Potential measurements include:
- stack voltage;
- cell voltage where available;
- temperature;
- anode pressure;
- cathode pressure;
- inlet or outlet flow;
- ambient conditions.
Not every sensor contributes equally to every internal state. Voltage is sensitive to many physical mechanisms simultaneously, which makes it informative but not uniquely diagnostic. Temperature and pressure measurements can improve state separation substantially when the corresponding internal dynamics are represented in the model.
Inputs and operating events
Known inputs are not measurements, but they strongly affect observability. Examples include:
- load current;
- purge command;
- fan command;
- gas-supply conditions;
- ambient temperature.
Changes in these inputs excite different model dynamics. A system operated indefinitely near a fixed point may reveal less information about internal states than one that experiences sufficiently rich transients. This creates a direct connection between estimation quality and operating trajectory.
Hybrid dynamics
Purge operation introduces discrete events into an otherwise continuous dynamical system. At a purge event, some internal states may change rapidly or according to a reset map. A generic hybrid formulation can be written as
where and denote the state immediately before and after the event. The estimator must remain consistent with these transitions. Treating a purge as an ordinary smooth time step can introduce artificial innovation spikes and state errors.
Physical constraints
Some estimated states have strict physical bounds. Examples include:
- positive absolute temperature;
- non-negative species inventories;
- bounded membrane hydration;
- non-negative liquid-water quantities.
A numerical estimator can violate such constraints if left unconstrained. Possible strategies include:
- state clipping;
- transformed coordinates;
- constrained filtering;
- physically bounded process models.
Simple clipping may be sufficient for robustness in some applications, but it can distort covariance interpretation and should therefore be used knowingly.
Model error
A Kalman filter does not correct an arbitrary model into a true one. Persistent structural model errors can be absorbed incorrectly into estimated states. For example, an underestimated ohmic resistance may cause the estimator to modify membrane hydration simply because hydration also influences voltage. This is one of the principal risks of model-based estimation. Estimated states must therefore be interpreted in the context of model validity and parameter uncertainty.
Innovation analysis
The innovation is It is more than a correction signal. Innovation statistics provide information about estimator consistency. Useful checks include:
- mean innovation close to zero;
- absence of persistent bias;
- covariance consistent with expected uncertainty;
- limited temporal correlation;
- response to known operating events.
Persistent structure in the innovation often indicates that the model, covariance assumptions, or sensor model is incomplete.
Numerical robustness
State estimation repeatedly executes the nonlinear model and covariance operations. Numerical robustness therefore becomes more critical than in isolated forward simulation. Important checks include:
- positive-semidefinite covariance matrices;
- stable sigma-point generation;
- well-conditioned matrix operations;
- finite model outputs;
- consistent state dimensions;
- deterministic model evaluation;
- bounded physical states;
- controlled behaviour under missing or invalid measurements.
Regression tests are particularly valuable because small changes in the model can alter estimator behaviour even when forward simulation still looks reasonable.
Verification of the estimator
Before experimental validation, the estimator can be verified against synthetic data generated from the model itself. A typical test consists of:
- generating a known state trajectory;
- computing synthetic measurements;
- adding controlled noise;
- starting the estimator from an imperfect initial state;
- checking whether the true state is recovered.
This is useful for testing implementation correctness and basic observability. It is not experimental validation because the synthetic data obey the same model assumptions as the estimator.
Experimental validation
Experimental validation requires comparison against a real system. For directly measured states, this is straightforward in principle. For internal states such as membrane hydration, validation is harder because the reference quantity may itself require indirect or laboratory measurement. Validation must therefore distinguish between:
- directly measured reference states;
- independently inferred reference quantities;
- output-prediction accuracy;
- consistency with known physical behaviour.
At present, experimental validation of the current PEMFC estimator has not yet been completed.
Digital-twin architecture
The state estimator is one component of a larger digital-twin architecture. A practical architecture can be viewed as several layers:
- physical system;
- sensors and acquisition;
- data conditioning;
- multiphysics model;
- state estimator;
- parameter and uncertainty management;
- diagnostics and indicators;
- control or decision support;
- persistent data and traceability.
The estimator connects measured behaviour to the internal physical model. Without this reconciliation step, the system is a simulator rather than a fully operational digital twin.
Parameter adaptation
A mature digital twin may eventually include online parameter adaptation. Potential targets include slowly varying quantities associated with:
- ageing;
- effective transport properties;
- thermal exchange;
- electrical resistance;
- actuator characteristics.
This should be introduced cautiously. Simultaneously estimating dynamic states and slowly varying parameters can create severe identifiability problems. A hierarchical approach is often preferable:
- estimate fast internal states online;
- update selected parameters on a slower timescale;
- preserve constraints and prior knowledge.
Diagnostics
Once internal states are estimated reliably, they can support diagnostics. Examples include detection of:
- abnormal drying;
- excessive water accumulation;
- unusual pressure evolution;
- purge inefficiency;
- thermal anomalies;
- deviations between expected and observed electrochemical behaviour.
A diagnostic indicator should ideally be linked to a physically interpretable state or residual rather than to an unexplained numerical threshold.
Control perspective
State estimation also prepares the model for closed-loop control. A controller may use estimated internal states that are not directly measurable. Possible objectives include:
- maintaining membrane hydration in a favourable range;
- limiting thermal excursions;
- scheduling purge events;
- avoiding flooding or starvation;
- balancing efficiency and durability.
This requires the estimator to operate reliably at the timescale of the control loop.
Uncertainty and confidence
A digital twin should not provide only point estimates. The estimator covariance contains useful information about confidence, although it must be interpreted carefully when model assumptions are imperfect. A state estimate with large uncertainty should not be presented as if it were a direct measurement.
This is especially important when the estimated quantities are later used for diagnostics or control decisions.
Reproducibility
For state-estimation work, reproducibility requires preserving more than source code. A complete record should include:
- model version;
- parameter set;
- estimator configuration;
- and matrices;
- initial state and covariance;
- input data;
- measurement preprocessing;
- solver configuration;
- software environment.
Without these elements, two apparently identical estimator runs may not be meaningfully comparable.
Current status
The current development includes:
- a complete multiphysics PEMFC model;
- a reduced nonlinear state-estimation formulation;
- an UKF implementation;
- Python-based numerical and software testing.
The present focus is on model formulation, numerical robustness, and estimator consistency. Experimental validation remains a later step.
Engineering principles
The main principles I apply are:
- estimate only states supported by the available information;
- distinguish states from parameters;
- make uncertainty explicit;
- avoid overconfident covariance assumptions;
- inspect innovations, not only reconstructed states;
- preserve physical constraints;
- test estimators on synthetic data before experimental deployment;
- distinguish implementation verification from experimental validation;
- treat state estimates as model-dependent quantities, not direct measurements;
- preserve reproducible estimator configurations.