kicad2ems.gui.drawmagnets

The Draw page's ferrites and magnets, without Qt: a magnet drawn in 3D as two
halves (its poles, N red and S blue), the board core.magnets works their bias
out on, the side panel's readout of it and the plan's map of it.

    v, f = magnet_mesh(g, z0, z1, zm)    # two halves meeting at zm (no faces
                                         # between them)
    c = pole_colours(v, f, zm, top, bottom)  # (m, 4) RGBA, a face's
    top, bottom = poles(br)              # the N / S colours on top / below
    b, at = bias_board(layout, stack, shapes)   # board.solids: the drawn
                                         # solids the bias depends on; at:
                                         # shape index -> board.solids index
    summary = core.magnets.summary(b)
    text = readout(summary, shapes, i, at)   # what shape i's panel says
    x0, y0, x1, y1, h, inside = bias_map(b, shapes, i, at)
                                         # H0 (Oe) on a grid over its
                                         # ferrite (or every ferrite)

A magnet's remanence `br` is signed (core.shapes): + magnetised up (+z), its N
pole on top; - down. Its top half is drawn in its top pole's colour. The bias
is core.magnets' (along z, the ferrite saturated where the field allows):
the readout gives the internal field's range, the share of the ferrite that
is saturated, and the two frequencies of the gyrotropy, f0 = gamma H0 and
fm = gamma 4 pi Ms.
kicad2ems.gui.drawmagnets.bearing(shapes, outline=None)[source]
The indices of the drawn solids the bias depends on: every ferrite and
magnet, and a solid drawn after a ferrite whose box meets the ferrite's
(a later solid takes a ferrite's place where they overlap). A via fence
beside a circulator is left out (core.solids would resolve it all: 300
vias took the readout from 20 ms to 50). outline(s): a shape's outline
(the page's kept ones; default Shape.outline).
kicad2ems.gui.drawmagnets.bias_board(layout, stack, shapes, outline=None)[source]
(board, at): a board for core.magnets, the board's outline and stack
(layout: the Draw page's board dict, or None) and the drawn solids the
bias depends on (bearing's; a hidden one too: a run applies it) as
core.shapes.apply makes them; at: {shape index: its board.solids
index}.
kicad2ems.gui.drawmagnets.bias_map(board, shapes, i, at, n=32)[source]
The internal field H0 over the ferrite of shape i (a magnet: over
every ferrite), along its magnetisation, in Oe, on an n x n grid of cell
centres at each ferrite piece's mid-height (core.magnets.bias; board, at:
bias_board's): (x0, y0, x1, y1, h, inside): h (n rows along y, n columns
along x) NaN outside the ferrite or where it is not saturated, inside
the cells in the ferrite; None for no ferrite left (32 x 32 over a 3 mm
puck under a 5 mm magnet: about 40 ms).
kicad2ems.gui.drawmagnets.magnet_mesh(g, z0, z1, zm)[source]
Polygon g extruded from z0 to z1 in two halves meeting at zm (vertices,
faces wound outward): the faces between them left out, so each face is
wholly above zm or wholly below it. zm not inside (z0, z1): one prism.
kicad2ems.gui.drawmagnets.pole_colours(v, f, zm, top, bottom)[source]
(m, 4) float32 RGBA of each face: `top` above zm, `bottom` below.
kicad2ems.gui.drawmagnets.poles(br)[source]
(top, bottom): the RGB of the pole on top and below of a magnet of
remanence br (+: N on top).
kicad2ems.gui.drawmagnets.readout(summary, shapes, i, at=None)[source]
What the side panel says of shape i (a ferrite or a magnet) from
core.magnets.summary's rows: a ferrite's internal field, saturation, f0
and fm (unbiased with no magnet drawn); a magnet's direction and each
ferrite's line. '' for anything else.
kicad2ems.gui.drawmagnets.solid_index(shapes, outline=None)[source]
{shape index: its board.solids index} of all the drawn solids
(apply's order: the solids with an outline). outline(s): a shape's
outline (default Shape.outline).