Skip to main content

MEC Public API

Overview

Re-exports the full public API for emachines.mec.

Importing from emachines.mec gives access to all public symbols without needing to know which submodule they live in.

Usage

from emachines.mec import *
# or selectively:
from emachines.mec import PermeabilityModel
from emachines.mec import BranchType
from emachines.mec import MECSolution

Test: public API works from the installed package

Builds and solves a one-mesh air-gap circuit using only emachines.mec, so nothing defined inside the notebooks leaks in. Checks the flux against the analytic value \(\Phi = F \mu_0 A / l\).

import math
import emachines.mec as mec_pkg

F, l, A = 100.0, 0.001, 0.01  # A-turns, m, m^2
m = mec_pkg.MEC()
mesh = m.add_mesh_branch(mmf=F)
gap = m.add_reluctance_branch(length=l, area=A, model=mec_pkg.LinearPermeabilityModel(mu_r=1.0),
                              meshes=[mesh], orientations=[1])
sol = m.solve()

phi_exact = F * 4e-7 * math.pi * A / l
assert sol.converged
assert math.isclose(sol.flux(gap), phi_exact, rel_tol=1e-9), (sol.flux(gap), phi_exact)
print(f"✓ MEC via package: flux = {sol.flux(gap):.6e} Wb (exact {phi_exact:.6e} Wb)")
✓ MEC via package: flux = 1.256637e-03 Wb (exact 1.256637e-03 Wb)