QuTiP: Quantum Toolbox in Python
Patch release fixing small issues, mostly with the migration from self hosting the documentation to using readthedocs.
QuTiP 5 is a redesign of many of the core components of QuTiP (Qobj
,
QobjEvo
, solvers) to make them more consistent and more flexible.
Qobj
may now be stored in either sparse or dense representations,
and the two may be mixed sensibly as needed. QobjEvo
is now used
consistently throughout QuTiP, and the implementation has been
substantially cleaned up. A new Coefficient
class is used to
represent the time-dependent factors inside QobjEvo
.
The solvers have been rewritten to work well with the new data layer
and the concept of Integrators
which solve ODEs has been introduced.
In future, new data layers may provide their own Integrators
specialized to their representation of the underlying data.
Much of the user-facing API of QuTiP remains familiar, but there have had to be many small breaking changes. If we can make changes to easy migrating code from QuTiP 4 to QuTiP 5, please let us know. A notebook to help with migration is available on colab.
An extensive list of changes follows.
QuTiP 5 has been a large effort by many people over the last three years.
In particular:
qutip_qip
.Other members of the QuTiP Admin team have been heavily involved in reviewing, testing and designing QuTiP 5:
Two Google Summer of Code contributors updated the tutorials and benchmarks to QuTiP 5:
During an internship at RIKEN, Patrick Hopf created a new quantum control method and improved the existing methods interface:
Four experimental data layers backends were written either as part of Google Summer of Code or as separate projects. While these are still alpha quality, they helped significantly to test the data layer API:
qutip-tensorflow
: a TensorFlow backend by Asier Galicia (https://github.com/qutip/qutip-tensorflow)qutip-cupy
: a CuPy GPU backend by Felipe Bivort Haiek (https://github.com/qutip/qutip-cupy/)qutip-tensornetwork
: a TensorNetwork backend by Asier Galicia (https://github.com/qutip/qutip-tensornetwork)qutip-jax
: a JAX backend by Eric Giguère (https://github.com/qutip/qutip-jax/)Finally, Yuji Tamakoshi updated the visualization function and added animation functions as part of Google Summer of Code project.
We have also had many other contributors, whose specific contributions are detailed below:
bloch_redfield_tensor
function to accept strings and callables for a_ops
, #1951)qutip_qip
to be imported as qutip.qip
, #1920)process_fidelity
and average_gate_fidelity
, #1712, #1748 , #1788)qutip.Bloch
, #1335)kraus_to_choi
making it faster, #2284)expect
documentation, #2331)Previously Qobj
data was stored in a SciPy-like sparse matrix. Now the
representation is flexible. Implementations for dense and sparse formats are
included in QuTiP and custom implementations are possible. QuTiP's performance
on dense states and operators is significantly improved as a result.
Some highlights:
.data
attribute, but is now an
instance of the underlying data type instead of a SciPy-like sparse matrix.
The operations available in qutip.core.data
may be used on .data
,
regardless of the data type.Qobj
with different data types may be mixed in arithmetic and other
operations. A sensible output type will be automatically determined..to(...)
method may be used to convert a Qobj
from one data type
to another. E.g. .to("dense")
will convert to the dense representation and
.to("csr")
will convert to the sparse type.Qobj
methods and methods that create Qobj
now accepted a dtype
parameter that allows the data type of the returned Qobj
to specified.&
operator may be used to obtain the tensor product.@
operator may be used to obtain the matrix / operator product.
bar @ ket
returns a scalar..contract()
method will collapse 1D subspaces of the dimensions of
the Qobj
..logm()
method returns the matrix logarithm of an operator..set_data
, .get_data
, .extract_state
, .eliminate_states
,
.evaluate
and .check_isunitary
have been removed.dtype
return the representation of the data used.data_as
allow to obtain the data as a common python formats:
numpy array, scipy sparse matrix, JAX Array, etc.The QobjEvo
type for storing time-dependent quantum objects has been
significantly expanded, standardized and extended. The time-dependent
coefficients are now represented using a new Coefficient
type that
may be independently created and manipulated if required.
Some highlights:
.compile()
method has been removed. Coefficients specified as
strings are automatically compiled if possible and the compilation is
cached across different Python runs and instances.Qobj
is now supported.QobjEvo
for convenience. Examples
include .dims
, .shape
, .superrep
and .isconstant
..cte
, .use_cython
, .type
, .const
,
and .coeff_file
were removed.Spline
coefficient supports spline interpolations of different
orders. The old Cubic_Spline
coefficient has been removed..arguments(...)
method allows additional arguments to the
underlying coefficient functions to be updated._step_func_coeff
argument has been replaced by the order
parameter. _step_func_coeff=False
is equivalent to order=3
.
_step_func_coeff=True
is equivalent to order=0
. Higher values
of order
gives spline interpolations of higher orders.bc_type
to control the boundary conditions.oper * qutip.coefficient(f, args=args)
is equivalent to
qutip.QobjEvo([[oper, f]], args=args)
.def f(t, A, w)
.
The dictionary args
second argument is no longer needed.
Function using the exact f(t, args)
signature will use the old method for
backward compatibility.The solvers in QuTiP have been heavily reworked and standardized.
Under the hood solvers now make use of swappable ODE Integrators
.
Many Integrators
are included (see the list below) and
custom implementations are possible. Solvers now consistently
accept a QobjEvo
instance at the Hamiltonian or Liouvillian, or
any object which can be passed to the QobjEvo
constructor.
A breakdown of highlights follows.
qutip.Options
is deprecated and returns a dict for backwards
compatibility.method
option.QobjEvo
instance is accepted for most operators, e.g.,
H
, c_ops
, e_ops
, a_ops
.progress_bar
option.
A new progess bar using the tqdm
Python library is provided.args={"state": MESolver.StateFeedback(default=rho0)}
bdf
and adams
.dop853
.lsoda
.vern7
and vern9
. See
http://people.math.sfu.ca/~jverner/ for a description of the methods.diag
. It only works on
time-independent systems and is slow to setup, but once the diagonalization
is complete, it generates solutions very quickly.krylov
. This integrator is only usable with sesolve
..e_data
attribute provides expectation values as a dictionary.
Unlike .expect
, the values are provided in a Python list rather than
a numpy array, which better supports non-numeric types..stats
attribute changed significantly and is
now more consistent across solvers.seed
parameter now supports supplying numpy SeedSequence
or
Generator
types.timeout
and target_tol
parameters allow the solver to exit
early if a timeout or target tolerance is reached.MCSolver
if setting up the solver uses a significant amount of time.map_func
parameter has been replaced by the map
option.mcsolve
now supports calculating photocurrents
and calculating the steady state over N trajectories.parfor
parallel execution function has been removed from
qutip.parallel
. Use parallel_map
, loky_map
or mpi_pmap
instead..trace
attribute of the result.timeout
and target_tol
added.seed
parameter now supports supplying numpy SeedSequence
.a_ops
and spectra
support implementations been heavily reworked to
reuse the techniques from the new Coefficient and QobjEvo classes.use_secular
parameter has been removed. Use sec_cutoff=-1
instead.qutip.settings
.SESolver
and the krylov
ODE integrator. The function krylovsolve
is maintained for convenience
and now supports many more options.sparse
parameter has been removed. Supply a sparse Qobj
for the
Hamiltonian instead.FloquetBasis
class
which manages the transformations from lab to Floquet basis and back.floquet_tensor
.w_th
, and the result states are stored in the lab basis and optionally
in the Floquet basis using store_floquet_state
.fmmesolve
must now be vectorized
(i.e. accept and return numpy arrays for frequencies and densities) and
must accept negative frequence (i.e. usually include a w > 0
factor
so that the returned densities are zero for negative frequencies).kmax
may only be supplied when using
the FMESolver
Tsteps
parameter has been removed from both fsesolve
and
fmmesolve
. The precompute
option to FloquetBasis
may be used
instead.essolve
has been removed. Use the diag
integration
method with sesolve
or mesolve
instead.method
parameter and solver
parameters have been separated. Previously
they were mixed together in the method
parameter.correlation_3op
function has been added. It supports MESolver
or BRMESolver
.correlation
, correlation_4op
, and correlation_ss
functions have been
removed.mcsolve
has been removed.qutip.Propagator
, has been added for propagators.QobjEvo
.unitary_mode
and parallel
options have been removed.spectrum_ss
and spectrum_pi
have been removed and
are now internal functions.use_pinv
parameter for spectrum
has been removed and the
functionality merged into the solver
parameter. Use solver="pi"
instead.There have been numerous other small changes to core QuTiP features:
qft(...)
the function that returns the quantum Fourier
transform operator was moved from qutip.qip.algorithm
into qutip
.brtensor
, has been moved into
qutip.core
. See the section above on the Bloch-Redfield solver
for details.mat2vec
and vec2mat
for transforming states to and
from super-operator states have been renamed to stack_columns
and
unstack_columns
.liouvillian_ref
has been removed. Used liouvillian
instead.super_to_choi
, choi_to_super
,
choi_to_kraus
, choi_to_chi
and chi_to_choi
have been removed.
Used to_choi
, to_super
, to_kraus
and to_chi
instead.Generator
as a seed.dims
parameter of all random object creation functions has
been removed. Supply the dimensions as the first parameter if
explicit dimensions are required.rand_unitary_haar
has been removed. Use
rand_unitary(distribution="haar")
instead.rand_dm_hs
and rand_dm_ginibre
have been removed.
Use rand_dm(distribution="hs")
and rand_dm(distribution="ginibre")
instead.rand_ket_haar
has been removed. Use
rand_ket(distribution="haar")
instead.target
parameter for
expanding the measurement operator removed. Used expand_operator
to expand the operator instead.qutip.Bloch
now supports applying colours per-point, state or vector in
add_point
, add_states
, and add_vectors
.qeye_like
and qzero_like
.Previously qutip.settings
was an ordinary module. Now qutip.settings
is
an instance of a settings class. All the runtime modifiable settings for
core operations are in qutip.settings.core
. The other settings are not
modifiable at runtime.
load
. reset
and save
functions..debug
, .fortran
, .openmp_thresh
..compile
stores the compilation options for compiled coefficients..core["rtol"]
core option gives the default relative tolerance used by QuTiP..atol
has been moved to .core["atol"]
.plot_wigner
and plot_wigner_fock_distribution
to specify parameters for wigner
.Bloch3D
. The same functionality is provided by Bloch
.fig
, ax
and cmap
keyword arguments to all visualization functions.colorblind_safe
setting.Qobj
or directly from solver results with saved states.qutip.qip
has been moved into its own package, qutip-qip. Once installed, qutip-qip is available as either qutip.qip
or qutip_qip
. Some widely useful gates have been retained in qutip.gates
.qutip.control
has been moved to qutip-qtrl and once installed qutip-qtrl is available as either qutip.control
or qutip_qtrl
. Note that quitp_qtrl
is provided primarily for backwards compatibility. Improvements to optimal control will take place in the new qutip_qoc
package.qutip.lattice
has been moved into its own package, qutip-lattice. It is available from <https://github.com/qutip/qutip-lattice>
.qutip.sparse
has been removed. It contained the old sparse matrix representation and is replaced by the new implementation in qutip.data
.qutip.piqs
functions are no longer available from the qutip
namespace. They are accessible from qutip.piqs
instead.setup.py
and passing
--with-idxint-64
.qutip.parfor
function has been removed. Use qutip.parallel_map
instead.qutip.graph
has been removed and replaced by SciPy's graph functions.qutip.topology
has been removed. It contained only one function berry_curvature
.~/.qutip/qutiprc
config file is no longer supported. It contained settings for the OpenMP support.three_level_atom
orbital
nm_mcsolve
. (#2234, by Paul)parallel_map
and loky_pmap
in the case of timeouts, errors or keyboard interrupts (#2280, by Paul)kraus_to_choi
making it faster (#2284, by Bogdan Reznychenko)dtype
to Qobj
and QobjEvo
(#2325)expect
documentation (#2331, by gabbence95)This is a bugfix release for QuTiP 4.7.X.
choi_to_kraus
, making it rely on an eigenstates solver that can choose eigh
if the Choi matrix is Hermitian, as it is more numerically stable. (#2276, by Bogdan Reznychenko)kraus_to_choi
, making it faster (#2283, by Bogdan Reznychenko and Rafael Haenel)This is a pre-release.
Continuation of the QuTiP 5 redesign.
It include fixing bugs and polishing features introduced in the alpha 1 release, updated stochastic solvers, a new solver: nm_mcsolve
and animation functions.
bloch_redfield_tensor
(#1951)expand_operator
(#1991)svn
and solve
to dispatched (#2002)nm_mcsolve
to provide support for Monte-Carlo simulations of master equations with possibly negative rates. The method implemented here is described in arXiv:2209.08958 [quant-ph]. (#2070 by pmenczel)__repr__
to QobjEvo (#2111 by lklivingstone)print(qutip.settings)
by make it shorter (#2113 by tamakoshi2001)trace_oper_ket
operation (#2126)Qobj.data_as
to extract underlying data in original format. (#2141)qeye_like
and qzero_like
(#2153)mcsolve
(#2218 by Daniel Weiss)floquet_markov_mesolve
(#1952 by christian512)fsesolve
call in fmmesolve
(#2225)qutip.control
and replace with qutip_qtrl. (#2116)_solve
in countstat.py and used _data.solve
. (#2120 by Yuji Tamakoshi)three_level_atom
(#2221)orbital
(#2223)sec_cutoff
to the documentation (#2136 by Gerardo Jose Suarez)MESolver
, SMESolver
, SSESolver
, NonMarkovianMCSolver
(#2167 by Cristian Emiliano Godinez Ramirez)HTMLProgressBar
from qutip/ipynbtools.py to qutip/ui/progressbar.py (#2112 by Harsh Khilawala)bc_type
to take boundary conditions when creating QobjEvo
(#2114 by Avatar Srinidhi P V )semidefinite
(#2138)sphereplot
so that the order is similar to those of plot_spin_distribution
(#2219 by Yuji Tamakoshi)This is a bugfix release for QuTiP 4.7.X.
Bug Fixes
Miscellaneous
This is a bugfix release for QuTiP 4.7.X. It adds support for numpy 1.25 and scipy 1.11.
Bug Fixes
subset_by_index=
. (#2081 by Simon Cross)Miscellaneous
ptrace
always return density matrix (#2185, issue by udevd)mesolve
can support mixed callable and Qobj
for e_ops
(#2184 issue by balopat)This is a pre-release.
QuTiP 5 is a redesign of many of the core components of QuTiP (Qobj
, QobjEvo
, solvers) to make them more consistent and more flexible.
Qobj
may now be stored in either sparse or dense representations, and the two may be mixed sensibly as needed. QobjEvo
is now used consistently throughout QuTiP, and the implementation has been substantially cleaned up. A new Coefficient
class is used to represent the time-dependent factors inside QobjEvo
.
The solvers have been rewritten to work well with the new data layer and the concept of Integrators
which solve ODEs has been introduced. In future, new data layers may provide their own Integrators
specialized to their representation of the underlying data.
Much of the user-facing API of QuTiP remains familiar, but there have had to be many small breaking changes. If we can make changes to easy migrating code from QuTiP 4 to QuTiP 5, please let us know.
Any extensive list of changes follows.
QuTiP 5 has been a large effort by many people over the last three years.
In particular:
qutip_qip
.Other members of the QuTiP Admin team have been heavily involved in reviewing, testing and designing QuTiP 5:
Two Google Summer of Code contributors updated the tutorials and benchmarks to QuTiP 5:
Four experimental data layers backends were written either as part of Google Summer of Code or as separate projects. While these are still alpha quality, the helped significantly to test the data layer API:
qutip-tensorflow
: a TensorFlow backend by Asier Galicia (https://github.com/qutip/qutip-tensorflow)qutip-cupy
: a CuPy GPU backend by Felipe Bivort Haiek (https://github.com/qutip/qutip-cupy)qutip-tensornetwork
: a TensorNetwork backend by Asier Galicia (https://github.com/qutip/qutip-tensornetwork)qutip-jax
: a JAX backend by Eric Giguère (https://github.com/qutip/qutip-jax)We have also had many other contributors, whose specific contributions are detailed below:
bloch_redfield_tensor
function to accept strings and callables for a_ops
, #1951)qutip_qip
to be imported as qutip.qip
, #1920)process_fidelity
and average_gate_fidelity
, #1712, #1748, #1788)qutip.Bloch
, #1335)Previously Qobj
data was stored in a SciPy-like sparse matrix. Now the representation is flexible. Implementations for dense and sparse formats are included in QuTiP and custom implementations are possible. QuTiP's performance on dense states and operators is significantly improved as a result.
Some highlights:
.data
attribute, but is now an instance of the underlying data type instead of a SciPy-like sparse matrix. The operations available in qutip.core.data
may be used on .data
, regardless of the data type.Qobj
with different data types may be mixed in arithmetic and other operations. A sensible output type will be automatically determined..to(...)
method may be used to convert a Qobj
from one data type to another. E.g. .to("dense")
will convert to the dense representation and .to("csr")
will convert to the sparse type.Qobj
methods and methods that create Qobj
now accepted a dtype
parameter that allows the data type of the returned Qobj
to specified.&
operator may be used to obtain the tensor product.@
operator may be used to obtain the matrix / operator product. bar @ ket
returns a scalar..contract()
method will collapse 1D subspaces of the dimensions of the Qobj
..logm()
method returns the matrix logarithm of an operator..set_data
, .get_data
, .extract_state
, .eliminate_states
, .evaluate
and .check_isunitary
have been removed.The QobjEvo
type for storing time-dependent quantum objects has been significantly expanded, standardized and extended. The time-dependent coefficients are now represented using a new Coefficient
type that may be independently created and manipulated if required.
Some highlights:
.compile()
method has been removed. Coefficients specified as strings are automatically compiled if possible and the compilation is cached across different Python runs and instances.Qobj
is now supported.QobjEvo
for convenience. Examples include .dims
, .shape
, .superrep
and .isconstant
..cte
, .use_cython
, .type
, .const
, and .coeff_file
were removed.Spline
coefficient supports spline interpolations of different orders. The old Cubic_Spline
coefficient has been removed..arguments(...)
method allows additional arguments to the underlying coefficient functions to be updated._step_func_coeff
argument has been replaced by the order
parameter. _step_func_coeff=False
is equivalent to order=3
. _step_func_coeff=True
is equivalent to order=0
. Higher values of order
gives spline interpolations of higher orders.The solvers in QuTiP have been heavily reworked and standardized. Under the hood solvers now make use of swappable ODE Integrators
. Many Integrators
are included (see the list below) and custom implementations are possible. Solvers now consistently accept a QobjEvo
instance at the Hamiltonian or Liouvillian, or any object which can be passed to the QobjEvo
constructor.
A breakdown of highlights follows.
All solvers:
qutip.Options
is deprecated and returns a dict for backwards compatibility.method
option.QobjEvo
instance is accepted for most operators, e.g., H
, c_ops
, e_ops
, a_ops
.progress_bar
option. A new progess bar using the tqdm
Python library is provided.Integrators:
bdf
and adams
.dop853
.lsoda
.vern7
and vern9
. See http://people.math.sfu.ca/~jverner/ for a description of the methods.diag
. It only works on time-independent systems and is slow to setup, but once the diagonalization is complete, it generates solutions very quickly.krylov
. This integrator is only usable with sesolve
.Result class:
.e_data
attribute provides expectation values as a dictionary. Unlike .expect
, the values are provided in a Python list rather than a numpy array, which better supports non-numeric types..stats
attribute changed significantly and is now more consistent across solvers.Monte-Carlo Solver (mcsolve):
seed
parameter now supports supplying numpy SeedSequence
or Generator
types.timeout
and target_tol
parameters allow the solver to exit early if a timeout or target tolerance is reached.MCSolver
if setting up the solver uses a significant amount of time.map_func
parameter has been replaced by the map
option. In addition to the existing serial
and parallel
values, the value loky
may be supplied to use the loky package to parallelize trajectories.mcsolve
now supports calculating photocurrents and calculating the steady state over N trajectories.parfor
parallel execution function has been removed from qutip.parallel
. Use parallel_map
or loky_map
instead.Bloch-Redfield Master Equation Solver (brmesolve):
a_ops
and spectra
support implementaitons been heavily reworked to reuse the techniques from the new Coefficient and QobjEvo classes.use_secular
parameter has been removed. Use sec_cutoff=-1
instead.qutip.settings
.Krylov Subspace Solver (krylovsolve):
SESolver
and the krylov
ODE integrator. The function krylovsolve
is maintained for convenience and now supports many more options.sparse
parameter has been removed. Supply a sparse Qobj
for the Hamiltonian instead.Floquet Solver (fsesolve and fmmesolve):
FloquetBasis
class which manages the transformations from lab to Floquet basis and back.floquet_tensor
.w_th
, and the result states are stored in the lab basis and optionally in the Floquet basis using store_floquet_state
.fmmesolve
must now be vectorized (i.e. accept and return numpy arrays for frequencies and densities) and must accept negative frequence (i.e. usually include a w > 0
factor so that the returned densities are zero for negative frequencies).kmax
may only be supplied when using the FMESolver
Tsteps
parameter has been removed from both fsesolve
and fmmesolve
. The precompute
option to FloquetBasis
may be used instead.Evolution of State Solver (essovle):
essolve
has been removed. Use the diag
integration method with sesolve
or mesolve
instead.Steady-state solvers (steadystate module):
method
parameter and solver
parameters have been separated. Previously they were mixed together in the method
parameter.Correlation functions (correlation module):
correlation_3op
function has been added. It supports MESolver
or BRMESolver
.correlation
, correlation_4op
, and correlation_ss
functions have been removed.mcsolve
has been removed.Propagators (propagator module):
qutip.Propagator
, has been added for propagators.QobjEvo
.unitary_mode
and parallel
options have been removed.Correlation spectra (spectrum module):
spectrum_ss
and spectrum_pi
have been removed and are now internal functions.use_pinv
parameter for spectrum
has been removed and the functionality merged into the solver
parameter. Use solver="pi"
instead.There have been numerous other small changes to core QuTiP features:
qft(...)
the function that returns the quantum Fourier transform operator was moved from qutip.qip.algorithm
into qutip
.brtensor
, has been moved into qutip.core
. See the section above on the Bloch-Redfield solver for details.mat2vec
and vec2mat
for transforming states to and from super-operator states have been renamed to stack_columns
and unstack_columns
.liouvillian_ref
has been removed. Used liouvillian
instead.super_to_choi
, choi_to_super
, choi_to_kraus
, choi_to_chi
and chi_to_choi
have been removed. Used to_choi
, to_super
, to_kraus
and to_chi
instead.Generator
as a seed.dims
parameter of all random object creation functions has been removed. Supply the dimensions as the first parameter if explicit dimensions are required.rand_unitary_haar
has been removed. Use rand_unitary(distribution="haar")
instead.rand_dm_hs
and rand_dm_ginibre
have been removed. Use rand_dm(distribution="hs")
and rand_dm(distribution="ginibre")
instead.rand_ket_haar
has been removed. Use rand_ket(distribution="haar")
instead.target
parameter for expanding the measurement operator removed. Used expand_operator
to expand the operator instead.qutip.Bloch
now supports applying colours per-point, state or vector in
add_point
, add_states
, and add_vectors
.Previously qutip.settings
was an ordinary module. Now qutip.settings
is an instance of a settings class. All the runtime modifiable settings for core operations are in qutip.settings.core
. The other settings are not modifiable at runtime.
load
. reset
and save
functions..debug
, .fortran
, .openmp_thresh
..compile
stores the compilation options for compiled coefficients..core["rtol"]
core option gives the default relative tolerance used by QuTiP..atol
has been moved to .core["atol"]
.qutip.qip
has been moved into its own package, qutip-qip. Once installed, qutip-qip is available as either qutip.qip
or qutip_qip
. Some widely useful gates have been retained in qutip.gates
.qutip.lattice
has been moved into its own package, qutip-lattice. It is available from <https://github.com/qutip/qutip-lattice>
.qutip.sparse
has been removed. It contained the old sparse matrix representation and is replaced by the new implementation in qutip.data
.qutip.piqs
functions are no longer available from the qutip
namespace. They are accessible from qutip.piqs
instead.setup.py
and passing --with-idxint-64
.qutip.parfor
function has been removed. Use qutip.parallel_map
instead.qutip.graph
has been removed and replaced by SciPy's graph functions.qutip.topology
has been removed. It contained only one function berry_curvature
.~/.qutip/qutiprc
config file is no longer supported. It contained settings for the OpenMP support.