Example #1
0
def test_open_odqd():
    n = 5
    n_a = 3
    n_b = n - n_a
    l = 20

    odho_res = ODQD(n, l, 11, 201, n_a=n_a)
    odho_res.setup_system(add_spin=False, anti_symmetrize=False)

    odho = ODQD(n, l, 11, 201, n_a=n_a)
    odho.setup_system()

    np.testing.assert_allclose(
        odho_res.spf[:n_a],
        odho.spf[odho.o_a],
    )

    np.testing.assert_allclose(
        odho_res.spf[:n - n_a],
        odho.spf[odho.o_b],
    )

    np.testing.assert_allclose(odho_res.h[:n_a, :n_a], odho.h[odho.o_a,
                                                              odho.o_a])

    np.testing.assert_allclose(odho_res.h[:n - n_a, :n - n_a],
                               odho.h[odho.o_b, odho.o_b])

    np.testing.assert_allclose(np.zeros((n_a, n_b)), odho.h[odho.o_a,
                                                            odho.o_b])

    np.testing.assert_allclose(np.zeros((n_b, n_a)), odho.h[odho.o_b,
                                                            odho.o_a])
Example #2
0
def get_oddw_smooth():
    n = 2
    l = 20

    grid_length = 5
    num_grid_points = 1001
    a = 5

    oddw_smooth = ODQD(n, l, grid_length, num_grid_points)
    oddw_smooth.setup_system(potential=DWPotentialSmooth(a=a))

    return oddw_smooth
Example #3
0
def get_odho():
    n = 2
    l = 20

    grid_length = 5
    num_grid_points = 1001
    omega = 1

    odho = ODQD(n, l, grid_length, num_grid_points)
    odho.setup_system(potential=HOPotential(omega))

    return odho
Example #4
0
def get_oddw():
    n = 2
    l = 20

    grid_length = 6
    num_grid_points = 1001

    omega = 1
    length_of_dw = 5

    oddw = ODQD(n, l, grid_length, num_grid_points)
    oddw.setup_system(potential=DWPotential(omega, length_of_dw))

    return oddw
Example #5
0
def get_odho_ao():
    n = 2
    l = 20

    grid_length = 5
    num_grid_points = 1001
    omega = 1

    odho = ODQD(n, l, grid_length, num_grid_points)
    odho.setup_system(
        potential=HOPotential(omega), add_spin=False, anti_symmetrize=False
    )

    return odho
Example #6
0
def test_copy():
    odho = ODQD(2, 12, 11, 201)
    odho.setup_system()

    odho_2 = odho.copy_system()

    assert id(odho) != id(odho_2)
    assert id(odho.h) != id(odho_2.h)

    np.testing.assert_allclose(odho.h, odho_2.h)

    odho.h[0, 0] = 10

    assert not np.equal(odho.h, odho_2.h).all()
Example #7
0
def get_qdot_matrix(n, l, omega, grid_length=5, n_grid=1001):
    odho = ODQD(n, l, grid_length, n_grid)
    odho.setup_system(potential=HOPotential(omega), add_spin=True)

    one_body = odho.h
    one_body[np.absolute(one_body) < 1e-8] = 0
    two_body = odho.u
    two_body[np.absolute(two_body) < 1e-8] = 0

    # Coupled Cluster
    Eref = odho.compute_reference_energy()
    ccsd = CCSD(odho, verbose=False)
    ccsd.compute_ground_state()
    Ecc = ccsd.compute_energy()
    return one_body, two_body, [Eref, Ecc]
Example #8
0
def get_odgauss():
    n = 2
    l = 20

    grid_length = 20
    num_grid_points = 1001

    weight = 1
    center = 0
    deviation = 2.5

    odgauss = ODQD(n, l, grid_length, num_grid_points)
    odgauss.setup_system(
        potential=GaussianPotential(weight, center, deviation, np=np)
    )

    return odgauss
Example #9
0
from quantum_systems import ODQD
from quantum_systems.quantum_dots.one_dim.one_dim_potentials import HOPotential
from coupled_cluster import CCSD

l = 4
n = 2

# Generate system
omega = 1

grid_length = 5
num_grid_points = 1001

odho = ODQD(n, l, grid_length, num_grid_points)
odho.setup_system(potential=HOPotential(omega), add_spin=True)

one_body = odho.h
one_body[np.absolute(one_body) < 1e-8] = 0
two_body = odho.u
two_body[np.absolute(two_body) < 1e-8] = 0

# Coupled Cluster
print('Reference energy:', odho.compute_reference_energy())
ccsd = CCSD(odho, verbose=False)
ccsd.compute_ground_state()
print('ECCSD =', ccsd.compute_energy())

# Prepare circuit list
H2 = SecondQuantizedHamiltonian(n, l)
H2.set_integrals(one_body, two_body, anti_symmetric=True)
Example #10
0
def save_data(system, system_name):
    np.save(f"{system_name}_dipole_moment", system.dipole_moment)
    np.save(f"{system_name}_h", system.h)
    np.save(f"{system_name}_u", system.u)
    np.save(f"{system_name}_spf", system.spf)


n = 2
l = 20

grid_length = 5
num_grid_points = 1001
omega = 1

odho = ODQD(n, l, grid_length, num_grid_points)
odho.setup_system(potential=ODQD.HOPotential(omega))
save_data(odho, "odho")

length_of_dw = 5

oddw = ODQD(n, l, 6, num_grid_points)
oddw.setup_system(potential=ODQD.DWPotential(omega, length_of_dw))
save_data(oddw, "oddw")

weight = 1
center = 0
deviation = 2.5

odgauss = ODQD(n, l, 20, num_grid_points)
odgauss.setup_system(
    potential=ODQD.GaussianPotential(weight, center, deviation, np=np))
Example #11
0
import numpy as np
import matplotlib.pyplot as plt

from quantum_systems import ODQD

n = 2
l = 10

odqd = ODQD(n, l, 4, 201)
odqd.setup_system(potential=ODQD.DWPotentialSmooth(a=4.5))

plt.plot(odqd.grid, odqd.potential(odqd.grid))

for i in range(l // 2):
    plt.plot(odqd.grid, odqd.eigen_energies[i] + np.abs(odqd.spf[i * 2])**2)

plt.show()
Example #12
0
def test_restricted_odho():
    n = 4
    l = 20

    odho_res = ODQD(n, l, 11, 201)
    odho_res.setup_system(add_spin=False, anti_symmetrize=False)

    odho = ODQD(n, l, 11, 201)
    odho.setup_system()

    assert odho.h.shape == tuple(2 * s for s in odho_res.h.shape)
    assert odho.u.shape == tuple(2 * s for s in odho_res.u.shape)

    np.testing.assert_allclose(
        odho.spf[odho.o_a],
        odho.spf[odho.o_b],
    )

    np.testing.assert_allclose(
        odho.spf[odho.v_a],
        odho.spf[odho.v_b],
    )

    np.testing.assert_allclose(odho.h[odho.o_a, odho.o_a], odho.h[odho.o_b,
                                                                  odho.o_b])

    np.testing.assert_allclose(odho.h[odho.v_a, odho.v_a], odho.h[odho.v_b,
                                                                  odho.v_b])

    np.testing.assert_allclose(np.zeros((n // 2, n // 2)), odho.h[odho.o_b,
                                                                  odho.o_a])

    np.testing.assert_allclose(np.zeros((n // 2, n // 2)), odho.h[odho.o_a,
                                                                  odho.o_b])

    np.testing.assert_allclose(
        odho.u[odho.o_a, odho.o_a, odho.o_a, odho.o_a],
        odho.u[odho.o_b, odho.o_b, odho.o_b, odho.o_b],
    )

    np.testing.assert_allclose(
        odho.u[odho.v_a, odho.v_a, odho.v_a, odho.v_a],
        odho.u[odho.v_b, odho.v_b, odho.v_b, odho.v_b],
    )

    o_res = slice(0, odho_res.n // 2)
    v_res = slice(odho_res.n // 2, odho_res.l // 2)

    np.testing.assert_allclose(
        odho_res.spf[o_res],
        odho.spf[odho.o_a],
    )

    np.testing.assert_allclose(
        odho_res.spf[v_res],
        odho.spf[odho.v_a],
    )

    np.testing.assert_allclose(odho_res.h[o_res, o_res], odho.h[odho.o_a,
                                                                odho.o_a])

    np.testing.assert_allclose(odho_res.h[o_res, o_res], odho.h[odho.o_b,
                                                                odho.o_b])

    np.testing.assert_allclose(odho_res.h[v_res, v_res], odho.h[odho.v_a,
                                                                odho.v_a])

    np.testing.assert_allclose(odho_res.h[v_res, v_res], odho.h[odho.v_b,
                                                                odho.v_b])
Example #13
0
            label=fr"$\psi_{i}(x)$",
        )

    plt.plot(system.grid, system.potential(system.grid), label=r"$v(x)$")
    plt.legend(loc="best")
    plt.show()


n = 2
l = 20
grid_length = 100
num_grid_points = 2001
omega = 1

odho = ODQD(n, l, grid_length, num_grid_points)
odho.setup_system(potential=ODQD.HOPotential(omega))
plot_one_body_system(odho)

length_of_dw = 5

dw = ODQD(n, l, 6, num_grid_points)
dw.setup_system(potential=ODQD.DWPotential(omega, length_of_dw))
plot_one_body_system(dw)

weight = 1
center = 0
deviation = 2.5

gauss = ODQD(n, l, 20, num_grid_points)
gauss.setup_system(
    potential=ODQD.GaussianPotential(weight, center, deviation, np=np))