kicad2ems.emsdev.numerics.geo

geo - the copper of a layer as a triangle mesh, and the geometry around it

  * mesh_polygons : constrained-Delaunay mesh of arbitrary polygons (holes
                    allowed) with
                    - graded edge refinement (inward offset rings, like the
                      tensor mesher's cosine grading)
                    - port gap/cut lines inserted as constraint segments (so
                      RWG edges lie on them)
                    - via points inserted as vertices, with a small ring of
                      radius = via radius around them so the via 'fan'
                      (triangles sharing the via vertex) matches the via
                      footprint
  * gap_zones     : the copper edges facing other copper across a narrow gap
  * to_geometry   : rectangles / shapely geometry -> one cleaned shapely
                    (Multi)Polygon
kicad2ems.emsdev.numerics.geo.gap_zones(geom, gmax, step, tol=1e-09)[source]
The copper edges facing other copper across a gap narrower than gmax:
[(zone, g)], each zone the copper within reach of the edges whose gap falls
in one band (about 1.4x wide), g the narrowest gap of that band. The gap at
an edge: a ray out of the copper along its normal, from points `step` apart,
to the copper it hits, counted only where the edge it hits faces back
(within 60 degrees) and is not the same outline within 20 gaps of the ray's
start: the wedge where a track's round end meets a pad or strip at a tangent
is no gap (rf_combline's bridged parts: gaps of 8 um, and rings that far in
left its complex64 LU unable to precondition).
kicad2ems.emsdev.numerics.geo.mesh_polygons(geom, dmax, w_ref, ncross=6, grade=1.0, lines=(), vias=(), amax=None, max_offset_frac=0.45, tol=1e-09, fine=None, dmax_fine=None, edge_zone=None, split_chains=False, coarsen=None, grow=0.5, structured=False, struct_w_max=0.02, gap_rings=None, quality=None, area_scale=1.0, coarsen_fine=True, core=None)[source]
geom   : shapely (Multi)Polygon of one metal layer (triangulated by mesh2d
         in a compiled core: cdtmesh.py)
dmax   : max edge length along conductors / in open regions
w_ref  : reference strip width for the edge grading (narrowest trace on the
         layer)
lines  : [(p0, p1), ...] constraint segments (port gap and cut lines),
         clipped to geom
vias   : [(x, y, radius), ...] points to insert as vertices (+ an octagon of
         the via radius); (x, y, radius, n) an n-gon; (x, y, radius, 4,
         True) a square that may snap to a cell of the structured grid
edge_zone : (experimental) shapely area where the current crowds at edges
         (the signal copper buffered by ~0.5 mm): the edge rings are kept
         only inside it. Demo transition (cropped): 4.9k unknowns instead of
         8.4k, S within 0.006 of the full rings (2.4x faster a solve);
         Simulation(zone=) passes it
split_chains : each outline at the spacing of the region it runs through
         (zone=; the default spaces a whole chain by where its centroid
         falls, which a closed outline's centroid can get wrong)
coarsen_fine : with coarsen, the fine regions coarsened too (True); False:
         they keep dmax_fine (sim.py: a meshed plane's, under the copper of
         the layers near it)
coarsen : (experimental) cells grow away from the features (corners and
         bends of the copper outline, vias, port and cut lines; _features)
         up to coarsen x dmax: dmax + grow x the distance to the nearest
         one, along the outline and the edge rings (their spacing across the
         edge is kept) and over the area inside them (the middle of wide
         traces, planes). None: dmax everywhere
structured : (experimental) straight runs of trace (runs.find_runs, up to
         struct_w_max wide: traces and rectangular pads) as a tensor grid:
         transverse lines across the run at stations along it (the spacing
         of the field, or dmax), and longitudinal ones across its middle
         (inside the edge rings), so its cells are rectangles - one diagonal
         each, quad cells of 0 degrees. Port / cut lines on a run are
         stations; square vias join the grid (_run_grid), around other vias
         it is left as is
gap_rings : fractions of the gap (e.g. (1/4, 1/8, 1/16)): rings that far in
         from the copper edges facing other copper across a gap g
         (gap_zones), where the width-graded rings are too coarse for the
         edge charge across it (g/4 under the first ring at w_ref's
         grading). Coupled lines: on the 10 dB coupler (0.14 mm gap, 1.28 mm
         strips) S31 -10.64 dB, against -10.24 to -10.29 from refined FDTD,
         until the edge cells came down to the gap's scale; isolated traces
         and planes keep their cost
quality : the minimum angle (degrees: mesh2d's refinement), on the
         uncoarsened path only. Off by default (the edge-ring strips of the
         RF meshes would split into fans); without it a small feature (a
         via's octagon) fans out to far vertices in long slivers, and the
         linear elements then underestimate the log spreading around it
         (DC: ~0.1 mOhm per via junction)
core   : the compiled core that triangulates (cdt_triangulate:
         emsdev/native/cdt_mesh.hpp); None: pcbqs's, else mom25d's (the same
         code in both)
Returns nodes (N,2), tris (M,3) counter-clockwise, and the list of via
vertex ids.
kicad2ems.emsdev.numerics.geo.ngon(x, y, R, n, closed=False)[source]
Vertices (n, 2) of the regular n-gon of circumradius R about (x, y), a
flat side at the bottom (closed: the first vertex repeated at the end).
kicad2ems.emsdev.numerics.geo.to_geometry(shapes)[source]
List of rectangles (x0,y0,x1,y1) and/or shapely geometries -> cleaned
(Multi)Polygon.