Classes
Parameters
Parameterized
- class sequencing.parameters.Parameterized(name: str, cls: str = '')[source]
A serializable object with parameters.
Parameterized objects must have a name and can have any number of parameters, which can be created using the functions defined in
sequencing.parameters, or by using attrs directly viaattr.ib().Parameterized offers the following convenient features:
Recursive
get()andset()methods for getting and setting attributes of nestedParameterizedobjects.Methods for converting a
Parameterizedobject into a Python dict, and creating a new Parameterized object from a dict.Methods for serializing a
Parameterizedobject to json and creating a newParameterizedobject from json.
Supported parameter types include:
StringParameterBoolParameterIntParameterFloatParameterNanosecondParameterGigahertzParameterRadianParameterDictParameterListParameter
Notes:
Subclasses of
Parameterizedmust be decorated with@attr.sSubclasses of
Parameterizedcan define aninitialize()method, which takes no arguments. It will be called on instantiation after the attrs-generated__init__method (see __attrs_post_init__ for more details). If defined, the subclass’initialize()method should always callsuper().initialize()to ensure that the superclass is correctly initialized.
- initialize()[source]
Called after the attrs-generated __init__ method.
Can be specialized to set private attributes or perform other setup tasks.
- get_param(address, *args, delimiter='.')[source]
Recursively “get” a single attribute of nested
Parameterizedobjects.
- set_param(address, value, delimiter='.')[source]
Recursively “set” a single attribute of nested
Parameterizedobjects.
- set(**kwargs)[source]
Recursively “set” attributes of nested
Parameterizedobjects.Attributes must be specified as keyword arguments:
attr_address=value, whereattr_addressis adelimiter-delimited string specifying the attribute to fetch, e.g.instance__param__sub_param=value. The defaultdelimiteris"__", i.e. two underscores. This can be overridden by passing indelimiteras a keyword argument.
- get(*addresses, delimiter='.')[source]
Recursively “get” attributes of nested
Parameterizedobjects.
- temporarily_set(**kwargs)[source]
A context mangaer that temporarily sets parameter values, then reverts them to the old values.
Delimiter for
get()andset()can be chosen using keyword argumentdelimiter="{whatever}". The default is two underscores,__.
- as_dict(json_friendly=True)[source]
Returns a dictionary representation of the object and all of its parameters.
- to_json(dumps=False, json_path=None)[source]
Serialize object to json.
- Parameters
- Returns
json string if
dumpsis True, else writes json to file and returns None.- Return type
str or None
- classmethod from_dict(d)[source]
Creates a new instance from a dict like that returned by
self.as_dict().- Parameters
d (dict) – Dict from which to create the Parameterized object.
- Returns
Instance of
Parameterizedwhose parameters have been populated fromd.- Return type
Pulses
Pulse
- class sequencing.pulses.Pulse(name: str, cls: str = '', amp=1, detune=0, phase=0, dt=1, noise_sigma=0, noise_alpha=0, scale_noise=False)[source]
Bases:
ParameterizedGenerates a parameterized complex pulse waveform using callable
pulse_func.- Parameters
amp (float) – Maximum amplitude of the pulse. Default: 1.
detune (float) – “Software detuning” (time-dependent phase) to apply to the waveform, in GHz. Default: 0.
phase (float) – Phase offset to apply to the waveform, in radians. Default: 0.
noise_sigma (float) – Standard deviation of additive Gaussian noise applied to the pulse (in the same units as
amp). Default: 0.noise_alpha (float) – Exponent for the noise PSD S(f). S(f) is proportional to (1/f)**noise_alpha. noise_alpha = 0 for white noise, noise_alpha = 1 for 1/f noise, etc. Default: 0 (white noise).
scale_noise (optional, bool) – Whether to scale the noise by
ampbefore adding it to the signal. If False, then noise_sigma has units of GHz. Default: True.
ConstantPulse
SmoothedConstantPulse
- class sequencing.pulses.SmoothedConstantPulse(name: str, cls: str = '', amp=1, detune=0, phase=0, dt=1, noise_sigma=0, noise_alpha=0, scale_noise=False, length=100, sigma=0, shape='tanh')[source]
Bases:
PulseA constant pulse with smoothed ring-up and ring-down.
- Parameters
amp (float) – Maximum amplitude of the pulse. Default: 1.
detune (float) – “Software detuning” (time-dependent phase) to apply to the waveform, in GHz. Default: 0.
phase (float) – Phase offset to apply to the waveform, in radians. Default: 0.
length (int) – Total length of the pulse in ns. Default: 100.
sigma (int) – Ring-up and ring-down time in ns. If sigma == 0, then this is equivalent to ControlPulse. The length of the constant portion of the pulse is
length - 2 * sigma. Default: 0.shape (str) – String specifying the type of ring-up and ring-down. Valid options are ‘tanh’, ‘cos’, and ‘gaussian’ (see
ringup_wave). Default: ‘tanh’.
GaussianPulse
- class sequencing.pulses.GaussianPulse(name: str, cls: str = '', amp=1, detune=0, phase=0, dt=1, noise_sigma=0, noise_alpha=0, scale_noise=False, sigma=10, chop=4, drag=0)[source]
Bases:
PulseA Gaussian that is “chopped” at +/-
(chop / 2) * sigma. The full pulse length is thereforesigma * chop.- Parameters
amp (float) – Maximum amplitude of the pulse. Default: 1.
detune (float) – “Software detuning” (time-dependent phase) to apply to the waveform, in GHz. Default: 0.
phase (float) – Phase offset to apply to the waveform, in radians. Default: 0.
sigma (float) – Gaussian sigma in ns. Default: 10.
chop (int) – The Gaussian is truncated at +/-
chop/2 * sigma. Default: 4.drag (float) – DRAG coefficient. Default: 0.
SechPulse
- class sequencing.pulses.SechPulse(name: str, cls: str = '', amp=1, detune=0, phase=0, dt=1, noise_sigma=0, noise_alpha=0, scale_noise=False, sigma=10, chop=4, drag=0)[source]
Bases:
PulseHyperbolic secant pulse that is “chopped” at +/-
(chop / 2) * sigma.\[\begin{split}A(t) &= \text{sech}(\rho t)\\ \rho &= \pi / (2\sigma)\end{split}\]
SlepianPulse
- class sequencing.pulses.SlepianPulse(name: str, cls: str = '', amp=1, detune=0, phase=0, dt=1, noise_sigma=0, noise_alpha=0, scale_noise=False, tau=40, width=10, drag=0)[source]
Bases:
PulseA Slepian Pulse.
See
scipy.signal.windows.slepian.
Modes
Mode
- class sequencing.modes.Mode(name: str, cls: str = '', levels=2, t1=inf, t2=inf, thermal_population=0, df=0, kerr=0)[source]
Bases:
ParameterizedAn oscillator that can be embedded in a larger Hilbert space.
Modeshave alogical_zerostate andlogical_one state, based on which Pauli operators and rotations are defined.- Parameters
name (str) – Name of the mode for which to construct operators.
levels (optional, int) – Number of levels in the mode subspace. Default: 2.
t1 (optional, float) – Mode T1 time in nanoseconds. Default: inf.
t2 (optional, float) – Mode T2 time in nanoseconds. Default: inf.
thermal_population (optional, float) – Mode excited state population (in [0..1]). Default: 0.
df (optional, float) – Mode detuning in GHz. Default: 0.
kerr (optional, float) – Mode self-Kerr in GHz. Default: 0.
- initialize()[source]
Called after the attrs-generated __init__ method.
Can be specialized to set private attributes or perform other setup tasks.
- property space
A list of Modes.
This is the Hilbert space in which the mode exists.
- property index
The index of the Mode in its Hilbert space.
- property I
Identity operator.
- property a
Annihilation operator.
- property ad
Creation operator.
- property n
Number operator.
- property x
Position operator.
- property y
Momentum (quadrature) operator.
- property detuning
Operator representation of a detuning on this mode.
- property self_kerr
Operator representation of the mode’s self-Kerr.
- property tphi
Pure dephasing time, calculated from
t1andt2.
- property Gamma_up
Excitation rate, calulcated from
t1andthermal_population.
- property Gamma_down
Decay rate, calculated from
t1andGamma_up.
- property decay
Collapse operator for energy decay.
- property excitation
Collapse operator for excitation.
- property dephasing
Collapse operator for pure dephasing.
- no_loss()[source]
A context manager that temporarily sets a Mode’s coherence parameters to the ideal values: T1 = inf, T2 = inf, thermal population = 0.
- use_space(modes)[source]
A context manager that temporarily sets
self.modestomodes, then reverts it to the previous value.
- fock(n=0, full_space=True)[source]
Returns the Fock state
|n>, optionally embedded in the full Hilbert space.
- basis(n=0, full_space=True)
Returns the Fock state
|n>, optionally embedded in the full Hilbert space.
- fock_dm(n=0, full_space=True)[source]
Returns the basis state
|n>, optionally embedded in the full Hilbert space, as a density matrix.
- tensor_with_zero(state)[source]
Returns
stateonself, tensored withket(0)on all other modes inself.space.- Parameters
state (qutip.Qobj) – State of the mode.
- Returns
stateon the mode, tensored withket(0)on all other modes in self.space.- Return type
qutip.Qobj
- tensor_with_I(operator)[source]
Returns operator for
self, tensored withIfor all other modes inself.space.- Parameters
state (qutip.Qobj) – State of the mode.
- Returns
operatorfor the mode, tensored withIon all other modes inself.space.- Return type
qutip.Qobj
- set_logical_states(logical_zero=None, logical_one=None)[source]
Sets the mode’s logical zero and logical one states.
- Parameters
logical_zero (optional, qutip.Qobj) – Ket representing the mode’s logical zero state. If None, the Fock state ket(0) is used as logical zero.
logical_zeromust have the same dimensions as the mode itself. Default: None.logical_one (optional, qutip.Qobj) – Ket representing the mode’s logical one state. If None, the Fock state ket(1) is used as logical one.
logical_onemust ahve the same dimensions as the mode itself. Default: None.
- logical_zero(full_space=True)[source]
Returns the mode’s logical zero state, optionally embedded in the full Hilbert space defined by
self.space.- Parameters
full_space (optional, bool) – Whether to embed
logical_zeroin the full Hilbert space. Default: True.- Returns
Ket representing the mode’s logical zero state.
- Return type
qutip.Qobj
- logical_one(full_space=True)[source]
Returns the mode’s logical one state, optionally embedded in the full Hilbert space defined by
self.space.- Parameters
full_space (optional, bool) – Whether to embed
logical_onein the full Hilbert space. Default: True.- Returns
Ket representing the mode’s logical one state.
- Return type
qutip.Qobj
- logical_states(full_space=True)[source]
Returns the mode’s logical zero and logical one states, optionally embedded in the full Hilbert space defined by
self.space.
- sigmax(full_space=True)[source]
Pauli X operator
\[X = \left|0_L\rangle\langle1_L\right| + \left|1_L\rangle\langle0_L\right|\]- Parameters
full_space (optional, bool) – Whether to embed the operator in the full Hilbert space. Default: True.
- Returns
Pauli X operator.
- Return type
qutip.Qobj
- sigmay(full_space=True)[source]
Pauli Y operator
\[Y = -i\left(\left|0_L\rangle\langle1_L\right| - \left|1_L\rangle\langle0_L\right|\right)\]- Parameters
full_space (optional, bool) – Whether to embed the operator in the full Hilbert space. Default: True.
- Returns
Pauli Y operator.
- Return type
qutip.Qobj
- sigmaz(full_space=True)[source]
Pauli Z operator.
\[Z = \left|0_L\rangle\langle0_L\right| - \left|1_L\rangle\langle1_L\right|\]- Parameters
full_space (optional, bool) – Whether to embed the operator in the full Hilbert space. Default: True.
- Returns
Pauli Z operator.
- Return type
qutip.Qobj
- Raxis(theta, phi, full_space=True)[source]
Operator for a rotation of angle
thetaabout an axis specified byphi.\[R_\text{axis}(\theta,\phi) = \exp\left(-i\theta/2 \cdot (\cos(\phi)X + \sin(\phi)Y)\right)\]
- Rx(theta, full_space=True)[source]
Operator for a rotation of angle
thetaabout the x axis.\[R_x(\theta) = \exp(-i\theta/2 \cdot X)\]
- Ry(theta, full_space=True)[source]
Operator for a rotation of angle
thetaabout the y axis.\[R_y(\theta) = \exp(-i\theta/2 \cdot Y)\]
- Rz(theta, full_space=True)[source]
Operator for a rotation of angle
thetaabout the z axis.\[R_z(\theta) = \exp(-i\theta/2 \cdot Z)\]
- hadamard(full_space=True)[source]
Hadamard operator.
\[H = \frac{1}{\sqrt{2}}\left(X + Z\right)\]- Parameters
full_space (optional, bool) – Whether to embed the operator in the full Hilbert space. Default: True.
- Returns
Hadamard operator.
- Return type
qutip.Qobj
PulseMode
- class sequencing.modes.PulseMode(name: str, cls: str = '', levels=2, t1=inf, t2=inf, thermal_population=0, df=0, kerr=0, pulses=NOTHING, default_pulse='gaussian_pulse')[source]
Bases:
ModeA Mode that has Pulses.
- Parameters
name (str) – Name of the mode for which to construct operators.
levels (optional, int) – Number of levels in the mode subspace. Default: 2.
t1 (optional, float) – Mode T1 time in nanoseconds. Default: inf.
t2 (optional, float) – Mode T2 time in nanoseconds. Default: inf.
thermal_population (optional, float) – Mode excited state population (in [0..1]). Default: 0.
df (optional, float) – Mode detuning in GHz. Default: 0.
kerr (optional, float) – Mode self-Kerr in GHz. Default: 0.
pulses (optional, dict[str, Pulse]) – Dict of pulses defined for this Mode. Default: empty dict {}.
default_pulse (optional, str) – Name of the default Pulse for this Mode. Default: “gaussian_pulse”.
- initialize()[source]
Called after the attrs-generated __init__ method.
Can be specialized to set private attributes or perform other setup tasks.
- add_pulse(cls=<class 'sequencing.pulses.GaussianPulse'>, name=None, error_if_exists=False, **kwargs)[source]
Creates a new pulse of type
clsand adds it toself.pulses.Keyword arguments are passed to
cls.__init__().- Parameters
cls (optional, type) – Pulse class to instantiate. Default:
GaussianPulse.name (optional, str) – Name of the new pulse. If None, will use the “snake case” version of the class name, e.g. “GaussianPulse” -> “gaussian_pulse”. Default: None.
error_if_exists (optional, bool) – Whether to raise an exception if a pulse with the same name already exists. Default: False.
- amplitude(amp, pulse_name=None)[source]
A context manager that temporarily sets the amplitude of a given pulse to
amp, then reverts it to its previous value.
Qubit
- class sequencing.modes.Qubit(name: str, cls: str = '', levels=2, t1=inf, t2=inf, thermal_population=0, df=0, kerr=0, pulses=NOTHING, default_pulse='gaussian_pulse')[source]
Bases:
PulseModeFixed-frequency qubit.
A PulseMode whose primary operations are rotations on the Bloch Sphere.
- Parameters
name (str) – Name of the mode for which to construct operators.
levels (optional, int) – Number of levels in the mode subspace. Default: 2.
t1 (optional, float) – Mode T1 time in nanoseconds. Default: inf.
t2 (optional, float) – Mode T2 time in nanoseconds. Default: inf.
thermal_population (optional, float) – Mode excited state population (in [0..1]). Default: 0.
df (optional, float) – Mode detuning in GHz. Default: 0.
kerr (optional, float) – Mode self-Kerr in GHz. Default: 0.
pulses (optional, dict[str, Pulse]) – Dict of pulses defined for this Mode. Default: empty dict {}.
default_pulse (optional, str) – Name of the default Pulse for this Mode. Default: “gaussian_pulse”.
- property anharmonicity
Alias for
Qubit.kerr
- rotate(angle, phase, pulse_name=None, unitary=False, **kwargs)[source]
Generate a pulse to rotate the qubit by a given angle about a given axis.
Keyword arguments are passed to the
Pulseobject.- Parameters
angle (float) – Rotation angle in radians.
phase (float) – Rotation axis relative to the x axis.
pulse_name (optional, str) – Name of the pulse to use. If None, will use
self.default_pulse. Default: None.unitary (optional, bool) – Whether to return the corresponding unitary operator instead of executing the pulse. Default: False.
- Returns
If
unitaryis True, returns the unitary operator Rx(angle), otherwise returns the resultingOperationobject.- Return type
qutip.Qobjor Operation
- rotate_x(angle, unitary=False, **kwargs)[source]
Generate a rotation about the x axis.
Keyword arguments are passed to
Qubit.rotate()ifunitaryis False.- Parameters
- Returns
If
unitaryis True, returns the unitary operator Rx(angle), otherwise returns the resultingOperationobject.- Return type
qutip.Qobjor Operation
- rotate_y(angle, unitary=False, **kwargs)[source]
Generate a rotation about the y axis.
Keyword arguments are passed to
Qubit.rotate()ifunitaryis False.- Parameters
- Returns
If
unitaryis True, returns the unitary operator Ry(angle), otherwise returns the resultingOperationobject.- Return type
qutip.Qobjor Operation
Transmon
- class sequencing.modes.Transmon(name: str, cls: str = '', levels=2, t1=inf, t2=inf, thermal_population=0, df=0, kerr=0, pulses=NOTHING, default_pulse='gaussian_pulse')[source]
Bases:
QubitFixed-frequency transmon qubit.
A PulseMode whose primary operations are rotations on the Bloch Sphere.
- Parameters
name (str) – Name of the mode for which to construct operators.
levels (optional, int) – Number of levels in the mode subspace. Default: 2.
t1 (optional, float) – Mode T1 time in nanoseconds. Default: inf.
t2 (optional, float) – Mode T2 time in nanoseconds. Default: inf.
thermal_population (optional, float) – Mode excited state population (in [0..1]). Default: 0.
df (optional, float) – Mode detuning in GHz. Default: 0.
kerr (optional, float) – Mode self-Kerr in GHz. Default: 0.
pulses (optional, dict[str, Pulse]) – Dict of pulses defined for this Mode. Default: empty dict {}.
default_pulse (optional, str) – Name of the default Pulse for this Mode. Default: “gaussian_pulse”.
Cavity
- class sequencing.modes.Cavity(name: str, cls: str = '', levels=2, t1=inf, t2=inf, thermal_population=0, df=0, kerr=0, pulses=NOTHING, default_pulse='gaussian_pulse')[source]
Bases:
PulseModeWeakly non-linear cavity.
A PulseMode whose primary operation is displacements.
- Parameters
name (str) – Name of the mode for which to construct operators.
levels (optional, int) – Number of levels in the mode subspace. Default: 2.
t1 (optional, float) – Mode T1 time in nanoseconds. Default: inf.
t2 (optional, float) – Mode T2 time in nanoseconds. Default: inf.
thermal_population (optional, float) – Mode excited state population (in [0..1]). Default: 0.
df (optional, float) – Mode detuning in GHz. Default: 0.
kerr (optional, float) – Mode self-Kerr in GHz. Default: 0.
pulses (optional, dict[str, Pulse]) – Dict of pulses defined for this Mode. Default: empty dict {}.
default_pulse (optional, str) – Name of the default Pulse for this Mode. Default: “gaussian_pulse”.
- displace(alpha, unitary=False, pulse_name=None, **kwargs)[source]
Generate a displacement of amplitude
alpha.Keyword arguments are passed to the
Pulseobject ifunitaryis False.- Parameters
- Returns
If
unitaryis True, returns the unitary operator Ry(angle), otherwise returns the resultingOperationobject.- Return type
qutip.Qobjor Operation
System
CouplingTerm
- class sequencing.system.CouplingTerm(*terms, strength=1, add_hc=False)[source]
An object representing a coupling between multiple
Modes, given by a Hamiltonian term of the formstrength * product(operators). If the keyword argumentadd_hcis provided and is True, then the Hamiltonian term takes the formstrength * (product(operators) + product(operators).dag()).- Parameters
terms (list[tuple[Mode, str]]) – List of tuples of
(mode, expr), which defines the coupling. Eachexpris a string containing an algebraic expression involving the Mode’s operators. SeeMode.operator_expr()for more details. The resulting operators are given bymode.operator_expr(expr).strength (optional, float) – Coefficient parameterizing the strength of the coupling. Strength should be given in units of 2 * pi * GHz. Default: 1.
add_hc (optional, bool) – Whether to add the Hermitian conjugate of the product of the operators. Default: False.
System
- class sequencing.system.System(name: str, cls: str = '', modes=NOTHING, cross_kerrs=NOTHING)[source]
Bases:
ParameterizedA collection of
Modesthat can be coupled together.- coupling_terms
A dictionary of CouplingTerm objects specifying all interactions in the system.
- Type
dict[frozenset[str], list[CouplingTerm]]
- initialize()[source]
Called after the attrs-generated __init__ method.
Can be specialized to set private attributes or perform other setup tasks.
- property levels
Dictionary of (mode_name, number_of_levels)
- property active_modes
List of the modes currently being used.
- use_modes(modes)[source]
A context manager that temporarily sets
self.active_modestomodes, then revertsself.active_modesto its previous value.
- eye(modes=None)
Identity operator.
- fock(*args, **kwargs)[source]
Returns a product state in the Fock basis. States can be specified either positionally or as keyword arguments.
- fock_dm(*args, **kwargs)[source]
Returns a product state in the Fock basis, as a density matrix.
States can be specified either positionally or as keyword arguments.
- basis(*args, **kwargs)
Returns a product state in the Fock basis. States can be specified either positionally or as keyword arguments.
- ground_state()[source]
Returns the ground state of the system.
- Returns
The system’s ground state.
- Return type
qutip.Qobj
- logical_basis(*args, **kwargs)[source]
Returns a product state in the basis spanned by the logical states of all modes. Logical states can be specified either positionally or as keyword arguments.
- set_cross_kerr(mode1, mode2, chi=0)[source]
Set the cross-Kerr (in GHz) between two modes. Note that the order of mode1 and mode2 doesn’t matter.
- couplings(modes=None, clean=True)[source]
Returns all of the static coupling terms in the Hamiltonian.
- H0(modes=None, clean=True)[source]
Returns the static Hamiltonian consisting of all self-Kerrs and inter-mode couplings.
- c_ops(modes=None, clean=True)[source]
Returns a list of collapse operators corresponding to loss (decay/excitation) and dephasing of all modes.
- as_dict(json_friendly=False)[source]
Overrides Parameterized.as_dict() in order to deal with cross_kerrs.
Sequencing
HamiltonianChannels
- class sequencing.sequencing.HamiltonianChannels(channels=None, collapse_channels=None, t0=0, dt=1)[source]
Object prepresenting a set of Hamiltonian ‘channels’ with time-dependent coefficients.
- Parameters
channels (optional, dict) – Dict of {channel_name: {‘H’: hamiltonian_term, ‘time_dependent’: td_bool}}, where hamiltonian_term is a qutip.Qobj and td_bool is a boolean flag indicating whether this Hamiltonian will be given time-dependence (defaults to False). Default: None.
collapse_channels (optional, dict) – Similar to channels, but for collapse operators instead of Hamiltonian terms. Default: None.
- property times
Array of times.
- add_channel(name, H=None, C_op=None, time_dependent=False, error_if_exists=True)[source]
Add a channel with specified Hamiltonian term H or collapse operator C_op.
- Parameters
name (str) – Name of the Hamiltonian channel.
H (optional, qutip.Qobj) – Hamiltonian term for this channel.
C_op (optional, qutip.Qobj) – Collapse operator for this channel.
time_dependent (optional, bool) – Whether this channel has time-dependent Hamiltonian coefficients. Default: False.
error_if_exists (optional, bool) – Whether to raise an exception if a channel with the same name already exists. Default: True.
- add_operation(channel_name, t0=None, duration=None, times=None, H=None, C_op=None, coeffs=1, coeffs_args=None, coeffs_kwargs=None)[source]
Add an operation to a given channel, padding all other channels accordingly.
- Parameters
channel_name (str) – Name of the Hamiltonian channel this operation acts on.
t0 (optional, int) – Starting time of this operation (required along with duration if you do not provide an array of times). Default: None.
duration (optional, int) – Length of this operation (required along with t0 if you do not provide an array of times). Default: None.
times (optional, sequence[int]) – Sequence of time points. Default: None.
H (optional, qutip.Qobj) – Hamiltonian for the given channel (required if this channel is not yet in self.channels). Default: None.
C_op (optional, qutip.Qobj) – Collapse operator for the given channel (required if this channel is not yet in self.collapse_channels).
coeffs (optional, number | sequence | callable) – Hamiltonian coefficients for the given time points. You can specify single int/float/complex for constant coefficients, or provide a function that takes time as its first argument and returns coefficiencts. Default: None.
coeffs_args (optional, sequence) – Positional arguments passed to coeffs if coeffs is callable. Default: None.
coeffs_kwargs (optional, dict) – Keyword arguments passed to coeffs if coeffs is a function. Default: None.
Important note: if
reset_t0is in coeffs_kwargs and is True, then the first argument for coeffs will betimes-times[0]instead oftimes. This allows for the user to take care of phase bookkeeping.
- delay_channels(channel_names, duration)[source]
Add a delay of length
durationto channels specified in the listchannel_names.
- build_hamiltonian()[source]
Assemble the channels into a list of Hamiltonian terms and collapse operators which can be ingested by
qutip.mesolve.
CompiledPulseSequence
- class sequencing.sequencing.CompiledPulseSequence(system=None, channels=None, t0=0)[source]
Creates time-dependent Hamiltonian channels from a sequence of Operations.
- Parameters
system (optional, subsystems.System) – System containing the Modes on which to operate.
channels (opional, dict) – Dict of initial channels to pass the HamiltonianChannels. Default: None.
- add_channel(name, H=None, C_op=None, time_dependent=False, error_if_exists=True)[source]
Add a channel with specified Hamiltonian term H or collapse operator C_op.
- Parameters
name (str) – Name of the Hamiltonian channel.
H (optional, qutip.Qobj) – Hamiltonian term for this channel.
C_op (optional, qutip.Qobj) – Collapse operator for this channel.
time_dependent (optional, bool) – Whether this channel has time-dependent Hamiltonian coefficients. Default: False.
error_if_exists (optional, bool) – Whether to raise an exception if a channel with the same name already exists. Default: True.
- add_operation(operation)[source]
Add an Operation (time dependent Hamiltonian or collapse terms) to the HamiltonianChannels at the current time.
- Parameters
operation (Operation) – Operation object to add to the pulse sequence.
- sync()[source]
Ensure that the Hamiltonian channels all align up to this point.
This means that all operations which follow the sync will be executed after all those before the sync. Sequences are constructed in terms of blocks of operations separated by sync()s. Within a block, channels are made to have equal duration by padding shorter channels to the maximum channel length.
- build_hamiltonian()[source]
Assemble the channels into a list of Hamiltonian terms and collapse operators which can be ingested by qutip.mesolve.
- run(init_state, c_ops=None, e_ops=None, options=None, only_final_state=False, progress_bar=None)[source]
Simulate the sequence using qutip.mesolve.
- Parameters
init_state (qutip.Qobj) – Inital state of the system.
c_ops (optional, list) – List of additional collapse operators. Default: None.
e_ops (optional, list) – List of expectation operators. Default: None.
options (optional, qutip.Options) – qutip solver options. Note: defaults to max_step = 1.
only_final_state (optional, bool) – Whether to query the system’s state at only the initial and final times rather than at every time step in the Hamiltonian. Default: False.
progress_bar (optional, None) – Whether to use qutip’s progress bar. Default: None (no progress bar).
- Returns
qutip.Solver.Result instance.
- Return type
qutip.solver.Result
- propagator(c_ops=None, options=None, unitary_mode='batch', parallel=False)[source]
Calculate the propagator using
qutip.propagator().- Parameters
c_ops (list[qutip.Qobj]) – List of collapse operators.
options (optional, qutip.Options) – qutip solver options. Note: defaults to max_step = 1.
progress_bar (optional, None) – Whether to use qutip’s progress bar. Default: None (no progress bar).
unitary_mode (optional, "batch" or "single") – Solve all basis vectors simulaneously (“batch”) or individually (“single”). Default: “batch”.
parallel (optional, bool) – Run the propagator in parallel mode. This will override the unitary_mode settings if set to True. Default: False.
- Returns
List of Qobjs representing the propagator U(t).
- Return type
list[qutip.Qobj]
PulseSequence
- class sequencing.sequencing.PulseSequence(system=None, t0=0, items=None)[source]
Bases:
ValidatedListA list-like container of Operation, SyncOperation, DelayOperation, and DelayChannelOperation objects, which can be compiled into a CompiledPulseSequence at a later time.
- Parameters
- compile()[source]
Compiles the PulseSequence into a CompiledPulseSequence.
- Returns
A new CompiledPulseSequence.
- Return type
- property times
Array of times.
- property channels
Dict of Hamiltonian channels.
- run(init_state, c_ops=None, e_ops=None, options=None, only_final_state=False, progress_bar=None)[source]
Simulate the sequence using qutip.mesolve.
- Parameters
init_state (qutip.Qobj) – Inital state of the system.
c_ops (optional, list) – List of additional collapse operators. Default: None.
e_ops (optional, list) – List of expectation operators. Default: None.
options (optional, qutip.Options) – qutip solver options. Note: defaults to max_step = 1.
only_final_state (optional, bool) – Whether to query the system’s state at only the initial and final times rather than at every time step in the Hamiltonian. Default: False.
progress_bar (optional, None) – Whether to use qutip’s progress bar. Default: None (no progress bar).
- Returns
qutip.solver.Result instance.
- Return type
qutip.solver.Result
- propagator(c_ops=None, options=None, unitary_mode='batch', parallel=False, progress_bar=None)[source]
Calculate the propagator using
qutip.propagator().- Parameters
c_ops (list[qutip.Qobj]) – List of collapse operators.
options (optional, qutip.Options) – qutip solver options. Note: defaults to max_step = 1.
progress_bar (optional, None) – Whether to use qutip’s progress bar. Default: None (no progress bar).
unitary_mode (optional, "batch" or "single") – Solve all basis vectors simulaneously (“batch”) or individually (“single”). Default: “batch”.
parallel (optional, bool) – Run the propagator in parallel mode. This will override the unitary_mode settings if set to True. Default: False.
- Returns
List of Qobjs representing the propagator U(t).
- Return type
list[qutip.Qobj]
- plot_coefficients(subplots=True, plot_imag=False, step=False)[source]
Plot the Hamiltionian coefficients for all channels.
- Parameters
- Returns
(fig, ax): matplotlib Figure and axes.
- Return type
- append(item)
Add an item to the end of the ValidatedList.
- clear()
Remove all items from the ValidatedList.
- extend(iterable)
Extend the ValidatedList by appending all the items from the iterable.
- insert(i, item)
Insert an item at a given position in the ValidatedList.
- pop(i=-1)
Remove the item at the given position in the ValidatedList, and return it.
Sequence
- class sequencing.sequencing.main.Sequence(system, operations=None)[source]
Bases:
ValidatedListA list-like container of PulseSequence, Operation, and unitary objects, which can be used to evolve an initial state.
- Parameters
system (System) – System upon which the sequence will act.
operations (optional, list[qutip.Qobj, PulseSequence, Operation]) – Initial list of Operations or unitaries. Default: None.
- run(init_state, e_ops=None, options=None, full_evolution=True, progress_bar=False)[source]
Evolves init_state using each PulseSequence, Operation, or unitary applied in series.
- Parameters
init_state (qutip.Qobj) – Initial state to evolve.
options (optional, qutip.Options) – qutip solver options. Default: None.
full_evolution (optional, bool) – Whether to store the states for every time point in the included Sequences. If False, only the final state will be stored. Default: True.
progress_bar (optional, bool) – If True, displays a progress bar when iterating through the Sequence. Default:True.
- Returns
SequenceResult containing the time evolution of the system.
- Return type
- propagator(c_ops=None, options=None, unitary_mode='batch', parallel=False, progress_bar=False)[source]
Calculate the propagator using
qutip.propagator().- Parameters
c_ops (list[qutip.Qobj]) – List of collapse operators.
options (optional, qutip.Options) – qutip solver options. Note: defaults to max_step = 1.
progress_bar (optional, bool) – Whether to use qutip’s progress bar. Default: None (no progress bar).
unitary_mode (optional, "batch" or "single") – Solve all basis vectors simulaneously (“batch”) or individually (“single”). Default: “batch”.
parallel (optional, bool) – Run the propagator in parallel mode. This will override the unitary_mode settings if set to True. Default: False.
progress_bar – If True, displays a progress bar when iterating through the Sequence. Default:True.
- Returns
List of Qobjs representing the propagator U(t).
- Return type
list[qutip.Qobj]
- plot_coefficients(subplots=True, sharex=True, sharey=True)[source]
Plot the Hamiltionian coefficients for all channels. Unitaries are represented by vertical lines.
- Parameters
- Returns
(fig, ax): matplotlib Figure and axes.
- Return type
- append(item)
Add an item to the end of the ValidatedList.
- clear()
Remove all items from the ValidatedList.
- extend(iterable)
Extend the ValidatedList by appending all the items from the iterable.
- insert(i, item)
Insert an item at a given position in the ValidatedList.
- pop(i=-1)
Remove the item at the given position in the ValidatedList, and return it.
SequenceResult
HTerm
- class sequencing.sequencing.HTerm(H, coeffs, args, kwargs)
A
namedtuplespecifying a time-depdendent Hamiltonian term.- Parameters
H (qutip.Qobj) – The Hamiltonian operator.
coeffs (optional, number, array-like, or callable) – Time-dependent coefficients for the given operator. You can specify single int/float/complex for constant coefficients, or provide a function that takes time as its first argument and returns coefficiencts. Default: None.
args (optional, iterable) – Positional arguments passed to coeffs if coeffs is callable. Default: None.
kwargs (optional, dict) – Keyword arguments passed to coeffs if coeffs is a function. Default: None.
- H
Alias for field number 0
- args
Alias for field number 2
- coeffs
Alias for field number 1
- kwargs
Alias for field number 3
CTerm
- class sequencing.sequencing.CTerm(op, coeffs, args, kwargs)
A
namedtuplespecifying a time-depdendent collapse operator.- Parameters
op (qutip.Qobj) – The collapse operator.
coeffs (optional, number, array-like, or callable) – Time-dependenct oefficients for the given operator. You can specify single int/float/complex for constant coefficients, or provide a function that takes time as its first argument and returns coefficiencts. Default: None.
args (optional, iterable) – Positional arguments passed to coeffs if coeffs is callable. Default: None.
kwargs (optional, dict) – Keyword arguments passed to coeffs if coeffs is a function. Default: None.
- args
Alias for field number 2
- coeffs
Alias for field number 1
- kwargs
Alias for field number 3
- op
Alias for field number 0
Operation
SyncOperation
- class sequencing.sequencing.SyncOperation[source]
When inserted into a PulseSequence, ensures that the Hamiltonian channels all align up to this point.
This means that all operations which follow the sync will be executed after all those before the sync. Sequences are constructed in terms of blocks of operations separated by syncs. Within a block, channels are made to have equal duration by padding shorter channels to the maximum channel length.
See also
DelayOperation
- class sequencing.sequencing.DelayOperation(length, sync_before=True, sync_after=True)[source]
When inserted into a PulseSequence, adds a global delay to the sequence, delaying all channels by the same amount.
See also
DelayChannelsOperation
- class sequencing.sequencing.DelayChannelsOperation(channels, length)[source]
When inserted into a PulseSequence, adds a delay of duration
lengthto only the channels specified inchannels.- Parameters
channels (str | list | dict) – Either the name of a single channel, a list of channel names, or a dict of the form {channel_name: H_op}, or a dict of the form {channel_name: (H_op, C_op)}. One of the latter two is required if the channels are not yet defined in seq.channels (i.e. if no previous Operations have involved these channels).
length (int) – Duration of the delay.
ValidatedList
- class sequencing.sequencing.common.ValidatedList(iterable=None)[source]
A list-like container which is enforced to only accept values of the types listed in the class attribute
VALID_TYPES.- Parameters
iterable (optional, iterable) – Iterable of initial values with which to populate the list. Default: None.
Gates
TwoQubitGate
ControlledTwoQubitGate
- class sequencing.gates.twoqubit.ControlledTwoQubitGate(control=None, target=None)[source]
Bases:
TwoQubitGateAn object representing a controlled 2-qubit gate, which handles validation of the objects on which it acts, as well as the creation of logical states for use in constructing the gate.
Control qubit is listed first, target is second.
CUGate
- class sequencing.gates.twoqubit.CUGate(control=None, target=None)[source]
Bases:
ControlledTwoQubitGateControlled-U gate.
\[\begin{split}CU(\theta,\phi,\lambda) &= |00\rangle\langle00|\\ &+ |01\rangle\langle01|\\ &+ \cos(\theta/2)|10\rangle\langle10|\\ &+ e^{i(\phi + \lambda)}\cos(\theta/2)|11\rangle\langle11|\\ &+ e^{i\phi}\sin(\theta/2)|11\rangle\langle10|\\ &- e^{i\lambda}\sin(\theta/2)|10\rangle\langle11|\\\end{split}\]- Parameters
See also
CXGate
CYGate
CZGate
CPhaseGate
- class sequencing.gates.CPhaseGate(control=None, target=None)[source]
Bases:
ControlledTwoQubitGateControlled-phase gate.
\[\begin{split}C_\text{phase} &= |00\rangle\langle00|\\ &+ |01\rangle\langle01|\\ &+ |10\rangle\langle10|\\ &+ e^{i\varphi}|11\rangle\langle11|\\ &= CU(0, 0, \varphi)\end{split}\]- Parameters
- __call__(phi)[source]
- Parameters
phi (float) – Phase in radians.
- Returns
The Cphase operator.
- Return type
qutip.Qobj
See also
SWAPGate
- class sequencing.gates.SWAPGate(qubit1, qubit2)[source]
Bases:
TwoQubitGateSWAP gate.
\[\begin{split}\text{SWAP} &= |00\rangle\langle00|\\ &+ |01\rangle\langle10|\\ &+ |10\rangle\langle01|\\ &+ |11\rangle\langle11|\\\end{split}\]- Parameters
See also
SWAPphiGate
- class sequencing.gates.SWAPphiGate(control=None, target=None)[source]
SWAPphi gate.
\[\begin{split}\text{SWAP}_\varphi &= |00\rangle\langle00|\\ &+ ie^{-i\varphi}|01\rangle\langle10|\\ &- ie^{i\varphi}|10\rangle\langle01|\\ &+ |11\rangle\langle11|\\\end{split}\]Note
SWAPphi is only a “controlled” gate for certain values of \(\varphi\). For \(\varphi = n\pi + \frac{\pi}{2}\) the gate is symmetric with respect to qubit ordering.
- Parameters
- __call__(phi)[source]
- Parameters
phi (float) – Phase in radians.
- Returns
The SWAPphi operator.
- Return type
qutip.Qobj
See also
iSWAPGate
- class sequencing.gates.iSWAPGate(qubit1, qubit2)[source]
Bases:
TwoQubitGateiSWAP gate.
\[\begin{split}i\text{SWAP} &= |00\rangle\langle00|\\ &+ i|01\rangle\langle10|\\ &+ i|10\rangle\langle01|\\ &+ |11\rangle\langle11|\\\end{split}\]- Parameters
See also
eSWAPGate
- class sequencing.gates.eSWAPGate(control=None, target=None)[source]
Bases:
ControlledTwoQubitGateeSWAP gate.
\[\begin{split}e\text{SWAP}_\varphi(\theta_c) &= \exp(-i\theta_c/2\cdot\text{SWAP}\varphi)\\ &= \cos(\theta_c/2) I - i\sin(\theta_c/2)\text{SWAP}_\varphi\end{split}\]Note
eSWAP is only a “controlled” gate for certain values of \(\varphi\). For \(\varphi = n\pi + \frac{\pi}{2}\) the gate is symmetric with respect to qubit ordering.
- Parameters
See also
SqrtSWAPGate
- class sequencing.gates.SqrtSWAPGate(qubit1, qubit2)[source]
Bases:
TwoQubitGateSqrtSWAP gate.
\[\sqrt{\text{SWAP}}\]- Parameters
See also
SqrtiSWAPGate
- class sequencing.gates.SqrtiSWAPGate(qubit1, qubit2)[source]
Bases:
TwoQubitGateSqrtiSWAP gate.
\[\sqrt{i\text{SWAP}}\]- Parameters
See also
QASM
QasmSequence
- class sequencing.qasm.QasmSequence(system, operations=None)[source]
Bases:
SequenceA Sequence with methods implementing the single-qubit gates defined in the OpenQASM specification.
References
- Parameters
system (System) – System upon which the sequence will act.
operations – (optional, list[CompiledPulseSequence, Operation, Sequence]): Initial list of Operations or unitaries. Default: None.
- U(theta, phi, lamda, *qubits, unitary=True, append=True)[source]
- \[U(\theta,\phi,\lambda) = u_3(\theta,\phi,\lambda) = R_z(\phi)R_y(\theta)R_z(\lambda)\]
- Returns
qutip.Qobjor list[qutip.Qobj] or None
- u3(theta, phi, lamda, *qubits, unitary=True, append=True)
- \[U(\theta,\phi,\lambda) = u_3(\theta,\phi,\lambda) = R_z(\phi)R_y(\theta)R_z(\lambda)\]
- Returns
qutip.Qobjor list[qutip.Qobj] or None
- u2(phi, lamda, *qubits, unitary=True, append=True)[source]
- \[u_2(\phi,\lambda) = U(\pi/2,\phi,\lambda)\]
- Returns
qutip.Qobjor list[qutip.Qobj] or None
- u1(lamda, *qubits, append=True)[source]
- \[p(\lambda) = u_1(\lambda) = U(0,0,\lambda) = R_z(\lambda)\]
- Returns
qutip.Qobjor list[qutip.Qobj] or None
- p(lamda, *qubits, append=True)
- \[p(\lambda) = u_1(\lambda) = U(0,0,\lambda) = R_z(\lambda)\]
- Returns
qutip.Qobjor list[qutip.Qobj] or None
- id(*qubits, unitary=True, append=True)[source]
Identity.
\[I = U(0,0,0)\]- Returns
qutip.Qobjor None
- x(*qubits, unitary=True, append=True)[source]
- \[x = u_3(\pi,0,\pi)\]
- Returns
qutip.Qobjor list[qutip.Qobj] or None
- y(*qubits, unitary=True, append=True)[source]
- \[y = u_3(\pi,\pi/2,\pi/2)\]
- Returns
qutip.Qobjor list[qutip.Qobj] or None
- h(*qubits, unitary=True, append=True)[source]
- \[h = i \cdot u_2(0,\pi)\]
- Returns
qutip.Qobjor list[qutip.Qobj] or None
- s(*qubits, append=True)[source]
- \[s = \sqrt{z} = u_1(\pi/2) = R_z(\pi/2)\]
- Returns
qutip.Qobjor list[qutip.Qobj] or None
- sdg(*qubits, append=True)[source]
- \[s^\dagger = u_1(-\pi/2) = R_z(-\pi/2)\]
- Returns
qutip.Qobjor list[qutip.Qobj] or None
- t(*qubits, append=True)[source]
- \[t = u_1(\pi/4) = R_z(\pi/4)\]
- Returns
qutip.Qobjor list[qutip.Qobj] or None
- tdg(*qubits, append=True)[source]
- \[t^\dagger = u_1(-\pi/4) = R_z(-\pi/4)\]
- Returns
qutip.Qobjor list[qutip.Qobj] or None
- rx(theta, *qubits, unitary=True, append=True)[source]
- \[R_x(\theta) = u_3(\theta,-\pi/2,\pi/2)\]
- Returns
qutip.Qobjor list[qutip.Qobj] or None
- ry(theta, *qubits, unitary=True, append=True)[source]
- \[R_y(\theta) = u_3(\theta,0,0)\]
- Returns
qutip.Qobjor list[qutip.Qobj] or None
- sx(*qubits, unitary=True, append=True)[source]
- \[\begin{split}\sqrt{X} &= \exp(i\pi/4)R_x(\pi/2)\\ &= \exp(-i\pi/4)R_z(-\pi/2)\cdot H\cdot R_z(-\pi/2)\\ &= \exp(-i\pi/4)s^\dagger\cdot H\cdot s^\dagger\end{split}\]
- Returns
qutip.Qobjor list[qutip.Qobj] or None
- gphase(gamma, *qubits, append=True)[source]
Adds a global phase to the sequence.
- Parameters
- Returns
If append is False, returns the gphase unitary, otherwise returns None.
- Return type
qutip.Qobjor None
- CX(control, target, append=True)[source]
Controlled-X gate.
\[\begin{split}CX &= |00\rangle\langle00|\\ &+ |01\rangle\langle01|\\ &+ |11\rangle\langle10|\\ &+ |10\rangle\langle11|\\\end{split}\]- Parameters
- Returns
If append is False, returns the CX unitary, otherwise returns None.
- Return type
qutip.Qobjor None
- barrier(*args, append=True)[source]
Equivalent to
sync().NOTE: Currently only a “global” barrier/sync is supported.
- assemble()[source]
Rearrange the sequence so that blocks of operations not separated by a barrier are executed in parallel.
- qasm(qasm_str, unitary=True, append=True)[source]
Executes a gate specified by a single QASM instruction, e.g. ‘rx(pi) q[0];’. The qubit index in the QuantumRegister corresponds to the index in self.system.active_modes.
- Parameters
qasm_str (str) – String specifying the QASM gate to execute.
unitary (optional, bool) – Whether to use the unitary instead of pulse-based version of the gate. This argument is ignored if only the unitary version exists. Default: True.
append (optional, bool) – Whether to append the gate to self instead of returning it to the user. This argument is ignored for barrier. Default: True.
- Returns
If append is False, returns the result of the gate, which will be either an Operation, a qutip.Qobj, or a list composed of those types. If append is True, returns None.
- Return type
list, Operation,
qutip.Qobj, or None
- qasm_circuit(circuit, unitary=True, append=True)[source]
Executes a full QASM circuit, ignoring reset, measure, and conditional instructions.
- Parameters
circuit (str or list[str]) – The circuit to execute, either as a list of gates or as a newline-delimited string.
unitary (optional, bool) – Whether to use the unitary instead of pulse-based version of the each gate. This argument is ignored if only the unitary version exists. Default: True.
append (optional, bool) – Whether to append each gate to self instead of returning it to the user. This argument is ignored for barrier. Default: True.
- Returns
If append is False, returns a list of
Operation(if unitary is False) andqutip.Qobj. If append is True, returns None.- Return type
list or None
- run(init_state, e_ops=None, options=None, full_evolution=True, progress_bar=False)[source]
Evolves init_state using each PulseSequence, Operation, or unitary applied in series.
- Parameters
init_state (qutip.Qobj) – Initial state to evolve.
options (optional, qutip.Options) – qutip solver options. Default: None.
full_evolution (optional, bool) – Whether to store the states for every time point in the included Sequences. If False, only the final state will be stored. Default: True.
progress_bar (optional, bool) – If True, displays a progress bar when iterating through the Sequence. Default:True.
- Returns
SequenceResult containing the time evolution of the system.
- Return type
- plot_coefficients(subplots=True, sharex=True, sharey=True)[source]
Plot the Hamiltionian coefficients for all channels. Unitaries are represented by vertical lines.
- Parameters
- Returns
(fig, ax): matplotlib Figure and axes.
- Return type
- measure(state, *qubits)[source]
Meausure each qubit in its logical basis by tracing over all other modes and then taking the expectation value of the projector onto logical one acting on the state.
- append(item)
Add an item to the end of the ValidatedList.
- capture()
Appends the current pulse sequence if it is not empty.
- clear()
Remove all items from the ValidatedList.
- extend(iterable)
Extend the ValidatedList by appending all the items from the iterable.
- insert(i, item)
Insert an item at a given position in the ValidatedList.
- pop(i=-1)
Remove the item at the given position in the ValidatedList, and return it.
- propagator(c_ops=None, options=None, unitary_mode='batch', parallel=False, progress_bar=False)
Calculate the propagator using
qutip.propagator().- Parameters
c_ops (list[qutip.Qobj]) – List of collapse operators.
options (optional, qutip.Options) – qutip solver options. Note: defaults to max_step = 1.
progress_bar (optional, bool) – Whether to use qutip’s progress bar. Default: None (no progress bar).
unitary_mode (optional, "batch" or "single") – Solve all basis vectors simulaneously (“batch”) or individually (“single”). Default: “batch”.
parallel (optional, bool) – Run the propagator in parallel mode. This will override the unitary_mode settings if set to True. Default: False.
progress_bar – If True, displays a progress bar when iterating through the Sequence. Default:True.
- Returns
List of Qobjs representing the propagator U(t).
- Return type
list[qutip.Qobj]
- reset_pulse_sequence()
Reset the current pulse sequence.
Benchmarking
Benchmark
- class sequencing.benchmarking.Benchmark(sequence, init_state, target_unitary, run_sequence=True)[source]
A class for comparing the performance of a given control sequence to a target unitary.
- Parameters
sequence (PulseSequence, CompiledPulseSequence, or Sequence) – The sequence to benchmark.
init_state (qutip.Qobj) – The initial state of the system.
target_unitary (qutip.Qobj) – The unitary to which to compare the sequence.
run_sequence (optional, bool) – Whether to run the sequence immediately upon creating the Benchmark. Default: True.
- run_sequence(**kwargs)[source]
Simulate the sequence and save the final state.
Keyword arguments are passed to
self.seq.run().
- fidelity(target_state=None)[source]
Returns the fidelty of the state resulting from the sequence to the target state.
- Parameters
target_state (optional, qutip.Qobj) – State to which to compare the final state. Defaults to``target_unitary * init_state``.
- Returns
float or None
- tracedist(target_state=None, sparse=False, tol=0)[source]
Returns the trace distance from the state resulting from the sequence to the target state.
- Parameters
target_state (optional, qutip.Qobj) – State to which to compare the final state. Defaults to``target_unitary * init_state``.
sparse – See
qutip.tracedist.tol – See
qutip.tracedist.
- Returns
float or None
- plot_wigners(target_state=None, actual_state=None, sel=None, cmap='RdBu', disp_range=(-5, 5, 201))[source]
Plots the Wigner function of the final state and the target state.
- Parameters
target_state (optional, qutip.Qobj) – State to which to compare the final state. Defaults to``target_unitary * init_state``.
actual_state (optional, qutip.Qobj) – State to compare the target_state. Defaults to
self.mesolve_state.sel (optional, int or list[int]) – Indices of modes to keep when taking the partial trace of the target and actual states. If None, no partial trace is taken. Default: None.
cmap (optional, str) – Name of the matplotlib colormap to use. Default: ‘RdBu’
disp_range (tuple[float, float, int]) – Range of displacements to use when compouting the Wigner function, specified as (start, stop, num_steps). Default: (-5, 5, 201).
- Returns
matplotlib Figure and Axis.
- Return type
- plot_fock_distribution(target_state=None, actual_state=None, sel=None, offset=0, ax=None, unit_y_range=True)[source]
Plots the photon number distribution of the target and actual states.
- Parameters
target_state (optional, qutip.Qobj) – State to which to compare the final state. Defaults to``target_unitary * init_state``.
actual_state (optional, qutip.Qobj) – State to compare the target_state. Defaults to
self.mesolve_state.sel (optional, int or list[int]) – Indices of modes to keep when taking the partial trace of the target and actual states. If None, no partial trace is taken. Default: None.
offset (optional, int) – Minimum photon number to plot. Default: 0.
ax (optional, Axis) – matplotlib axis on which to plot. If None, one is automatically created. Default: None.
unit_y_range (optional, bool) – Whether to force the y axis limits to (0, 1). Default: True.
- Returns
matplotlib Figure and Axis.
- Return type