magnelio.circuit#

Circuit — lumped elements, the shared curve rasteriser, edge tools. SeriesRLC/ParallelRLC are trapezoidal companion models; a port carries them via PortLumped(..., element=...) (the port supplies the endpoints, the element the terminal relation), and a passive in-circuit load is declared as a LumpedElement on the geometry model via add_element.

class magnelio.circuit.EdgePath(axes, ijk, signs, dls, flat_indices)#

An ordered, directed chain of primary-grid E-edges (a rasterised Curve).

Entry k describes one traversed edge: axes[k] is 'x'/'y'/ 'z', ijk[k] is the edge’s lower-index base node, signs[k] is +1 if the curve runs along +axis there (else -1), dls[k] is the edge length [m], and flat_indices[k] indexes the flat E layout (Ex|Ey|Ez concatenated — the FieldState / M_eps ordering), so the same path serves both field-array and flat-vector consumers.

Parameters:
  • axes (list[str])

  • ijk (list[tuple[int, int, int]])

  • signs (list[int])

  • dls (list[float])

  • flat_indices (list[int])

property length: float#

Total traversed (staircase) edge length [m].

class magnelio.circuit.LumpedElement(name, start, end, element)#

Passive lumped RLC element on a straight interior edge path.

Parameters:
  • name (str) – Unique identifier; shares one namespace with the port names of the model it is added to.

  • start (tuple of float) – Endpoints in metres; must differ along exactly one Cartesian axis after grid snapping. Under a clipping symmetry declaration the endpoints stay in full-model coordinates — an element whose chain crosses an electric symmetry plane is clipped to the meshed half automatically.

  • end (tuple of float) – Endpoints in metres; must differ along exactly one Cartesian axis after grid snapping. Under a clipping symmetry declaration the endpoints stay in full-model coordinates — an element whose chain crosses an electric symmetry plane is clipped to the meshed half automatically.

  • element (SeriesRLC or ParallelRLC) – Trapezoidal companion model providing the terminal relation, e.g. SeriesRLC(R=100.0) for an ideal 100 Ω resistor. Always the full-model values: under symmetry the solver internally scales the companion to the meshed half.

Examples

>>> from magnelio import circuit
>>> iso = circuit.LumpedElement(
...     name="iso",
...     start=(0.0, 0.8e-3, 10e-3),
...     end=(0.5e-3, 0.8e-3, 10e-3),
...     element=circuit.SeriesRLC(R=100.0),
... )
class magnelio.circuit.ParallelRLC(R=None, L=None, C=None)#

Parallel R–L–C companion (shared voltage), any subset present.

Parameters:
  • R (float, optional) – Resistance [Ω], inductance [H], capacitance [F]. None omits that element; at least one must be given.

  • L (float, optional) – Resistance [Ω], inductance [H], capacitance [F]. None omits that element; at least one must be given.

  • C (float, optional) – Resistance [Ω], inductance [H], capacitance [F]. None omits that element; at least one must be given.

advance(i, v, dt)#

Advance the internal state given the solved element voltage v.

i (the total element current) is unused for a parallel bundle — the per-element currents follow from the shared voltage.

Parameters:
  • i (float)

  • v (float)

  • dt (float)

Return type:

None

r_eq(dt)#

Equivalent resistance [Ω] = 1 / G_eq at time step dt.

Parameters:

dt (float)

Return type:

float

reset()#

Zero the internal state (reuse across excitations).

Return type:

None

v_hist(dt)#

History EMF [V] from the Norton→Thévenin conversion −I_hist/G_eq.

Parameters:

dt (float)

Return type:

float

class magnelio.circuit.SeriesRLC(R=None, L=None, C=None)#

Series R–L–C companion (shared current), any subset present.

Parameters:
  • R (float, optional) – Resistance [Ω], inductance [H], capacitance [F]. None omits that element; at least one must be given. SeriesRLC(R=Z0) reproduces a plain resistor (the discrete-port internal impedance).

  • L (float, optional) – Resistance [Ω], inductance [H], capacitance [F]. None omits that element; at least one must be given. SeriesRLC(R=Z0) reproduces a plain resistor (the discrete-port internal impedance).

  • C (float, optional) – Resistance [Ω], inductance [H], capacitance [F]. None omits that element; at least one must be given. SeriesRLC(R=Z0) reproduces a plain resistor (the discrete-port internal impedance).

advance(i, v, dt)#

Advance the internal state to step n+1 given the solved i.

v (the total element voltage) is unused for a series string — the per-element voltages follow from the shared current.

Parameters:
  • i (float)

  • v (float)

  • dt (float)

Return type:

None

r_eq(dt)#

Equivalent series resistance [Ω] at time step dt.

Parameters:

dt (float)

Return type:

float

reset()#

Zero the internal state (reuse across excitations).

Return type:

None

v_hist(dt)#

History EMF [V]: the V_hist of V^{n+1} = R_eq·I^{n+1}+V_hist.

Parameters:

dt (float)

Return type:

float

magnelio.circuit.integrate_E(field, curve, grid, *, samples_per_cell=4)#

Line integral ∫_curve E·dl [V] of an E field along curve.

The first (read-only) consumer of rasterize_curve(): it sums the signed edge voltages Σ sign · E · dl along the rasterised chain. For a conservative field the result depends only on the curve’s endpoints, so it validates the rasteriser before any physics is built on it.

Parameters:
  • field (FieldState) – The E field to integrate (field.Ex/Ey/Ez).

  • curve (Curve) – The path of integration.

  • grid (GridLines) – The simulation grid the field lives on.

  • samples_per_cell (int, default 4) – Forwarded to rasterize_curve().

Returns:

The line integral [V] (the total voltage along the curve).

Return type:

float

magnelio.circuit.rasterize_curve(curve, grid, *, samples_per_cell=4, scale=None)#

Rasterise curve onto the primary E-edges of grid.

Parameters:
  • curve (Curve) – The abstract 3D locus to rasterise (any Curve).

  • grid (GridLines) – The simulation grid (mesh.grid).

  • samples_per_cell (int, default 4) – Curve samples per smallest cell length; >= 2 guarantees no node is skipped, higher values only refine the staircase geometry (the line integral of a conservative field is unaffected).

  • scale (float or None, default None) – Model scale factor to build the curve’s OCC wire at. None derives it from the curve’s own analytic bounding box.

Returns:

The ordered, directed edge chain the curve occupies.

Return type:

EdgePath

Raises:

ValueError – If the curve is shorter than one cell (rasterises to a single node), or samples_per_cell < 2.