kicad2ems.core.magnets

The static field that biases a drawn ferrite: the drawn permanent magnets'
and the ferrite's own (its demagnetising field), for the ferrite's
gyrotropic permeability (gfdtd's FerriteMaterial). No Qt, no solver.

    src = sources(board)                 # the magnets: [(polygon, z0, z1, M)]
    hz = field_z(src, pts)               # their Hz (A/m) at points (N, 3) mm
    h = field(src, pts)                  # their H vector (N, 3)
    f = magnetisation(board)             # the ferrites' magnetisation,
    h, m = f.at(pts)                     #   self-consistent: the internal
                                         #   field and M / Ms at points
    b = bias(board, ps, pts)             # the quick model (along z):
    b['hz'], b['sat']                    #   A/m, NaN where not saturated
    summary(board)                       # per ferrite (the quick model):
                                         #   applied and internal field, FMR
                                         #   frequency, saturation

How. The Draw page's solids are prisms: an outline extruded along z. A prism
magnetised uniformly along z (a magnet's rigid magnetisation M = Br / mu0)
has its magnetic charge on its top and bottom faces only (+M on the top, -M
on the bottom; none on the sides), so its H is the two faces': a face of
charge density s at height zf gives, at a point,

    Hz = s / (4 pi) * Omega,   H_xy = s / (4 pi) * sum over its edges of
                               n ln((Ra + Rb + L) / (Ra + Rb - L))

with Omega the solid angle the face subtends there (+ above it, - below;
the polygon's triangles by Van Oosterom and Strackee's formula) and, across
it, the divergence theorem's line integral of 1 / R round its edges (n each
edge's outward normal, Ra, Rb the distances to its ends, L its length): both
exact. Inside an infinite slab Hz is -M (a demagnetising factor of 1); on a
disc's axis 2 pi (1 - d / sqrt(d^2 + a^2)); off a cylinder magnet's axis it
is its surface current's (current loops) to 3e-6 of M.

The ferrite (magnetisation()) is an ideal soft one on a voxel grid over all
the drawn ferrites (64 across the widest, 4 through the thinnest, each voxel
uniformly magnetised over its share of ferrite): its magnetisation M is the
least energy -Ha . M - 1/2 M . Hd(M) + |M|^2 / (2 chi) with |M| <= Ms, Hd
the voxels' own field (their faces' charges, exact for boxes, an FFT
convolution), found by Nesterov's projected gradient steps. Where the
magnets can, it is saturated (|M| = Ms) along its internal field H = Ha + Hd
(tilted where the magnets' field spreads); elsewhere partly magnetised, H
all but 0 (M / chi: chi 50, the initial susceptibility, makes M unique, the
domains' mean). A sphere: H = Ha - Ms / 3 within 1 %, M = 3 Ha partly; a
thin disc along z: the face model's (below) within 0.5 % (2 % at its rim);
a long cylinder across: N 1/2 within 3 %.

The quick model (bias(), the Draw page's readout) takes the ferrite
saturated along z (its magnetisation the sign of the magnets' field over
it), its internal field the magnets' Hz plus its own faces':

    H0 = Hz_magnets + sign * Hz_ferrite(Ms)

NaN where H0 has not the sign of the magnetisation (not saturated). It is
exact for a z prism magnetised along z; under a small magnet the field
spreads (rf_circulator's puck, self-consistent: magnetised 36 deg off z on
the mean, up to 49, its internal field 540 to 990 Oe, where this model has
350 to 785 along z).

What both leave out: magnetic materials other than the magnets and the
ferrite (no steel pole pieces or return path: the metal is copper,
non-magnetic), a magnet's recoil permeability (about 1.05: rigid),
anisotropy and hysteresis, and temperature (Br and 4 pi Ms at 25 C).
class kicad2ems.core.magnets.Ferrites(**kw)[source]
The drawn ferrites' static magnetisation, self-consistent
(magnetisation()): the voxel grid (lo: its first voxel's centre, d: the
spacing, mm; n), fill (each voxel's share of ferrite), M (3, n: the
ferrite's magnetisation in it, A/m, |M| <= Ms), H and Ha (3, n: the
internal field and the magnets' at its centre, A/m), Ms (A/m), the
iterations and the last step's change (of Ms).
at(pts, exact=False)[source]
(h, m) at pts (N, 3) mm: the internal field (A/m) and M / Ms there,
m and the ferrite's own field those of the nearest voxel at least
half ferrite (piecewise constant), the magnets' field (smooth: no
magnet in the ferrite) interpolated from the voxels' centres
(trilinear) or, exact, worked out at the points.
kicad2ems.core.magnets.alpha(dh_oe, f=9400000000.0, g=2.0)[source]
Gilbert's damping of a ferrite whose FMR linewidth (full width at half
maximum, Oe) is dh_oe at f Hz (the datasheets': 9.4 GHz): dH = 2 alpha w /
gamma.
kicad2ems.core.magnets.bias(board, ps, pts, owner=None, zmap=None)[source]
The ferrite's internal static field along z at pts (N, 3) mm, each in
the ferrite solid owner[k] (an index into board.solids; None: all in
one), the ferrite saturated along z (the quick model: the Draw page's
readout; magnetisation() has the field's direction and the partly
magnetised ferrite). dict(hz: A/m, NaN where not saturated; applied: the
magnets' Hz; sign: {solid index: +1 / -1, its magnetisation's
direction}; sat: bool (N,)). With no magnet the ferrite is unbiased: hz
all NaN.
kicad2ems.core.magnets.ferrite_sources(ps, zmap=None, ms=True)[source]
The ferrite pieces (core.solids pieces with .ferrite) as field_z's
sources at their saturation (M = Ms, along +z), with their solid's
index.
kicad2ems.core.magnets.field(srcs, pts)[source]
The H vector (A/m, (N, 3)) at pts (N, 3) mm of prisms magnetised along
z (srcs as field_z's): each face's Hz its solid angle, its Hx and Hy its
edges' log terms (_face).
kicad2ems.core.magnets.field_z(srcs, pts)[source]
Hz (A/m) at pts (N, 3) mm of prisms magnetised along z: srcs
[(polygon, z0, z1, M A/m)], each a charge +M on its top face and -M on its
bottom one.
kicad2ems.core.magnets.fmr(h0, ms_g, g=2.0)[source]
(f0, fm) Hz: the precession frequency gamma H0 of internal field h0
(A/m) and gamma 4 pi Ms of a ferrite of ms_g gauss.
kicad2ems.core.magnets.magnetisation(board, ps=None, zmap=None, voxel=None, applied=None, chi=50.0, tol=0.0001, max_iter=3000)[source]
The drawn ferrites' static magnetisation in the magnets' field,
self-consistent: each ferrite an ideal soft one (no anisotropy, no
hysteresis) on a voxel grid over all of them (voxel: its spacing, mm, or
None: 64 across the widest, at least 4 through the thinnest), each voxel
uniformly magnetised over the share of it that is ferrite (fill: 4 x 4
points across, its overlap in z). The equilibrium is the least energy
-Ha . M - 1/2 M . Hd(M) + |M|^2 / (2 chi) with |M| <= Ms in every voxel,
the demagnetising field Hd the voxels' face charges (exact for uniform
boxes: _box_kernel, an FFT convolution); projected gradient steps
(Nesterov's), M <- P(M + H - M / chi): saturated where it can be (|M| =
Ms along its internal field H), else partly magnetised with H = M / chi
inside, near 0 (H_a all but cancelled by its own field). chi, the
initial susceptibility, makes that M unique (the least that carries the
charge: the domains' mean, no vortex added). applied: a function pts (N,
3) mm -> H (N, 3) A/m instead of the drawn magnets' field (tests). A
Ferrites (None: no ferrite).
kicad2ems.core.magnets.magnetised(board)[source]
The drawn ferrites' names when a magnet is drawn too ([] when there is
no ferrite or no magnet: an unbiased ferrite is a dielectric to every
solver).
kicad2ems.core.magnets.ms_si(ms_g)[source]
Saturation magnetisation (A/m) of 4 pi Ms in gauss.
kicad2ems.core.magnets.refusal(board, solver)[source]
A solver's assess() reason for a magnetised ferrite it cannot model
(None: none drawn).
kicad2ems.core.magnets.sources(board, zmap=None)[source]
The drawn magnets (board.solids of material 'magnet') as field_z's
sources, M = Br / mu0; zmap maps their heights (the FDTD's thick-copper
plan).
kicad2ems.core.magnets.summary(board, ps=None, n=15)[source]
Per drawn ferrite solid: dict(name, index, applied_oe (min, mean, max of
the magnets' Hz over it), internal_oe (the same of H0 where saturated),
saturated (the share of it), f0 (Hz, gamma H0 at the mean), fm (Hz),
sign), from a grid of n x n x 3 points over each piece.