Skip to content
Ehsan Mazaheri Tehrani
All labs

CH4Inverse PINN flux observer

A hidden parameter, recovered in this tab.

A simulated drive runs a permanent magnet motor. One number inside it, the magnet's flux linkage, is hidden from the estimator: losing it is what demagnetization means. A small physics-informed network is trained from scratch here, once per 13 ms slice of the voltages and currents, and each time it has to find that number from the terminals alone. No model is downloaded. Your browser does the optimization.

The q-axis voltage equation the estimator is held to. Voltage, currents and speed are measured at the terminals; resistance and inductance come off the datasheet. The flux linkage is the one term nothing supplies, so it is what the network has to solve for. Note where it sits: multiplied by speed, and nowhere else. That is why a stationary rotor hides it completely.

Inside one window

How the inverse PINN learns

Choose a step to explore at your own pace.

Predict

Time and both measured voltages enter the network. Two hidden layers predict the d-axis current, q-axis current and electrical speed.

Inputs
Neural network

3 → 32 → 32 → 3

Two hidden layers with swish activations.

Predicted states

These feed both the data comparison and the motor equations.

Read the diagram explanation

The loop runs repeatedly within one measurement window. Time and measured d-axis and q-axis voltages enter a 3 → 32 → 32 → 3 neural network with swish hidden layers. Its outputs are the two currents and electrical speed.

The two current predictions are differentiated with respect to time while voltage inputs are held fixed. Their derivatives and all three predicted states enter the electrical motor equations. Resistance and inductances stay fixed; the flux-linkage estimate enters only the q-axis equation. There is no speed-derivative residual.

Data loss is the mean squared difference between predicted and measured currents and electrical speed, averaged over all samples and all three states.

Physics loss is the sum of the mean squared d-axis and q-axis electrical residuals. Each residual measures how far the predictions depart from a motor voltage equation. The optional normalization preset scales state errors and voltage residuals before comparison.

The total objective is α times the data loss plus β times the physics loss. These weights control each loss’s influence on training.

Parameter updates. The iRprop− optimizer uses the sign of each total-loss gradient, with an adaptive step size per parameter. Network weights and biases, , receive gradients through both losses. The flux-linkage estimate, , receives its gradient only through the q-axis physics residual; no measured flux target is supplied. The updated values feed the next iteration.

Illustrative training loop. 1,283 network parameters and one physical parameter, . Every window starts with a fresh network and flux-linkage estimate.

Hidden flux linkage0.206 Wb

The estimator is never shown this. Lower it and you have demagnetized the magnet.

Dyno speed1000 rpm

sensitivity 419 V/Wb

Measurement noise5%
Window15 ms
Epochs per window150

Inductance falls with current in the plant. The estimator keeps using the datasheet values.

Recovered flux linkage per window, Wb0 of ...
500 rpmsensitivity is , so the left half should scatter about twice as wide1000 rpm
Drive signals, what the estimator is shown, amperes

is the current that makes torque; runs along the magnet axis and makes none. The drive holds each at a commanded value and steps between eight operating points. 2.0 s at 10 kHz, decimated to 1 kHz.

Inside the last window: 150 gradient steps

from a deliberately wrong 0.10 Wb

starting...

1,284 trainable values, 1 of them physicalNo pretrained weights. Everything computed in this tab.ipinn-pmsm

The other lab

Runs a trained modelONNX Runtime Web
  1. Healthy
  2. Demagnetization
  3. Eccentricity
  4. Inter-turn short
Illustration: motion slowed, geometry exaggerated.

Motor-fault classifier

Pick a fault, watch its signature appear in the spectrum, and see a 1D CNN call it from the raw current.

Open the lab

Added Sep 2026