openEMS Electromagnetic Field Solver Documentation

repository·master·Indexed 20 days ago

https://github.com/thliebig/openems-project

A free and open-source electromagnetic field solver based on the Finite-Difference Time-Domain (FDTD) method. It supports high-performance simulations with multi-threading, SIMD (SSE), and MPI, providing scripting interfaces for Python, Matlab, and Octave. Key features include 3D Cartesian and cylindrical mesh support, dispersive material modeling (Drude, Lorentz, Debye), and data export in .vtk and .hdf5 formats. Includes the CSXCAD library for 3D model creation and management.

Tokens
52.2K
Snippets
136
Records
218
Agent score
70%

What's inside openEMS

  1. Overview of openEMS electromagnetic field solver

    master

    openEMS is a free and open-source electromagnetic field solver that utilizes the Finite-Difference Time-Domain (FDTD) method. It is designed for high-performance simulations and provides flexible scripting interfaces via Octave, Matlab, and Python.

    Key features include:

    • Mesh Support: Fully 3D Cartesian and cylindrical coordinates with graded mesh capabilities.
    • Performance: High-speed FDTD via multi-threading, SIMD (SSE), and MPI support.
    • Material Modeling: Support for dispersive materials using Drude, Lorentz, and Debye models.
    • Data Export: Field dumps available in both time and frequency domains using .vtk or .hdf5 file formats.
    • Post-processing: Flexible routines available through Octave, Matlab, and Python interfaces.
  2. What is openEMS?

    master

    openEMS is an open-source electromagnetic field solver that uses the Equivalent-Circuit Finite-Difference Time Domain (EC-FDTD) method. It solves Maxwell's equations in a 3D full-wave manner to simulate electromagnetic wave propagation.

    Key components include:

    • The Engine: Written in C++ for high performance.
    • Interfaces: Extensive Matlab/Octave and Python interfaces for defining simulations.
    • CSXCAD: A separate library used for handling the geometry of FDTD simulations.
    • AppCSXCAD: A graphical user interface for inspecting 3D models created in CSXCAD.
  3. Compare Lumped Ports vs. Transmission Line Ports

    master

    openEMS provides two main categories of ports: Lumped Ports and Transmission Line Ports.

    Lumped Ports

    • Mechanism: Injects a constant-value electric field at a defined position. Automatically creates a lumped resistor and a probe at that location.
    • Best Use: Simple 2-conductor TEM transmission lines where the port size is much smaller than the structure.
    • Limitations: Cannot excite hollow waveguides; performs poorly with complex field shapes (e.g., striplines, CPW, or differential pairs); requires a user-specified characteristic impedance ($Z_0$) and a matched lumped termination to avoid reflections.

    Transmission Line Ports

    • Mechanism: Designed for structures with known propagating modes (MSL, Stripline, CPW, Coaxial, Waveguides). Instead of relying on a user-provided $Z_0$, they measure voltage and current at multiple positions along the line to separate incident and reflected waves. $Z_0$ is then extracted from these waves.
    • Best Use: Microstrip (MSL), Stripline, Coplanar Waveguide (CPW), Coaxial cables, and hollow metallic waveguides.
    • Advantages: Does not require a matched lumped termination at the port plane (though the far end of the line still needs termination, e.g., via PML/MUR or a lumped resistor).
  4. Understand the Lorentz model for dielectric and magnetic materials

    master

    The Lorentz model extends the Drude model by adding Lorentz pole frequencies. It can be used for both dielectric and magnetic materials.

    Key Parameters:

    • $f_{\mathrm{Lor}\epsilon}(n)$: $n$-th electric Lorentz pole frequency.
    • $f_{\mathrm{Lor}\mu}(n)$: $n$-th magnetic Lorentz pole frequency.
    • $\tau_{\epsilon}(n)$ / $\tau_{\mu}(n)$: Relaxation times (inverse of damping factor).
    • $\omega_{p\epsilon}(n)$ / $\omega_{p\mu}(n)$: Plasma frequencies.

    Note: If the Lorentz pole frequency terms are zeroed, the Lorentz model reduces to the Drude model.

  5. How symbolic expressions work with fparser

    master

    In openEMS, you can customize simulations using user-defined symbolic mathematical expressions passed as strings. These strings are evaluated by the C++ engine using the fparser library.

    Custom expressions are used for three primary purposes:

    1. Varying material properties in space: Using a weighting function via SetMaterialWeight.
    2. Constructing custom excitation signals: Creating a custom input waveform $e[t]$ via SetCustomExcite.
    3. Varying excitation field values in space: Using a weighting function via SetExcitationWeight to construct custom field patterns or polarizations (e.g., for hollow waveguides or coaxial cables).

    Important: fparser uses its own Domain-Specific Language (DSL). Its syntax is independent of the outer interface (C++, Matlab/Octave, or Python).

  6. What are Field Dumps and when to use them

    master

    Field Dumps (or "dump boxes") allow you to record raw electromagnetic field values within a specific region in space, rather than just characterizing a structure by its input/output port signals. This is useful for visualizing problematic regions during troubleshooting or for specialized applications like SAR analysis or antenna NF2FF transformations.

    Available Dump Types

    • Time-domain dumps (0–5): Records electric field $\mathbf{E}$, magnetic field $\mathbf{H}$, electric conduction current $\mathbf{J}$, total current density $\nabla \times \mathbf{H}$, electric displacement field $\mathbf{D}$, and magnetic flux density $\mathbf{B}$.
      • Warning: These generate one file per timestep, which can create massive datasets and slow down simulations. Use frequency-domain dumps if you only need the steady-state response.
    • Frequency-domain dumps (10–15): Records the same quantities as time-domain but in the frequency domain.
      • Note: These require at least one simulation frequency to be specified, otherwise no output is produced.
    • Specific Absorption Rate (SAR) (20–22): Used for biological EM radiation exposure analysis.
    • Near-Field to Far-Field Transformation (NF2FF): Used for antenna analysis. This requires a special setup via openEMS.openEMS.CreateNF2FFBox and a separate post-processing tool.
  7. How properties and primitives work together

    master

    In openEMS, a property defines the material or simulation behavior (e.g., metal, dielectric, magnetic material, or lumped elements like resistors). A primitive is a geometrical shape (e.g., a Box or Cylinder).

    To create a physical or non-physical object in the CSXCAD model, you must assign one or more primitives to a property. Simulation entities like excitation sources, probes, and field dump boxes are also treated as properties assigned to geometrical shapes.

    # Example: Creating a property and assigning a primitive (conceptual)
    # In Python:
    metal = csx.AddMetal('plate')
    metal.AddBox([x1, y1, z1], [x2, y2, z2])
  8. Understand Magnetic Conductivity

    master

    Magnetic Conductivity ($\sigma$) is a hypothetical property used to model magnetic conduction currents. While magnetic monopoles do not exist physically, this parameter is used in openEMS to:

    1. Implement the Perfect Magnetic Conductor (PMC) boundary condition (where $\sigma \to \infty$).
    2. Implement Perfectly Matched Layers (PML) for EM wave absorption.
    3. Create custom localized EM wave absorbers by combining electric and magnetic conductivity with weighting functions.
  9. How the mesh and coordinate systems work in openEMS

    master

    A mesh partitions a 3D volume into discrete rectangular cuboids called Yee cells, which are the fundamental units for electromagnetic field computation.

    Coordinate Systems

    • Cartesian: The default system using a standard FDTD algorithm. It supports non-uniform meshes, allowing fine mesh sizes around small features to save computational resources while using coarse meshes elsewhere.
    • Cylindrical: An extension for simulating round structures without "staircasing" errors. It can be uniform or non-uniform. Because the origin is a coordinate singularity (cells become progressively smaller near the origin), openEMS provides a subgridding feature to reduce angular resolution by dropping half of the azimuthal mesh lines within specific radii.
  10. Understand signal waveforms in openEMS

    master

    In openEMS, signals are defined by specific waveforms used to excite the simulation. Common waveform types include Sinusoids, Dirac Impulses, Heaviside Steps, and Gaussian Pulses.

    Important Simulation Constraints:

    • Bandwidth Limitation: Note that bandwidth limitation is currently not implemented and is ignored by the simulation engine.
    • Simulation Termination: To prevent simulations from running indefinitely, it is recommended to limit the maximum simulation to 10,000 timesteps.
  11. How Absorbing Boundary Conditions (ABC) work

    master

    Absorbing Boundary Conditions (ABC) are used in open-boundary problems (like antennas) to suppress reflections and simulate an infinitely large free space. They act like a termination resistor in a transmission line.

    There are two implementations in openEMS:

    1. Mur's Absorbing Boundary (MUR): A first-generation ABC defined by differential equations. It has moderate computational overhead. It works best when the EM wave is traveling orthogonally to the boundary at a known phase velocity (defaults to the speed of light in free space).
    2. Perfectly Matched Layer (PML): A second-generation ABC that models a wave-absorbing material. It is a more effective absorber but has the highest computational overhead. Unlike MUR, PML occupies physical cells in the simulation box.

    Best Practices for PML:

    • Placement: Keep radiating structures at least $\lambda / 4$ away from the PML boundary to avoid instability caused by evanescent waves (fringe fields).
    • Efficiency: If efficiency is critical, use PML only on faces directly hit by radiation and use MUR for other boundaries.
    • Termination: You can run a transmission line directly into the PML to act as a perfect termination for impedance measurements.