¶
Object Placement and Parameters¶
fdtdx.place_objects(volume, config, constraints, key)
¶
Places simulation objects according to specified constraints and initializes containers.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
volume
|
SimulationObject
|
The volume object defining the simulation boundaries |
required |
config
|
SimulationConfig
|
The simulation configuration |
required |
constraints
|
Sequence[PositionConstraint | SizeConstraint | SizeExtensionConstraint | GridCoordinateConstraint | RealCoordinateConstraint]
|
Sequence of positioning and sizing constraints for objects |
required |
key
|
Array
|
JAX random key for initialization |
required |
Returns:
Type | Description |
---|---|
tuple[ObjectContainer, ArrayContainer, ParameterContainer, SimulationConfig, dict[str, Any]]
|
A tuple containing: - ObjectContainer with placed simulation objects - ArrayContainer with initialized field arrays - ParameterContainer with device parameters - Updated SimulationConfig - Dictionary with additional initialization info |
Source code in src/fdtdx/fdtd/initialization.py
Main entry point for placing and initializing simulation objects.
fdtdx.apply_params(arrays, objects, params, key, **transform_kwargs)
¶
Applies parameters to devices and updates source states.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
arrays
|
ArrayContainer
|
Container with field arrays |
required |
objects
|
ObjectContainer
|
Container with simulation objects |
required |
params
|
ParameterContainer
|
Container with device parameters |
required |
key
|
Array
|
JAX random key for source updates |
required |
Returns:
Type | Description |
---|---|
tuple[ArrayContainer, ObjectContainer, dict[str, Any]]
|
A tuple containing: - Updated ArrayContainer with applied device parameters - Updated ObjectContainer with new source states - Dictionary with parameter application info |
Source code in src/fdtdx/fdtd/initialization.py
Applies parameters to devices and updates source states to be ready for simulation.
Core FDTD Algorithm¶
fdtdx.run_fdtd(arrays, objects, config, key)
¶
Source code in src/fdtdx/fdtd/wrapper.py
Time-reversal symmetric FDTD implementation with memory-efficient autodiff.
Python Objects used for FDTD simulation¶
fdtdx.ArrayContainer
¶
Bases: ExtendedTreeClass
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.
Attributes:
Name | Type | Description |
---|---|---|
E |
Array
|
Electric field array. |
H |
Array
|
Magnetic field array. |
inv_permittivities |
Array
|
Inverse permittivity values array. |
inv_permeabilities |
Array | float
|
Inverse permeability values array. |
boundary_states |
dict[str, BaseBoundaryState]
|
Dictionary mapping boundary names to their states. |
detector_states |
dict[str, DetectorState]
|
Dictionary mapping detector names to their states. |
recording_state |
RecordingState | None
|
Optional state for recording simulation data. |
Source code in src/fdtdx/fdtd/container.py
Container holding the electric/magnetic fields as well as permittivity/permeability arrays for simulation
fdtdx.ObjectContainer
¶
Bases: ExtendedTreeClass
Container for managing simulation objects and their relationships.
This class provides a structured way to organize and access different types of simulation objects like sources, detectors, PML/periodic boundaries and devices. It maintains object lists and provides filtered access to specific object types.
Attributes:
Name | Type | Description |
---|---|---|
object_list |
list[SimulationObject]
|
List of all simulation objects in the container. |
volume_idx |
int
|
Index of the volume object in the object list. |
Source code in src/fdtdx/fdtd/container.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
|
Container holding all the objects in a simulation scene
fdtdx.ParameterContainer = dict[str, dict[str, jax.Array] | jax.Array]
module-attribute
¶
Dictionary holding the parameters for every device in the simulation
fdtdx.SimulationState = tuple[jax.Array, ArrayContainer]
module-attribute
¶
Simulation state returned by the FDTD simulations. This is a tuple of the simulation time step and an array container.