kicad2ems.mom25d.api¶
mom25d.api - one call for a program that hands mom25d a board and wants
S-parameters back, without reaching into the Simulation's internals (kicad2ems's
MoM solver is the first user of this seam).
from kicad2ems.mom25d.api import solve_board
res = solve_board('out/filter_board.json', np.linspace(1e9, 6e9, 401),
dmax=0.3e-3)
res.S, res.names, res.zref # (nf, n, n) at the ports' reference impedances,
# port names, ohms
res.ports, res.unknowns, res.solves, res.seconds, res.notes
The board is kicad2ems's file format (see board.BoardModel): the path of a
<name>_board.json, or its content. Fields of Result are the stable part;
Result.model and Result.sim give the objects behind it for anything else (and
change with mom25d).
- class kicad2ems.mom25d.api.Result(f: numpy.ndarray, S: numpy.ndarray, names: list, zref: list, ports: list, unknowns: int, triangles: int, solver: str, precision: str, mesher: str, solves: int, solved: list, seconds: float, notes: list = <factory>, afs: list = <factory>, afs_tol: float = None, model: object = None, sim: object = None)[source]¶
- kicad2ems.mom25d.api.build_board(board, fmin, fmax, dmax=0.0003, plane_factor=3.0, port='auto', pairs=False, mesher='auto', metal=None, ground=None, log=<built-in function print>, quads=False, zone=None, stitching_vias='auto', quad_tol=35.0, coarsen=2.0, planes='pec', stitching_pads='drop', wideband=None, title=None, mesh_only=False, characterize=True, cells=30.0, thickness='sides', edges='fine')[source]¶
(BoardModel, Simulation) of a board as solve_board builds them, with its options (solve_board's). mesh_only: stop once the mesh and its unknowns are known (a preview of the mesh solve_board would solve on; the quad cells are paired only after that, so a mesh_only simulation has none).
- kicad2ems.mom25d.api.cell_growth(model, planes, fmax, dmax, cells=30.0, coarsen=2.0, log=None)[source]¶
{layer: x}: how far each layer's cells grow away from the features (corners, line ends, vias, ports; the edge rings as they are), x times their size there (dmax; a plane's, planes[layer]: the layers whose metal covers more than half the board), None where they do not. To the larger of two sizes: - a wavelength / cells in the densest dielectric at fmax, on a signal layer at most 4 x its narrowest conductor (longer cells cannot follow its current), on a plane x its cells' factor. As planar MoM tools size their cells (30 per wavelength: the current along a line within about 1 %). On 16 Solver Matrix boards against openEMS: 38 % of dmax's unknowns, a quarter of the time, the median RMS 0.059 against 0.057 (2026-11-15); the same size everywhere, not graded, lost 0.04 on resonators and via boards; - coarsen x the layer's size, where that is no more than a wavelength / OPEN (a plane's: / PLANE). At 8-13 GHz the first is 0.4-0.6 mm, under 2 x 0.3 mm: the 45 Solver Matrix boards in 10.6 min against 15.2 with it, 44 within 0.005 of their RMS against openEMS without it (median 0.0632 both; 2026-11-18, before the bounds). Past a wavelength / 15 patch arrays moved (cells of / 9: 0.036 to 0.041), and a slot along plane cells of a wavelength / 6.7 by 0.024. cells 0: the second alone; coarsen 0 or 1: the first alone.
- kicad2ems.mom25d.api.edge_kw(edges)[source]¶
Simulation's mesh options for edges= ('fine', 'coarse').
- kicad2ems.mom25d.api.solve_board(board, freq, dmax=0.0003, plane_factor=3.0, port='auto', pairs=False, mesher='auto', metal=None, ground=None, max_solves=60, afs_tol=0.005, log=<built-in function print>, progress=None, on_step=None, quads=False, zone=None, stitching_vias='auto', keep_at=(), quad_tol=35.0, coarsen=2.0, planes='pec', stitching_pads='drop', wideband=None, cells=30.0, thickness='sides', edges='fine', excite=None)[source]¶
S-parameters of a board (a <name>_board.json path, or its content) on `freq` (Hz). excite: the port names driven (every port terminated in its reference; the rest of S by reciprocity, 0 between two undriven ports: sim._sparams_terminated), None: every port. dmax (m): largest cell along the copper; layers whose metal covers more than half the board (planes) get plane_factor x dmax (refined near the copper of other layers). port: 'auto' (de-embedded wave ports where the straight feed spans enough for the fit down to the lowest frequency, else lumped), 'wave' or 'via' (lumped). pairs: P<n>+ / P<n>- ports as one mixed-mode port. metal: a sim.Metal (conductor loss), or None (lossless). log: lines of progress (the adaptive sweep's); progress(solves, max_solves, f): after each EM solve. on_step(entry): after each model of the adaptive sweep (its change and prediction error, afs.adaptive_sweep). quads: near-rectangular triangle pairs as quad cells (True, or 'centre'), quad_tol: the largest deviation of their corners from 90 degrees. coarsen: cells grow from dmax at corners, vias and ports to coarsen x dmax away from them (geo.mesh_polygons; None: dmax everywhere). planes: 'pec' (default: solid planes as the ground and a PEC cover, not meshed: mom25d.board) or 'mesh'. stitching_pads: 'drop' (default: a ground via's pad with nothing else on its layer left out, the via kept) or 'keep'. thickness: one of mom25d.thickness.MODES ('sides', the default: the copper's edges stood up as plates; 'off', 'grow', 'edge'), as mom25d.thickness.resolve allows it on the board. wideband: None (constant er, tand) or the frequency (Hz) the stack's er and tand hold at, Djordjevic-Sarkar elsewhere.