Drone outrunner lab, SI units unless marked mm. This package is self contained.
On Debian or Ubuntu install python3-numpy python3-scipy python3-matplotlib gmsh octave gnuplot-nox ngspice.
Run from the extracted folder:
  OPENBLAS_NUM_THREADS=1 PYTHONNOUSERSITE=1 /usr/bin/python3 field.py --out run
  octave --quiet --no-gui scope.m run
  octave --quiet --no-gui spin.m run
  gmsh run/outrunner-field.msh
  gmsh outrunner.geo -0 -format step -o outrunner.step
  ngspice -b conducting-pair.cir
To refine, repeat the field command with --refine 2 --out fine. Pass fine to the Octave scripts.
To reproduce the design sweep, try --gap-mm 1.2 --out wide or --turns 24 --out rewound on the base mesh. Run scope.m on each output. Change phase resistance in spin.m to match your actual wire when modelling a rewound motor.
The 3D STEP concept has rectangular teeth. The independent 2D FEM slice uses sector teeth, a 0.6 mm radial clearance and 5/6 magnet coverage.
The field solution uses a 35 mm outer boundary, linear steel (relative permeability 500) and radial magnets (remanence 1.15 T, recoil permeability approximated as 1). Screenshots and examples are educational predictions, not measured motor data.
scope.csv: electrical degrees, three phase EMFs (V), A-B (V), ideal two-phase torque (Nm).
spin.csv: seconds, A current (A), B current (A), rad/s, mechanical radians. The third phase current is i_c = -(i_a+i_b).

To reproduce the interactive commutation field gallery:
  OPENBLAS_NUM_THREADS=1 /usr/bin/python3 field.py --frames --out run
The run/sectors folder contains sectors.json and 18 WebP images (Python Pillow required).
At six equally spaced shaft positions over one electrical period, the largest and smallest phase linkage slopes select the two conducting phases. The imposed currents are +2 A and -2 A.
rotor = permanent magnets only; winding = coil field only; combined = vector sum before taking magnitude. Colour limits are fixed at 0–1.6 T. White lines are contours of axial vector potential with levels spaced separately in each image. The torque is i dot d(lambda_PM)/d(theta_mechanical), excluding cogging and saturation.

Three-phase inverter scope (separate circuit experiment):
  python3 esc_scope.py --bus 12 --rpm 1000 --out esc-run
Requires ngspice and Python with NumPy. Repeat with --bus 6 or speeds 100 and 10000.
esc.cir is the runnable six-switch deck. trace.dat is the raw ngspice output: time (s), Va/Vb/Vc to DC negative (V), Ia/Ib/Ic into the windings (A), and the low-side shunt drop (V). scope.json converts the shunt probe to mV. The moving-average overview spans one electrical turn; each raw window spans two PWM periods. This model imposes rotor speed, trapezoidal EMF and position-scheduled switching. The controller explanation describes how to infer timing on hardware.
  python3 adc_replay.py esc-run/trace.dat --rpm 1000
The replay uses the same speed as the deck to identify the commanded sector, then detects the floating-phase crossing using voltage samples. It reports the available sample count and shunt current. The netlist drives the gates; the replay observes its results offline.
