This repository implements the methodology from the paper “Learning Electromagnetic Fields Based on Finite Element Basis Functions”. It combines Isogeometric Analysis (IGA), Proper Orthogonal Decomposition (POD), and Deep Neural Networks (DNNs) to efficiently predict electromagnetic fields in a parametric model of a Permanent Magnet Synchronous Machine (PMSM). Instead of learning field values directly, the network predicts coefficients in a reduced POD basis derived from high-fidelity IGA simulations, ensuring physical consistency and enabling rapid evaluation of quantities of interest such as torque. Two surrogate models are provided:
- Airgap field surrogate for torque-focused applications.
- Full field surrogate for detailed rotor, stator, and airgap predictions.
If you use this code, please cite:
10.1109/TMAG.2025.3629546
- Python 3.11+
- MATLAB R2024b (tested until R2026a) with MATLAB Curve Fitting Toolbox
Install Python dependencies:
pip install -r requirements.txtPython dependencies:
pandas 2.3.3
torch 2.8.0
numpy 2.3.4
matplotlib 3.10.6
No other packages need to be downloaded at this point. To provide a fully working snapshot, we already include here the code snapshots for the packages:
- GeoPDEs: [https://rafavzqz.github.io/geopdes/]
- NURBS toolbox: [https://de.mathworks.com/matlabcentral/fileexchange/26390-nurbs-toolbox-by-d-m-spink]
We acknowledge these toolboxes and also reused parts of the code published here.
To reproduce the full pipeline:
Run:
matlab -batch "computeSamples(isgap)"Where isgap is:
truefor airgap fieldfalsefor full field
python perform_pod.py trueReplace true with false for full field.
python train_net.py trueReplace true with false for full field.
python analyze_net.py true falseArguments:
- first:
truefor airgap field,falsefor full field - second:
falseto use your trained network
Run:
matlab -batch "computeErrors(isgap, paper)"Arguments:
isgap:truefor airgap field,falsefor full fieldpaper:falseto use your generated predictions
- Directories:
sol_XX_training,sol_XX_testing,sol_XX_validation - Torch model:
model_XX.pt - Predictions:
Predictions_XX_XX - Error tables:
Error_XX_XX.csv
Important: The mean, standard deviation, and maximum values of the computed error tables may differ slightly from those in the paper because of numerical errors during data generation, projection matrix computation, and training, as well as minor hyperparameter differences.
Download the training, testing, and validation data as well as the two files MatrixK_full.csv and MatrixK_gap.csv from Zenodo and put them into the main folder:
Run:
python analyze_net.py true trueThen:
matlab -batch "computeErrors(true, true)"