kicad2ems.core.board

The canonical board: what every solver gets, from any importer (units mm, model
coordinates: y up, the negative of KiCad's y).

    board = Board(raw, nets=['RF', 'GND'], pos_file='board-top.pos',
                  ground='B.Cu')
        # resolve an import
    board.save('board.json');  board = Board.load('board.json')
        # the file contract
    board.summary()
        # what the parity checks compare (copper area per layer and net, ...)

  layers      dielectric slabs dict(name, z0, z1, er, tand, kind), bottom to top
  cu_z, cu_t  copper layer heights and thicknesses (cu_order: bottom to top);
              thickness: the stack's
  outline     the dielectric's extent: the board outline, cropped to the region
              if one is given
  copper      {layer: [polygons]} the selected copper, merged per layer;
              copper_nets: the net of each
  vias        [(x, y, radius, z0, z1)] plated holes as metal cylinders;
              via_nets, via_signal (on a port net)
  ports       [Port] from the P<n> footprints, the settings and region cuts;
              user_ports groups the legs of differential ports
  parts       [parts.Part] lumped R / L / C parts between two pads
  walls       [(axis, coord, t0, t1, z0, z1)] edge walls where the ground planes
              end (edges.py)
  solids      drawn 3D shapes (core.shapes.apply): dict(shape, material, z0,
              z1, er, tand, polygon); the FDTD and Palace mesh them
              (core.solids)
  prims       the primitives behind the copper, for the line model: items,
              shapes, tracks, footprints, vias
  ground, ground_nets, signal_nets, sel (the nets kept; None: all), region,
  cut_sides, notes, source, request

Physical intent only: what is on the board and what was asked for. Nothing is
snapped to a mesh, split for a solver or fitted: the solvers do that, and say
so. board.json holds all of it (format kicad2ems-board, version 1); a reader
refuses a newer major version and ignores keys it does not know.
class kicad2ems.core.board.Board(raw, nets=None, pos_file=None, include_mask=False, region=None, ground=None, parts='auto', log=<built-in function print>, ports=None, cut_ports=False, edge_walls=(), edge_keepout=0.5, need_ports=True, fill_voids='off', part_ports=(), shapes=None)[source]
The board of a run, resolved from an imported board (`raw`: KiCadBoard,
GerberBoard) and the selection settings: nets, pick-and-place file, solder
mask, region, solid ground layer, lumped parts, extra ports, ports where
tracks cross the region edge and edge walls. need_ports=False: a board
without ports is fine (the KiCad plugin's impedance map, before any are
placed).
copper_at(lay, pt)[source]
The modelled copper polygon on layer `lay` containing point pt (model
coordinates), or None.
property cu_order[source]
Copper layers, bottom to top.
describe()[source]
The board as the log shows it: the stack, the copper, the outline and
vias, each port and part, the notes.
net_at(lay, x, y)[source]
Net of the selected copper on layer `lay` at model point (x, y), or
None.
save(path)[source]
Writes the board file (to_dict as JSON: <name>_board.json); returns
path.
property signal_nets[source]
The nets of the traces the ports sit on; vias on them are 'signal
vias'.
summary(nd=4)[source]
The numbers two boards (two importers, a refactor, a solver's
readback) should agree on: the stack, copper area per layer and net,
vias, ports, parts, edge walls, the outline (rounded to nd decimals).
to_dict(prims=True)[source]
The board as plain data (board.json): lengths in mm, model
coordinates, polygons as GeoJSON. prims False: without the board's
primitives (mom25d reads none of them; a segment piece carries the
whole board's, 35 MB of a Thor window's 35.0: 0.75 s a call).
property user_ports[source]
[(name, [ports])]: one entry per port as the user named it, the two
legs of a differential port together.
class kicad2ems.core.board.Port(name, layer, z_sig, z_ref, c, axis, sgn, w, z0, leg=None, pair=None, ref_layer='', kind='z', gap=None, net=None, source='', internal=False, d=None)[source]
Lumped port. kind 'z': a vertical sheet across the trace from the
reference copper to the trace (feed lines over a plane); kind 'gap': a sheet
in the copper plane across a gap between two conductors on the same layer
(centre-fed dipoles, gap feeds), from gap[0] to gap[1] along axis. c is the
port's centre, d the unit direction into the circuit (a vertical port's
trace at any angle, R-E1), axis (0: x, 1: y) and sgn its dominant axis and
sign there (the port's sheet is normal to that axis), w the trace's
width.
box()[source]
Lumped-port sheet: across the trace, from reference copper to the
trace ('z'), or across the gap in the copper plane ('gap'). An oblique
trace's: in the plane normal to its dominant axis, as wide as the
trace's cut there (w / |d[axis]|).
property oblique[source]
Its trace runs at an angle to x and y (more than 0.06 deg).
planes()[source]
Coordinates along the axis that must be mesh lines.
class kicad2ems.core.board.Prims(items=(), shapes=(), tracks=(), vias=(), footprints=())[source]
The primitives the copper is made of, in model coordinates (what the line
model reads): items [(layer, net, geometry)], shapes (the zones and drawn
copper among the items), tracks [dict(layer, net, width, pts)], vias
[dict(x, y, size, drill, layers, net[, pth])] and footprints [dict(ref,
value, props, x, y, rot, side, dnp, exclude_from_sim, pads [dict(name, xy,
layers, net, geom, rot)])].
classmethod from_raw(raw, keep, layers, outline)[source]
The primitives of an imported board (KiCad coordinates) on copper
`layers` that reach `outline` (model coordinates): a cropped region of a
large board keeps only what it can use. keep: its items that do
(inside_items).
kicad2ems.core.board.cross_section(cu, probe, t, reach=20.0)[source]
Width (mm) and mid point of the copper polygon `cu` along the line
through `probe` in direction t (unit vector): the piece of that line inside
the copper nearest to the probe.
kicad2ems.core.board.inside_items(raw, layers, outline)[source]
The items of an imported board (KiCad coordinates) on copper `layers`
whose bounding box meets the outline's (model coordinates).
kicad2ems.core.board.port_field(props, key, default=None)[source]
Port footprint field: 'port.<key>' (preferred) or 'mom.<key>' (mom25d
footprints).