tidy3d.CustomSourceTime#
- class CustomSourceTime[source]#
Bases:
Pulse
Custom source time dependence consisting of a real or complex envelope modulated at a central frequency, as shown below.
- 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()
.amplitude (NonNegativeFloat = 1.0) โ Real-valued maximum amplitude of the time dependence.
phase (float = 0.0) โ [units = rad]. Phase shift of the time dependence.
freq0 (PositiveFloat) โ [units = Hz]. Central frequency of the pulse.
fwidth (PositiveFloat) โ [units = Hz]. Standard deviation of the frequency content of the pulse.
offset (float = 0.0) โ Time delay of the envelope in units of 1 / (
2pi * fwidth
).source_time_dataset (Optional[TimeDataset]) โ Dataset for storing the envelope of the custom source time. This envelope will be modulated by a complex exponential at frequency
freq0
.
Note
\[amp\_time(t) = amplitude \cdot \ e^{i \cdot phase - 2 \pi i \cdot freq0 \cdot t} \cdot \ envelope(t - offset / (2 \pi \cdot fwidth))\]Note
Depending on the envelope, field decay may not occur. If field decay does not occur, then the simulation will run for the full
run_time
. Also, if field decay does not occur, then source normalization of frequency-domain monitors is not meaningful.Note
The source time dependence is linearly interpolated to the simulation time steps. The sampling rate should be sufficiently fast that this interpolation does not introduce artifacts. The source time dependence should also start at zero and ramp up smoothly. The first and last values of the envelope will be used for times that are out of range of the provided data.
Example
>>> cst = CustomSourceTime.from_values(freq0=1, fwidth=0.1, ... values=np.linspace(0, 9, 10), dt=0.1)
Attributes
Times of envelope definition.
Methods
amp_time
(time)Complex-valued source amplitude as a function of time.
end_time
()Time after which the source is effectively turned off / close to zero amplitude.
from_values
(freq0,ย fwidth,ย values,ย dt)Create a
CustomSourceTime
from a numpy array.Inherited Common Usage
- offset#
- source_time_dataset#
- classmethod from_values(freq0, fwidth, values, dt)[source]#
Create a
CustomSourceTime
from a numpy array.- Parameters:
freq0 (float) โ Central frequency of the source. The envelope provided will be modulated by a complex exponential at this frequency.
fwidth (float) โ Estimated frequency width of the source.
values (ArrayComplex1D) โ Complex values of the source envelope.
dt (float) โ Time step for the
values
array. This value should be sufficiently small that the interpolation to simulation time steps does not introduce artifacts.
- Returns:
CustomSourceTime
with envelope given byvalues
, modulated by a complex exponential at frequencyfreq0
. The time coordinates are evenly spaced between0
anddt * (N-1)
with a step size ofdt
, whereN
is the length of the values array.- Return type:
- property data_times#
Times of envelope definition.
- amp_time(time)[source]#
Complex-valued source amplitude as a function of time.
- Parameters:
time (float) โ Time in seconds.
- Returns:
Complex-valued source amplitude at that time.
- Return type:
complex
- end_time()[source]#
Time after which the source is effectively turned off / close to zero amplitude.
- __hash__()#
Hash method.