def test_tddw(get_tddw): tddw = get_tddw h_dw = get_double_well_one_body_elements( tddw.l // 2, tddw._basis_set.omega, tddw._basis_set.mass, tddw._basis_set.barrier_strength, dtype=np.complex128, axis=0, ) epsilon, C_dw = np.linalg.eigh(h_dw) C = BasisSet.add_spin_one_body(C_dw, np=np) tddw.change_basis(C[:, : tddw.l]) dip = np.load(os.path.join("tests", "dat", "tddw_dipole_moment.npy")) np.testing.assert_allclose( np.abs(dip), np.abs(tddw.dipole_moment), atol=1e-10 ) h = np.load(os.path.join("tests", "dat", "tddw_h.npy")) np.testing.assert_allclose(h, tddw.h, atol=1e-10) u = np.load(os.path.join("tests", "dat", "tddw_u.npy")) np.testing.assert_allclose(np.abs(u), np.abs(tddw.u), atol=1e-10) spf = np.load(os.path.join("tests", "dat", "tddw_spf.npy")) np.testing.assert_allclose(np.abs(spf), np.abs(tddw.spf), atol=1e-10)
def test_add_spin_one_body(): l_half = 10 h = np.random.random((l_half, l_half)) l = l_half * 2 h_spin = np.zeros((l, l)) for p in range(l): for q in range(l): h_spin[p, q] = spin_delta(p, q) * h[p // 2, q // 2] np.testing.assert_allclose(h_spin, BasisSet.add_spin_one_body(h, np=np), atol=1e-10)
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_antisymmetric_one_body_elements(h): l = len(h) _h = BasisSet.add_spin_one_body(get_one_body_elements(l // 2), np=np) np.testing.assert_allclose(h, _h, atol=1e-6, rtol=1e-6)