示例#1
0
文件: dimer.py 项目: vkxlzptm/pydmft
def sorted_basis(basis_numbering=False):
    """Sorts the basis of states for the electrons in the molecule
    Enforces ordering in particle number an Sz projection"""

    ind = np.array([0, 1, 2, 4, 8, 5, 10, 6, 9, 12, 3, 7, 11, 13, 14, 15])
    if basis_numbering:
        ind = basis_numbering

    basis = [fermion.destruct(4, sigma)[ind][:, ind] for sigma in range(4)]
    return basis
示例#2
0
def test_gf_lehmann2():
    """Verifies the lehmann representation of a random Hamiltonian"""
    w = np.linspace(-1.5, 1.5, 500)
    d_up = fermion.destruct(6, 0)
    H = np.random.rand(*d_up.shape)
    H += H.T

    e, v = operators.diagonalize(H)
    g_up_diag = operators.gf_lehmann(e, v, d_up.T, 400, w)
    g_up_cross = operators.gf_lehmann(e, v, d_up.T, 400, w, d_up)
    assert np.allclose(g_up_diag, g_up_cross)
def test_gf_lehmann2():
    """Verifies the lehmann representation of a random Hamiltonian"""
    w = np.linspace(-1.5, 1.5, 500)
    d_up = fermion.destruct(6, 0)
    H = np.random.rand(*d_up.shape)
    H += H.T

    e, v = operators.diagonalize(H)
    g_up_diag = operators.gf_lehmann(e, v, d_up.T, 400, w)
    g_up_cross = operators.gf_lehmann(e, v, d_up.T, 400, w, d_up)
    assert np.allclose(g_up_diag, g_up_cross)
示例#4
0
    def __init__(self, beta, t):
        self.beta = beta
        self.t = t
        self.m2 = m2_weight(t)
        self.mu = 0.
        self.e_c = 0.

        self.eig_energies = None
        self.eig_states = None
        self.oper = [fermion.destruct(4, index) for index in range(4)]
        self.H_operators = self.hamiltonian()
        self.GF = {}
示例#5
0
    def __init__(self, beta, t):
        self.beta = beta
        self.t = t
        self.m2 = m2_weight(t)
        self.mu = 0.
        self.e_c = 0.

        self.eig_energies = None
        self.eig_states = None
        self.oper = [fermion.destruct(4, index) for index in range(4)]
        self.H_operators = self.hamiltonian()
        self.GF = {}
示例#6
0
def hamiltonian(U, mu):
    r"""Generate a single orbital isolated atom Hamiltonian in particle-hole
    symmetry. Include chemical potential for grand Canonical calculations

    .. math::
        \mathcal{H} - \mu N = -\frac{U}{2}(n_\uparrow - n_\downarrow)^2
        - \mu(n_\uparrow + n_\downarrow)

    """
    d_up, d_dw = [fermion.destruct(2, sigma) for sigma in range(2)]
    sigma_z = d_up.T * d_up - d_dw.T * d_dw
    H = -U / 2 * sigma_z * sigma_z - mu * (d_up.T * d_up + d_dw.T * d_dw)
    return H, d_up, d_dw
示例#7
0
def test_fermion_anticommut():
    """Verifies the fermion anticommutation relations"""
    particles = 3
    c = [fermion.destruct(particles, index) for index in range(particles)]

    for i in range(particles):
        for j in range(i, particles):
            assert operators.anticommutator(c[i].T, c[j].T).nnz == 0
            assert operators.anticommutator(c[i], c[j]).nnz == 0

            k_delta = operators.anticommutator(c[i], c[j].T)
            if i == j:
                assert (k_delta - eye(2**particles)).nnz == 0
            else:
                assert k_delta.nnz == 0
def test_fermion_anticommut():
    """Verifies the fermion anticommutation relations"""
    particles = 3
    c = [fermion.destruct(particles, index) for index in range(particles)]

    for i in range(particles):
        for j in range(i, particles):
            assert operators.anticommutator(c[i].T, c[j].T).nnz == 0
            assert operators.anticommutator(c[i], c[j]).nnz == 0

            k_delta = operators.anticommutator(c[i], c[j].T)
            if i == j:
                assert (k_delta - eye(2**particles)).nnz == 0
            else:
                assert k_delta.nnz == 0
示例#9
0
def test_gf_lehmann(U, mu, beta):
    """Verifies the lehmann representation of the atom"""
    w = np.linspace(-1.5*U, 1.5*U, 500)
    d_up, d_dw = [fermion.destruct(2, sigma) for sigma in range(2)]
    sigma_z = d_up.T*d_up - d_dw.T*d_dw
    H = - U/2 * sigma_z * sigma_z - mu * (d_up.T*d_up + d_dw.T*d_dw)

    e, v = operators.diagonalize(H.todense())
    g_up = operators.gf_lehmann(e, v, d_up.T, beta, w)
    g_up_cross = operators.gf_lehmann(e, v, d_up.T, beta, w, d_up)

    Z = 1+2*np.exp(beta*(U/2+mu)) + np.exp(2*beta*mu)
    g_up_ref = ((1+np.exp(beta*(U/2+mu)))/(w + mu + U/2.) +
                (np.exp(beta*(U/2+mu)) + np.exp(2*beta*mu))/(w + mu - U/2.))/Z

    assert np.allclose(g_up, g_up_ref)
    assert np.allclose(g_up_cross, g_up_ref)
示例#10
0
def test_gf_lehmann(U, mu, beta):
    """Verifies the lehmann representation of the atom"""
    w = np.linspace(-1.5 * U, 1.5 * U, 500)
    d_up, d_dw = [fermion.destruct(2, sigma) for sigma in range(2)]
    sigma_z = d_up.T * d_up - d_dw.T * d_dw
    H = -U / 2 * sigma_z * sigma_z - mu * (d_up.T * d_up + d_dw.T * d_dw)

    e, v = operators.diagonalize(H.todense())
    g_up = operators.gf_lehmann(e, v, d_up.T, beta, w)
    g_up_cross = operators.gf_lehmann(e, v, d_up.T, beta, w, d_up)

    Z = 1 + 2 * np.exp(beta * (U / 2 + mu)) + np.exp(2 * beta * mu)
    g_up_ref = ((1 + np.exp(beta * (U / 2 + mu))) / (w + mu + U / 2.) +
                (np.exp(beta * (U / 2 + mu)) + np.exp(2 * beta * mu)) /
                (w + mu - U / 2.)) / Z

    assert np.allclose(g_up, g_up_ref)
    assert np.allclose(g_up_cross, g_up_ref)