simulate_step_FDTD#

simpleEMS.fdtd_import_step.simulate_step_FDTD(step_file: str | Path, freqs: ndarray[tuple[Any, ...], dtype[_ScalarT]], dielectrics: dict[str, tuple[float, float]], pec: list[str], ports: dict[str, dict], output_path: str | Path | None = None, charac_imp: float = 50.0, FDTD_boundary: list[str] | None = None, FDTD_timestep: int = 90000000, FDTD_end_criteria: float = 0.0001, FDTD_mesh_resolution_factor: int = 10, FDTD_metal_mesh_resolution_factor: int = 40, num_points: int = 1000, show_structure: bool = True, run: bool = True) → tuple[SimData, object]#

Simulate a STEP file with the FDTD backend and return the results.

Rebuilds each named solid as CSXCAD geometry, meshes it, runs openEMS, and reads the results back, all in one call. Name each solid you want in the simulation in dielectrics, pec, or ports; any solid none of them names is left out.

Parameters:
  • step_file (str | Path) – Path to the STEP file to simulate.

  • freqs (NDArray) – Frequency points (Hz) to report results at. The lowest and highest of them also set the band the structure is excited over.

  • dielectrics (dict[str, tuple[float, float]]) – Dielectric solids, as {solid_name: (eps_r, tan_d)}.

  • pec (list[str]) – Names of the solids to treat as perfect electric conductors.

  • ports (dict[str, dict]) – Ports, as {solid_name: {...}}, where each port accepts number (defaults to its position in the dict), z0 (defaults to charac_imp), direction ("x", "y", or "z", defaults to "z"), and excite (defaults to 1.0 for the first port and 0.0 for the rest).

  • output_path (str | Path, optional) – Directory for the simulation results and intermediate files. Defaults to cwd / "Sim_Path".

  • charac_imp (float) – Port reference impedance in ohms, used for any port that does not set its own. Default 50.0.

  • FDTD_boundary (list[str], optional) – Six boundary conditions, one per face of the simulation box, in the order [xmin, xmax, ymin, ymax, zmin, zmax]. Defaults to ["PML_8"] * 6.

  • FDTD_timestep (int) – Largest number of time steps to run. Default 90000000.

  • FDTD_end_criteria (float) – How far the energy must decay before the solver stops. Smaller values are more accurate and take longer. Default 1e-4.

  • FDTD_mesh_resolution_factor (int) – How fine the mesh is overall. Higher is finer. Default 10.

  • FDTD_metal_mesh_resolution_factor (int) – How fine the mesh is near metal. Higher is finer. Default 40.

  • num_points (int) – Number of frequency points to report results at. Default 1000.

  • show_structure (bool) – Show the geometry in AppCSXCAD before the solver runs. Default True.

  • run (bool) – Whether to run the solver. Default True. Set to False to re-read results already in output_path without solving again; post-processing still runs either way, so a False call against a directory holding no results raises FileNotFoundError on the missing port probes.

Returns:

(sim_data, nf2ff) – the S-parameters, impedance, VSWR and port power, and the object that records the far-field data. Pass the second straight to the SimTools radiation plots.

Return type:

tuple[SimData, object]

Raises:
  • KeyError – If a name given in dielectrics, pec, or ports is not one of the STEP file’s solids.

  • RuntimeError – If no ports are given.