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)
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
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)
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 print