fdtdx.SingleFrequencyProfile#

class fdtdx.SingleFrequencyProfile(num_startup_periods=4, *, phase_shift=3.141592653589793)[source]#

Bases: TemporalProfile

Simple sinusoidal temporal profile at a single frequency.

Quick Reference#

Attributes

Methods

Attributes#

SingleFrequencyProfile.num_startup_periods: int#

number of periods between start

SingleFrequencyProfile.phase_shift: float#

Phase shift of the carrier wave

Methods#

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

SingleFrequencyProfile.frequency_spectrum(period, time_step_duration, num_time_steps, phase_shift=0.0, normalize=True)#

Return the one-sided FFT magnitude of the sampled source signal.

Return type:

tuple[ndarray, ndarray]

SingleFrequencyProfile.get_amplitude(time, period, phase_shift=0.0)[source]#

Calculate the temporal amplitude at given time points.

Parameters:
  • time (jax.Array) – Time points to evaluate amplitude at

  • period (float) – Period of the carrier wave (1/frequency)

  • phase_shift (float) – Phase shift of the carrier wave

Returns:

Amplitude values at the given time points

Return type:

jax.Array

SingleFrequencyProfile.get_class_fields()#
Return type:

list[TreeClassField]

SingleFrequencyProfile.get_frequency_plot_range(period, frequencies, spectrum)#

Return a profile-specific frequency plot range, or None to use automatic range detection.

Subclasses may override this hook when the profile has known physical frequency properties (e.g. a Gaussian pulse).

Return type:

tuple[float, float] | None

SingleFrequencyProfile.get_public_fields()#
Return type:

list[TreeClassField]

SingleFrequencyProfile.get_reference_frequency(period)#

Return the frequency expected to dominate the plotted spectrum.

Return type:

float

SingleFrequencyProfile.get_time_plot_range(period, total_time)#

Return a profile-specific time plot range, or None to use automatic range detection.

Subclasses may override this hook when the profile has known physical time properties (e.g. a Gaussian pulse).

Return type:

tuple[float, float] | None

SingleFrequencyProfile.plot_time_signal_and_spectrum(period, time_step_duration, num_time_steps, phase_shift=0.0, axs=None, filename=None, time_range='auto', frequency_range='auto', relative_threshold=0.01, normalize_spectrum=True)#

Plot the sampled source time signal and its one-sided frequency spectrum.

SingleFrequencyProfile.sample_time_signal(period, time_step_duration, num_time_steps, phase_shift=0.0)#

Sample this temporal profile at the same cadence as an FDTD simulation.

Return type:

tuple[ndarray, ndarray]

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