kicad2ems.fdtd.mesh

Automatic rectilinear mesh for openEMS.

  x / y : thirds rule at Manhattan copper edges (1/3 inside, 2/3 outside the
          metal), end points of oblique edges, via centre +- radius, drawn
          solids' faces (small posts snapped as ground vias), port planes and
          the board outline kept exactly; lines closer than fine/2 merged by
          priority; graded smoothing (<= ratio growth) up to lambda/res in the
          dielectric and in air
  z     : every interface, >= nz cells per dielectric, copper sheets exactly
          on lines, air margin (none below a PEC bottom plane), PML cells added
          only on PML sides; with --thickness on, both faces of each copper
          layer, the stack moved up to make room (thick.py)
kicad2ems.fdtd.mesh.air_text(air)[source]
The air margin as the log says it: '11.5 mm', or per side when they
differ.
kicad2ems.fdtd.mesh.auto_mesh(m, fmin, fmax, res=20, fine=None, air=5.0, ratio=1.4, bc=('MUR', 'MUR', 'MUR', 'MUR', 'MUR', 'MUR'), nz_min=4, curves='extremes', vias='auto', via_snap=0.2, refine=(), z_sheet=1.0, curve_res=6.0, zone=False, thickness=False, nz_mask=None, log=<built-in function print>)[source]
Mesh lines (mm) for model m. Returns dict(x, y, z, vias, info, thick,
enclosure, posts): thick is the copper thickness plan (thick.plan, None:
zero-thickness sheets) that build_fdtd builds the model with; enclosure
the drawn metal's box (core.solids.enclosure, board heights) when it
closes round the board and the mesh ends at its outer faces, else None;
posts the drawn metal posts snapped onto line crossings, [[k, dx, dy]]
(k: the piece's index in core.solids.pieces, moved by dx, dy mm:
moved_pieces).

curves: 'extremes' (default) or 'vertices' - see curve_lines().
vias:   'exact'  lines at the centre and +-radius of every via (round
                 barrel resolved)
        'centre' one line per axis through the centre (barrel modelled on
                 that line)
        'snap'   no lines of their own: each via moves onto the nearest
                 existing line crossing if it is within via_snap mm (else
                 it gets centre lines)
        'auto'   (default) 'exact' for vias on the port (signal) nets,
                 'snap' for all others (ground stitching / fence vias)
        with 'snap' and 'auto' a drawn metal post (no wider than
        POST_MAX in plan) is snapped as a ground via: no x / y lines of
        its own, its centre moved onto the nearest line crossing
refine: [(x0, y0, x1, y1, step)] boxes (model coordinates, mm) with x and
        y lines every `step`
z_sheet: the first z cell either side of a copper sheet with signal edges,
         x fine, graded into the dielectric (0: uniform cells, nz_min per
         dielectric). On 0.8 mm FR-4 the default nz of 4 gave a 10 dB
         coupler -8.6 dB (converged -10.24 to -10.29, lossless) and a
         grounded CPW's S11 at 5 GHz -19 dB (about -33); grading from the
         fine cell gave -10.3 and -31.6 dB for 1.4x the run time. The gap
         and edge cells in x / y hardly mattered (docs/meshing.md#z-lines)
curve_res: over curved copper (curve_lines' boxes) the largest cell is the
         dielectric's / curve_res: a radial stub's fan had cells up to
         1.8 mm and notched at 2.03 GHz instead of 2.13
zone:   True: the ground copper's edges get mesh lines only near the
         signal copper (signal_zone); far from it the planes' pours,
         antipads and pads are left to the graded mesh. A number: the
         zone's reach (mm)
thickness: copper with its stackup thickness, the stack moved to make
         room (thick.py); False: sheets

Drawn solids (board.solids, as core.solids.pieces resolves them): lines at
their pieces' faces (solid_lines; a metal face wins a merge, a
dielectric's or air's gives way to the copper's; a post's heights alone),
the dielectric ones' own largest cell, and the air margin past them as
well as past the board.
kicad2ems.fdtd.mesh.curve_lines(xy, fine, mode='extremes', step=None, boxes=None, inside=None)[source]
Mesh-line candidates of the curved parts of a ring (rounded pad corners,
round track ends, arcs, circular antipads, oblique edges). Edges that are
Manhattan and at least `fine` long are handled by the thirds rule instead.
mode 'extremes': for each run of consecutive curved edges only its two end
points and its local x / y extremes (a round antipad gives 2 lines per axis
instead of one per vertex), and with `step` also a line wherever the run has
gone `step` mm in x or y since the last one: a thin curved track (the
copper's width as the step) stays connected on the mesh. With the extremes
alone a rat-race's 0.8 mm ring sat on cells up to 1.8 mm, broke apart, and
S21 came out -35.8 dB instead of -3.4. 'vertices': every vertex (dense,
closest to the drawn geometry). boxes: a list that gets (x0, y0, x1, y1) of
each curved run longer than 4 fine and twice `step` (the copper's width):
arcs, rings and fans, not the round end of a track or a pad's corner.
inside: a test of (x, y): only the lines of points it passes (the ground
copper within the signal zone).
kicad2ems.fdtd.mesh.dead_spans(ps, axis, box6)[source]
[(a, b)] along an axis where drawn metal (core.solids pieces) fills the
whole of the domain box6 (x0, y0, z0, x1, y1, z1) across it: a can's floor,
lid and walls once the mesh ends at its outer faces. No field there: no
lines inside, nothing to grade beside them (smooth_lines' dead).
kicad2ems.fdtd.mesh.manhattan(d, L, fine)[source]
Edges (vectors d, lengths L) treated as Manhattan: at least `fine` long
and drifting at most fine/10 across their axis. Near-Manhattan edges come
from simplify() merging a tiny step (a 1.5 um jog where a track meets a
slightly wider rectangle); they still get the thirds rule.
kicad2ems.fdtd.mesh.moved_pieces(ps, shifts)[source]
ps with the snapped posts moved (shifts: the mesh's 'posts', [[k, dx,
dy], ...]); the others as they are.
kicad2ems.fdtd.mesh.post_lines(cs, reach)[source]
Lines for posts with none within `reach`: their centres cs in runs no
longer than 2 reach, a line at each run's middle (every post within reach
of one). A fence at a pitch under the cell: one line every 2 reach, not
one a post (the merge's fine / 2 had kept one every 0.2 mm on a 0.147 mm
fence).
kicad2ems.fdtd.mesh.posts(ps, vias='auto')[source]
Indices into ps (core.solids pieces) of the drawn metal posts the mesh
snaps (POST_MAX; vias 'snap' or 'auto', as a ground via): none for
'exact' or 'centre'.
kicad2ems.fdtd.mesh.signal_gaps(m, near=2.0)[source]
The gaps (mm) between the copper the ports sit on and other copper of the
same layer, closer than `near`: coupled lines, a grounded CPW's slots.
Copper pieces are the separate polygons of a layer.
kicad2ems.fdtd.mesh.signal_sheets(m, plane=0.85)[source]
Heights of the copper sheets with signal edges on them: the ports' layers
and every layer that is not a plane (copper over less than `plane` of the
board).
kicad2ems.fdtd.mesh.signal_zone(m, dist=None)[source]
Where the mesh resolves the ground copper's edges (model mm): within
`dist` of the signal copper (copper of any net but the ground nets, on any
layer) and of the signal vias. dist None: ZONE_DIST or ZONE_H x the thickest
dielectric, whichever is more. None when the board has no signal copper
apart from the ground.
kicad2ems.fdtd.mesh.smooth_lines(fixed, maxres, ratio=1.4, fine=None, whole=(), rounds=30, dead=())[source]
Insert lines between fixed lines so that every cell is <= maxres(x) and
neighbouring cells differ by at most `ratio`, across the fixed lines too.
maxres: float or callable(x) (taken at each fixed interval's middle).

Each fixed line has the size its cells may have (e): ratio times the fixed
gap beside it (a cell that size beside one gap wide), with fine 3 fine
ratio (a feature's cells as before), carried along the axis in both
directions growing (ratio - 1) times the distance (as cells growing by
ratio do), so a fixed gap split into small cells is seen beyond its
neighbours too. whole: points (a copper edge's x or y) whose fixed
interval is not split (the thirds-rule pair round the edge: a line inside
it moves the edge), unless past maxres or wider than fine; a jump beside
one is left. Each interval is graded from its
two ends' sizes; where the two cells at a fixed line still differ by more
than ratio (an interval split into slivers), the line's size is lowered to
ratio times the smaller and the intervals graded again. Each interval had
been graded from its neighbouring fixed gaps alone: a gap split into
0.031 mm cells beside one started at 0.21 mm (6.8x), and 8.9x on rf_ratrace's
mesh (the review, F42). dead: [(a, b)] spans of metal across the whole
domain (dead_spans): a fixed interval inside one is not split and sets
nothing beside it (no field there to grade).
kicad2ems.fdtd.mesh.solid_lines(ps, fine, curves='extremes')[source]
Mesh-line candidates of drawn solids' pieces (core.solids.pieces):
{0: [(x, metal)], 1: [(y, metal)], 2: [(z, metal)]}. x / y: each Manhattan
edge's own coordinate (manhattan), a curved run's ends and extremes
(curve_lines); z: each piece's two heights. metal: a metal piece's face
(it wins a merge against the copper's thirds-rule lines: a wall thinner
than the cell keeps a line on it).