qiskit.pulse.library.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 Waveform . |
cos (duration, amp[, freq, phase, name]) | Generates cosine wave Waveform . |
drag (duration, amp, sigma, beta[, name, …]) | Generates Y-only correction DRAG Waveform for standard nonlinear oscillator (SNO) [1]. |
gaussian (duration, amp, sigma[, name, zero_ends]) | Generates unnormalized gaussian Waveform . |
gaussian_deriv (duration, amp, sigma[, name]) | Generates unnormalized gaussian derivative Waveform . |
gaussian_square (duration, amp, sigma[, …]) | Generates gaussian square Waveform . |
sawtooth (duration, amp[, freq, phase, name]) | Generates sawtooth wave Waveform . |
sech (duration, amp, sigma[, name, zero_ends]) | Generates unnormalized sech Waveform . |
sech_deriv (duration, amp, sigma[, name]) | Generates unnormalized sech derivative Waveform . |
sin (duration, amp[, freq, phase, name]) | Generates sine wave Waveform . |
square (duration, amp[, freq, phase, name]) | Generates square wave Waveform . |
triangle (duration, amp[, freq, phase, name]) | Generates triangle wave Waveform . |
zero (duration[, name]) | Generates zero-sampled Waveform . |
constant
constant(duration, amp, name=None)
Generates constant-sampled Waveform
.
For amp
, samples from the function:
Parameters
- duration (
int
) – Duration of pulse. Must be greater than zero. - amp (
complex
) – Complex pulse amplitude. - name (
Optional
[str
]) – Name of pulse.
Return type
Waveform
cos
cos(duration, amp, freq=None, phase=0, name=None)
Generates cosine wave Waveform
.
For amp
, freq
, and phase
, applies the midpoint sampling strategy to generate a discrete pulse sampled from the continuous function:
Parameters
- duration (
int
) – Duration of pulse. Must be greater than zero. - amp (
complex
) – Pulse amplitude. - freq (
Optional
[float
]) – Pulse frequency, units of 1/dt. IfNone
defaults to single cycle. - phase (
float
) – Pulse phase. - name (
Optional
[str
]) – Name of pulse.
Return type
Waveform
drag
drag(duration, amp, sigma, beta, name=None, zero_ends=True)
Generates Y-only correction DRAG Waveform
for standard nonlinear oscillator (SNO) [1].
For amp
, sigma
, and beta
, applies the midpoint
sampling strategy to generate a discrete pulse sampled from the continuous function:
where is the function sampled in gaussian()
, and is the function sampled in gaussian_deriv()
.
If zero_ends == True
, the samples from are remapped as in gaussian()
.
References
Parameters
- duration (
int
) – Duration of pulse. Must be greater than zero. - amp (
complex
) – Pulse amplitude at centerduration/2
. - sigma (
float
) – Width (standard deviation) of pulse. - beta (
float
) – Y correction amplitude. For the SNO this is . Where is the relative coupling strength between the first excited and second excited states and is the detuning between the respective excited states. - name (
Optional
[str
]) – Name of pulse. - zero_ends (
bool
) – If True, zero ends atx = -1, x = duration + 1
, but rescale to preserve amp.
Return type
Waveform
gaussian
gaussian(duration, amp, sigma, name=None, zero_ends=True)
Generates unnormalized gaussian Waveform
.
For amp
and sigma
, applies the midpoint
sampling strategy to generate a discrete pulse sampled from the continuous function:
with the center duration/2
.
If zero_ends==True
, each output sample is modifed according to:
where is the value of the endpoint samples. This sets the endpoints to while preserving the amplitude at the center. If , is set to . By default, the endpoints are at x = -1, x = duration + 1
.
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 atduration/2
. - sigma (
float
) – Width (standard deviation) of pulse. - name (
Optional
[str
]) – Name of pulse. - zero_ends (
bool
) – If True, zero ends atx = -1, x = duration + 1
, but rescale to preserve amp.
Return type
Waveform
gaussian_deriv
gaussian_deriv(duration, amp, sigma, name=None)
Generates unnormalized gaussian derivative Waveform
.
For amp
and sigma
applies the midpoint sampling strategy to generate a discrete pulse sampled from the continuous function:
i.e. the derivative of the Gaussian function, with center 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
Waveform
gaussian_square
gaussian_square(duration, amp, sigma, risefall=None, width=None, name=None, zero_ends=True)
Generates gaussian square Waveform
.
For duration
, amp
, sigma
, and risefall
, applies the midpoint
sampling strategy to generate a discrete pulse sampled from the continuous function:
where is the Gaussian function sampled from in gaussian()
with amp
, , and sigma
. I.e. 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 beduration-2*risefall
. - width (
Optional
[float
]) – The duration of the embedded square pulse. Only one ofwidth
orrisefall
should be specified as the functional form requireswidth = duration - 2 * risefall
. - name (
Optional
[str
]) – Name of pulse. - zero_ends (
bool
) – If True, zero ends atx = -1, x = duration + 1
, but rescale to preserve amp.
Raises
PulseError – If risefall
and width
arguments are inconsistent or not enough info.
Return type
Waveform
sawtooth
sawtooth(duration, amp, freq=None, phase=0, name=None)
Generates sawtooth wave Waveform
.
For amp
, period
, and phase
, applies the midpoint sampling strategy to generate a discrete pulse sampled from the continuous function:
where .
Parameters
- duration (
int
) – Duration of pulse. Must be greater than zero. - amp (
complex
) – Pulse amplitude. Wave range isamp
amp
. - freq (
Optional
[float
]) – Pulse frequency, units of 1./dt. IfNone
defaults to 1./duration. - phase (
float
) – Pulse phase. - name (
Optional
[str
]) – Name of pulse.
Example
import matplotlib.pyplot as plt
from qiskit.pulse.library import sawtooth
import numpy as np
duration = 100
amp = 1
freq = 1 / duration
sawtooth_wave = np.real(sawtooth(duration, amp, freq).samples)
plt.plot(range(duration), sawtooth_wave)
[<matplotlib.lines.Line2D at 0x7fc352516090>]
Return type
Waveform
sech
sech(duration, amp, sigma, name=None, zero_ends=True)
Generates unnormalized sech Waveform
.
For amp
and sigma
, applies the midpoint
sampling strategy to generate a discrete pulse sampled from the continuous function:
with the center duration/2
.
If zero_ends==True
, each output sample is modifed according to:
where is the value of the endpoint samples. This sets the endpoints to while preserving the amplitude at the center. If , is set to . By default, the endpoints are at x = -1, x = duration + 1
.
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, zero ends atx = -1, x = duration + 1
, but rescale to preserve amp.
Return type
Waveform
sech_deriv
sech_deriv(duration, amp, sigma, name=None)
Generates unnormalized sech derivative Waveform
.
For amp
, sigma
, and center duration/2
, applies the midpoint sampling strategy to generate a discrete pulse sampled from the continuous function:
i.e. the derivative of .
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
Waveform
sin
sin(duration, amp, freq=None, phase=0, name=None)
Generates sine wave Waveform
.
For amp
, freq
, and phase
, applies the midpoint sampling strategy to generate a discrete pulse sampled from the continuous function:
Parameters
- duration (
int
) – Duration of pulse. Must be greater than zero. - amp (
complex
) – Pulse amplitude. - freq (
Optional
[float
]) – Pulse frequency, units of 1/dt. IfNone
defaults to single cycle. - phase (
float
) – Pulse phase. - name (
Optional
[str
]) – Name of pulse.
Return type
Waveform
square
square(duration, amp, freq=None, phase=0, name=None)
Generates square wave Waveform
.
For amp
, period
, and phase
, applies the midpoint sampling strategy to generate a discrete pulse sampled from the continuous function:
with the convention .
Parameters
- duration (
int
) – Duration of pulse. Must be greater than zero. - amp (
complex
) – Pulse amplitude. Wave range isamp
amp
. - freq (
Optional
[float
]) – Pulse frequency, units of 1./dt. IfNone
defaults to 1./duration. - phase (
float
) – Pulse phase. - name (
Optional
[str
]) – Name of pulse.
Return type
Waveform
triangle
triangle(duration, amp, freq=None, phase=0, name=None)
Generates triangle wave Waveform
.
For amp
, period
, and phase
, applies the midpoint sampling strategy to generate a discrete pulse sampled from the continuous function:
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 isamp
amp
. - freq (
Optional
[float
]) – Pulse frequency, units of 1./dt. IfNone
defaults to 1./duration. - phase (
float
) – Pulse phase. - name (
Optional
[str
]) – Name of pulse.
Example
import matplotlib.pyplot as plt
from qiskit.pulse.library import triangle
import numpy as np
duration = 100
amp = 1
freq = 1 / duration
triangle_wave = np.real(triangle(duration, amp, freq).samples)
plt.plot(range(duration), triangle_wave)
[<matplotlib.lines.Line2D at 0x7fc352006190>]
Return type
Waveform
zero
zero(duration, name=None)
Generates zero-sampled Waveform
.
Samples from the function:
Parameters
- duration (
int
) – Duration of pulse. Must be greater than zero. - name (
Optional
[str
]) – Name of pulse.
Return type
Waveform