Open in CoCalc

Some of Introduction to QuTiP...

from qutip import * RealNumber = float; Integer = int
q = Qobj([, ]) q
Quantum object: dims = [, ], shape = [2, 1], type = ket Qobj data = [[ 1.] [ 0.]]
# the dimension, or composite Hilbert state space structure q.dims
[, ]
# the shape of the matrix data representation q.shape
[2, 1]
# the matrix data itself. in sparse matrix format. q.data
<2x1 sparse matrix of type '<type 'numpy.complex128'>' with 1 stored elements in Compressed Sparse Row format>
# get the dense matrix representation q.full()
array([[ 1.+0.j], [ 0.+0.j]])
# some additional properties q.isherm, q.type
(False, 'ket')
sy = Qobj([[0,-1j], [1j,0]]) # the sigma-y Pauli operator sy
Quantum object: dims = [, ], shape = [2, 2], type = oper, isherm = True Qobj data = [[ 0.+0.j 0.-1.j] [ 0.+1.j 0.+0.j]]
sz = Qobj([[1,0], [0,-1]]) # the sigma-z Pauli operator sz
Quantum object: dims = [, ], shape = [2, 2], type = oper, isherm = True Qobj data = [[ 1. 0.] [ 0. -1.]]
# some arithmetic with quantum objects H = 1.0 * sz + 0.1 * sy print("Qubit Hamiltonian = \n") H
Qubit Hamiltonian = Quantum object: dims = [, ], shape = [2, 2], type = oper, isherm = True Qobj data = [[ 1.+0.j 0.-0.1j] [ 0.+0.1j -1.+0.j ]]
# The hermitian conjugate sy.dag()
Quantum object: dims = [, ], shape = [2, 2], type = oper, isherm = True Qobj data = [[ 0.+0.j 0.-1.j] [ 0.+1.j 0.+0.j]]
# The trace H.tr()
0.0
# Eigen energies H.eigenenergies()
array([-1.00498756, 1.00498756])