Skip to main contentIBM Quantum Documentation
This page is from an old version of Qiskit SDK and does not exist in the latest version. We recommend you migrate to the latest version. See the release notes for more information.

discrete

Module for builtin discrete pulses.

Note the sampling strategy use for all discrete pulses is midpoint.

Functions

constant(duration, amp[, name])Generates constant-sampled SamplePulse.
cos(duration, amp[, freq, phase, name])Generates cosine wave SamplePulse.
drag(duration, amp, sigma, beta[, name, …])Generates Y-only correction DRAG SamplePulse for standard nonlinear oscillator (SNO) [1].
gaussian(duration, amp, sigma[, name, zero_ends])Generates unnormalized gaussian SamplePulse.
gaussian_deriv(duration, amp, sigma[, name])Generates unnormalized gaussian derivative SamplePulse.
gaussian_square(duration, amp, sigma[, …])Generates gaussian square SamplePulse.
sawtooth(duration, amp[, freq, period, …])Generates sawtooth wave SamplePulse.
sech(duration, amp, sigma[, name, zero_ends])Generates unnormalized sech SamplePulse.
sech_deriv(duration, amp, sigma[, name])Generates unnormalized sech derivative SamplePulse.
sin(duration, amp[, freq, phase, name])Generates sine wave SamplePulse.
square(duration, amp[, freq, period, phase, …])Generates square wave SamplePulse.
triangle(duration, amp[, freq, period, …])Generates triangle wave SamplePulse.
zero(duration[, name])Generates zero-sampled SamplePulse.

constant

constant(duration, amp, name=None)

GitHub

Generates constant-sampled SamplePulse.

For A=A= amp, samples from the function:

f(x)=Af(x) = A

Parameters

  • duration (int) – Duration of pulse. Must be greater than zero.
  • amp (complex) – Complex pulse amplitude.
  • name (Optional[str]) – Name of pulse.

Return type

SamplePulse

cos

cos(duration, amp, freq=None, phase=0, name=None)

GitHub

Generates cosine wave SamplePulse.

For A=A= amp, ω=\omega= freq, and ϕ=\phi= phase, applies the midpoint sampling strategy to generate a discrete pulse sampled from the continuous function:

f(x)=Acos(2πωx+ϕ)f(x) = A \cos(2 \pi \omega x + \phi)

Parameters

  • duration (int) – Duration of pulse. Must be greater than zero.
  • amp (complex) – Pulse amplitude.
  • freq (Optional[float]) – Pulse frequency, units of 1/dt. If None defaults to single cycle.
  • phase (float) – Pulse phase.
  • name (Optional[str]) – Name of pulse.

Return type

SamplePulse

drag

drag(duration, amp, sigma, beta, name=None, zero_ends=True)

GitHub

Generates Y-only correction DRAG SamplePulse for standard nonlinear oscillator (SNO) [1].

For A=A= amp, σ=\sigma= sigma, and β=\beta= beta, applies the midpoint sampling strategy to generate a discrete pulse sampled from the continuous function:

f(x)=g(x)+iβh(x),f(x) = g(x) + i \beta h(x),

where g(x)g(x) is the function sampled in gaussian(), and h(x)h(x) is the function sampled in gaussian_deriv().

If zero_ends == True, the samples from g(x)g(x) are remapped as in gaussian().

References

  1. Gambetta, J. M., Motzoi, F., Merkel, S. T. & Wilhelm, F. K. “Analytic control methods for high-fidelity unitary operations in a weakly nonlinear oscillator.” Phys. Rev. A 83, 012308 (2011).

Parameters

  • duration (int) – Duration of pulse. Must be greater than zero.
  • amp (complex) – Pulse amplitude at center duration/2.
  • sigma (float) – Width (standard deviation) of pulse.
  • beta (float) – Y correction amplitude. For the SNO this is β=λ124Δ2\beta=-\frac{\lambda_1^2}{4\Delta_2}. Where λ1\lambda_1 is the relative coupling strength between the first excited and second excited states and Δ2\Delta_2 is the detuning between the respective excited states.
  • name (Optional[str]) – Name of pulse.
  • zero_ends (bool) – If True, make the first and last sample zero, but rescale to preserve amp.

Return type

SamplePulse

gaussian

gaussian(duration, amp, sigma, name=None, zero_ends=True)

GitHub

Generates unnormalized gaussian SamplePulse.

For A=A= amp and σ=\sigma= sigma, applies the midpoint sampling strategy to generate a discrete pulse sampled from the continuous function:

f(x)=Aexp((xμ2σ)2),f(x) = A\exp\left(\left(\frac{x - \mu}{2\sigma}\right)^2 \right),

with the center μ=\mu= duration/2.

If zero_ends==True, each output sample yy is modifed according to:

yAyyAy,y \mapsto A\frac{y-y^*}{A-y^*},

where yy^* is the value of the endpoint samples. This sets the endpoints to 00 while preserving the amplitude at the center. If A=yA=y^*, yy is set to 11.

Integrated area under the full curve is amp * np.sqrt(2*np.pi*sigma**2)

Parameters

  • duration (int) – Duration of pulse. Must be greater than zero.
  • amp (complex) – Pulse amplitude at duration/2.
  • sigma (float) – Width (standard deviation) of pulse.
  • name (Optional[str]) – Name of pulse.
  • zero_ends (bool) – If True, make the first and last sample zero, but rescale to preserve amp.

Return type

SamplePulse

gaussian_deriv

gaussian_deriv(duration, amp, sigma, name=None)

GitHub

Generates unnormalized gaussian derivative SamplePulse.

For A=A= amp and σ=\sigma= sigma applies the midpoint sampling strategy to generate a discrete pulse sampled from the continuous function:

f(x)=A(xμ)σ2exp((xμ2σ)2)f(x) = A\frac{(x - \mu)}{\sigma^2}\exp\left(\left(\frac{x - \mu}{2\sigma}\right)^2 \right)

i.e. the derivative of the Gaussian function, with center μ=\mu= duration/2.

Parameters

  • duration (int) – Duration of pulse. Must be greater than zero.
  • amp (complex) – Pulse amplitude of corresponding Gaussian at the pulse center (duration/2).
  • sigma (float) – Width (standard deviation) of pulse.
  • name (Optional[str]) – Name of pulse.

Return type

SamplePulse

gaussian_square

gaussian_square(duration, amp, sigma, risefall=None, width=None, name=None, zero_ends=True)

GitHub

Generates gaussian square SamplePulse.

For d=d= duration, A=A= amp, σ=\sigma= sigma, and r=r= risefall, applies the midpoint sampling strategy to generate a discrete pulse sampled from the continuous function:

f(x)={g(xr))xrArxdrg(x(dr))drx\begin{split}f(x) = \begin{cases} g(x - r) ) & x\leq r \\ A & r\leq x\leq d-r \\ g(x - (d - r)) & d-r\leq x \end{cases}\end{split}

where g(x)g(x) is the Gaussian function sampled from in gaussian() with A=A= amp, μ=1\mu=1, and σ=\sigma= sigma. I.e. f(x)f(x) represents a square pulse with smooth Gaussian edges.

If zero_ends == True, the samples for the Gaussian ramps are remapped as in gaussian().

Parameters

  • duration (int) – Duration of pulse. Must be greater than zero.
  • amp (complex) – Pulse amplitude.
  • sigma (float) – Width (standard deviation) of Gaussian rise/fall portion of the pulse.
  • risefall (Optional[float]) – Number of samples over which pulse rise and fall happen. Width of square portion of pulse will be duration-2*risefall.
  • width (Optional[float]) – The duration of the embedded square pulse. Only one of width or risefall should be specified as the functional form requires width = duration - 2 * risefall.
  • name (Optional[str]) – Name of pulse.
  • zero_ends (bool) – If True, make the first and last sample zero, but rescale to preserve amp.

Raises

PulseError – If risefall and width arguments are inconsistent or not enough info.

Return type

SamplePulse

sawtooth

sawtooth(duration, amp, freq=None, period=None, phase=0, name=None)

GitHub

Generates sawtooth wave SamplePulse.

For A=A= amp, T=T= period, and ϕ=\phi= phase, applies the midpoint sampling strategy to generate a discrete pulse sampled from the continuous function:

f(x)=2A(g(x)12+g(x))f(x) = 2 A \left( g(x) - \left\lfloor \frac{1}{2} + g(x) \right\rfloor\right)

where g(x)=x/T+ϕ/πg(x) = x/T + \phi/\pi.

Parameters

  • duration (int) – Duration of pulse. Must be greater than zero.
  • amp (complex) – Pulse amplitude. Wave range is [[- amp ,, amp ]].
  • freq (Optional[float]) – Pulse frequency, units of 1./dt. If None defaults to 1./duration.
  • period (Optional[float]) – Pulse period, units of dt. (Deprecated, use freq instead)
  • phase (float) – Pulse phase.
  • name (Optional[str]) – Name of pulse.

Example

import matplotlib.pyplot as plt
from qiskit.pulse.pulse_lib import sawtooth
import numpy as np
 
duration = 100
amp = 1
period = duration
sawtooth_wave = np.real(sawtooth(duration, amp, period).samples)
plt.plot(range(duration), sawtooth_wave)
[<matplotlib.lines.Line2D at 0x7f1bfbc7c910>]

Return type

SamplePulse

sech

sech(duration, amp, sigma, name=None, zero_ends=True)

GitHub

Generates unnormalized sech SamplePulse.

For A=A= amp and σ=\sigma= sigma, applies the midpoint sampling strategy to generate a discrete pulse sampled from the continuous function:

f(x)=Asech(xμσ)f(x) = A\text{sech}\left(\frac{x-\mu}{\sigma} \right)

with the center μ=\mu= duration/2.

If zero_ends==True, each output sample yy is modifed according to:

yAyyAy,y \mapsto A\frac{y-y^*}{A-y^*},

where yy^* is the value of the endpoint samples. This sets the endpoints to 00 while preserving the amplitude at the center. If A=yA=y^*, yy is set to 11.

Parameters

  • duration (int) – Duration of pulse. Must be greater than zero.
  • amp (complex) – Pulse amplitude at duration/2.
  • sigma (float) – Width (standard deviation) of pulse.
  • name (Optional[str]) – Name of pulse.
  • zero_ends (bool) – If True, make the first and last sample zero, but rescale to preserve amp.

Return type

SamplePulse

sech_deriv

sech_deriv(duration, amp, sigma, name=None)

GitHub

Generates unnormalized sech derivative SamplePulse.

For A=A= amp, σ=\sigma= sigma, and center μ=\mu= duration/2, applies the midpoint sampling strategy to generate a discrete pulse sampled from the continuous function:

f(x)=ddx[Asech(xμσ)],f(x) = \frac{d}{dx}\left[A\text{sech}\left(\frac{x-\mu}{\sigma} \right)\right],

i.e. the derivative of sech\text{sech}.

Parameters

  • duration (int) – Duration of pulse. Must be greater than zero.
  • amp (complex) – Pulse amplitude at center.
  • sigma (float) – Width (standard deviation) of pulse.
  • name (Optional[str]) – Name of pulse.

Return type

SamplePulse

sin

sin(duration, amp, freq=None, phase=0, name=None)

GitHub

Generates sine wave SamplePulse.

For A=A= amp, ω=\omega= freq, and ϕ=\phi= phase, applies the midpoint sampling strategy to generate a discrete pulse sampled from the continuous function:

f(x)=Asin(2πωx+ϕ)f(x) = A \sin(2 \pi \omega x + \phi)

Parameters

  • duration (int) – Duration of pulse. Must be greater than zero.
  • amp (complex) – Pulse amplitude.
  • freq (Optional[float]) – Pulse frequency, units of 1/dt. If None defaults to single cycle.
  • phase (float) – Pulse phase.
  • name (Optional[str]) – Name of pulse.

Return type

SamplePulse

square

square(duration, amp, freq=None, period=None, phase=0, name=None)

GitHub

Generates square wave SamplePulse.

For A=A= amp, T=T= period, and ϕ=\phi= phase, applies the midpoint sampling strategy to generate a discrete pulse sampled from the continuous function:

f(x)=Asign[sin(2πxT+2ϕ)]f(x) = A \text{sign}\left[ \sin\left(\frac{2 \pi x}{T} + 2\phi\right) \right]

with the convention sign(0)=1\text{sign}(0) = 1.

Parameters

  • duration (int) – Duration of pulse. Must be greater than zero.
  • amp (complex) – Pulse amplitude. Wave range is [[- amp ,, amp ]].
  • freq (Optional[float]) – Pulse frequency, units of 1./dt. If None defaults to 1./duration.
  • period (Optional[float]) – Pulse period, units of dt. (Deprecated, use freq instead)
  • phase (float) – Pulse phase.
  • name (Optional[str]) – Name of pulse.

Return type

SamplePulse

triangle

triangle(duration, amp, freq=None, period=None, phase=0, name=None)

GitHub

Generates triangle wave SamplePulse.

For A=A= amp, T=T= period, and ϕ=\phi= phase, applies the midpoint sampling strategy to generate a discrete pulse sampled from the continuous function:

f(x)=A(2sawtooth(x,A,T,ϕ)+1)f(x) = A \left(-2\left|\text{sawtooth}(x, A, T, \phi)\right| + 1\right)

This a non-sinusoidal wave with linear ramping.

Parameters

  • duration (int) – Duration of pulse. Must be greater than zero.
  • amp (complex) – Pulse amplitude. Wave range is [[- amp ,, amp ]].
  • freq (Optional[float]) – Pulse frequency, units of 1./dt. If None defaults to 1./duration.
  • period (Optional[float]) – Pulse period, units of dt. (Deprecated, use freq instead)
  • phase (float) – Pulse phase.
  • name (Optional[str]) – Name of pulse.

Example

import matplotlib.pyplot as plt
from qiskit.pulse.pulse_lib import triangle
import numpy as np
 
duration = 100
amp = 1
period = duration
triangle_wave = np.real(triangle(duration, amp, period).samples)
plt.plot(range(duration), triangle_wave)
[<matplotlib.lines.Line2D at 0x7f1bf94d9a90>]

Return type

SamplePulse

zero

zero(duration, name=None)

GitHub

Generates zero-sampled SamplePulse.

Samples from the function:

f(x)=0f(x) = 0

Parameters

  • duration (int) – Duration of pulse. Must be greater than zero.
  • name (Optional[str]) – Name of pulse.

Return type

SamplePulse

Was this page helpful?
Report a bug or request content on GitHub.