kicad2ems.pcbqs.pdn.mesh

The copper of a net as triangle meshes, one per layer (pcbqs's own mesher,
geo.mesh_polygons), and the linear (P1) finite-element matrices on them: what
the DC drop (dc.py) and the plane-pair cavity (cavity.py) solve on.

    sheets = net_sheets(board, '+1V0', points=[(x, y, r), ...], dmax=1.0)
        # {layer: Sheet}, board.json units (mm)
    K, M = stiffness(sh.nodes, sh.tris), mass(sh.nodes, sh.tris)

A point (a via) is a vertex of the mesh with an octagon of its radius around it
(the via fan of mesh_polygons); Sheet.at(i) is the vertex ids of point i on that
sheet: its centre and its ring. A region (a pad) has its outline made mesh
edges; Sheet.region(k) is the vertex ids on and in it.
class kicad2ems.pcbqs.pdn.mesh.Sheet(layer: str, z: float, t: float, geom: object, nodes: numpy.ndarray, tris: numpy.ndarray, points: list, rings: list, key: list, regions: list = None)[source]
at(i)[source]
The vertex ids of the caller's point i on this sheet ([]: not on
it).
kicad2ems.pcbqs.pdn.mesh.copper_centres(board)[source]
{layer: (centre z, t)}, mm, of each layer's copper with its thickness put
into the stack. board.json (from kicad2ems) stacks the dielectrics and puts
each copper layer at their interface with no thickness: KiCad's dielectric
thickness is the gap between facing copper surfaces. Thick copper keeps
those gaps when each layer's slab starts at its z plus the copper below it:
[z + C, z + C + t], C the thicknesses of the layers beneath.
kicad2ems.pcbqs.pdn.mesh.copper_of(board, net, layer)[source]
The copper of `net` (a name, or a set of names: a rail tree's nets) on
`layer` (board.json's dict), one shapely geometry in mm, or None.
kicad2ems.pcbqs.pdn.mesh.gradient(nodes, tris, v)[source]
The gradient of a P1 field v (one value per node) on each triangle, (M,
2) per unit of the node units.
kicad2ems.pcbqs.pdn.mesh.mass(nodes, tris, lumped=True)[source]
The P1 mass matrix (lumped: a third of each triangle's area on each of
its vertices, diagonal).
kicad2ems.pcbqs.pdn.mesh.mesh_sheet(geom, points=(), dmax=1.0, w_ref=None, coarsen=None, regions=(), fine=None, dmax_fine=None, grow=0.5, edge_rings=1, edge_zone=None, via_sides=None, quality=None, info=None)[source]
Mesh one piece of copper (mm): (nodes mm, tris, [vertex ids of each
point: centre + ring], [vertex ids of each region]) for the points (x, y, r)
inside it (None where one is not) and the regions (shapely polygons, mm:
pads), whose outlines are made mesh edges (a region on none of this copper:
[]). fine (shapely, mm) is meshed at dmax_fine (mm). coarsen: mesh_polygons'
(cells grow away from the features to coarsen x dmax). via_sides: each via's
ring a regular polygon of that many sides with the via circle's perimeter
(default: an octagon in it). Vias whose rings overlap are meshed as the
largest one's ring, shared (overlapping_vias); info (a dict), if given, has
their count added to info['merged_vias'].
kicad2ems.pcbqs.pdn.mesh.net_sheets(board, net, points=(), dmax=1.0, layers=None, coarsen=None, regions=None, fine=None, dmax_fine=None, quality=None, info=None)[source]
{layer: Sheet} of the copper of `net` (a name or a set: a rail tree) on
each copper layer (or `layers`), every point (x, y, r) of `points` that lies
on a layer's copper made a vertex with its ring. regions: {layer:
[polygon]} (pads) whose outlines become mesh edges; Sheet.region(k) their
vertex ids. fine, dmax_fine: a region (shapely, mm) meshed finer.
kicad2ems.pcbqs.pdn.mesh.outline_segments(geom)[source]
The outlines of a geometry's polygons (mm) as mesh_polygons' constraint
segments (m).
kicad2ems.pcbqs.pdn.mesh.overlapping_vias(points, margin=0.1)[source]
Vias whose rings would cross or nearly touch, as {absorbed index: host
index} over `points` [(x, y, r)].

Two rings closer than `margin` x the smaller radius (crossing, or one
drilled into the other) leave the mesher acute corners and slivers of copper
between them; with a minimum-angle switch Triangle then refines without end
(wpthb's ground: two stitching vias 0.25 mm apart, 2.3 million vertices at
any dmax). Such vias are one plated hole electrically, so the larger one's
ring is meshed and the others share its vertices. Largest first: each via
still free hosts the free vias its ring overlaps, so a chain is not
collapsed onto one end.
kicad2ems.pcbqs.pdn.mesh.simplify_copper(geom, keep=(), points=(), drop_lone=True, area=1.0, sides=8)[source]
Copper (mm) with lone pads dropped and small round pads/holes made
regular polygons.

A piece under `area` mm^2 that touches no `keep` polygon (terminal pads) and
holds at most one of `points` (via centres) carries no lateral current: its
via passes through to the next layer with copper, so it is dropped.
Remaining small round pieces and holes become `sides`-gons of equal area
(None/0 keeps them). Returns (geometry or None, counts).
kicad2ems.pcbqs.pdn.mesh.stack_z(board)[source]
{layer: (z, t)} of the copper layers, mm.
kicad2ems.pcbqs.pdn.mesh.stiffness(nodes, tris, coef=1.0)[source]
The P1 stiffness matrix: sum over triangles of coef * area * grad(phi_i)
. grad(phi_j). coef: a scalar or one per triangle (a sheet conductance, S
per square, makes it the sheet's conductance matrix).