kicad2ems.gfdtd.engine¶
The time loop: H and E updates on a backend, the extensions (PML slabs, Mur
boundaries, Debye poles, soft E excitations, lumped branches), probes, field
dumps, the energy end criterion (the field's and the lumped branches'), and
openEMS's outputs: its status lines on stdout, its probe files (port_ut_1 ...)
and its dump files in the run folder.
Engine(op, backend='auto').run(path, nr_ts, end_crit)
Backends: vulkan (the GPU through Vulkan and slangpy: any Vulkan GPU) and core
(the compiled CPU core, gfdtd._core: OpenMP) run the compressed operator
(operator.compress: material codes and line arrays in place of the coefficient
arrays) through the same
update code (core/fdtd_core.h); numpy runs the dense coefficient arrays, slowly:
the reference.
A file ABORT in the run folder ends the run as with openEMS (kicad2ems's port
watch and Stop use it).
- class kicad2ems.gfdtd.engine.CoreBackend(op, dtype=<class 'numpy.float32'>)[source]¶
The compiled CPU core (gfdtd._core, OpenMP) on the compressed operator; the sparse extensions as numpy.
- class kicad2ems.gfdtd.engine.NumpyBackend(op, dtype=<class 'numpy.float32'>)[source]¶
The dense reference: coefficient arrays vv, vi, iv, numpy slices.
- energy()[source]¶
The energy (J) the end criterion watches: the field's and the lumped branches' (one host sync).
- excite_more(field, n)[source]¶
The excitation groups on field 'V' or 'I' at step n: each its delay late, on the H signal (half a step later) for 'I'; a hard group sets its edges, a soft one adds to them.
- ferrite()[source]¶
The ferrite's magnetisation (operator._ferrite): each cell's from the b on its edges, then the edges' h less the change.
- lumped_energy()[source]¶
The energy in the lumped branches (J, a scalar on the backend's device): L I^2 / 2 in the inductors, q^2 / 2C in the series capacitors. Not in the field: a lumped LC filter rings in its branches.
- class kicad2ems.gfdtd.engine.VulkanBackend(op, dtype=<class 'numpy.float32'>)[source]¶
The GPU through Vulkan (slangpy: Slang kernels, kernels_vk.py) on the compressed operator: any Vulkan GPU. Its steps (fused / split / separate: _choose_mode) are recorded into command buffers that are submitted every SUBMIT launches and at each host read, so the host records while the GPU runs.
- IDX¶
alias of
int32
- ferrite()[source]¶
The ferrite's magnetisation (operator._ferrite): each cell's from the b on its edges, then the edges' h less the change.
- step(sig=None, n=None)[source]¶
One timestep in three launches: H with its PML and the Mur copies, E with the Debye poles and its PML, then the excitation, lumped branches and Mur update together (or the separate kernels: _choose_mode). The H excitations and the delayed ones (n: the step) run between them.
- kicad2ems.gfdtd.engine.backend_info(name)[source]¶
One line: what backend `name` (as resolve_backend gives it) runs on.
- kicad2ems.gfdtd.engine.concurrent_runs(cells, runs)[source]¶
How many runs of a model of `cells` to have on the GPU at once. Small models leave it idle between kernel launches, and two to four runs side by side fill it. That holds while their fields fit in its cache together: on an RX 7800 XT (64 MB Infinity Cache) 4 runs of 0.29 M cells gave 1.46 times one run's throughput and 2 of 0.59 M cells 1.16, but 2 of 1.48 M cells 0.64 (they thrash the cache). Hence up to CONCURRENT_CELLS in all.
- kicad2ems.gfdtd.engine.fits(op, free, where='the GPU')[source]¶
MemoryError where operator op will not fit in `free` bytes of GPU memory (None: not known, not checked); ValueError past the GPU kernels' nodes.
- kicad2ems.gfdtd.engine.gpu_backend()[source]¶
The GPU backend 'gpu' means here, or None: Vulkan (slangpy).
- kicad2ems.gfdtd.engine.gpu_bytes(op)[source]¶
About what the GPU holds of operator op (R-D7): the two fields (24 B a node, float32), the node codes and slots, the PML's auxiliary fields, the ferrite's, and 64 MB for the tables, the kernels and the rest.
- kicad2ems.gfdtd.engine.gpu_info()[source]¶
(usable, one line): is there a GPU to run on, through the backend 'gpu' picks (gpu_backend)?
- kicad2ems.gfdtd.engine.make_backend(op, backend='auto', dtype=<class 'numpy.float32'>)[source]¶
The backend for op: `backend` as resolve_backend names it. auto (or gpu not named outright) whose GPU has too little memory for the model runs on the CPU instead, its reason in the backend's `fallback`.
- kicad2ems.gfdtd.engine.resolve_backend(name='auto')[source]¶
'vulkan', 'core' or 'numpy' for a backend name: auto (the GPU, else the core, else numpy), gpu or vulkan (vk), cpu (the core, else numpy), core, numpy. GFDTD_BACKEND overrides it.
- kicad2ems.gfdtd.engine.runs_that_fit(cells, runs, free)[source]¶
How many of `runs` runs of a model of `cells` fit in `free` bytes of GPU memory at once (each excitation's fields are its own: gpu_bytes per run, its PML left out, within fits' 0.92), at least 1; free None: all of them.
- kicad2ems.gfdtd.engine.vulkan_gpus()[source]¶
[(index, name)] of the Vulkan GPUs runs may be shared out to (EMSDEV_VULKAN_DEVICE=index in each run's process): the discrete ones with the kernels' features (an integrated GPU's memory is the system's); [] where Vulkan is not there. Threads cannot share them out: two driving two GPUs from one process ran each at a fifth of its speed, the interpreter's lock between them (R-D9).