예제 #1
0
def signed_identity(n):
    """
    returns the kronecker product of n signed identity 2 x 2 matrices
    sI = [[1, 0],
          [0, -1]]
    out = sI \otimes sI \otimes sI \otimes .....
    """
    sI = sm([[1, 0], [0, -1]])
    out = sI.copy()

    for x in xrange(n - 1):
        out = kron(out, sI)
    return out
예제 #2
0
def signed_identity(n):
    """
    returns the kronecker product of n signed identity 2 x 2 matrices
    sI = [[1, 0],
          [0, -1]]
    out = sI \otimes sI \otimes sI \otimes .....
    """
    sI = sm([[1, 0], [0, -1]])
    out = sI.copy()

    for x in xrange(n - 1):
        out = kron(out, sI)
    return out
예제 #3
0
def f_destroy(n, Ntot):
    """
    returns a fermionic descruction operator for the n'th single-particle
    state out of N_tot states.
    assumes that the states are ordered as:
    |n_0, n_1, n_2, .... , n_(Ntot - 2), n_(Ntot - 1)>
    """

    if n < 0 or n >= Ntot:
        raise ValueError('n has to be in [0, 1, ..., Ntot - 1]')

    # destruction operator for 1-state space
    # |basis 0> = |0>, |basis 1> = c^+|0>,
    c = sm([[0, 0], [1, 0]])

    if n == 0:
        return sm(kron(c, unsigned_identity(Ntot - 1)))
    elif n == Ntot - 1:
        return sm(kron(signed_identity(Ntot - 1), c))
    else:
        # signed identity and c
        tmp = kron(signed_identity(n), c)
        # this times unsigned indentity
        return sm(kron(tmp, unsigned_identity(Ntot - 1 - n)))
예제 #4
0
def f_destroy(n, Ntot):
    """
    returns a fermionic descruction operator for the n'th single-particle
    state out of N_tot states.
    assumes that the states are ordered as:
    |n_0, n_1, n_2, .... , n_(Ntot - 2), n_(Ntot - 1)>
    """

    if n < 0 or n >= Ntot:
        raise ValueError('n has to be in [0, 1, ..., Ntot - 1]')

    # destruction operator for 1-state space
    # |basis 0> = |0>, |basis 1> = c^+|0>,
    c = sm([[0, 0], [1, 0]])

    if n == 0:
        return sm(kron(c, unsigned_identity(Ntot - 1)))
    elif n == Ntot - 1:
        return sm(kron(signed_identity(Ntot - 1), c))
    else:
        # signed identity and c
        tmp = kron(signed_identity(n), c)
        # this times unsigned indentity
        return sm(kron(tmp, unsigned_identity(Ntot - 1 - n)))
예제 #5
0
sys.path.insert(0, '.')

import squanf_class

Ne = 1
Nh = 1

eh = squanf_class.squanf(Ne=Ne, Nh=Nh, use_spin=True)

# short hands

e = eh.e
eD = eh.eD
h = eh.h
hD = eh.hD

# Hamiltonian

H = sm(e(0, 'u').shape)

Eex = 1.
V1 = 20.
V2 = 10.

for spin in ['u', 'd']:
    H = H + Eex / 2 * eD(0, spin) * e(0, spin)
    H = H + Eex / 2 * hD(0, spin) * h(0, spin)

print H.todense().astype(int)