# Architecture [← Transmission-line model](transmission-lines.md) · [Index](index.md) · [Next: APIs →](api.md) ![The parts of kicad2ems: the front ends, the core, the analyses and solvers, the engines](img/stack-map.svg) The parts are the subpackages of the one package, `kicad2ems`: the front ends (`ipc`, the KiCad plugin; `gui`; `dfsynth`) drive `core`; the analyses (`pcbqs`, `fem`) and the solvers (`fdtd`, `mom25d`, `fem`) plug into it through `core.analyses` and `core.solvers` ([APIs](api.md)); `fdtd` runs one FDTD model on openEMS or `gfdtd`, and `emsdev` probes the machine for the rest. ## The run pipeline `cli.main` reads the command line and the config into one `config.Settings`. `pipeline.Job` then runs the stages in order. Everything solver-specific goes through the solver's class. ```mermaid flowchart LR P["preflight
can the solvers run?"] --> A[".kicad_pcb / Gerber
/ board.json"] A --> B["importers/"] B --> C["Board
→ <name>_board.json"] C --> L["lines
the line model"] L --> S["assess
can each solver model it?"] S --> E["prepare
(FDTD: mesh)"] E --> F["solve"] F --> G["outputs
.sNp, plots, comparisons"] G --> R["report
_run.json, _report.html"] ``` | Stage | What it does | |---|---| | preflight | resolves which solvers run and checks each can. A named solver that can't stops the run (exit 2); a reference is dropped with a warning | | model | builds the `Board` and writes `_board.json` | | lines | builds the line model, `_tlines.png` and `_lines.json` (its sections, for the GUI) | | assess | asks each solver whether it can model this board (mom25d can't model gap ports) | | prepare | each solver builds its own form of the board (FDTD: the mesh). With `--preview`, it stops here | | solve | runs each solver, cheapest first. A failure is a warning (exit 1 for a named solver) | | outputs | writes each solver's Touchstone file, the comparison plot, and each solver's extra outputs | | report | writes `_run.json` and `_report.html` | Each stage adds its results to `Job.summary`, a JSON-friendly dict ([keys](postprocessing.md#json-summary)). The report is rendered from that dict alone, so it can be rebuilt from the JSON file. All messages go through `Job.log`, which prints them, keeps them for the report and sends them to `--events`; lines containing `WARNING` go into the report's warning list. Lower-level functions take a `log` callable, so they can be used without a `Job`. Plots are matplotlib `Figure` objects without pyplot, so the GUI can embed them. ## Solvers A solver is a subclass of `solvers.Solver`, and `solvers.SOLVERS` lists every one by its module and class (imported on the first `registry()` call): the line solvers in `core/solvers/lines/`; openEMS's and gfdtd's in [kicad2ems.fdtd](fdtd/README.md), on the FDTD layer they share; mom25d's in `kicad2ems.mom25d.solvers`; Palace's in `kicad2ems.fem`; pcbqs's in `kicad2ems.pcbqs.analyses`. [APIs](api.md#solvers) lists what a solver declares and implements. A solver, or a program that drives kicad2ems (the GUI, the KiCad plugin, dfsynth), imports from the core's modules the names in each one's `__all__` ([APIs](api.md) lists them); the rest of kicad2ems.core is the core's own. A listed solver then appears in `--solvers`, `--check`, the config (`[solver.mysolver]`), the GUI (a section per option group), the Filter page and the KiCad plugin's menu. One whose program or package is missing says what to install in its `check()`. The names, aliases and settings of the listed solvers are each one's own: `tests/core/test_registry_lists.py` holds them to that. In kicad2ems.fdtd, `solver.FDTD` builds the mesh and the model, runs the excitations and writes the dumps and antenna results; `openems` and `gfdtd` subclass it, each naming its engine (`''` or `':