¶
Core Functions¶
These core functions are used by many different parts of the FDTDX package
fdtdx.core.WaveCharacter
¶
Bases: ExtendedTreeClass
Class describing a wavelength/period/frequency in free space. Importantly, the wave characteristic conversion is based on a free space wave when using the wavelength (For conversion, a refractive index of 1 is used).
Attributes:
Name | Type | Description |
---|---|---|
_period |
float | None
|
Optional period in seconds. Mutually exclusive with _wavelength and _frequency. |
_wavelength |
float | None
|
Optional wavelength in meters. Mutually exclusive with _period and _frequency. |
_frequency |
float | None
|
Optional frequency in Hz. Mutually exclusive with _period and _wavelength. |
Source code in src/fdtdx/core/wavelength.py
frequency: float
property
¶
Gets the frequency in Hz.
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
The frequency in Hz. |
period: float
property
¶
Gets the period in seconds.
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
The period in seconds. |
Raises:
Type | Description |
---|---|
Exception
|
If neither period nor wavelength is set, or if both are set. |
wavelength: float
property
¶
Gets the wavelength in meters.
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
The wavelength in meters. |
Raises:
Type | Description |
---|---|
Exception
|
If neither period nor wavelength is set, or if both are set. |
A container for specifying the character of a wave by either frequency, period or wavelength. Additionally, a phase offset can be set.
Physical metrics¶
fdtdx.core.metric_efficiency(detector_states, in_names, out_names, metric_name)
¶
Calculate efficiency metrics between input and output detectors.
Computes efficiency ratios between input and output detectors by comparing their metric values (e.g. energy, power). For each input-output detector pair, calculates the ratio of output/input metric values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
detector_states
|
dict[str, dict[str, Array]]
|
Dictionary mapping detector names to their state dictionaries, which contain metric values as JAX arrays |
required |
in_names
|
Sequence[str]
|
Names of input detectors to use as reference |
required |
out_names
|
Sequence[str]
|
Names of output detectors to compare against inputs |
required |
metric_name
|
str
|
Name of the metric to compare between detectors (e.g. "energy") |
required |
Returns:
Type | Description |
---|---|
tuple[Array, dict[str, Any]]
|
tuple containing: - jax.Array: Mean efficiency across all input-output pairs - dict: Additional info including individual metric values and efficiencies with keys like: "{detector}{metric}" for raw metric values "{out}{by}_{in}_efficiency" for individual efficiency ratios |
Source code in src/fdtdx/core/physics/losses.py
Convenience function that computes the ratio between a physical metrics measured at different places in the simulation.
fdtdx.core.compute_energy(E, H, inv_permittivity, inv_permeability, axis=0)
¶
Computes the total electromagnetic energy density of the field.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
E
|
Array
|
Electric field array with shape (3, nx, ny, nz) |
required |
H
|
Array
|
Magnetic field array with shape (3, nx, ny, nz) |
required |
inv_permittivity
|
Array
|
Inverse of the electric permittivity array |
required |
inv_permeability
|
Array | float
|
Inverse of the magnetic permeability array |
required |
axis
|
int
|
Axis index of the X,Y,Z component for the E and H field |
0
|
Returns: Total energy density array with shape (nx, ny, nz)
Source code in src/fdtdx/core/physics/metrics.py
Computes the physical energy in the simualation grid.
fdtdx.core.poynting_flux(E, H, axis=0)
¶
Calculates the Poynting vector (energy flux) from E and H fields.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
E
|
Array
|
Electric field array with shape (3, nx, ny, nz) |
required |
H
|
Array
|
Magnetic field array with shape (3, nx, ny, nz) |
required |
Returns:
Type | Description |
---|---|
Array
|
Poynting vector array with shape (3, nx, ny, nz) representing |
Array
|
energy flux in each direction |
Source code in src/fdtdx/core/physics/metrics.py
Computes the poynting flux.