Esempio n. 1
0
 def runSpectrumComparisonWithSasha(self):
     mu = 0.27
     beta = 20
     results = list()
     u = 3
     t = -1
     r = 0.3
     h = Hubbard([[-mu, t, t, r], [t, -mu, r, t], [t, r, -mu, t], [r, t, t, -mu]], u, verbose=False)
     h.solve()
     energies = list(h.eigenEnergies)
     energiesSasha = numpy.loadtxt("spectrumSasha.dat")[:, 1]
     self.assertEqual(len(energies), len(energiesSasha))
     for j, eS in enumerate(energiesSasha):
         energyFound = False
         for i, e in enumerate(energies):
             if equals(eS, e):
                 energyFound = True
                 del energies[i]
                 break
         self.assertTrue(energyFound)
Esempio n. 2
0
 def runEigenstatesEquation(self):
     mu = 0.27
     beta = 20
     results = list()
     u = 3
     t = -1
     r = 0.3
     h = Hubbard([[-mu, t, t, r], [t, -mu, r, t], [t, r, -mu, t], [r, t, t, -mu]], u, verbose=False)
     h.solve()
     hmatrix = h.matrix
     statesMatrix = h.eigenStates.toarray()
     for i in range(256):
         e = h.eigenEnergies[i] + h.energyShift
         ve = statesMatrix[:, i]
         eve = hmatrix.dot(ve)
         zeros = eve - e * ve
         for zero in zeros:
             self.assertTrue(
                 equals(zero, 0, rtol=1e-05, atol=1e-12)
             )  # max abs tolerance with scipy.linalg.eigh for that system
Esempio n. 3
0
    def runHubbardAtom(self):
        h = Hubbard([[-0.5]], 1)
        h.solve()
        self.assertEqual(-0.5, h.getGroundStateEnergy())
        self.assertEqual(h.getEnergies(), [0, 0.5])
        self.assertTrue((h.eigenEnergies == numpy.array([0.5, 0, 0, 0.5])).all())
        for state in h.getGroundStatesAlgebraically():
            self.assertTrue(state in ["+1.0 c^('up', 0)\n", "+1.0 c^('dn', 0)\n"])
        for states_e, e in zip(h.getStatesEnergySortedAlgebraically(), h.getEnergies()):
            for state in states_e:
                if e == 0:
                    self.assertTrue(state in ["+1.0 c^('up', 0)\n", "+1.0 c^('dn', 0)\n"])
                elif e == 0.5:
                    self.assertTrue(state in ["+1.0 \n", "+1.0 c^('up', 0) c^('dn', 0)\n"])
                else:
                    self.assertTrue(False)

        c = AnnihilationOperator(h.getSingleParticleBasis())
        n_tot_hat = numpy.sum([c[s, 0].H.dot(c[s, 0]) for s in ["up", "dn"]], axis=0)
        self.assertEqual(h.getGroundStates()[0].getQuantumNumber(n_tot_hat), 1)
        self.assertEqual(h.getGroundStates()[1].getQuantumNumber(n_tot_hat), 1)
Esempio n. 4
0
u = 3
mu = u*.5

hop = [[0,t,t,tp],[t,0,tp,t],[t,tp,0,t],[tp,t,t,0]]
hamiltonian = Hubbard2(hop, u)
plaq = GrandcanonicalEnsemble(hamiltonian, beta, mu)
plaq.calcEigensystem()
e0 = plaq.hamiltonian.getGroundStateEnergy()
energies = plaq.hamiltonian.eigenEnergies
eigenstates = plaq.hamiltonian.eigenStates.toarray()
rho_dim = RDM(beta, eigenstates, energies, 4, 4, [], [0])
rho_dim.calculate()
print rho_dim.get_entanglement_spectrum()
print rho_dim.get_entanglement_entropy()

hamiltonian = Hubbard(hop, u)
print hamiltonian.singleParticleBasis
plaq = GrandcanonicalEnsemble(hamiltonian, beta, mu)
plaq.calcEigensystem()
e0 = plaq.hamiltonian.getGroundStateEnergy()
energies = plaq.hamiltonian.eigenEnergies
eigenstates = plaq.hamiltonian.eigenStates.toarray()
rho_0 = RDM(beta, eigenstates, energies, 4, 4, [(3,4),(2,3),(1,2),(4,5),(3,4)], [0])
rho_0.calculate()
print rho_0.get_entanglement_spectrum()
print rho_0.get_entanglement_entropy()

hamiltonian = Hubbard(hop, u)
plaq = GrandcanonicalEnsemble(hamiltonian, beta, mu)
plaq.calcEigensystem()
e0 = plaq.hamiltonian.getGroundStateEnergy()
Esempio n. 5
0
    with h5py.File('intersectionstprime.h5', 'r') as data:
        i_tnnn = np.where(data['tnnns'][:] == tnnn)[0]
        phaseboundary = data['intersections'][i_tnnn, 1]
    return phaseboundary


beta = 30
t = -1
tp = .3
hop = [[0, t, t, tp], [t, 0, tp, t], [t, tp, 0, t], [tp, t, t, 0]]
umu = get_u_mu24(0.3)
results = []

for u, mu in zip(umu[0, :, 0], umu[0, :, 1]):
    print u, mu
    hamiltonian = Hubbard(hop, u)  # basis: [['up', 'dn'], [0, 1, 2, 3]]
    plaq = GrandcanonicalEnsemble(hamiltonian, beta, mu)
    plaq.calcEigensystem()
    energies = plaq.hamiltonian.eigenEnergies
    eigenstates = plaq.hamiltonian.eigenStates.toarray()
    rho_0 = RDM(beta, eigenstates, energies, 2, 6, [(3, 4), (2, 3), (1, 2)],
                range(9))
    rho_0.calculate()
    rho_01 = RDM(beta, eigenstates, energies, 4, 4, [(3, 4), (2, 3), (1, 2),
                                                     (4, 5), (3, 4)], range(9))
    rho_01.calculate()
    rho_03 = RDM(beta, eigenstates, energies, 4, 4, [(3, 4), (2, 3), (1, 2),
                                                     (3, 4), (2, 3), (6, 7),
                                                     (5, 6), (4, 5), (3, 4)],
                 range(9))
    rho_03.calculate()
Esempio n. 6
0
from EasyED.hamiltonians import Hubbard
from EasyED.operators import AnnihilationOperator
from EasyED.util import report

from itertools import product
from matplotlib import pyplot as plt
from numpy import array, sqrt, sort, arange
import numpy



numpy.set_printoptions(suppress=True)
structure = Hubbard([[.5, 0], [0, .5]], 1)
c = AnnihilationOperator(structure.getSingleParticleBasis())

report(structure.blocksizes)
structure.solve()
print structure.eigenEnergies

print 'groundstateenergy: ', structure.getGroundStateEnergy()
print 'groundstates:'
for state in structure.getGroundStatesAlgebraically():
    print state
    print

print 'states:'
for energyGroup, energy in zip(structure.getStatesEnergySortedAlgebraically(), structure.getEnergies()):
    print 'E = ', energy
    print
    for state in energyGroup:
        print state