Field and Efficiency Metrics¶
Field Metrics¶
fdtdx.core.physics.metrics.compute_energy(E, H, inv_permittivity, inv_permeability)
¶
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
|
Inverse of the magnetic permeability array |
required |
Returns:
Type | Description |
---|---|
Array
|
Total energy density array with shape (nx, ny, nz) |
Source code in src/fdtdx/core/physics/metrics.py
fdtdx.core.physics.metrics.normalize_by_energy(E, H, inv_permittivity, inv_permeability)
¶
Normalizes electromagnetic fields by their total energy.
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
|
Inverse of the magnetic permeability array |
required |
Returns:
Type | Description |
---|---|
tuple[Array, Array]
|
Tuple of (normalized E field, normalized H field) |
Source code in src/fdtdx/core/physics/metrics.py
fdtdx.core.physics.metrics.poynting_flux(E, H)
¶
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
Efficiency Metrics¶
fdtdx.core.physics.losses.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 |