def test_spf(spf_2dho): n, l, radius, num_grid_points, spf_test = spf_2dho tdho = TwoDimensionalHarmonicOscillator(n, l, radius, num_grid_points) tdho.setup_spf() for p in range(l // 2): np.testing.assert_allclose(spf_test[p], tdho.spf[p])
def test_two_body_elements_compare(): n = 2 l = 6 grid_length = 5 num_grid_points = 201 mass = 1 omega = 1 omega_c = 0 two_dim_ho = GeneralOrbitalSystem( n, TwoDimensionalHarmonicOscillator( l, grid_length, num_grid_points, mass=mass, omega=omega ), ) two_dim_ho_b = GeneralOrbitalSystem( n, TwoDimHarmonicOscB( l, grid_length, num_grid_points, mass=mass, omega=omega, omega_c=omega_c, ), ) np.testing.assert_allclose(two_dim_ho.u, two_dim_ho_b.u, atol=1e-8)
def test_change_of_basis(): # We try to construct a two-dimensional double-well system from a # two-dimensional harmonic oscillator system by using the change-of-basis # function with C found from diagonalizing the double-well one-body # Hamiltonian. n = 2 l = 12 omega = 1 mass = 1 barrier_strength = 3 radius = 10 num_grid_points = 401 axis = 0 tdho = GeneralOrbitalSystem( n, TwoDimensionalHarmonicOscillator( l, radius, num_grid_points, omega=omega ), ) h_dw = get_double_well_one_body_elements( l, omega, mass, barrier_strength, dtype=np.complex128, axis=axis ) epsilon, C_dw = np.linalg.eigh(h_dw) C = BasisSet.add_spin_one_body(C_dw, np=np) tdho.change_basis(C) tddw = GeneralOrbitalSystem( n, TwoDimensionalDoubleWell( l, radius, num_grid_points, omega=omega, mass=mass, barrier_strength=barrier_strength, axis=axis, ), ) tddw.change_basis(C) np.testing.assert_allclose(tdho.u, tddw.u, atol=1e-7) np.testing.assert_allclose(tdho.spf, tddw.spf, atol=1e-7)
def test_zero_barrier(): """Test checking if we can reproduce the regular two-dimensional harmonic oscillator system when setting the barrier strength to zero. """ n = 2 l = 12 radius = 10 num_grid_points = 401 tddw = TwoDimensionalDoubleWell( l, radius, num_grid_points, barrier_strength=0, axis=0 ) tdho = TwoDimensionalHarmonicOscillator(l, radius, num_grid_points) np.testing.assert_allclose(tddw.h, tdho.h, atol=1e-7) np.testing.assert_allclose(tddw.u, tdho.u, atol=1e-7) np.testing.assert_allclose(tddw.spf, tdho.spf, atol=1e-7)
import numpy as np from matplotlib import cm import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D from quantum_systems import TwoDimensionalHarmonicOscillator n = 2 l = 30 radius_length = 4 num_grid_points = 101 tdho = TwoDimensionalHarmonicOscillator(n, l, radius_length, num_grid_points) tdho.setup_spf() fig = plt.figure(figsize=(16, 12)) fig.suptitle(r"Probability density $\langle \phi_p \vert \phi_p \rangle$") for p in range(l // 2): ax = fig.add_subplot(3, 5, p + 1, polar=True) ax.set_title(fr"$p = {p}$", loc="left") plt.contourf(tdho.T, tdho.R, np.abs(tdho.spf[2 * p] * tdho.spf[2 * p].conj())) fig = plt.figure(figsize=(16, 12)) fig.suptitle(r"$\Re(\phi_p(\mathbf{r}))^2$") for p in range(l // 2): ax = fig.add_subplot(3, 5, p + 1, polar=True) ax.set_title(fr"$p = {p}$", loc="left")
import numpy as np import matplotlib.pyplot as plt from quantum_systems import TwoDimensionalHarmonicOscillator n = 2 l = 30 radius_length = 4 num_grid_points = 101 tdho = TwoDimensionalHarmonicOscillator(n, l, radius_length, num_grid_points) tdho.construct_dipole_moment() plt.subplot(2, 2, 1) plt.imshow(tdho.dipole_moment[0].real) plt.title(r"$\Re(\langle p | \hat{x} | q \rangle)$") plt.xlabel(r"$q$") plt.ylabel(r"$p$") ax = plt.gca() ax.set_xticks(np.arange(0, l)) ax.set_yticks(np.arange(0, l)) ax.set_xticklabels(np.arange(0, l)) ax.set_yticklabels(np.arange(0, l)) ax.set_xticks(np.arange(-0.5, l - 0.5), minor=True) ax.set_yticks(np.arange(-0.5, l - 0.5), minor=True) ax.grid(which="minor", color="w", linewidth=1)