tidy3d.CustomCurrentSource#
- class CustomCurrentSource[source]#
Bases:
ReverseInterpolatedSource
Implements a source corresponding to an input dataset containing
E
andH
fields.- Parameters:
attrs (dict = {}) β Dictionary storing arbitrary metadata for a Tidy3D object. This dictionary can be freely used by the user for storing data without affecting the operation of Tidy3D as it is not used internally. Note that, unlike regular Tidy3D fields,
attrs
are mutable. For example, the following is allowed for setting anattr
obj.attrs['foo'] = bar
. Also note that Tidy3D` will raise aTypeError
ifattrs
contain objects that can not be serialized. One can check ifattrs
are serializable by callingobj.json()
.name (Optional[str] = None) β Optional name for the source.
center (Union[tuple[Union[float, autograd.tracer.Box], Union[float, autograd.tracer.Box], Union[float, autograd.tracer.Box]], Box] = (0.0, 0.0, 0.0)) β [units = um]. Center of object in x, y, and z.
size (Union[tuple[Union[pydantic.v1.types.NonNegativeFloat, autograd.tracer.Box], Union[pydantic.v1.types.NonNegativeFloat, autograd.tracer.Box], Union[pydantic.v1.types.NonNegativeFloat, autograd.tracer.Box]], Box]) β [units = um]. Size in x, y, and z directions.
source_time (Union[GaussianPulse, ContinuousWave, CustomSourceTime]) β Specification of the source time-dependence.
interpolate (bool = True) β Handles reverse-interpolation of zero-size dimensions of the source. If
False
, the source data is snapped to the nearest Yee grid point. IfTrue
, equivalent source data is applied on the surrounding Yee grid points to emulate placement at the specified location using linear interpolation.confine_to_bounds (bool = False) β If
True
, any source amplitudes which, after discretization, fall beyond the bounding box of the source are zeroed out, but only along directions where the source has a non-zero extent. The bounding box is inclusive. Should be set`True
when the current source is being used to excite a current in a conductive material.current_dataset (Optional[FieldDataset]) β
FieldDataset
containing the desired frequency-domain electric and magnetic current patterns to inject.
Notes
Injects the specified components of the
E
andH
dataset directly asJ
andM
current distributions in the FDTD solver. The coordinates of all provided fields are assumed to be relative to the source center.The syntax is very similar to
CustomFieldSource
, except instead of afield_dataset
, the source accepts acurrent_dataset
. This dataset still contains \(E_{x,y,z}\) and \(H_{x,y, z}\) field components, which correspond to \(J\) and \(M\) components respectively. There are also fewer constraints on the data requirements forCustomCurrentSource
. It can be volumetric or planar without requiring tangential components. Finally, note that the dataset is still defined w.r.t. the source center, just as in the case of theCustomFieldSource
, and can then be placed anywhere in the simulation.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 = CustomCurrentSource( ... center=(1, 1, 1), ... size=(2, 2, 0), ... source_time=pulse, ... current_dataset=dataset)
See also
- Notebooks
Attributes
Methods
Inherited Common Usage
- current_dataset#
- __hash__()#
Hash method.