tidy3d.CustomFieldSource#
- class CustomFieldSource[source]#
Bases:
FieldSource
,PlanarSource
Implements a source corresponding to an input dataset containing
E
andH
fields, using the equivalence principle to define the actual injected currents.- Parameters:
name (Optional[str] = None) β Optional name for the source.
center (Tuple[float, float, float] = (0.0, 0.0, 0.0)) β [units = um]. Center of object in x, y, and z.
size (Tuple[NonNegativeFloat, NonNegativeFloat, NonNegativeFloat]) β [units = um]. Size in x, y, and z directions.
source_time (Union[GaussianPulse, ContinuousWave, CustomSourceTime]) β Specification of the source time-dependence.
field_dataset (Optional[FieldDataset]) β
FieldDataset
containing the desired frequency-domain fields patterns to inject. At least one tangential field component must be specified.Notes
For the injection to work as expected (i.e. to reproduce the required
E
andH
fields), the field data must decay by the edges of the source plane, or the source plane must span the entire simulation domain and the fields must match the simulation boundary conditions.The equivalent source currents are fully defined by the field components tangential to the source plane. For e.g. source normal along
z
, the normal components (Ez
andHz
) can be provided but will have no effect on the results, and at least one of the tangential components has to be in the dataset, i.e. at least one ofEx
,Ey
,Hx
, andHy
.If the data is not coming from a
tidy3d
simulation, the normalization is likely going to be arbitrary and the directionality of the source will likely not be perfect, even if both theE
andH
fields are provided. An empty normalizing run may be needed to accurately normalize results.The coordinates of all provided fields are assumed to be relative to the source center. If only the
E
or only theH
fields are provided, the source will not be directional, but will inject equal power in both directions instead.
Example
>>> from tidy3d import ScalarFieldDataArray >>> pulse = GaussianPulse(freq0=200e12, fwidth=20e12) >>> x = np.linspace(-1, 1, 101) >>> y = np.linspace(-1, 1, 101) >>> z = np.array([0]) >>> f = [2e14] >>> coords = dict(x=x, y=y, z=z, f=f) >>> scalar_field = ScalarFieldDataArray(np.ones((101, 101, 1, 1)), coords=coords) >>> dataset = FieldDataset(Ex=scalar_field) >>> custom_source = CustomFieldSource( ... center=(1, 1, 1), ... size=(2, 2, 0), ... source_time=pulse, ... field_dataset=dataset)
See also
- Notebooks
Attributes
Methods
- field_dataset#
- __hash__()#
Hash method.