Python Scripting API Specification
Complete documentation for the embedded in-browser Python (Pyodide) environment. Automate electromagnetic circuit design, batch sweeps, time-domain stepping, waveform acquisition, and geometric optimization using the global sim module.
Getting Started Example: Synchronous Motor Speed Sweep
# 1. Load an existing interactive preset scene
sim.load_preset("Synchronous motor (rotating magnet in three-phase field)")
# 2. Acquire a handle to the rotating permanent magnet
rotor = sim.part("Rotor (magnet)")
# 3. Drive the rotor with an external prime mover at 600 RPM
rotor.drive(rpm=600)
# 4. Advance time-domain simulation by 0.5 seconds
sim.run_for(0.5)
# 5. Extract mechanical status (torque, angular velocity, thrust)
status = rotor.info()
print(f"Rotor mechanical speed: {rotor.rpm:.1f} RPM")
print(f"Electrodynamic torque: {status['torque']:.4e} N*m")