fdtdx.ArrayContainer#
- class fdtdx.ArrayContainer(fields, alpha, kappa, sigma, inv_permittivities, inv_permeabilities, detector_states, recording_state, electric_conductivity=None, magnetic_conductivity=None, dispersive_P_curr=None, dispersive_P_prev=None, dispersive_c1=None, dispersive_c2=None, dispersive_c3=None, dispersive_inv_c2=None)[source]#
Bases:
TreeClassContainer for simulation field arrays and states.
This class holds the electromagnetic field arrays and various state information needed during FDTD simulation. It includes the E and H fields, material properties, and states for boundaries, detectors and recordings.
Quick Reference#
Attributes
Methods
Attributes#
-
ArrayContainer.alpha:
Array# Alpha array for PML calculations.
-
ArrayContainer.detector_states:
dict[str,dict[str,Array]]# Dictionary mapping detector names to their states.
-
ArrayContainer.dispersive_P_curr:
Array|None# Dispersive ADE polarization state at time step
n. Shape(num_poles, 3, Nx, Ny, Nz).Nonefor non-dispersive simulations.
-
ArrayContainer.dispersive_P_prev:
Array|None# Dispersive ADE polarization state at time step
n-1. Shape(num_poles, 3, Nx, Ny, Nz).Nonefor non-dispersive simulations.
-
ArrayContainer.dispersive_c1:
Array|None# Per-cell dispersive recurrence coefficient c1. Shape
(num_poles, 1, Nx, Ny, Nz).Nonefor non-dispersive simulations.
-
ArrayContainer.dispersive_c2:
Array|None# Per-cell dispersive recurrence coefficient c2. Shape
(num_poles, 1, Nx, Ny, Nz).Nonefor non-dispersive simulations.
-
ArrayContainer.dispersive_c3:
Array|None# Per-cell dispersive recurrence coefficient c3. Shape
(num_poles, 1, Nx, Ny, Nz).Nonefor non-dispersive simulations.
-
ArrayContainer.dispersive_inv_c2:
Array|None# Per-cell cached
1 / c2with non-dispersive cells set to 0. Lets the reverse-time ADE update avoid ajnp.where+ division per step. Derived fromdispersive_c2; never differentiated independently. Shape(num_poles, 1, Nx, Ny, Nz).Nonefor non-dispersive simulations.
-
ArrayContainer.electric_conductivity:
Array|None# field for electric conductivity terms. Defaults to None.
-
ArrayContainer.fields:
FieldState# Dynamic electromagnetic fields (E, H and PML auxiliaries).
-
ArrayContainer.inv_permeabilities:
Array|float# Inverse permeability values array.
-
ArrayContainer.inv_permittivities:
Array# Inverse permittivity values array.
-
ArrayContainer.kappa:
Array# Kappa array for PML calculations.
-
ArrayContainer.magnetic_conductivity:
Array|None# field for magnetic conductivity terms. Defaults to None.
-
ArrayContainer.recording_state:
RecordingState|None# Optional state for recording simulation data.
-
ArrayContainer.sigma:
Array# Sigma array for PML calculations.
Methods#
- ArrayContainer.aset(attr_name, val, create_new_ok=False)#
Sets an attribute of this class. In contrast to the classical .at[].set(), this method updates the class attribute directly and does not only operate on jax pytree leaf nodes. Instead, replaces the full attribute with the new value.
The attribute can either be the attribute name of this class, or for nested classes it can also be the attribute name of a class, which itself is an attribute of this class. The syntax for this operation could look like this: “a->b->[0]->[‘name’]”. Here, the current class has an attribute a, which has an attribute b, which is a list, which we index at index 0, which is an element of type dictionary, which we index using the dictionary key ‘name’.
Note that dictionary keys cannot contain square brackets or single quotes (even if they are escaped).
- Parameters:
attr_name (str) – Name of attribute to set
val (Any) – Value to set the attribute to
create_new_ok (bool, optional) – If false (default), throw an error if the attribute does not exist. If true, creates a new attribute if the attribute name does not exist yet.
- Returns:
Updated instance with new attribute value
- Return type:
Self
- ArrayContainer.get_class_fields()#
- Return type:
list[TreeClassField]
- ArrayContainer.get_public_fields()#
- Return type:
list[TreeClassField]
- ArrayContainer.reset(reset_detector_states=True, reset_recording_state=False)[source]#
Return a reset copy of this array container.
Dynamic field arrays are zeroed while material arrays and conductivity arrays are preserved. Detector states are reset by default because they accumulate time-dependent measurements. Recording state is preserved by default so partial simulations can continue writing to the same buffers.
- Parameters:
reset_detector_states (
bool) – Whether to zero all detector state arrays. Defaults to True.reset_recording_state (
bool) – Whether to zero recording data and state arrays when a recording state is present. Defaults to False.
- Return type:
- Returns:
A new ArrayContainer with reset dynamic state.
If you find any errors in the documentation, please report them in the Github Issues!