add_fdtd_setup#

simpleEMS.fdtd_standalone_model.add_fdtd_setup(structure_xml_path: str | Path, freq_range: tuple[float, float], output_xml_path: str | Path | None = None, excitation: str = 'gauss', FDTD_boundary: list[str] | None = None, FDTD_timestep: int = 90000000, FDTD_end_criteria: float = 0.0001, overwrite: bool = False) → Path#

Attach an openEMS FDTD setup to a geometry-only structure.xml.

A file written by CSX.Write2XML() (root <ContinuousStructure>) holds the mesh, materials, metals, lumped-port properties and probes, but none of the solver settings simulate_model() needs – the excitation waveform, the boundary conditions and the run limits all live in the <FDTD> section that only openEMS.Write2XML() writes. This function supplies those settings and re-writes the model as a full <openEMS> document, ready for simulate_model().

An existing <openEMS> file is also accepted, in which case its <FDTD> section is replaced – use that to re-band or re-terminate a model without rebuilding its geometry.

Parameters:
  • structure_xml_path (str | Path) – Path to the model, root <ContinuousStructure> or <openEMS>.

  • freq_range (tuple[float, float]) – (fmin, fmax) in Hz. The Gaussian excitation is centred at (fmin + fmax) / 2 with cutoff (fmax - fmin) / 2, matching setup_simulation().

  • output_xml_path (str | Path, optional) – Where to write the result. Defaults to <stem>_fdtd.xml in cwd / "Sim_Path".

  • excitation (str) – "gauss" (default), "sinus", "dirac" or "step". Only "gauss" lets simulate_model() derive its post-processing band from the file; the others require an explicit freqs= argument there.

  • FDTD_boundary (list[str], optional) – Six openEMS boundary-condition strings, in the order [xmin, xmax, ymin, ymax, zmin, zmax]. Defaults to ["PML_8"] * 6.

  • FDTD_timestep (int) – Maximum FDTD time-step count. Default 90000000.

  • FDTD_end_criteria (float) – Energy decay stopping criterion. Default 1e-4.

  • overwrite (bool) – Allow writing over an existing output_xml_path. Default False.

Returns:

Path to the written <openEMS> XML.

Return type:

Path

Raises:
  • ValueError – If the source root element is neither <ContinuousStructure> nor <openEMS>, if freq_range is not a positive increasing pair, if excitation is unknown, or if the loaded structure carries no mesh lines on some axis (openEMS cannot run an unmeshed model).

  • RuntimeError – If the loaded structure carries no lumped ports (port_resist_<N> properties).

  • FileExistsError – If output_xml_path exists and overwrite is False.