emachines is an open-source Python library of well-documented, tested, and citable implementations of the analytical models used in electric motor design. It is the physics engine behind emdesignlabs.com .
Every function documents the equation it implements and its bibliographic source.
Installation
Requires Python >= 3.10.
Modules
Winding
Winding factors (kp, kd, kw), MMF distribution, star-of-slots phasor method
Motors
PMSM dq-frame model, DC motor analytical model
Magnetics
BH curve models, iron loss (Steinmetz, Bertotti), electrical steel & PM databases, hysteresis (Takács, dynamic widening)
Transformer
Single-phase transformer: no-load current waveform, core loss, equivalent circuit, load performance
MEC
Magnetic equivalent circuit Newton-Raphson solver with nonlinear materials
Quick Start
from emachines.winding import winding_factor
from emachines.magnetics.iron_loss import bertotti
from emachines.motors.pmsm import PMSMParams, torque
# Winding factor -- 12s/10p FSCW tooth-coil
kw = winding_factor(5 , Q= 12 , P= 10 , w= 1 ) # mechanical order: working harmonic ν = p = 5
print (f'kw1 = { kw:.4f} ' ) # 0.9330
# Iron loss -- Bertotti forward model
loss = bertotti(f= 400 , B_peak= 1.5 , k_h= 0.02 , k_e= 1e-4 , k_a= 1e-3 )
print (f'Total loss = { loss["total" ]:.2f} W/kg' )
# PMSM torque
motor = PMSMParams(p= 3 , Ld= 5e-3 , Lq= 8e-3 , psi_m= 0.15 , Rs= 0.1 )
Te = torque(motor, id =- 3.0 , iq= 10.0 )
print (f'Torque = { Te:.2f} Nm' )
kw1 = 0.9330
Total loss = 68.70 W/kg
Torque = 7.16 Nm
Design Philosophy
Equations first – every function leads with the formula it implements
Cited – every formula references a specific textbook, paper, or standard
Notebook-driven – source lives in Jupyter notebooks; Python modules are auto-generated via nbdev
Tested – validated against published datasets and reference tools
Dependency-light – only numpy, scipy, pandas, and matplotlib required