A class for representing quantum objects, such as quantum operators and states.
The Qobj class is the QuTiP representation of quantum operators and state vectors. This class also implements math operations +,,* between Qobj instances (and / by a Cnumber), as well as a collection of common operator/state operations. The Qobj constructor optionally takes a dimension list and/or shape list as arguments.
Parameters:  inpt : array_like
dims : list
shape : list
fast : bool


Attributes
data  (array_like) Sparse matrix characterizing the quantum object. 
dims  (list) List of dimensions keeping track of the tensor structure. 
shape  (list) Shape of the underlying data array. 
type  (str) Type of quantum object: ‘bra’, ‘ket’, ‘oper’, ‘operatorket’, ‘operatorbra’, or ‘super’. 
superrep  (str) Representation used if type is ‘super’. One of ‘super’ (Liouville form) or ‘choi’ (Choi matrix with tr = dimension). 
isherm  (bool) Indicates if quantum object represents Hermitian operator. 
iscp  (bool) Indicates if the quantum object represents a map, and if that map is completely positive (CP). 
istp  (bool) Indicates if the quantum object represents a map, and if that map is trace preserving (TP). 
iscptp  (bool) Indicates if the quantum object represents a map that is completely positive and trace preserving (CPTP). 
isket  (bool) Indicates if the quantum object represents a ket. 
isbra  (bool) Indicates if the quantum object represents a bra. 
isoper  (bool) Indicates if the quantum object represents an operator. 
issuper  (bool) Indicates if the quantum object represents a superoperator. 
isoperket  (bool) Indicates if the quantum object represents an operator in column vector form. 
isoperbra  (bool) Indicates if the quantum object represents an operator in row vector form. 
Methods
conj()  Conjugate of quantum object. 
dag()  Adjoint (dagger) of quantum object. 
eigenenergies(sparse=False, sort=’low’, eigvals=0, tol=0, maxiter=100000)  Returns eigenenergies (eigenvalues) of a quantum object. 
eigenstates(sparse=False, sort=’low’, eigvals=0, tol=0, maxiter=100000)  Returns eigenenergies and eigenstates of quantum object. 
expm()  Matrix exponential of quantum object. 
full()  Returns dense array of quantum object data attribute. 
groundstate(sparse=False,tol=0,maxiter=100000)  Returns eigenvalue and eigenket for the groundstate of a quantum object. 
matrix_element(bra, ket)  Returns the matrix element of operator between bra and ket vectors. 
norm(norm=’tr’, sparse=False, tol=0, maxiter=100000)  Returns norm of a ket or an operator. 
permute(order)  Returns composite qobj with indices reordered. 
ptrace(sel)  Returns quantum object for selected dimensions after performing partial trace. 
sqrtm()  Matrix square root of quantum object. 
tidyup(atol=1e12)  Removes small elements from quantum object. 
tr()  Trace of quantum object. 
trans()  Transpose of quantum object. 
transform(inpt, inverse=False)  Performs a basis transformation defined by inpt matrix. 
unit(norm=’tr’, sparse=False, tol=0, maxiter=100000)  Returns normalized quantum object. 
Check if the quantum object is hermitian.
Returns:  isherm: bool


Conjugate operator of quantum object.
Adjoint operator of quantum object.
Diagonal elements of quantum object.
Returns:  diags: array


Eigenenergies of a quantum object.
Eigenenergies (eigenvalues) are defined for operators or superoperators only.
Parameters:  sparse : bool
sort : str
eigvals : int
tol : float
maxiter : int


Returns:  eigvals: array

Notes
The sparse eigensolver is much slower than the dense version. Use sparse only if memory requirements demand it.
Eigenstates and eigenenergies.
Eigenstates and eigenenergies are defined for operators and superoperators only.
Parameters:  sparse : bool
sort : str
eigvals : int
tol : float
maxiter : int


Returns:  eigvals : array
eigvecs : array

Notes
The sparse eigensolver is much slower than the dense version. Use sparse only if memory requirements demand it.
Creates a new quantum object with states in state_inds eliminated.
Parameters:  states_inds : list of integer
normalize : True / False


Returns:  q : qutip.Qobj
Note Experimental. 
Evaluate a timedependent quantum object in list format. For example,
qobj_list = [H0, [H1, func_t]]
is evaluated to
Qobj(t) = H0 + H1 * func_t(t, args)
and
qobj_list = [H0, [H1, ‘sin(w * t)’]]
is evaluated to
Qobj(t) = H0 + H1 * sin(args[‘w’] * t)
Parameters:  qobj_list : list
t : float
args : dictionary


Returns:  output : Qobj

Matrix exponential of quantum operator.
Input operator must be square.
Parameters:  method : str {‘dense’, ‘sparse’, ‘scipydense’, ‘scipysparse’}


Returns:  oper : qobj

Raises:  TypeError

Qobj with states in state_inds only.
Parameters:  states_inds : list of integer
normalize : True / False


Returns:  q : qutip.Qobj
Note Experimental. 
Dense array from quantum object.
Returns:  data : array


Ground state Eigenvalue and Eigenvector.
Defined for quantum operators or superoperators only.
Parameters:  sparse : bool
tol : float
maxiter : int


Returns:  eigval : float
eigvec : qobj

Notes
The sparse eigensolver is much slower than the dense version. Use sparse only if memory requirements demand it.
Calculates a matrix element.
Gives the matrix element for the quantum object sandwiched between a bra and ket vector.
Parameters:  bra : qobj
ket : qobj


Returns:  elem : complex

Raises:  TypeError

Norm of a quantum object.
Default norm is L2norm for kets and tracenorm for operators. Other ket and operator norms may be specified using the norm and argument.
Parameters:  norm : str
sparse : bool
tol : float
maxiter : int


Returns:  norm : float

Notes
The sparse eigensolver is much slower than the dense version. Use sparse only if memory requirements demand it.
Overlap between two state vectors.
Gives the overlap (scalar product) for the quantum object and state state vector.
Parameters:  state : qobj


Returns:  overlap : complex

Raises:  TypeError

Permutes a composite quantum object.
Parameters:  order : list/array


Returns:  P : qobj

Partial trace of the quantum object.
Parameters:  sel : int/list


Returns:  oper: qobj

Notes
This function is identical to the qutip.qobj.ptrace function that has been deprecated.
Sqrt of a quantum operator.
Operator must be square.
Parameters:  sparse : bool
tol : float
maxiter : int


Returns:  oper: qobj

Raises:  TypeError

Notes
The sparse eigensolver is much slower than the dense version. Use sparse only if memory requirements demand it.
Removes small elements from the quantum object.
Parameters:  atol : float


Returns:  oper: qobj

Trace of a quantum object.
Returns:  trace: float


Transposed operator.
Returns:  oper : qobj


Basis transform defined by input array.
Input array can be a matrix defining the transformation, or a list of kets that defines the new basis.
Parameters:  inpt : array_like
inverse : bool


Returns:  oper : qobj

Notes
This function is still in development.
Operator or state normalized to unity.
Uses norm from Qobj.norm().
Parameters:  norm : str
sparse : bool
tol : float
maxiter: int


Returns:  oper : qobj

Class representation of an exponentialseries expansion of timedependent quantum objects.
Attributes
ampl  (ndarray) Array of amplitudes for exponential series. 
rates  (ndarray) Array of rates for exponential series. 
dims  (list) Dimensions of exponential series components 
shape  (list) Shape corresponding to exponential series components 
Methods
value(tlist)  Evaluate an exponential series at the times listed in tlist 
spec(wlist)  Evaluate the spectrum of an exponential series at frequencies in wlist. 
tidyup()  Returns a tidier version of the exponential series 
Evaluate the spectrum of an exponential series at frequencies in wlist.
Parameters:  wlist : array_like


Returns:  val_list : ndarray

Returns a tidier version of exponential series.
Evaluates an exponential series at the times listed in tlist.
Parameters:  tlist : ndarray


Returns:  val_list : ndarray

Class for plotting data on the Bloch sphere. Valid data can be either points, vectors, or qobj objects.
Attributes
axes  (instance {None}) User supplied Matplotlib axes for Bloch sphere animation. 
fig  (instance {None}) User supplied Matplotlib Figure instance for plotting Bloch sphere. 
font_color  (str {‘black’}) Color of font used for Bloch sphere labels. 
font_size  (int {20}) Size of font used for Bloch sphere labels. 
frame_alpha  (float {0.1}) Sets transparency of Bloch sphere frame. 
frame_color  (str {‘gray’}) Color of sphere wireframe. 
frame_width  (int {1}) Width of wireframe. 
point_color  (list {[“b”,”r”,”g”,”#CC6600”]}) List of colors for Bloch sphere point markers to cycle through. i.e. By default, points 0 and 4 will both be blue (‘b’). 
point_marker  (list {[“o”,”s”,”d”,”^”]}) List of point marker shapes to cycle through. 
point_size  (list {[25,32,35,45]}) List of point marker sizes. Note, not all point markers look the same size when plotted! 
sphere_alpha  (float {0.2}) Transparency of Bloch sphere itself. 
sphere_color  (str {‘#FFDDDD’}) Color of Bloch sphere. 
figsize  (list {[7,7]}) Figure size of Bloch sphere plot. Best to have both numbers the same; otherwise you will have a Bloch sphere that looks like a football. 
vector_color  (list {[“g”,”#CC6600”,”b”,”r”]}) List of vector colors to cycle through. 
vector_width  (int {5}) Width of displayed vectors. 
vector_style  (str {‘>’, ‘simple’, ‘fancy’, ‘’}) Vector arrowhead style (from matplotlib’s arrow style). 
vector_mutation  (int {20}) Width of vectors arrowhead. 
view  (list {[60,30]}) Azimuthal and Elevation viewing angles. 
xlabel  (list {[“$x$”,”“]}) List of strings corresponding to +x and x axes labels, respectively. 
xlpos  (list {[1.1,1.1]}) Positions of +x and x labels respectively. 
ylabel  (list {[“$y$”,”“]}) List of strings corresponding to +y and y axes labels, respectively. 
ylpos  (list {[1.2,1.2]}) Positions of +y and y labels respectively. 
zlabel  (list {[r’$left0right>$’,r’$left1right>$’]}) List of strings corresponding to +z and z axes labels, respectively. 
zlpos  (list {[1.2,1.2]}) Positions of +z and z labels respectively. 
Methods
add_annotation  
add_points  
add_states  
add_vectors  
clear  
make_sphere  
plot_annotations  
plot_axes  
plot_axes_labels  
plot_back  
plot_front  
plot_points  
plot_vectors  
render  
save  
set_label_convention  
show 
Add a text or LaTeX annotation to Bloch sphere, parametrized by a qubit state or a vector.
Parameters:  state_or_vector : Qobj/array/list/tuple
text : str/unicode
**kwargs :


Add a list of data points to bloch sphere.
Parameters:  points : array/list
meth : str {‘s’, ‘m’, ‘l’}


Add a state vector Qobj to Bloch sphere.
Parameters:  state : qobj
kind : str {‘vector’,’point’}


Add a list of vectors to Bloch sphere.
Parameters:  vectors : array/list


Render the Bloch sphere and its data sets in on given figure and axes.
Saves Bloch sphere to file of type format in directory dirc.
Parameters:  name : str
format : str
dirc : str


Returns:  File containing plot of Bloch sphere. 
Set x, y and z labels according to one of conventions.
Parameters:  convention : string


Sets the width of the vectors arrowhead
Width of Bloch vectors, default = 5
Class for plotting data on a 3D Bloch sphere using mayavi. Valid data can be either points, vectors, or qobj objects corresponding to state vectors or density matrices. for a twostate system (or subsystem).
Notes
The use of mayavi for 3D rendering of the Bloch sphere comes with a few limitations: I) You can not embed a Bloch3d figure into a matplotlib window. II) The use of LaTex is not supported by the mayavi rendering engine. Therefore all labels must be defined using standard text. Of course you can postprocess the generated figures later to add LaTeX using other software if needed.
Attributes
fig  (instance {None}) User supplied Matplotlib Figure instance for plotting Bloch sphere. 
font_color  (str {‘black’}) Color of font used for Bloch sphere labels. 
font_scale  (float {0.08}) Scale for font used for Bloch sphere labels. 
frame  (bool {True}) Draw frame for Bloch sphere 
frame_alpha  (float {0.05}) Sets transparency of Bloch sphere frame. 
frame_color  (str {‘gray’}) Color of sphere wireframe. 
frame_num  (int {8}) Number of frame elements to draw. 
frame_radius  (floats {0.005}) Width of wireframe. 
point_color  (list {[‘r’, ‘g’, ‘b’, ‘y’]}) List of colors for Bloch sphere point markers to cycle through. i.e. By default, points 0 and 4 will both be blue (‘r’). 
point_mode  (string {‘sphere’,’cone’,’cube’,’cylinder’,’point’}) Point marker shapes. 
point_size  (float {0.075}) Size of points on Bloch sphere. 
sphere_alpha  (float {0.1}) Transparency of Bloch sphere itself. 
sphere_color  (str {‘#808080’}) Color of Bloch sphere. 
size  (list {[500,500]}) Size of Bloch sphere plot in pixels. Best to have both numbers the same otherwise you will have a Bloch sphere that looks like a football. 
vector_color  (list {[‘r’, ‘g’, ‘b’, ‘y’]}) List of vector colors to cycle through. 
vector_width  (int {3}) Width of displayed vectors. 
view  (list {[45,65]}) Azimuthal and Elevation viewing angles. 
xlabel  (list {[‘x>’, ‘’]}) List of strings corresponding to +x and x axes labels, respectively. 
xlpos  (list {[1.07,1.07]}) Positions of +x and x labels respectively. 
ylabel  (list {[‘y>’, ‘’]}) List of strings corresponding to +y and y axes labels, respectively. 
ylpos  (list {[1.07,1.07]}) Positions of +y and y labels respectively. 
zlabel  (list {[‘0>’, ‘1>’]}) List of strings corresponding to +z and z axes labels, respectively. 
zlpos  (list {[1.07,1.07]}) Positions of +z and z labels respectively. 
Methods
add_points  
add_states  
add_vectors  
clear  
make_sphere  
plot_points  
plot_vectors  
save  
show 
Add a list of data points to bloch sphere.
Parameters:  points : array/list
meth : str {‘s’,’m’}


Add a state vector Qobj to Bloch sphere.
Parameters:  state : qobj
kind : str {‘vector’,’point’}


Add a list of vectors to Bloch sphere.
Parameters:  vectors : array/list


Saves Bloch sphere to file of type format in directory dirc.
Parameters:  name : str
format : str
dirc : str


Returns:  File containing plot of Bloch sphere. 
Class of options for evolution solvers such as qutip.mesolve and qutip.mcsolve. Options can be specified either as arguments to the constructor:
opts = Options(order=10, ...)
or by changing the class attributes after creation:
opts = Options()
opts.order = 10
Returns options class to be used as options in evolution solvers.
Attributes
atol  (float {1e8}) Absolute tolerance. 
rtol  (float {1e6}) Relative tolerance. 
method  (str {‘adams’,’bdf’}) Integration method. 
order  (int {12}) Order of integrator (<=12 ‘adams’, <=5 ‘bdf’) 
nsteps  (int {2500}) Max. number of internal steps/call. 
first_step  (float {0}) Size of initial step (0 = automatic). 
min_step  (float {0}) Minimum step size (0 = automatic). 
max_step  (float {0}) Maximum step size (0 = automatic) 
tidy  (bool {True,False}) Tidyup Hamiltonian and initial state by removing small terms. 
num_cpus  (int) Number of cpus used by mcsolver (default = # of cpus). 
norm_tol  (float) Tolerance used when finding wavefunction norm in mcsolve. 
norm_steps  (int) Max. number of steps used to find wavefunction norm to within norm_tol in mcsolve. 
average_states  (bool {False}) Average states values over trajectories in stochastic solvers. 
average_expect  (bool {True}) Average expectation values over trajectories for stochastic solvers. 
mc_corr_eps  (float {1e10}) Arbitrarily small value for eliminating any dividebyzero errors in correlation calculations when using mcsolve. 
ntraj  (int {500}) Number of trajectories in stochastic solvers. 
rhs_reuse  (bool {False,True}) Reuse Hamiltonian data. 
rhs_with_state  (bool {False,True}) Whether or not to include the state in the Hamiltonian function callback signature. 
rhs_filename  (str) Name for compiled Cython file. 
seeds  (ndarray) Array containing random number seeds for mcsolver. 
store_final_state  (bool {False, True}) Whether or not to store the final state of the evolution in the result class. 
store_states  (bool {False, True}) Whether or not to store the state vectors or density matrices in the result class, even if expectation values operators are given. If no expectation are provided, then states are stored by default and this option has no effect. 
Class for storing simulation results from any of the dynamics solvers.
Attributes
solver  (str) Which solver was used [e.g., ‘mesolve’, ‘mcsolve’, ‘brmesolve’, ...] 
times  (list/array) Times at which simulation data was collected. 
expect  (list/array) Expectation values (if requested) for simulation. 
states  (array) State of the simulation (density matrix or ket) evaluated at times. 
num_expect  (int) Number of expectation value operators in simulation. 
num_collapse  (int) Number of collapse operators in simualation. 
ntraj  (int/list) Number of trajectories (for stochastic solvers). A list indicates that averaging of expectation values was done over a subset of total number of trajectories. 
col_times  (list) Times at which state collpase occurred. Only for Monte Carlo solver. 
col_which  (list) Which collapse operator was responsible for each collapse in col_times. Only for Monte Carlo solver. 
Class of options for stochastic solvers such as qutip.stochastic.ssesolve, qutip.stochastic.smesolve, etc. Options can be specified either as arguments to the constructor:
sso = StochasticSolverOptions(nsubsteps=100, ...)
or by changing the class attributes after creation:
sso = StochasticSolverOptions()
sso.nsubsteps = 1000
The stochastic solvers qutip.stochastic.ssesolve, qutip.stochastic.smesolve, qutip.stochastic.ssepdpsolve and qutip.stochastic.smepdpsolve all take the same keyword arguments as the constructor of these class, and internally they use these arguments to construct an instance of this class, so it is rarely needed to explicitly create an instance of this class.
Attributes
H  (qutip.Qobj) System Hamiltonian. 
state0  (qutip.Qobj) Initial state vector (ket) or density matrix. 
times  (list / array) List of times for \(t\). Must be uniformly spaced. 
c_ops  (list of qutip.Qobj) List of deterministic collapse operators. 
sc_ops  (list of qutip.Qobj) List of stochastic collapse operators. Each stochastic collapse operator will give a deterministic and stochastic contribution to the equation of motion according to how the d1 and d2 functions are defined. 
e_ops  (list of qutip.Qobj) Single operator or list of operators for which to evaluate expectation values. 
m_ops  (list of qutip.Qobj) List of operators representing the measurement operators. The expected format is a nested list with one measurement operator for each stochastic increament, for each stochastic collapse operator. 
args  (dict / list) List of dictionary of additional problemspecific parameters. 
ntraj  (int) Number of trajectors. 
nsubsteps  (int) Number of sub steps between each timespep given in times. 
d1  (function) Function for calculating the operatorvalued coefficient to the deterministic increment dt. 
d2  (function) Function for calculating the operatorvalued coefficient to the stochastic increment(s) dW_n, where n is in [0, d2_len[. 
d2_len  (int (default 1)) The number of stochastic increments in the process. 
dW_factors  (array) Array of length d2_len, containing scaling factors for each measurement operator in m_ops. 
rhs  (function) Function for calculating the deterministic and stochastic contributions to the righthand side of the stochastic differential equation. This only needs to be specified when implementing a custom SDE solver. 
generate_A_ops  (function) Function that generates a list of precomputed operators or super operators. These precomputed operators are used in some d1 and d2 functions. 
generate_noise  (function) Function for generate an array of precomputed noise signal. 
homogeneous  (bool (True)) Wheter or not the stochastic process is homogenous. Inhomogenous processes are only supported for poisson distributions. 
solver  (string) Name of the solver method to use for solving the stochastic equations. Valid values are: ‘eulermaruyama’, ‘fasteulermaruyama’, ‘milstein’, ‘fastmilstein’, ‘platen’. 
method  (string (‘homodyne’, ‘heterodyne’, ‘photocurrent’)) The name of the type of measurement process that give rise to the stochastic equation to solve. Specifying a method with this keyword argument is a shorthand notation for using predefined d1 and d2 functions for the corresponding stochastic processes. 
distribution  (string (‘normal’, ‘poission’)) The name of the distribution used for the stochastic increments. 
store_measurements  (bool (default False)) Whether or not to store the measurement results in the qutip.solver.SolverResult instance returned by the solver. 
noise  (array) Vector specifying the noise. 
normalize  (bool (default True)) Whether or not to normalize the wave function during the evolution. 
options  (qutip.solver.Options) Generic solver options. 
map_func: function  A map function or managing the calls to singletrajactory solvers. 
map_kwargs: dictionary  Optional keyword arguments to the map_func function function. 
progress_bar  (qutip.ui.BaseProgressBar) Optional progress bar class instance. 
A class for representation spatial distribution functions.
The Distribution class can be used to prepresent spatial distribution functions of arbitray dimension (although only 1D and 2D distributions are used so far).
It is indented as a base class for specific distribution function, and provide implementation of basic functions that are shared among all Distribution functions, such as visualization, calculating marginal distributions, etc.
Parameters:  data : array_like
xvecs : list
xlabels : list


Methods
marginal  
project  
visualize  
visualize_1d  
visualize_2d_colormap  
visualize_2d_surface 
Calculate the marginal distribution function along the dimension dim. Return a new Distribution instance describing this reduced dimensionality distribution.
Parameters:  dim : int


Returns:  d : Distributions

Calculate the projection (max value) distribution function along the dimension dim. Return a new Distribution instance describing this reduceddimensionality distribution.
Parameters:  dim : int


Returns:  d : Distributions

Visualize the data of the distribution in 1D or 2D, depending on the dimensionality of the underlaying distribution.
Parameters:
Returns:  fig, ax : tuple


Methods
marginal  
project  
update  
visualize  
visualize_1d  
visualize_2d_colormap  
visualize_2d_surface 
Methods
marginal  
project  
update  
visualize  
visualize_1d  
visualize_2d_colormap  
visualize_2d_surface 
Methods
marginal  
project  
update  
update_psi  
update_rho  
visualize  
visualize_1d  
visualize_2d_colormap  
visualize_2d_surface 
calculate probability distribution for quadrature measurement outcomes given a twomode wavefunction or density matrix
Methods
marginal  
project  
update  
visualize  
visualize_1d  
visualize_2d_colormap  
visualize_2d_surface 
Representation of a quantum gate, with its required parametrs, and target and control qubits.
Representation of a quantum program/algorithm, maintaining a sequence of gates.
Attributes
png  
svg 
Methods
add_1q_gate  
add_circuit  
add_gate  
adjacent_gates  
latex_code  
propagators  
qasm  
remove_gate  
resolve_gates  
reverse_circuit 
Adds a single qubit gate with specified parameters on a variable number of qubits in the circuit. By default, it applies the given gate to all the qubits in the register.
Parameters:  name: String
start: Integer
end: Integer
qubits: List
arg_value: Float
arg_label: String


Adds a block of a qubit circuit to the main circuit. Globalphase gates are not added.
Parameters:  qc: QubitCircuit
start: Integer


Adds a gate with specified parameters to the circuit.
Parameters:  name: String
targets: List
controls: List
arg_value: Float
arg_label: String


Method to resolve two qubit gates with nonadjacent control/s or target/s in terms of gates with adjacent interactions.
Returns:  qc: QubitCircuit


Propagator matrix calculator for N qubits returning the individual steps as unitary matrices operating from left to right.
Returns:  U_list: list


Removes a gate with from a specific index or the first, last or all instances of a particular gate.
Parameters:  index: Integer
name: String
remove: String


Unitary matrix calculator for N qubits returning the individual steps as unitary matrices operating from left to right in the specified basis.
Parameters:  basis: list.


Returns:  qc: QubitCircuit

Base class for representation of the physical implementation of a quantum program/algorithm on a specified qubit system.
Methods
adjacent_gates  
eliminate_auxillary_modes  
get_ops_and_u  
get_ops_labels  
load_circuit  
optimize_circuit  
plot_pulses  
pulse_matrix  
run  
run_state 
Function to take a quantum circuit/algorithm and convert it into the optimal form/basis for the desired physical system.
Parameters:  qc: QubitCircuit
setup: String


Returns:  qc: QubitCircuit

Returns the Hamiltonian operators and corresponding values by stacking them together.
Returns the Hamiltonian operators and corresponding labels by stacking them together.
Translates an abstract quantum circuit to its corresponding Hamiltonian for a specific model.
Parameters:  qc: QubitCircuit


Function to take a quantum circuit/algorithm and convert it into the optimal form/basis for the desired physical system.
Parameters:  qc: QubitCircuit


Returns:  qc: QubitCircuit

Maps the physical interaction between the circuit components for the desired physical system.
Returns:  fig, ax: Figure


Generates the pulse matrix for the desired physical system.
Returns:  t, u, labels:


Generates the propagator matrix by running the Hamiltonian for the appropriate time duration for the desired physical system.
Parameters:  qc: QubitCircuit


Returns:  U_list: list

Generates the propagator matrix by running the Hamiltonian for the appropriate time duration for the desired physical system with the given initial state of the qubit register.
Parameters:  qc: QubitCircuit
states: Qobj


Returns:  U_list: list

Representation of the physical implementation of a quantum program/algorithm on a spin chain qubit system.
Methods
adjacent_gates  
eliminate_auxillary_modes  
get_ops_and_u  
get_ops_labels  
load_circuit  
optimize_circuit  
plot_pulses  
pulse_matrix  
run  
run_state 
Method to resolve 2 qubit gates with nonadjacent control/s or target/s in terms of gates with adjacent interactions for linear/circular spin chain system.
Parameters:  qc: QubitCircuit
setup: Boolean


Returns:  qc: QubitCircuit

Representation of the physical implementation of a quantum program/algorithm on a spin chain qubit system arranged in a linear formation. It is a subclass of SpinChain.
Methods
adjacent_gates  
eliminate_auxillary_modes  
get_ops_and_u  
get_ops_labels  
load_circuit  
optimize_circuit  
plot_pulses  
pulse_matrix  
run  
run_state 
Representation of the physical implementation of a quantum program/algorithm on a spin chain qubit system arranged in a circular formation. It is a subclass of SpinChain.
Methods
adjacent_gates  
eliminate_auxillary_modes  
get_ops_and_u  
get_ops_labels  
load_circuit  
optimize_circuit  
plot_pulses  
pulse_matrix  
run  
run_state 
Representation of the physical implementation of a quantum program/algorithm on a dispersive cavityQED system.
Methods
adjacent_gates  
dispersive_gate_correction  
eliminate_auxillary_modes  
get_ops_and_u  
get_ops_labels  
load_circuit  
optimize_circuit  
plot_pulses  
pulse_matrix  
run  
run_state 
Method to resolve ISWAP and SQRTISWAP gates in a cQED system by adding single qubit gates to get the correct output matrix.
Parameters:  qc: Qobj
rwa: Boolean


Returns:  qc: QubitCircuit

Class for representing the result of a GRAPE simulation.
Attributes
u  (array) GRAPE control pulse matrix. 
H_t  (timedependent Hamiltonian) The timedependent Hamiltonian that realize the GRAPE pulse sequence. 
U_f  (Qobj) The final unitary transformation that is realized by the evolution of the system with the GRAPE generated pulse sequences. 
This is a base class only. See subclass descriptions and choose an appropriate one for the application.
Note that initialize_controls must be called before any of the methods can be used.
Attributes
log_level  (integer) level of messaging output from the logger. Options are attributes of qutip.logging, in decreasing levels of messaging, are: DEBUG_INTENSE, DEBUG_VERBOSE, DEBUG, INFO, WARN, ERROR, CRITICAL Anything WARN or above is effectively ‘quiet’ execution, assuming everything runs as expected. The default NOTSET implies that the level will be taken from the QuTiP settings file, which by default is WARN Note value should be set using set_log_level 
stats  (Stats) Attributes of which give performance stats for the optimisation set to None to reduce overhead of calculating stats. Note it is (usually) shared with the Optimizer object 
tslot_computer  (TimeslotComputer (subclass instance)) Used to manage when the timeslot dynamics generators, propagators, gradients etc are updated 
prop_computer  (PropagatorComputer (subclass instance)) Used to compute the propagators and their gradients 
fid_computer  (FidelityComputer (subclass instance)) Used to computer the fidelity error and the fidelity error gradient. 
num_tslots  (integer) Number of timeslots, aka timeslices 
num_ctrls  (integer) Number of controls. Note this is set when get_num_ctrls is called based on the length of ctrl_dyn_gen 
evo_time  (float) Total time for the evolution 
tau  (array[num_tslots] of float) Duration of each timeslot Note that if this is set before initialize_controls is called then num_tslots and evo_time are calculated from tau, otherwise tau is generated from num_tslots and evo_time, that is equal size time slices 
time  (array[num_tslots+1] of float) Cumulative time for the evolution, that is the time at the start of each time slice 
drift_dyn_gen  (Qobj) Drift or system dynamics generator Matrix defining the underlying dynamics of the system 
ctrl_dyn_gen  (List of Qobj) Control dynamics generator: ctrl_dyn_gen () List of matrices defining the control dynamics 
initial  (Qobj) Starting state / gate The matrix giving the initial state / gate, i.e. at time 0 Typically the identity 
target  (Qobj) Target state / gate: The matrix giving the desired state / gate for the evolution 
ctrl_amps  (array[num_tslots, num_ctrls] of float) Control amplitudes The amplitude (scale factor) for each control in each timeslot 
initial_ctrl_scaling  (float) Scale factor applied to be applied the control amplitudes when they are initialised This is used by the PulseGens rather than in any fucntions in this class 
self.initial_ctrl_offset = 0.0  Linear offset applied to be applied the control amplitudes when they are initialised This is used by the PulseGens rather than in any fucntions in this class 
dyn_gen  (List of Qobj) Dynamics generators the combined drift and control dynamics generators for each timeslot 
prop  (list of Qobj) Propagators  used to calculate time evolution from one timeslot to the next 
prop_grad  (array[num_tslots, num_ctrls] of Qobj) Propagator gradient (exact gradients only) Array of matrices that give the gradient with respect to the control amplitudes in a timeslot Note this attribute is only created when the selected PropagatorComputer is an exact gradient type. 
evo_init2t  (List of Qobj) Forward evolution (or propagation) the time evolution operator from the initial state / gate to the specified timeslot as generated by the dyn_gen 
evo_t2end  (List of Qobj) Onward evolution (or propagation) the time evolution operator from the specified timeslot to end of the evolution time as generated by the dyn_gen 
evo_t2targ  (List of Qobj) ‘Backward’ List of Qobj propagation the overlap of the onward propagation with the inverse of the target. Note this is only used (so far) by the unitary dynamics fidelity 
evo_current  (Boolean) Used to flag that the dynamics used to calculate the evolution operators is current. It is set to False when the amplitudes change 
decomp_curr  (List of boolean) Indicates whether the diagonalisation for the timeslot is fresh, it is set to false when the dyn_gen for the timeslot is changed Only used when the PropagatorComputer uses diagonalisation 
dyn_gen_eigenvectors  (List of array[drift_dyn_gen.shape]) Eigenvectors of the dynamics generators Used for calculating the propagators and their gradients Only used when the PropagatorComputer uses diagonalisation 
prop_eigen  (List of array[drift_dyn_gen.shape]) Propagator in diagonalised basis of the combined dynamics generator Used for calculating the propagators and their gradients Only used when the PropagatorComputer uses diagonalisation 
dyn_gen_factormatrix  (List of array[drift_dyn_gen.shape]) Matrix of scaling factors calculated duing the decomposition Used for calculating the propagator gradients Only used when the PropagatorComputer uses diagonalisation 
fact_mat_round_prec  (float) Rounding precision used when calculating the factor matrix to determine if two eigenvalues are equivalent Only used when the PropagatorComputer uses diagonalisation 
def_amps_fname  (string) Default name for the output used when save_amps is called 
Methods
check_ctrls_initialized  
clear  
combine_dyn_gen  
compute_evolution  
ensure_decomp_curr  
flag_system_changed  
get_amp_times  
get_ctrl_dyn_gen  
get_drift_dim  
get_dyn_gen  
get_num_ctrls  
get_owd_evo_target  
init_time_slots  
initialize_controls  
reset  
save_amps  
set_log_level  
spectral_decomp  
update_ctrl_amps 
Computes the dynamics generator for a given timeslot The is the combined Hamiltion for unitary systems
Recalculate the time evolution operators Dynamics generators (e.g. Hamiltonian) and prop (propagators) are calculated as necessary Actual work is completed by the recompute_evolution method of the timeslot computer
Checks to see if the diagonalisation has been completed since the last update of the dynamics generators (after the amplitude update) If not then the diagonlisation is completed
Get the dynamics generator for the control Not implemented in the base class. Choose a subclass
Returns the size of the matrix that defines the drift dynamics that is assuming the drift is NxN, then this returns N
Get the combined dynamics generator for the timeslot Not implemented in the base class. Choose a subclass
calculate the of controls from the length of the control list sets the num_ctrls property, which can be used alternatively subsequently
Get the inverse of the target. Used for calculating the ‘backward’ evolution
Generate the timeslot duration array ‘tau’ based on the evo_time and num_tslots attributes, unless the tau attribute is already set in which case this step in ignored Generate the cumulative time array ‘time’ based on the tau values
Set the initial control amplitudes and time slices Note this must be called after the configuration is complete before any dynamics can be calculated
Save a file with the current control amplitudes in each timeslot The first column in the file will be the start time of the slot
Parameters:  file_name : string
times : List type (or string)
amps : Array[num_tslots, num_ctrls]
verbose : Boolean


Set the log_level attribute and set the level of the logger that is call logger.setLevel(lvl)
Calculate the diagonalization of the dynamics generator generating lists of eigenvectors, propagators in the diagonalised basis, and the ‘factormatrix’ used in calculating the propagator gradient Not implemented in this base class, because the method is specific to the matrix type
This is the subclass to use for systems with dynamics described by unitary matrices. E.g. closed systems with Hermitian Hamiltonians Note a matrix diagonalisation is used to compute the exponent The eigen decomposition is also used to calculate the propagator gradient. The method is taken from DYNAMO (see file header)
Attributes
drift_ham  (Qobj) This is the drift Hamiltonian for unitary dynamics It is mapped to drift_dyn_gen during initialize_controls 
ctrl_ham  (List of Qobj) These are the control Hamiltonians for unitary dynamics It is mapped to ctrl_dyn_gen during initialize_controls 
H  (List of Qobj) The combined drift and control Hamiltonians for each timeslot These are the dynamics generators for unitary dynamics. It is mapped to dyn_gen during initialize_controls 
Methods
check_ctrls_initialized  
clear  
combine_dyn_gen  
compute_evolution  
ensure_decomp_curr  
flag_system_changed  
get_amp_times  
get_ctrl_dyn_gen  
get_drift_dim  
get_dyn_gen  
get_num_ctrls  
get_owd_evo_target  
init_time_slots  
initialize_controls  
reset  
save_amps  
set_log_level  
spectral_decomp  
update_ctrl_amps 
Symplectic systems This is the subclass to use for systems where the dynamics is described by symplectic matrices, e.g. coupled oscillators, quantum optics
Attributes
omega  (array[drift_dyn_gen.shape]) matrix used in the calculation of propagators (time evolution) with symplectic systems. 
Methods
check_ctrls_initialized  
clear  
combine_dyn_gen  
compute_evolution  
ensure_decomp_curr  
flag_system_changed  
get_amp_times  
get_ctrl_dyn_gen  
get_drift_dim  
get_dyn_gen  
get_num_ctrls  
get_omega  
get_owd_evo_target  
init_time_slots  
initialize_controls  
reset  
save_amps  
set_log_level  
spectral_decomp  
update_ctrl_amps 
Pulse generator Base class for all Pulse generators The object can optionally be instantiated with a Dynamics object, in which case the timeslots and amplitude scaling and offset are copied from that. Otherwise the class can be used independently by setting: tau (array of timeslot durations) or num_tslots and pulse_time for equally spaced timeslots
Attributes
num_tslots  (integer) Number of timeslots, aka timeslices (copied from Dynamics if given) 
pulse_time  (float) total duration of the pulse (copied from Dynamics.evo_time if given) 
scaling  (float) linear scaling applied to the pulse (copied from Dynamics.initial_ctrl_scaling if given) 
offset  (float) linear offset applied to the pulse (copied from Dynamics.initial_ctrl_offset if given) 
tau  (array[num_tslots] of float) Duration of each timeslot (copied from Dynamics if given) 
lbound  (float) Lower boundary for the pulse amplitudes Note that the scaling and offset attributes can be used to fully bound the pulse for all generators except some of the random ones This bound (if set) may result in additional shifting / scaling Default is Inf 
ubound  (float) Upper boundary for the pulse amplitudes Note that the scaling and offset attributes can be used to fully bound the pulse for all generators except some of the random ones This bound (if set) may result in additional shifting / scaling Default is Inf 
periodic  (boolean) True if the pulse generator produces periodic pulses 
random  (boolean) True if the pulse generator produces random pulses 
Methods
gen_pulse  
init_pulse  
reset 
Generates random pulses as simply random values for each timeslot
Methods
gen_pulse  
init_pulse  
reset 
Generates linear pulses
Attributes
gradient  (float) Gradient of the line. Note this is calculated from the start_val and end_val if these are given 
start_val  (float) Start point of the line. That is the starting amplitude 
end_val  (float) End point of the line. That is the amplitude at the start of the last timeslot 
Methods
gen_pulse  
init_pulse  
reset 
Generate a linear pulse using either the gradient and start value or using the end point to calulate the gradient Note that the scaling and offset parameters are still applied, so unless these values are the default 1.0 and 0.0, then the actual gradient etc will be different Returns the pulse as an array of vales for each timeslot
Generates linear pulses
Attributes
gradient  (float) Gradient of the line. Note this is calculated from the start_val and end_val if these are given 
start_val  (float) Start point of the line. That is the starting amplitude 
end_val  (float) End point of the line. That is the amplitude at the start of the last timeslot 
Methods
gen_pulse  
init_pulse  
reset 
Generate a linear pulse using either the gradient and start value or using the end point to calulate the gradient Note that the scaling and offset parameters are still applied, so unless these values are the default 1.0 and 0.0, then the actual gradient etc will be different Returns the pulse as an array of vales for each timeslot
Calulate the gradient if pulse is defined by start and end point values
reset attributes to default values
Intermediate class for all periodic pulse generators All of the periodic pulses range from 1 to 1 All have a start phase that can be set between 0 and 2pi
Attributes
num_waves  (float) Number of complete waves (cycles) that occur in the pulse. wavelen and freq calculated from this if it is given 
wavelen  (float) Wavelength of the pulse (assuming the speed is 1) freq is calculated from this if it is given 
freq  (float) Frequency of the pulse 
start_phase  (float) Phase of the pulse signal when t=0 
Methods
gen_pulse  
init_pulse  
reset 
Calculate the wavelength, frequency, number of waves etc from the each other and the other parameters If num_waves is given then the other parameters are worked from this Otherwise if the wavelength is given then it is the driver Otherwise the frequency is used to calculate wavelength and num_waves
Generates sine wave pulses
Methods
gen_pulse  
init_pulse  
reset 
Generate a sine wave pulse If no params are provided then the class object attributes are used. If they are provided, then these will reinitialise the object attribs. returns the pulse as an array of vales for each timeslot
Generates square wave pulses
Methods
gen_pulse  
init_pulse  
reset 
Generates saw tooth wave pulses
Methods
gen_pulse  
init_pulse  
reset 