示例#1
0
def enforce_eh(h, mf):
    """Enforce eh symmetry in a mean field Hamiltonian"""
    from superconductivity import eh_operator
    eh = eh_operator(h.intra)  # get the function
    for key in mf:
        mf[key] = np.matrix(mf[key])  # dense matrix
    mfout = dict()
    for key in mf:
        mkey = (-key[0], -key[1], -key[2])
        mfout[key] = (mf[key] - eh(mf[mkey].H)) / 2.
    return mfout
示例#2
0
def electron_hole_symmetry(h,tol=1e-5,ntries=10):
   """Check that a system has electron-hole symmetry"""
   if not h.has_eh: return # skip if there is no e-h sector
   from superconductivity import eh_operator
   ehop = eh_operator(h.intra) # get the operator
   def ehsym(m1,m2):
     """Test eh symmetry"""
     diff = m1 + ehop(m2)
     diff = np.sum(np.abs(diff))
     if diff>tol: raise
   ehsym(h.intra,h.intra) # do it for the intra matrix
   if h.dimensionality>0:
     for i in range(ntries):
       hkgen = h.get_hk_gen() # generator
       k = np.random.random(h.dimensionality) # kpoint
       ehsym(hkgen(k),hkgen(-k))
       print("Checking k-point",k)
   print("Electron-hole symmetry is ok")
示例#3
0
文件: check.py 项目: zx-sdu/pygra
def check_hamiltonian(h):
    """Do various checks in Hamiltonian, to ensure that nothing weird happens"""
    hk = h.get_hk_gen()  # get generator
    m = hk(np.random.random(3))  # random k-point
    if not equal(m, m.H):
        print("CHECK FAILED, Hamiltonian is not Hermitian")
        raise  # not hermitian
    if h.has_eh:  # if it has electron hole degree of freedom
        v = np.random.random(3)  # random kpoint
        m1 = hk(v)  # Hamiltonian
        m2 = hk(-v)  # Hamiltonian in time reversal
        from superconductivity import eh_operator
        eh = eh_operator(m1)  # get the function
        if not equal(m1, -eh(m2)):
            print(
                "CHECK FAILED, Hamiltonian does not have electron-hole symmetry"
            )
            raise
        print("CHECKED that the Hamiltonian has electron-hole symmetry")
示例#4
0
 def enforce_eh(self):
     """Enforce electron-hole symmetry in the Hamiltonian"""
     self.turn_multicell()  # turn to multicell mode
     from superconductivity import eh_operator
     f = eh_operator(self.intra)  # electron hole operator
     raise  # not implemented