fdtdx.ArrayContainer#

class fdtdx.ArrayContainer(fields, inv_permittivities, inv_permeabilities, detector_states, recording_state, electric_conductivity=None, magnetic_conductivity=None, dispersive_c1=None, dispersive_c2=None, dispersive_c3=None, dispersive_c4=None, dispersive_inv_c2=None, initial_inv_permittivities=None)[source]#

Bases: TreeClass

Container 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.detector_states: dict[str, dict[str, Array]]#

Dictionary mapping detector names to their states.

ArrayContainer.dispersive_c1: Array | None#

Per-cell dispersive recurrence coefficient c1. Shape (num_poles, num_components, Nx, Ny, Nz) with num_components 1 (isotropic dispersion, broadcast over the field components) or 3 (per-axis / diagonally anisotropic dispersion). None for non-dispersive simulations.

ArrayContainer.dispersive_c2: Array | None#

Per-cell dispersive recurrence coefficient c2. Shape (num_poles, num_components, Nx, Ny, Nz), num_components in (1, 3). None for non-dispersive simulations.

ArrayContainer.dispersive_c3: Array | None#

Per-cell dispersive recurrence coefficient c3. Shape (num_poles, num_components, Nx, Ny, Nz), num_components in (1, 3). None for non-dispersive simulations.

ArrayContainer.dispersive_c4: Array | None#

Per-cell dispersive recurrence coefficient c4 (the dE/dt / CCPR coupling to E^{n+1}). Shape (num_poles, num_components, Nx, Ny, Nz), num_components in (1, 3). None unless at least one CCPR pole with non-zero coupling_edot is present; Lorentz/Drude-only sims leave it None and skip the CCPR update path.

ArrayContainer.dispersive_inv_c2: Array | None#

Per-cell cached 1 / c2 with non-dispersive cells set to 0. Lets the reverse-time ADE update avoid a jnp.where + division per step. Derived from dispersive_c2; never differentiated independently. Shape (num_poles, num_components, Nx, Ny, Nz), num_components in (1, 3). None for 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.initial_inv_permittivities: Array | None#

Backup of inverse permittivity values array. Only used when etching a device.

ArrayContainer.inv_permeabilities: Array | float#

Inverse permeability values array.

ArrayContainer.inv_permittivities: Array#

Inverse permittivity values array.

ArrayContainer.magnetic_conductivity: Array | None#

field for magnetic conductivity terms. Defaults to None.

ArrayContainer.recording_state: RecordingState | None#

Optional state for recording simulation data.

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:

ArrayContainer

Returns:

A new ArrayContainer with reset dynamic state.

If you find any errors in the documentation, please report them in the Github Issues!