kicad2ems.fdtd.run

FDTD runs: one run per excited port (in parallel with --jobs), each in its own
folder <out>/<engine>/exc_<port>; the end criteria (PortWatch), progress, and
the S-parameter columns from the port probes. Any engine with openEMS's
interface (engines.py) runs the same way.
class kicad2ems.fdtd.run.PortWatch(path, end_db, t_min, window, z=50.0, interval=2.0, stall_db=1.5)[source]
Thread that ends a run whose field energy has stalled once every port
signal has died away. openEMS's own end criterion is the total field energy,
which can level off above --end-db when some energy sits where no port sees
it (a static field, a mode the ports do not couple to) while the
S-parameters are long settled. Every `interval` s it reads the port voltage
/ current probes (port_ut* / port_it*, which openEMS flushes as it runs) and
the energy from openEMS's status lines (openems.log). It writes ABORT into
the run folder (openEMS stops and finishes normally) and records why in
run_end.json when all of these hold:
  - the time is past t_min (the excitation pulse) and the largest
    u^2 + (z i)^2 of any port over the last `window` s is end_db below its
    peak;
  - the energy has stalled: over the last quarter of the steps so far (and
    at least 8 status lines) it fell by less than `stall_db`.
The second condition matters: in a high-Q circuit (a filter) the stored
energy leaks out through the ports slowly, the port signals sit far below
their peak while it does, and stopping then cuts the ring-down off (the
response comes out smoothed and shifted). Port signals below DEAD_DB end it
without the stall: nothing reaches the ports any more (a radial stub held
the pulse's DC charge at -33 dB of energy, its ports at -222 dB, for 176k
timesteps where 20k were enough).
level()[source]
(time of the last sample s, level of the last window below the peak
in dB) or None.
stalled()[source]
The energy fell by less than stall_db over the last quarter of the
steps (>= 8 status lines).
class kicad2ems.fdtd.run.RunResult(S)[source]
Result of run_excitations: S (nf, n, n) over the single-ended ports (NaN
in the columns of ports not excited), dump_files {(port, dump name): path},
dump_norm {port: {freq: incident voltage}} (field maps scaled to a 1 V
incident wave), seconds / steps {port: value} per run, extra {port: what the
run's `analyse` hook returned} (antenna mode: the far-field results).
kicad2ems.fdtd.run.execute(FDTD, path, threads=0, verbose=1, progress=None, watch=None)[source]
FDTD.Run in `path`, restoring the working directory (openEMS changes it).
Returns seconds taken. progress: None (openEMS writes to the terminal), or
dict(mode, label, end_db, max_steps[, on_status]):
openEMS's output goes to <path>/openems.log and, for mode 'bar' / 'raw', a
progress line / the raw lines to the terminal ('file': the log only -
parallel workers, monitored by the main process); on_status(label, status
dict) is called for every openEMS status line.
kicad2ems.fdtd.run.log_path(path)[source]
openEMS's output of a run (written when the run has a progress
setting).
kicad2ems.fdtd.run.port_decay(path, window, z=50.0)[source]
(last probe time s, max over ports of the signal power in the last
`window` s relative to its peak, dB) from the port probe files of a run
folder, or None when there are none yet.
kicad2ems.fdtd.run.run_dir(m, k, out_dir, engine=None)[source]
Folder of the run that excites port k: <out>/openems/exc_<port> (P1+ /
P1- -> exc_P1p / exc_P1n); another engine's under <out>/<engine>/.
kicad2ems.fdtd.run.run_excitations(m, mesh, freq, excite, bc, out_dir, end_db=-40, sigma=None, rough=None, copper_kw=None, threads=0, xml_path=None, dumps=(), dump_runs=None, jobs=1, diel='fixed', diel_fref=1000000000.0, max_steps=1000000, progress=None, exc_fmax=None, setup=None, analyse=None, log=<built-in function print>, end_on='ports', engine=None, line_plan=None)[source]
One openEMS run per excited port, `jobs` of them at a time (separate
processes; without `threads`, half the logical CPUs are shared between them;
gfdtd: threads of this process, on the GPU a stream each). Field dumps are
added to the runs in dump_runs (port indices; default: the first excited
port). progress: None or dict(mode='bar' | 'raw'[, on_status]) - see
execute(). setup / analyse: hooks of every run (see _run_port; picklable for
jobs > 1). engine: see _run_port. line_plan: lineport.plan_ports' (R-E1):
each run's probe readings in RunResult.lines. Returns a RunResult.
kicad2ems.fdtd.run.s_column(ports, k, z0)[source]
Column k of S (nf, n) from a run that excites port k: the power waves'
S_pk = b_p / a_k, a = uf_inc / sqrt(z0) and b = uf_ref / sqrt(z0) at each
port's own (real) z0. The voltage waves' ratio uf_ref_p / uf_inc_k is that
only where the ports share one z0: a matched thru from 50 to 75 ohm had
read |S21| 1.22 and |S12| 0.82, which the reciprocity fill and the mixed
modes then took for S (mom25d's S is in power waves).
kicad2ems.fdtd.run.step_limit_warning(name, steps, max_steps, end_db)[source]
Warning text when a run stopped at --max-steps instead of decaying to
--end-db (None otherwise).
kicad2ems.fdtd.run.steps_taken(path, dt_ps=None)[source]
Timesteps a finished run took: the last sample time of its port voltage
probe divided by openEMS's time step, read from the excitation signal file
'et' (one sample per step; the mesher's estimate dt_ps, used only without
'et', can be ~10 % off). The probes are subsampled, so this may undercount
by a few dozen steps. None if there is no probe file.
kicad2ems.fdtd.run.watch_window(m, fmin)[source]
PortWatch's window (s): two periods of the slowest ringing the ports can
see. That is fmin's, except on a board without lumped parts on its signal
nets: nothing there rings below its lowest cavity mode, c0 / (2 D sqrt(er))
over the outline's diagonal D, so a band reaching far below it (fmin 0.1
GHz: a 20 ns window, longer than a whole run on a 6-layer board) waits no
longer than that mode's two periods. At least 1 ns.