Comprehensive Python library for simulating quantum systems dynamics and quantum information processing.
npx @tessl/cli install tessl/pypi-qutip@5.2.00
# QuTiP
1
2
QuTiP (Quantum Toolbox in Python) is a comprehensive library for simulating quantum systems dynamics and quantum information processing. It provides user-friendly and efficient numerical simulations of quantum mechanical problems, including systems with arbitrary time-dependent Hamiltonians and collapse operators, commonly found in quantum optics, quantum computing, and condensed matter physics.
3
4
## Package Information
5
6
- **Package Name**: qutip
7
- **Package Type**: pypi
8
- **Language**: Python
9
- **Installation**: `pip install qutip` or `conda install -c conda-forge qutip`
10
11
## Core Imports
12
13
```python
14
import qutip
15
```
16
17
Common imports for specific functionality:
18
19
```python
20
from qutip import Qobj, basis, coherent, destroy, num, sigmax, sigmay, sigmaz
21
from qutip import mesolve, sesolve, mcsolve, steadystate
22
from qutip import tensor, expect, ptrace
23
from qutip import Bloch, hinton, plot_wigner
24
```
25
26
## Basic Usage
27
28
```python
29
import qutip as qt
30
import numpy as np
31
32
# Create quantum objects
33
psi = qt.basis(2, 0) # |0⟩ state
34
sigma_x = qt.sigmax() # Pauli-X operator
35
a = qt.destroy(10) # Annihilation operator for 10-level system
36
37
# Quantum operations
38
psi_x = sigma_x * psi # Apply Pauli-X
39
rho = psi * psi.dag() # Create density matrix
40
exp_val = qt.expect(sigma_x, psi) # Expectation value
41
42
# Time evolution
43
H = qt.sigmaz() # Hamiltonian
44
times = np.linspace(0, 10, 100)
45
result = qt.sesolve(H, psi, times) # Solve Schrödinger equation
46
47
# Visualization
48
b = qt.Bloch()
49
b.add_states(psi)
50
b.show()
51
```
52
53
## Architecture
54
55
QuTiP is built around the **Qobj** (Quantum Object) class, which represents quantum states, operators, and superoperators in a unified framework. The library uses efficient sparse matrix representations from SciPy and provides multiple solver backends for different types of quantum systems:
56
57
- **States and Operators**: Core quantum objects with automatic type detection
58
- **Solvers**: Time evolution algorithms for closed and open quantum systems
59
- **Superoperators**: Liouvillian formalism for open system dynamics
60
- **Visualization**: Tools for quantum state and process visualization
61
- **Quantum Information**: Measures of entanglement, entropy, and quantum correlations
62
63
The modular design allows users to combine components flexibly while maintaining computational efficiency through optimized linear algebra backends.
64
65
## Capabilities
66
67
### Quantum Objects and States
68
69
Fundamental quantum object manipulation, state construction, and basic operations. The Qobj class serves as the foundation for all quantum computations in QuTiP.
70
71
```python { .api }
72
class Qobj:
73
def __init__(self, inpt=None, dims=None, shape=None, type=None,
74
isherm=None, isunitary=None, copy=True): ...
75
def copy(self) -> 'Qobj': ...
76
def dag(self) -> 'Qobj': ...
77
def conj(self) -> 'Qobj': ...
78
def trans(self) -> 'Qobj': ...
79
def norm(self, norm=None, sparse=False, tol=0, maxiter=100000): ...
80
def tr(self): ...
81
def ptrace(self, sel): ...
82
def eigenstates(self, sparse=False, sort='low', eigvals=0, tol=0, maxiter=100000): ...
83
def eigenenergies(self, sparse=False, sort='low', eigvals=0, tol=0, maxiter=100000): ...
84
def expm(self, dtype=None): ...
85
def logm(self, dtype=None): ...
86
def sqrtm(self, dtype=None): ...
87
def unit(self, inplace=False): ...
88
def tidyup(self, atol=None, rtol=None): ...
89
```
90
91
[Quantum Objects and States](./quantum-objects.md)
92
93
### Quantum State Construction
94
95
Creation of fundamental quantum states including basis states, coherent states, squeezed states, and multi-qubit entangled states.
96
97
```python { .api }
98
def basis(N: int, n: int = 0, offset: int = 0) -> Qobj: ...
99
def coherent(N: int, alpha: complex, offset: int = 0, method: str = 'operator') -> Qobj: ...
100
def fock(N: int, n: int = 0, offset: int = 0) -> Qobj: ...
101
def thermal_dm(N: int, n: float, method: str = 'operator') -> Qobj: ...
102
def bell_state(state: str = '00') -> Qobj: ...
103
def ghz_state(N: int = 3) -> Qobj: ...
104
def w_state(N: int = 3) -> Qobj: ...
105
```
106
107
[Quantum State Construction](./states.md)
108
109
### Quantum Operators
110
111
Construction of quantum operators including Pauli matrices, creation/annihilation operators, spin operators, and quantum gates.
112
113
```python { .api }
114
def create(N: int, offset: int = 0) -> Qobj: ...
115
def destroy(N: int, offset: int = 0) -> Qobj: ...
116
def num(N: int, offset: int = 0) -> Qobj: ...
117
def sigmax() -> Qobj: ...
118
def sigmay() -> Qobj: ...
119
def sigmaz() -> Qobj: ...
120
def jmat(j: float, op: str = None) -> Qobj: ...
121
def squeeze(N: int, z: complex, offset: int = 0) -> Qobj: ...
122
def displace(N: int, alpha: complex, offset: int = 0) -> Qobj: ...
123
```
124
125
[Quantum Operators](./operators.md)
126
127
### Time Evolution Solvers
128
129
Comprehensive suite of solvers for quantum system dynamics including unitary evolution, open system dynamics, and stochastic methods.
130
131
```python { .api }
132
def sesolve(H, psi0, tlist, e_ops=None, options=None) -> Result: ...
133
def mesolve(H, rho0, tlist, c_ops=None, e_ops=None, options=None) -> Result: ...
134
def mcsolve(H, psi0, tlist, c_ops=None, e_ops=None, ntraj=500, options=None) -> McResult: ...
135
def steadystate(A, c_ops=None, method='direct', sparse=True, use_wbm=False) -> Qobj: ...
136
def floquet_modes(H, T, args=None, sort=True, U=None) -> tuple: ...
137
def propagator(H, t, c_ops=None, args=None, options=None, unitary_mode='batch', parallel=False) -> Qobj: ...
138
```
139
140
[Time Evolution Solvers](./solvers.md)
141
142
### Tensor Operations and Composite Systems
143
144
Operations for combining quantum systems and manipulating composite quantum states and operators.
145
146
```python { .api }
147
def tensor(*args) -> Qobj: ...
148
def ptrace(obj: Qobj, sel) -> Qobj: ...
149
def expect(oper: Qobj, state: Qobj) -> float: ...
150
def variance(oper: Qobj, state: Qobj) -> float: ...
151
def composite(*args) -> Qobj: ...
152
def tensor_swap(obj: Qobj, mask) -> Qobj: ...
153
```
154
155
[Tensor Operations](./tensor-operations.md)
156
157
### Quantum Gates and Circuits
158
159
Quantum gate operations for quantum computing applications including single-qubit, two-qubit, and multi-qubit gates.
160
161
```python { .api }
162
def rx(phi: float, N: int = None) -> Qobj: ...
163
def ry(phi: float, N: int = None) -> Qobj: ...
164
def rz(phi: float, N: int = None) -> Qobj: ...
165
def cnot(N: int = None, control: int = 0, target: int = 1) -> Qobj: ...
166
def hadamard_transform(N: int = 1) -> Qobj: ...
167
def toffoli(N: int = None, controls: list = [0, 1], target: int = 2) -> Qobj: ...
168
def qft(N: int, swap: bool = True) -> Qobj: ...
169
```
170
171
[Quantum Gates](./quantum-gates.md)
172
173
### Superoperators and Open Systems
174
175
Superoperator representations for open quantum system dynamics and Liouvillian formalism.
176
177
```python { .api }
178
def liouvillian(H: Qobj, c_ops: list = None) -> Qobj: ...
179
def lindblad_dissipator(a: Qobj, b: Qobj = None) -> Qobj: ...
180
def spre(A: Qobj) -> Qobj: ...
181
def spost(A: Qobj) -> Qobj: ...
182
def sprepost(A: Qobj, B: Qobj) -> Qobj: ...
183
def operator_to_vector(op: Qobj) -> Qobj: ...
184
def vector_to_operator(vec: Qobj) -> Qobj: ...
185
```
186
187
[Superoperators](./superoperators.md)
188
189
### Visualization and Graphics
190
191
Comprehensive visualization tools for quantum states, processes, and dynamics including Bloch sphere, Wigner functions, and matrix representations.
192
193
```python { .api }
194
class Bloch:
195
def __init__(self, fig=None, axes=None, view=None, figsize=None, background=False): ...
196
def add_states(self, state, kind='vector'): ...
197
def add_vectors(self, list_of_vectors): ...
198
def render(self, title=''): ...
199
def show(self): ...
200
201
def hinton(rho: Qobj, xlabels=None, ylabels=None, title=None, ax=None) -> None: ...
202
def plot_wigner(rho: Qobj, xvec=None, yvec=None, method='clenshaw', projection='2d') -> tuple: ...
203
def matrix_histogram(M: Qobj, xlabels=None, ylabels=None, title=None, limits=None, ax=None) -> None: ...
204
```
205
206
[Visualization](./visualization.md)
207
208
### Quantum Information and Entanglement
209
210
Tools for quantum information processing including entropy measures, entanglement quantification, and quantum correlations.
211
212
```python { .api }
213
def entropy_vn(rho: Qobj, base: float = np.e, sparse: bool = False) -> float: ...
214
def entropy_mutual(rho: Qobj, selA: list, selB: list, base: float = np.e, sparse: bool = False) -> float: ...
215
def concurrence(rho: Qobj) -> float: ...
216
def negativity(rho: Qobj, mask) -> float: ...
217
def entangling_power(U: Qobj, targets: list = None) -> float: ...
218
def quantum_relative_entropy(rho: Qobj, sigma: Qobj, base: float = np.e, sparse: bool = False) -> float: ...
219
```
220
221
[Quantum Information](./quantum-information.md)
222
223
### Random Objects and Testing
224
225
Generation of random quantum objects for testing, benchmarking, and quantum algorithm development.
226
227
```python { .api }
228
def rand_herm(N: int, density: float = 0.75, dims: list = None) -> Qobj: ...
229
def rand_unitary(N: int, density: float = 0.75, dims: list = None) -> Qobj: ...
230
def rand_dm(N: int, density: float = 0.75, dims: list = None) -> Qobj: ...
231
def rand_ket(N: int, density: float = 1, dims: list = None) -> Qobj: ...
232
def rand_kraus_map(N: int, dims: list = None) -> list: ...
233
```
234
235
[Random Objects](./random-objects.md)
236
237
### Phase Space and Wigner Functions
238
239
Phase space representations and quasi-probability distributions for continuous variable quantum systems.
240
241
```python { .api }
242
def wigner(rho: Qobj, xvec: ArrayLike, yvec: ArrayLike, g: float = np.sqrt(2)) -> np.ndarray: ...
243
def qfunc(rho: Qobj, xvec: ArrayLike, yvec: ArrayLike, g: float = np.sqrt(2)) -> np.ndarray: ...
244
def spin_wigner(rho: Qobj, theta: ArrayLike, phi: ArrayLike) -> np.ndarray: ...
245
def spin_q_function(rho: Qobj, theta: ArrayLike, phi: ArrayLike) -> np.ndarray: ...
246
```
247
248
[Phase Space Functions](./phase-space.md)
249
250
### Process Tomography and Characterization
251
252
Quantum process tomography tools for characterizing quantum operations and noise processes.
253
254
```python { .api }
255
def qpt(U: Qobj, op_basis: list = None) -> Qobj: ...
256
def qpt_plot(chi: Qobj, lbls_list: list = None, title: str = None, fig: object = None, threshold: float = None) -> None: ...
257
def qpt_plot_combined(chi: Qobj, lbls_list: list = None, title: str = None, fig: object = None, threshold: float = 0.01) -> None: ...
258
```
259
260
[Process Tomography](./process-tomography.md)
261
262
### File I/O and Utilities
263
264
Data persistence, file operations, and utility functions for QuTiP objects and calculations.
265
266
```python { .api }
267
def qsave(obj, name: str, format: str = 'pickle') -> None: ...
268
def qload(name: str, format: str = 'pickle') -> object: ...
269
def about() -> None: ...
270
def cite() -> str: ...
271
def n_thermal(w: float, w_th: float) -> float: ...
272
def clebsch(j1: float, j2: float, j3: float, m1: float, m2: float, m3: float) -> float: ...
273
```
274
275
[Utilities and I/O](./utilities.md)
276
277
## Types
278
279
```python { .api }
280
class Qobj:
281
"""
282
Quantum object class representing quantum states, operators, and superoperators.
283
284
Attributes:
285
data: Underlying sparse or dense matrix data
286
dims: List representing the tensor structure dimensions
287
shape: Tuple of matrix dimensions
288
type: String indicating 'ket', 'bra', 'oper', or 'super'
289
isherm: Boolean indicating if operator is Hermitian
290
isunitary: Boolean indicating if operator is unitary
291
"""
292
293
class Result:
294
"""
295
Result object for time evolution solvers.
296
297
Attributes:
298
solver: String name of solver used
299
times: Array of time points
300
states: List of quantum states at each time
301
expect: List of expectation values (if e_ops provided)
302
num_expect: Number of expectation operators
303
num_collapse: Number of collapse events (Monte Carlo)
304
"""
305
306
class McResult(Result):
307
"""
308
Monte Carlo result object with trajectory information.
309
310
Additional Attributes:
311
ntraj: Number of trajectories computed
312
col_times: Collapse times for each trajectory
313
col_which: Which collapse operator caused each collapse
314
"""
315
```