fdtdx.FieldState#

class fdtdx.FieldState(E, H, psi_E, psi_H, dispersive_P_curr=None, dispersive_P_prev=None)[source]#

Bases: TreeClass

Dynamic electromagnetic field state that evolves each time step.

Grouping these together makes it impossible to forget a field when resetting simulation state — ArrayContainer.reset() zeroes this entire struct at once.

Quick Reference#

Attributes

Methods

Attributes#

FieldState.E: Array#

Electric field array.

FieldState.H: Array#

Magnetic field array.

FieldState.dispersive_P_curr: Array | None#

Dispersive ADE polarization state at time step n. Shape (num_poles, 3, Nx, Ny, Nz). None for non-dispersive simulations.

FieldState.dispersive_P_prev: Array | None#

Dispersive ADE polarization state at time step n-1. Shape (num_poles, 3, Nx, Ny, Nz). None for non-dispersive simulations.

FieldState.psi_E: dict[str, tuple[Array, Array]]#

PML auxiliary electric field, stored as a dictionary mapping each PML object’s name to a tuple of two arrays (each of shape pml.grid_shape).

FieldState.psi_H: dict[str, tuple[Array, Array]]#

PML auxiliary magnetic field, stored as a dictionary mapping each PML object’s name to a tuple of two arrays (each of shape pml.grid_shape).

Methods#

FieldState.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

FieldState.get_class_fields()#
Return type:

list[TreeClassField]

FieldState.get_public_fields()#
Return type:

list[TreeClassField]

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