import matplotlib.pyplot as plt
import numpy as np
import qutip as qt
from qutip import about, basis, identity, sigmax, sigmay, sigmaz
from scipy.special import sph_harm
%matplotlib inline
rho = qt.rand_dm(5)
fig, ax = qt.hinton(rho)
ax.set_title('hinton');
theta = np.linspace(0, np.pi, 90)
phi = np.linspace(0, 2 * np.pi, 60)
phi_mesh, theta_mesh = np.meshgrid(phi, theta)
orbital = sph_harm(-1, 2, phi_mesh, theta_mesh).T
qt.sphereplot(orbital, theta, phi);
fig = plt.figure(figsize=(16, 4))
ax = fig.add_subplot(1, 3, 1, projection="3d")
orbital = sph_harm(-1, 1, phi_mesh, theta_mesh).T
qt.sphereplot(orbital, theta, phi, ax=ax)
ax = fig.add_subplot(1, 3, 2, projection="3d")
orbital = sph_harm(0, 1, phi_mesh, theta_mesh).T
qt.sphereplot(orbital, theta, phi, ax=ax)
ax = fig.add_subplot(1, 3, 3, projection="3d")
orbital = sph_harm(1, 1, phi_mesh, theta_mesh).T
qt.sphereplot(orbital, theta, phi, ax=ax);
qt.matrix_histogram(rho.full().real);
qt.matrix_histogram(rho.full(), limits=[0, 1],
bar_style='abs', color_style='phase');
H0 = qt.tensor(sigmaz(), identity(2)) + qt.tensor(identity(2), sigmaz())
Hint = 0.1 * qt.tensor(sigmax(), sigmax())
fig = plt.figure(figsize=(8, 4))
qt.plot_energy_levels([H0, Hint], h_labels=['H0', 'H0+Hint'], fig=fig);
rho = (qt.coherent(15, 1.5) + qt.coherent(15, -1.5)).unit()
qt.plot_fock_distribution(rho);
fig, axes = plt.subplots(1, 2, figsize=(8, 4))
qt.plot_fock_distribution(rho, fig=fig, ax=axes[0])
qt.plot_wigner(rho, fig=fig, ax=axes[1]);
qt.plot_wigner(rho);
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(Q, THETA, PHI);
/usr/share/miniconda3/envs/test-environment/lib/python3.10/site-packages/qutip/visualization.py:1386: 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. artist_list.append([ax.pcolor(X, Y, P.real, cmap=cmap)])
fig, ax = qt.plot_spin_distribution(Q, THETA, PHI, projection='3d')
ax.view_init(15, 30);
fig = plt.figure(figsize=(14, 6))
ax = fig.add_subplot(1, 2, 1)
f1, a1 = qt.plot_spin_distribution(Q, THETA, PHI, fig=fig, ax=ax)
ax = fig.add_subplot(1, 2, 2, projection="3d")
f2, a2 = qt.plot_spin_distribution(Q, THETA, PHI, projection='3d', 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(W.real, THETA, PHI, fig=fig, ax=ax)
ax = fig.add_subplot(1, 2, 2, projection="3d")
f2, a2 = qt.plot_spin_distribution(W.real, THETA, PHI, projection='3d', 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: 5.1.0.dev0+50fc9b7 Numpy Version: 1.22.4 Scipy Version: 1.13.0 Cython Version: 3.0.10 Matplotlib Version: 3.5.2 Python Version: 3.10.4 Number of CPUs: 4 BLAS Info: Generic 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()`