Usage¶
← Getting started · Index · Next: GUI →
Running kicad2ems¶
kicad2ems board.toml # everything from a config file
kicad2ems board.kicad_pcb --fmin 1 --fmax 6 # no config file
kicad2ems board.kicad_pcb --config run.toml # the board on the command line, options from a file
kicad2ems board.toml --preview # build the model and mesh, don't solve
kicad2ems --init board.kicad_pcb # write a starter config with the ports found
kicad2ems --check # what this Python can run
kicad2ems study board.toml # every question the config's study asks, one run after the other
python -m kicad2ems does the same with a particular Python.
The exit code is 0 when the run finished, 1 when a solver you named gave no result, and 2 when a setting is invalid or a named solver cannot run. Settings and solvers are checked before any work starts.
Choosing solvers¶
--solvers (or solvers = [...] in a config) picks the solvers. Each writes <name>_<solver>.sNp.
Name |
Solver |
Needs |
|---|---|---|
|
openEMS, 3D FDTD |
openEMS |
|
gfdtd, 3D FDTD on the GPU or the CPU: openEMS’s model, its own engine (details) |
slangpy (Vulkan) for the GPU, or its compiled core |
|
mom25d, 2.5D method of moments (details) |
nothing extra |
|
the line model, solved by qucsator |
qucsator on PATH |
|
the line model, solved by scikit-rf |
scikit-rf |
|
|
|
|
pcbqs, quasi-static: the low end of a band, from DC to about a tenth of a wavelength, with the return current where it flows (details) |
the |
|
the default: the full-wave solver expected to be fastest, plus the line model |
|
|
every solver |
kicad2ems board.toml --solvers mom # MoM only
kicad2ems board.toml --solvers openems,lines # openEMS and the line model
kicad2ems board.toml --solvers all # everything, compared in one plot
The first solver in the table order is the reference: its plot is <name>_<solver>.png, and the others
are drawn over it and compared with it in the report.
--mom and --fast add mom25d or the line model as an extra reference. If a reference can’t run, you
get a warning and the run continues. If a solver named in --solvers can’t run or can’t model the
board, the run stops before starting.
Below a few hundred MHz on a board of a few centimetres the full-wave solvers are slow and lose accuracy (an FDTD
run of 100,000 steps or more; mom25d’s mixed-precision solves falling back to double precision), and the line
model has no DC resistance and no return path. --solvers pcbqs solves the copper’s currents there instead,
and its charge where the band asks for it: --fmin 0.00001 --fmax 0.1 --sweep log is 10 kHz to 100 MHz, evenly
spaced on a log scale. Its run says to
what frequency it holds on the board, and two ports whose return is not joined (a ground via missing between
two planes) are reported as such.
One band from both. With pcbqs and a full-wave solver in one run (--solvers pcbqs,mom25d --fmin 0.01 --fmax 6 --sweep log), the run also writes <name>_joined.sNp: pcbqs’s answer below a crossover,
mom25d’s (else the other full-wave solver’s) above it, and across a fifth of a decade each side of it a
raised-cosine blend in log f, so the joined curve has no step. The crossover is where the two agree best, at or
below the frequency pcbqs says it holds to (a rule of thumb: a tenth of a wavelength of the ports’ copper). The
log says how far the two disagree there, and warns above 0.1 in |S|. On demo_transition pcbqs’s estimate is
714 MHz, where they differ by 0.043 (its one-sheet copper reads the matched line’s |S11| about 3.5 dB high, as
its docs say); the crossover goes to 17 MHz, where they differ by 0.0012.
Antenna mode (mode = "antenna") needs openEMS, gfdtd or mom25d. mom25d models antennas over an infinite
ground plane, so it suits patches and arrays but not antennas that use the board edge.
Which solver¶
gfdtd and mom25d are the working solvers, and the line model is for tuning. openEMS is the slower reference, for what the other two lack and for checking gfdtd’s engine.

The largest |ΔS| from openEMS over S11 and S21 against the wall time, on eight examples (benchmarks:
24 CPU threads, an RX 7800 XT for gfdtd and mom25d); python tools/doc_figures.py solvers draws it.
gfdtd solves openEMS’s model (the same mesh, ports, parts and end criteria) with its own engine: the fastest full-wave solver on every example, 3–35 times faster than openEMS on the GPU (its CPU core faster too), and within 0.02 of it on 7 of the 8. It handles what FDTD handles: board edges, enclosures, antennas with a finite ground, gap ports. Its copper takes
--sigmaas openEMS’s does and--roughover the band (openEMS takes it at the band centre). It has no--converge, and its lumped parts are modelled differently (demo_bandpass’s 0.126). Agreeing with openEMS checks its engine, not the model.mom25d is a different method, so it is the independent cross-check: no air box or enclosure resonances, radiation and surface waves in, conductor loss (
--sigma,--rough) and de-embedded wave ports. It is quick on thin trace filters and slow on large planes with many vias (memory grows with the square of the unknowns, time with their cube: sma_launch 108 s against gfdtd’s 2.8 s). Its dielectric extends sideways forever, so antennas that use the board edge come out wrong (antenna_ifa and antenna_slot: 1.4 from openEMS); it can’t model gap ports, and its loss tangent doesn’t vary with frequency. It lands 0.04–0.3 from openEMS on most boards.openEMS does the most (conductor loss, phased drive,
--converge) on the CPU only, and was the slowest full-wave solver on all but the smallest boards.The line model is a circuit of line sections, solved in milliseconds: close on plain distributed circuits (0.06–0.09), 0.4–0.8 off on filters and transitions (no coupling, radiation or parasitics), no antennas.
auto¶
auto drops the solvers that can’t run here or can’t model the board, estimates
how long each remaining full-wave solver would take, runs the fastest and adds
the line model. gfdtd’s estimate is openEMS’s mesh and timesteps at gfdtd’s
measured speed (about 8 times openEMS’s on the GPU, 2 times on its CPU core);
with --converge auto leaves gfdtd out, as it would ignore it. mom25d’s is the
matrix work for its unknowns on the CPU or GPU; a solver that needs more than
80 % of the RAM is dropped. The log says what it chose:
solvers auto: gfdtd + qucs (0.31 M cells, 1 run(s) of ~146,729 timesteps on the GPU, ~13 s); openems not chosen
(0.31 M cells, 1 run(s) of ~146,729 timesteps, ~89 s); mom25d not chosen (4,763 unknowns, ~16 EM solves, ~19 s);
force one with --solvers <name>
The estimates are rough: calibrated on the examples, they picked the faster solver on 10 of 13, and the others
were at most 1.6 times slower. With --preview, auto only reports what it would run.
Config files¶
A config is a TOML file. Every option can be a top-level key, with dashes or underscores (end-db or
end_db). A solver’s own options can also go in a [solver.<name>] table under their short names:
board = "board.kicad_pcb"
nets = ["RF", "GND"]
fmax = 6.0
solvers = ["openems", "mom25d"]
[solver.openems]
excite = "P1"
dump = ["[email protected]@2,6"]
[solver.mom25d]
dmax = 0.4
Lists can be TOML arrays or comma-separated strings (
nets = "RF,GND").Paths in a config are relative to the config file, so you can run it from any directory.
Unknown keys are reported, with the option they are probably a typo of.
Settings are applied in this order: defaults, then the config file, then the command line.
An invalid value stops the run with a one-line error. Set
KICAD2EMS_TRACEBACK=1for the traceback.
A study: several questions of one board¶
A run of kicad2ems answers one thing, the ports’ S-parameters. A study asks more of the same board: the
crosstalk between traces (kicad2ems’s own), a rail’s drop, the temperature, a circuit on the copper,
each by an engine installed for it (kicad2ems --check lists the questions and who answers them). The config says which, and kicad2ems study runs them in order:
board = "board.kicad_pcb"
[study]
run = ["sparams", "dc", "thermal"] # the questions
[study.sparams]
engine = ["mom25d", "pcbqs"] # who answers: one engine, or several to compare; none: the default
[study.thermal]
engine = ["pcbqs", "Elmer"] # by its name (elmer_thermal) or as a list shows it
fields = true # its field dumps too, where the engine can write them
[analysis.pdn] # an engine's own settings: an analysis's under [analysis.<name>],
rail = "+5V" # a solver's under [solver.<name>] or at the top level, as before
kicad2ems study board.toml # all of it
kicad2ems study board.toml --list # the runs it takes, without making them
kicad2ems study board.toml --only thermal # some of its questions (or engines)
kicad2ems study board.toml --preview # the runs that have a preview, without solving
The solvers named for S-parameters, an antenna and the line model run first, together, as kicad2ems’s own run
(without an engine, the solvers the settings name, auto by default); then each analysis in its order, so
that the temperature follows the circuit whose losses it takes. An engine that answers two questions answers
them in one run (a rail’s drop and its impedance). Each run goes into a folder of its own under the output
folder, <board>_<date>_<time> for the solvers and <board>_<engine>_<what>_<date>_<time> for an analysis,
with a kicad2ems-study.json that says who made it, what was asked, the config it came from and how it ended,
and the run’s whole output (stdout.log): each is a command of its own, as the window starts it, and the window
lists them on its Runs page (This config: those of the config open).
A run that fails or cannot start says why and the rest go on. The exit code is 0 when every run finished, 1 when
one did not, 2 when the study cannot be read.
An analysis may be given several tables, as an array, and is then run once for each: a board’s rails, one after the other, each into its own folder (named by the rail) with its own result.
[study]
run = ["dc", "pdn"]
[[analysis.pdn]]
rail = "+5V"
volts = 5
source = "J101"
load = ["U702=1.4"]
[[analysis.pdn]]
rail = "+3V3"
volts = 3.3
load = ["U1=0.8", "U4=0.2"]
kicad2ems study board.toml --list then reads Rail drop, Rail impedance: Power integrity (kicad2ems.pcbqs.pdn), 2 runs: +5V, +3V3. An analysis that starts from another’s result takes the last of them.
A config without [study] is S-parameters alone, which kicad2ems board.toml runs just the same.
Older configs are read as they were meant, by one migration as the file is loaded
(study.load_config, config.setting_keys), so the rest of kicad2ems sees only the current form:
Older form |
Read as |
|---|---|
|
|
an analysis table’s |
that variant engine ( |
|
its keys at the top level, with a note |
|
|
Options¶
Board¶
Option |
Default |
Meaning |
|---|---|---|
|
the |
|
|
a pick-and-place file (ports can be listed there instead of a Fab text) |
|
|
all copper |
the nets to include, or |
|
crop to a rectangle (KiCad mm) or to the shapes on a drawing layer (details) |
|
|
off |
add a port where a signal track crosses the region edge |
|
an extra port: |
|
|
treat this copper layer as a solid plane |
|
|
off |
fill the ground copper’s voids left by the nets not selected (details) |
|
off |
include the solder mask |
|
auto |
lumped R/L/C parts from two-pad footprints (details) |
Frequency and mesh (openEMS)¶
Option |
Default |
Meaning |
|---|---|---|
|
0.5, 10 |
the band, GHz |
|
401 |
frequency points |
|
|
their spacing: |
|
20 |
cells per wavelength at fmax |
|
automatic |
cell size at copper edges, mm (details) |
|
5 |
air between the board and the boundary, mm (antenna mode: at least λ/4); or six values xmin,xmax,ymin,ymax,zmin,zmax, ymax being the board’s top edge in KiCad |
|
1.4 |
largest size ratio of neighbouring cells |
|
4 |
fewest cells through each dielectric layer |
|
1 |
fewest cells through the solder mask (with |
|
extremes |
mesh lines for curved copper |
|
1 |
first z cell next to signal copper, × the fine cell, graded into the dielectric; 0: uniform (details) |
|
6 |
over arcs and fans the largest cell is the dielectric’s ÷ this; 1: off |
|
auto |
mesh lines for vias |
|
0.2 |
how far a snapped via may move, mm |
|
off |
copper with its stackup thickness, the stack moved to make room (details) |
|
off |
metal walls at the board edge, standing in for stitching vias ( |
|
0.5 |
gap between edge walls and signal copper, mm |
|
also run coarser meshes and check the result has converged (details) |
|
|
0.1,2 |
the convergence tolerance |
openEMS run¶
Option |
Default |
Meaning |
|---|---|---|
|
auto |
boundaries: |
|
−40 |
stop when the signals have decayed by this much (details) |
|
ports |
what the decay is measured on |
|
1 000 000 |
the timestep limit per run |
|
perfect conductor |
copper conductivity, S/m |
|
smooth |
copper roughness, µm RMS, with |
|
auto |
surface finish of the outer copper, with |
|
fixed |
the dielectric loss model (details) |
|
1 |
the frequency at which the stackup’s εr and tan δ apply, GHz |
|
lumped |
the FDTD solvers’ S at the lumped ports, or from probes on each port’s straight feed, moved back to the port (every port driven; line ports) |
|
all ports |
the ports to drive |
|
0 |
openEMS threads per run (0: automatic) |
|
1 |
runs in parallel |
Antenna mode¶
Option |
Default |
Meaning |
|---|---|---|
|
sparams |
antenna: one driven port, absorbing boundaries, the far field (details) |
|
one port |
drive several ports, |
|
a line |
the ports’ places in a 2D array: |
|
none |
phase steps added to |
|
none |
point the beam at |
|
uniform |
amplitude taper for lower sidelobes: |
|
the resonance |
the frequencies of the radiation patterns, GHz |
|
2 |
the angle step of the pattern cuts, degrees |
Field dumps¶
Option |
Meaning |
|---|---|
|
save E, H or J on a layer, a plane, the volume or a box; repeatable (details) |
|
which driven port’s run records the dumps (default: the first) |
|
also animate each frequency-domain dump over one period (MP4 needs ffmpeg) |
Solvers¶
Option |
Default |
Meaning |
|---|---|---|
|
|
the solvers to run (above) |
|
off |
also solve the line model, as a reference |
|
off |
also run mom25d, as a reference |
mom25d ([solver.mom25d])¶
Option (short name) |
Default |
Meaning |
|---|---|---|
|
0.3 |
largest mesh cell along the copper, mm (planes get 3× this) |
|
auto |
port type: de-embedded wave ports where the feed line is long enough, otherwise lumped |
|
60 |
most frequencies the adaptive sweep may solve |
|
save the surface currents at these frequencies (details) |
|
|
with |
Line model ([solver.qucs])¶
Option (short name) |
Default |
Meaning |
|---|---|---|
|
found on PATH |
the qucsator program |
Output¶
Option |
Default |
Meaning |
|---|---|---|
|
|
the output folder |
|
draw another result on the S-parameter plot |
|
|
off |
build the model and mesh, don’t solve |
|
off |
skip the HTML report |
|
solve again for each combination of these settings’ values, each in |
|
|
1 |
run the solvers N at a time (threads), not one after another: it pays only where one solver’s run hides beneath a much longer one’s (measured) |
|
off |
show openEMS’s own output instead of the progress line |
|
also write progress as JSON lines (below) |
Output files¶
File |
Contents |
|---|---|
|
each solver’s S-parameters (terms that weren’t computed are 0 and listed in the header) |
|
pcbqs below the frequency it holds to and a full-wave solver above, in one band (details) |
|
the S-parameter plot and Smith chart, the other solvers overlaid |
|
everything on one page (details) |
|
the run summary (details) |
|
the converted board every solver gets (details) |
|
the openEMS mesh, or the model alone without openEMS |
|
the line sections (details) |
|
the line sections’ geometry and impedances, for the GUI’s Viewer |
|
openEMS’s geometry, for AppCSXCAD |
|
antenna results |
|
the mesh convergence check |
|
each solver’s mesh for the GUI’s 3D view: openEMS’s grid lines, mom25d’s surface triangles (written by a preview too) |
|
field dump images and animations |
|
one FDTD run folder per driven port, with its log and dumps |
|
mom25d’s current dumps |
Progress¶
While openEMS runs, its output goes to openems/exc_<port>/openems.log and the terminal shows a progress
line:
P1 [##############------] 71% step 23184 -28.4/-40 dB 305 MC/s ETA 18s
The bar follows the signal decay towards --end-db, or the step count towards --max-steps, whichever
is further. energy flat means the field isn’t decaying (see
maintenance). With --jobs above 1, all runs share one line.
Events for a GUI or script¶
--events FILE writes the run as JSON lines as it goes. t is seconds since the start.
{"t": 0.0, "kind": "format", "format": "kicad2ems-events", "format_version": 1}
{"t": 0.0, "kind": "stage", "name": "model"}
{"t": 0.4, "kind": "log", "text": "mesh: 188 x 115 x 25 = 0.54 M cells ..."}
{"t": 9.8, "kind": "status", "run": "P1", "step": 6118, "db": -3.2, "fraction": 0.08, "eta": 95.0}
{"t": 99.1, "kind": "file", "label": "S-parameters, openEMS (FDTD)", "path": "out/board_openems.s2p"}
{"t": 99.3, "kind": "done", "code": 0}
kind |
Fields |
|---|---|
|
|
|
|
|
openEMS: |
|
|
|
|