Ejemplo n.º 1
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)
Ejemplo n.º 2
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