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

sz_tot = .5 * (c['up', 0].H.dot(c['up', 0]) - c['dn', 0].H.dot(c['dn', 0])) + .5 * (c['up', 1].H.dot(c['up', 1]) - c['dn', 1].H.dot(c['dn', 1]))
chi_zz_tot = sz_tot.dot(sz_tot)
print 'corresponding S2_tot qnrs:'
energies, degeneracies = structure.getSpectrum()
for energyGroup, energy  in zip(structure.getSuperpositionStatesEnergySorted(), sort(energies)):
    for state in energyGroup:
        print str(energy)+' -> '+str(3*state.getQuantumNumber(chi_zz_tot))
print