kicad2ems.fdtd.progress¶
Progress and ETA for openEMS runs.
openEMS (C++) writes its status to the process's stdout / stderr. During a run,
redirect_output() sends both file descriptors to <run>/openems.log, and a
Monitor thread tails the log(s) and writes to the real terminal either a
progress line per run or (--openems-output) the raw openEMS lines. With --jobs
the workers only redirect; the main process monitors all their logs.
openEMS status lines look like
[@ 1m32s] Timestep: 265424 || Speed: 377.2 MC/s (3.435e-04 s/TS) ||
Energy: ~1.56e-19 (-36.27dB)
A run ends when the energy has fallen by --end-db or after --max-steps
timesteps: progress is the further of the two, and the ETA the sooner (the
energy decay rate over the last status lines, the step rate towards the limit).
- class kicad2ems.fdtd.progress.Monitor(runs, mode='bar', out_fd=None, interval=0.25, plain_every=30.0, on_status=None)[source]¶
Thread tailing openEMS logs: runs = [(label, log path, Tracker)]. mode 'bar' (progress lines) or 'raw' (the openEMS lines, prefixed with the label when there are several runs). out_fd: where to write (the terminal, also while stdout is redirected). on_status(label, status): called for every status line with the parsed values plus the run's progress fraction and ETA (seconds or None).
- class kicad2ems.fdtd.progress.Tracker(name, end_db=-40.0, max_steps=1000000)[source]¶
Progress of one run from its status lines.
- eta()[source]¶
(seconds, by): by 'decay' - the energy trend reaches --end-db (a straight-line fit of dB over time to the later half of the status lines since the energy first fell below -3 dB: the slow tail, not the first plunge, with the swings of resonant circuits averaged out; 0 when the trend is already past --end-db and only those swings keep the run going); by 'limit' - the step rate reaches --max-steps, an upper bound used when it is sooner or the energy is not (yet) falling.
- kicad2ems.fdtd.progress.flush_c_stdio()[source]¶
fflush(NULL): every C stdio stream of this process. Linux and macOS: the C library this process links; Windows: the Universal CRT (ucrtbase), whose streams Python and an MSVC-built openEMS share.
- kicad2ems.fdtd.progress.parse_line(line)[source]¶
dict(t, step, speed, db) of an openEMS status line (t: wall seconds, db: energy in dB, <= 0), or None.