import matplotlib.pyplot as plt
import numpy as np
import qutip as qt
from qutip import about, basis, identity, sigmax, sigmay, sigmaz
%matplotlib inline
rho = qt.rand_dm(5)
qt.hinton(rho);
theta = np.linspace(0, np.pi, 90)
phi = np.linspace(0, 2 * np.pi, 60)
qt.sphereplot(theta, phi, qt.orbital(theta, phi, basis(3, 0)).T);
fig = plt.figure(figsize=(16, 4))
ax = fig.add_subplot(1, 3, 1, projection="3d")
qt.sphereplot(theta, phi, qt.orbital(theta, phi, basis(3, 0)).T, fig, ax)
ax = fig.add_subplot(1, 3, 2, projection="3d")
qt.sphereplot(theta, phi, qt.orbital(theta, phi, basis(3, 1)).T, fig, ax)
ax = fig.add_subplot(1, 3, 3, projection="3d")
qt.sphereplot(theta, phi, qt.orbital(theta, phi, basis(3, 2)).T, fig, ax);
qt.matrix_histogram(rho.full().real);
qt.matrix_histogram_complex(rho.full());
H0 = qt.tensor(sigmaz(), identity(2)) + qt.tensor(identity(2), sigmaz())
Hint = 0.1 * qt.tensor(sigmax(), sigmax())
qt.plot_energy_levels([H0, Hint], figsize=(8, 4));
rho = (qt.coherent(15, 1.5) + qt.coherent(15, -1.5)).unit()
qt.plot_fock_distribution(rho);
qt.plot_wigner_fock_distribution(rho);
qt.plot_wigner(rho, figsize=(6, 6));
H = sigmaz() + 0.3 * sigmay()
e_ops = [sigmax(), sigmay(), sigmaz()]
times = np.linspace(0, 10, 100)
psi0 = (basis(2, 0) + basis(2, 1)).unit()
result = qt.mesolve(H, psi0, times, [], e_ops)
qt.plot_expectation_values(result);
b = qt.Bloch()
b.add_vectors(qt.expect(H.unit(), e_ops))
b.add_points(result.expect, meth="l")
b.make_sphere()
j = 5
psi = qt.spin_state(j, -j)
psi = qt.spin_coherent(j, np.random.rand() * np.pi,
np.random.rand() * 2 * np.pi)
rho = qt.ket2dm(psi)
theta = np.linspace(0, np.pi, 50)
phi = np.linspace(0, 2 * np.pi, 50)
Q, THETA, PHI = qt.spin_q_function(psi, theta, phi)
qt.plot_spin_distribution_2d(Q, THETA, PHI);
/usr/share/miniconda3/envs/test-environment/lib/python3.10/site-packages/qutip/visualization.py:1330: UserWarning: The input coordinates to pcolor are interpreted as cell centers, but are not monotonically increasing or decreasing. This may lead to incorrectly calculated cell edges, in which case, please supply explicit cell edges to pcolor. ax.pcolor(X, Y, P.real, cmap=cmap)
fig, ax = qt.plot_spin_distribution_3d(Q, THETA, PHI)
ax.view_init(15, 30)
fig = plt.figure(figsize=(14, 6))
ax = fig.add_subplot(1, 2, 1)
f1, a1 = qt.plot_spin_distribution_2d(Q, THETA, PHI, fig=fig, ax=ax)
ax = fig.add_subplot(1, 2, 2, projection="3d")
f2, a2 = qt.plot_spin_distribution_3d(Q, THETA, PHI, fig=fig, ax=ax)
W, THETA, PHI = qt.spin_wigner(psi, theta, phi)
fig = plt.figure(figsize=(14, 6))
ax = fig.add_subplot(1, 2, 1)
f1, a1 = qt.plot_spin_distribution_2d(W.real, THETA, PHI, fig=fig, ax=ax)
ax = fig.add_subplot(1, 2, 2, projection="3d")
f2, a2 = qt.plot_spin_distribution_3d(W.real, THETA, PHI, fig=fig, ax=ax)
about()
QuTiP: Quantum Toolbox in Python ================================ Copyright (c) QuTiP team 2011 and later. Current admin team: Alexander Pitchford, Nathan Shammah, Shahnawaz Ahmed, Neill Lambert, Eric Giguère, Boxi Li, Jake Lishman, Simon Cross and Asier Galicia. Board members: Daniel Burgarth, Robert Johansson, Anton F. Kockum, Franco Nori and Will Zeng. Original developers: R. J. Johansson & P. D. Nation. Previous lead developers: Chris Granade & A. Grimsmo. Currently developed through wide collaboration. See https://github.com/qutip for details. QuTiP Version: 4.7.6 Numpy Version: 1.22.4 Scipy Version: 1.12.0 Cython Version: 0.29.37 Matplotlib Version: 3.5.2 Python Version: 3.10.4 Number of CPUs: 4 BLAS Info: Generic OPENMP Installed: False INTEL MKL Ext: False Platform Info: Linux (x86_64) Installation path: /usr/share/miniconda3/envs/test-environment/lib/python3.10/site-packages/qutip ================================================================================ Please cite QuTiP in your publication. ================================================================================ For your convenience a bibtex reference can be easily generated using `qutip.cite()`