spin_pulse.environment.noise

This modules provides a set of noise classes for simulating different noise processes:

Re-exported objects

The following objects can be directly imported from spin_pulse.environment.noise even if they are implemented in submodules.

NoiseTimeTrace

Base class for generating and manipulating noise time traces.

NoiseType

Enumerate the supported noise models for spin-qubit simulations.

PinkNoiseTimeTrace

Generate a pink noise time trace with a 1/f power spectral density.

QuasistaticNoiseTimeTrace

Generate a quasi-static noise time trace for spin-qubit simulations.

WhiteNoiseTimeTrace

Generate a white noise time trace.

Submodules

Classes

NoiseTimeTrace

Base class for generating and manipulating noise time traces.

NoiseType

Enumerate the supported noise models for spin-qubit simulations.

PinkNoiseTimeTrace

Generate a pink noise time trace with a 1/f power spectral density.

QuasistaticNoiseTimeTrace

Generate a quasi-static noise time trace for spin-qubit simulations.

WhiteNoiseTimeTrace

Generate a white noise time trace.

Package Contents

class spin_pulse.environment.noise.NoiseTimeTrace(duration)[source]

Base class for generating and manipulating noise time traces.

A noise time trace is represented as an array of length duration, containing the instantaneous noise values \(\epsilon(t)\) that affect the qubit. Subclasses implement specific noise models (quasistatic, pink, white, etc.) and populate the values array accordingly.

- duration

Total number of time steps in the noise trace.

Type:

int

- values

Array of noise values of length duration.

Type:

ndarray

Initializes an empty noise time trace of given duration.

Parameters:

duration (int) – Total number of time steps in the noise trace.

duration
values
ramsey_contrast(ramsey_duration)[source]

Compute the Ramsey contrast for a qubit subject to this noise trace.

The qubit is initialized in the equal superposition state \(\frac{\\lvert 0 \rangle + \\lvert 1 \rangle}{\\sqrt{2}}\) and evolves under a pure dephasing Hamiltonian \(H(t) = \\omega(t) Z\). The Ramsey contrast is obtained from the accumulated phase \(\\sum_t \\omega(t)\) over segments of length ramsey_duration. The trace is divided into independent experiments of equal length and the contrast is averaged over all experiments.

Parameters:

ramsey_duration (int) – Number of time steps per Ramsey experiment.

Returns:

Averaged Ramsey contrast of length ramsey_duration.

Return type:

  • float

plot_ramsey_contrast(ramsey_duration)[source]

Plot the Ramsey contrast computed from the noise trace.

Parameters:

ramsey_duration (int) – Number of time steps per Ramsey experiment.

plot(n_max=None)[source]

Plot the noise trace up to a specified number of points.

Parameters:

n_max (int | None) – Number of time steps to display. If None, the full trace is shown.

class spin_pulse.environment.noise.NoiseType(*args, **kwds)[source]

Bases: enum.Enum

Enumerate the supported noise models for spin-qubit simulations.

Each enum value corresponds to the time-trace class used to generate the associated noise realization.

Noise types:
  • QUASISTATIC: Quasistatic noise generated by

    QuasistaticNoiseTimeTrace.

  • PINK: Pink (1/f) noise generated by PinkNoiseTimeTrace.

  • WHITE: White Gaussian noise generated by WhiteNoiseTimeTrace.

QUASISTATIC = 'QuasistaticNoiseTimeTrace'
PINK = 'PinkNoiseTimeTrace'
WHITE = 'WhiteNoiseTimeTrace'
class spin_pulse.environment.noise.PinkNoiseTimeTrace(T2S, duration, segment_duration, seed=None)[source]

Bases: spin_pulse.environment.noise.noise_time_trace.NoiseTimeTrace

Generate a pink noise time trace with a 1/f power spectral density.

This class constructs a noise trace of length duration where the spectral density follows a pink noise distribution proportional to 1/f. A low-frequency cutoff is enforced at 1/segment_duration by building the trace from repeated pink noise segments. The parameter T2S determines the noise intensity through the scaling factor S0 defined as:

S0 = 1 / (4 * pi^2 * log(segment_duration) * T2S^2)

The internal array values contains the generated noise samples and is used by methods such as ramsey_contrast to evaluate the effect of pink noise on qubit coherence.

- segment_duration

Length of each pink noise segment.

Type:

int

- S0

Scaling factor controlling the noise intensity.

Type:

float

- T2S

Coherence time parameter determining the noise intensity.

Type:

float

- sigma

Standard deviation of the generated noise values.

Type:

float

- values

Noise values of length duration.

Type:

ndarray

Create a pink noise time trace for spin qubit simulations.

The generated noise satisfies a spectral density proportional to 1/(f*ts) with a low frequency cutoff f_min=1/segment_duration. The parameter T2S sets the noise intensity through the relation S0 = 1 / (4 * pi^2 * log(segment_duration) * T2S^2). The internal noise trace has length duration and is constructed by repeating pink noise segments.

Parameters:
  • T2S (float) – Coherence time parameter determining the noise intensity.

  • duration (int) – Total number of time steps in the noise trace.

  • segment_duration (int) – Length of each pink noise segment.

  • seed (int | None) – Optional seed for reproducible random number generation.

Returns:

The time trace is stored internally in self.values.

Return type:

None

segment_duration
values
S0
T2S
sigma
plot_ramsey_contrast(ramsey_duration)[source]

Plot analytical and numerical Ramsey contrast curves.

This method overlays:
  • the analytical Gaussian contrast expected for pink noise,

  • a corrected analytical contrast that accounts for the frequency cutoff imposed by segment_duration,

  • the numerical contrast obtained from the underlying noise trace.

Parameters:

ramsey_duration (int) – Number of time steps used in the Ramsey experiment evaluation.

Returns:

The function produces a plot of the Ramsey contrast.

Return type:

None

class spin_pulse.environment.noise.QuasistaticNoiseTimeTrace(T2S, duration, segment_duration, seed=None)[source]

Bases: spin_pulse.environment.noise.noise_time_trace.NoiseTimeTrace

Generate a quasi-static noise time trace for spin-qubit simulations.

This noise type produces a sequence of piecewise-constant Gaussian noise segments. Each segment has duration segment_duration, and all samples within a segment share the same random value. The resulting noise corresponds to a quasi-static fluctuation with standard deviation determined by the coherence time T2S.

- segment_duration

Duration of each constant-noise segment.

Type:

int

- sigma

Standard deviation of the quasistatic noise, computed as \(\sqrt{2}/T_2^*\).

Type:

float

- T2S

Coherence time parameter used to scale the noise.

Type:

float

- values

Array of noise values of length duration.

Type:

ndarray

Initialize a quasi-static Gaussian noise trace.

The noise trace is constructed from repeated Gaussian segments of length segment_duration. Each segment takes a single Gaussian random value with zero mean and standard deviation \(\sqrt{2}/T_2^*\). The total duration must be an integer multiple of the segment length.

Parameters:
  • T2S (float) – Coherence time parameter defining the noise intensity.

  • duration (int) – Total number of time steps in the noise trace.

  • segment_duration (int) – Length of each piecewise-constant segment.

  • seed (int | None) – Optional seed for reproducible random generation.

Raises:

ValueError – If duration is not divisible by segment_duration.

segment_duration
sigma
T2S
values
plot_ramsey_contrast(ramsey_duration)[source]

Plot the analytical and simulated Ramsey contrast.

The analytical contrast \(\exp(-t^2 / T_2^{*2})\) is plotted together with the contrast returned by the parent NoiseTimeTrace class.

Parameters:

ramsey_duration (int) – Duration over which the Ramsey signal is evaluated.

class spin_pulse.environment.noise.WhiteNoiseTimeTrace(T2S, duration, segment_duration, seed=None)[source]

Bases: spin_pulse.environment.noise.noise_time_trace.NoiseTimeTrace

Generate a white noise time trace.

This class constructs a noise trace of length duration where each time step is drawn from an independent Gaussian distribution. The noise intensity is determined by the coherence time T2S that fixes the standard deviation \(\sqrt{2/T_2^*}\). White noise corresponds to a flat power spectral density and requires segment_duration = 1.

- segment_duration

Always equal to 1 for white noise.

Type:

int

- sigma

Standard deviation controlling the noise intensity.

Type:

float

- T2S

Coherence time parameter determining the noise intensity.

Type:

float

- values

Noise samples of length duration.

Type:

ndarray

Initialize a white noise time trace for spin qubit simulations.

Each value of the trace is drawn independently from a Gaussian distribution with zero mean and standard deviation \(\sqrt{2/T_2^*}\). The segment_duration parameter must be equal to 1, since white noise has no temporal correlations.

Parameters:
  • T2S (float) – Coherence time parameter determining the noise intensity.

  • duration (int) – Total number of time steps in the noise trace.

  • segment_duration (int) – Must be equal to 1 for white noise.

  • seed (int | None) – Optional seed for reproducible random number generation.

Returns:

The generated noise values are stored in self.values.

Return type:

None

segment_duration = 1
sigma
values
T2S
plot_ramsey_contrast(ramsey_duration)[source]

Plot analytical and numerical Ramsey contrast for white noise.

The plot overlays:

  • the analytical exponential decay expected for white noise,

  • the numerical contrast computed from the generated time trace.

Parameters:

ramsey_duration (int) – Number of time steps used in the Ramsey experiment evaluation.

Returns:

The function produces a plot of the Ramsey contrast.

Return type:

None