コード例 #1
0
ファイル: do.py プロジェクト: Matteo294/FYS4411
    def __init__(self,
                 l=10,
                 grid_length=10,
                 num_grid_points=201,
                 alpha=1.0,
                 a=0.25,
                 Omega=0.25,
                 omega=2,
                 epsilon0=1,
                 nparticles=2,
                 potential=None,
                 antisymmetrize=False):

        self.potential = ODQD.HOPotential(Omega)

        self.system = ODQD(l,
                           grid_length,
                           num_grid_points,
                           a,
                           alpha,
                           potential=self.potential)
        self.nparticles = nparticles
        self.Omega = Omega
        self.omega = omega
        self.epsilon0 = epsilon0
コード例 #2
0
ファイル: do.py プロジェクト: Matteo294/FYS4411
    def __init__(self,
                 l=10,
                 grid_length=10,
                 num_grid_points=201,
                 alpha=1.0,
                 a=0.25,
                 Omega=0.25,
                 omega=2,
                 epsilon0=1,
                 nparticles=2,
                 antisymmetrize=True):

        self.potential = ODQD.HOPotential(Omega)

        odho = ODQD(l,
                    grid_length,
                    num_grid_points,
                    a,
                    alpha,
                    potential=self.potential)
        self.system = GeneralOrbitalSystem(n=nparticles,
                                           basis_set=odho,
                                           anti_symmetrize=antisymmetrize)

        self.nparticles = nparticles
        self.Omega = Omega
        self.omega = omega
        self.epsilon0 = epsilon0
コード例 #3
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
コード例 #4
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
コード例 #5
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
コード例 #6
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
コード例 #7
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])
コード例 #8
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]
コード例 #9
0
def get_odho():
    n = 2
    l = 10

    grid_length = 5
    num_grid_points = 1001
    omega = 1

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

    return odho
コード例 #10
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
コード例 #11
0
def get_oddw_smooth():
    n = 2
    l = 10

    grid_length = 5
    num_grid_points = 1001
    a = 5

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

    return oddw_smooth
コード例 #12
0
ファイル: test_spin.py プロジェクト: einaur/quantum-systems
def test_spin_squared():
    n = 2
    l = 2
    dim = 2

    spas = SpatialOrbitalSystem(n, RandomBasisSet(l, dim))
    spas = SpatialOrbitalSystem(
        n, ODQD(l, 8, 1001, potential=ODQD.HOPotential(1)))
    gos = spas.construct_general_orbital_system(a=[1, 0], b=[0, 1])

    overlap = spas.s
    overlap_sq = np.einsum("pr, qs -> pqrs", overlap, overlap)

    a = gos._basis_set.a
    b = gos._basis_set.b

    aa = np.kron(a, a)
    ab = np.kron(a, b)
    ba = np.kron(b, a)
    bb = np.kron(b, b)

    triplets = [aa, 1 / np.sqrt(2) * (ab + ba), bb]
    singlet = [1 / np.sqrt(2) * (ab - ba)]

    # S^2 with alpha = [1, 0]^T and beta = [0, 1]^T
    S_sq_spin = np.zeros((4, 4))
    S_sq_spin[0, 0] = 2
    S_sq_spin[3, 3] = 2
    S_sq_spin[1, 1] = 1
    S_sq_spin[2, 2] = 1
    S_sq_spin[1, 2] = 1
    S_sq_spin[2, 1] = 1
    S_sq_spin = S_sq_spin.reshape(2, 2, 2, 2)

    for trip in triplets:
        # Check that the eigenvalue of all triplet states is 2
        np.testing.assert_allclose(trip.T @ S_sq_spin.reshape(4, 4) @ trip, 2)

    # Check that the eigenvalue of the singlet state is 0
    np.testing.assert_allclose(
        singlet[0].T @ S_sq_spin.reshape(4, 4) @ singlet[0], 0)
コード例 #13
0
def get_oddw():
    n = 2
    l = 10

    grid_length = 6
    num_grid_points = 1001

    omega = 1
    length_of_dw = 5

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

    return oddw
コード例 #14
0
ファイル: test_copy.py プロジェクト: haakoek/quantum-systems
def test_copy():
    odho = GeneralOrbitalSystem(2, ODQD(12, 11, 201))

    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()
コード例 #15
0
def get_odgauss():
    n = 2
    l = 10

    grid_length = 20
    num_grid_points = 1001

    weight = 1
    center = 0
    deviation = 2.5

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

    return odgauss
コード例 #16
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()
コード例 #17
0
from quantum_circuit import QuantumCircuit, SecondQuantizedHamiltonian

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)
コード例 #18
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(
コード例 #19
0
            system.spf[2 * i].real**2 + system.eigen_energies[i],
            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(
コード例 #20
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])
コード例 #21
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()