示例#1
0
    def __init__(self, t, t2=0, U=0, mu=0., occ=True, nsite=6):
        self.t, self.t2, self.U, self.mu = t, t2, U, mu
        self.occ = occ
        self.nsite = nsite

        #occupation representation will use <SuperSpaceConfig>, otherwise <SpaceConfig>.
        if self.occ:
            spaceconfig = SuperSpaceConfig(chorder([nsite, 2, 1]))
        else:
            spaceconfig = SpaceConfig(chorder([1, 2, nsite, 1]), kspace=False)
            if abs(U) > 0:
                warnings.warn('U is ignored in non-occupation representation.')
        hgen = RHGenerator(spaceconfig=spaceconfig)

        #define the operator of the system
        hgen.register_params({
            't1': self.t,
            't2': self.t2,
            'U': self.U,
            '-mu': -self.mu,
        })

        #define a structure and initialize bonds.
        rlattice = Chain(N=nsite)
        hgen.uselattice(rlattice)

        b1s = rlattice.getbonds(1)  #the nearest neighbor
        b2s = rlattice.getbonds(2)  #the nearest neighbor

        #add the hopping term.
        op_t1 = op_simple_hopping(label='hop1',
                                  spaceconfig=spaceconfig,
                                  bonds=b1s)
        hgen.register_operator(op_t1, param='t1')
        op_t2 = op_simple_hopping(label='hop2',
                                  spaceconfig=spaceconfig,
                                  bonds=b2s)
        hgen.register_operator(op_t2, param='t2')
        op_n = op_simple_onsite(label='n', spaceconfig=spaceconfig)
        hgen.register_operator(op_n, param='-mu')

        #add the hubbard interaction term if it is in the occupation number representation.
        if self.occ:
            op_ninj = op_U(label='ninj', spaceconfig=spaceconfig)
            hgen.register_operator(op_ninj, param='U')

        self.hgen = hgen