---
title: "Inverse PINN flux observer"
description: "A physics-informed neural network that recovers the permanent-magnet flux linkage of a synchronous motor from simulated drive voltages and currents, trained from random initialization in the visitor's browser with no pretrained weights."
url: "https://emazaheri.com/lab/flux-observer"
runtime: "Web Worker"
author: "Ehsan Mazaheri Tehrani"
---

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

## What it shows

A second in-browser lab, and a different kind of thing from the first: it trains rather than infers. A simulated field-oriented drive runs a permanent magnet motor, and the magnet's flux linkage is hidden from the estimator. A [3, 32, 32, 3] swish network is fitted from scratch to each 13 ms window of the terminal voltages and currents, with the flux linkage as a trainable scalar inside the physics residual, initialised deliberately wrong at 0.1 Wb. Nothing is downloaded: 1283 weights are generated per window in the page and optimised there with iRprop-. Sensitivity to the parameter is exactly the electrical angular velocity, so the estimate is worse at low speed and the parameter is unidentifiable at standstill, which the demo lets you verify by stalling the rotor. Reference implementation and the four published validation cases at https://github.com/emazaheri/ipinn-pmsm.

The lab is interactive and has no Markdown equivalent. Open the page in a browser to run it.

Source: https://github.com/emazaheri/ipinn-pmsm

## Other labs

- [Motor-fault classifier](https://emazaheri.com/lab/motor-fault): Pick a fault, watch its signature appear in the spectrum, and see a 1D CNN call it from the raw current.
