コード例 #1
0
def full_fill_Gweiss_iw(Gweiss_iw, G_ij_iw, Sigma_imp_iw):
  if mpi.is_master_node(): print "full_fill_Gweiss_iw"
  for name,g in Gweiss_iw:
    nw = len(g.data[:,0,0])
    for wi in range(nw):
      g.data[wi,:,:] = inv( inv(G_ij_iw[name].data[wi,:,:]) + Sigma_imp_iw[name].data[wi,:,:] )
    fit_fermionic_gf_tail(g)
コード例 #2
0
def full_full_Gweiss_iw_from_G_proj_iw_and_Sigma_imp_iw(Gweiss_iw, G_proj_iw, Sigma_imp_iw, bosonic_fit = False):   
  for C, g in Gweiss_iw:
    nw = len(g.data[:,0,0])
    for wi in range(nw):
      g.data[wi,:,:] = inv(inv(G_proj_iw[C].data[wi,:,:]) + Sigma_imp_iw[C].data[wi,:,:])

    if bosonic_fit:
      fit_bosonic_tail(Gweiss_iw[C])
    else:
      fit_fermionic_gf_tail(Gweiss_iw[C])
コード例 #3
0
def blockwise_get_G_loc_tau_from_G_loc_iw(G_loc_iw,                                          
                                          fit_tail_starting_iw = 14.0, ntau = None):
  if mpi.is_master_node(): print "blockwise_get_G_loc_tau_from_G_loc_iw"

  fit_fermionic_gf_tail(G_loc_iw, starting_iw=fit_tail_starting_iw)       
  if ntau is None:
    ntau = 3*len(G_loc_iw.data[:,0,0])

  Nc = len(G_loc_iw.data[0,0,:])
  G_loc_tau = GfImTime(indices = range(Nc), beta = G_loc_iw.beta, n_points = ntau, statistic = 'Fermion')
  G_loc_tau << InverseFourier(G_loc_iw)  
  return G_loc_tau
コード例 #4
0
def blockwise_fill_Gweiss_iw_from_Gijw_and_Sigma_imp_iw(Gweiss_iw,Gijw,Sigma_imp_iw, mapping = lambda i,j: [0,0], bosonic_fit = False):
  if mpi.is_master_node(): print "blockwise_fill_Gweiss_iw_from_Gijw_and_Sigma_imp_iw"
  n_sites = len(Gweiss_iw.data[0,0,:])
  nw = len(Gweiss_iw.data[:,0,0])
  Gtemp = numpy.zeros((nw,n_sites,n_sites), dtype=numpy.complex_)
  for i in range(n_sites):
    for j in range(n_sites):
       Gtemp[:,i,j] = Gijw[:,mapping(i,j)[0], mapping(i,j)[1]] 

  invGtemp = Gtemp[:,:,:]
  for wi in range(nw):
    #print "in Gweiss fill: wi:",wi
    #print Gtemp[wi,:,:]
    invGtemp[wi,:,:] = inv(Gtemp[wi,:,:])
    Gweiss_iw.data[wi,:,:] = inv(invGtemp[wi,:,:] + Sigma_imp_iw.data[wi,:,:])

  if bosonic_fit:
    fit_bosonic_tail(Gweiss_iw)
  else:
    fit_fermionic_gf_tail(Gweiss_iw)
コード例 #5
0
def blockwise_flexible_Gweiss_iw_from_Gweiss_iw_Gijw_and_G_imp_iw(Gweiss_iw,Gijw,G_imp_iw,
                                                                  mapping, sign, sign_up_to ):
  if mpi.is_master_node(): print "blockwise_flexible_Gweiss_iw_from_Gweiss_iw_Gijw_and_G_imp_iw"
  n_sites = len(Gweiss_iw.data[0,0,:])
  nw = len(Gweiss_iw.data[:,0,0])
  Gtemp = numpy.zeros((nw,n_sites,n_sites), dtype=numpy.complex_)
  for i in range(n_sites):
    for j in range(n_sites):
       Gtemp[:,i,j] = Gijw[:,mapping(i,j)[0], mapping(i,j)[1]] 

  invGtemp = Gtemp[:,:,:]
  for wi in range(nw):
    n_mats = wi-nw/2    
    if sign_up_to == -1: sign_up_to = nw
    if ( n_mats>=0 and n_mats<sign_up_to) \
        or n_mats<0 and abs(n_mats)-1<sign_up_to:
        sgn = sign
    else: sgn= -sign    
    invGtemp[wi,:,:] = inv(Gtemp[wi,:,:])
    Gweiss_iw.data[wi,:,:] = inv( inv(Gweiss_iw.data[wi,:,:]) + sgn*(invGtemp[wi,:,:] - inv(G_imp_iw.data[wi,:,:])) )

  fit_fermionic_gf_tail(Gweiss_iw)
コード例 #6
0
def invf(Qw,
         beta,
         ntau,
         n_iw,
         statistic,
         fit_tail,
         fit_tail_like_sigma=False,
         no_loc=True):
    g = GfImFreq(indices=[0], beta=beta, n_points=n_iw, statistic=statistic)
    gtau = GfImTime(indices=[0], beta=beta, n_points=ntau, statistic=statistic)
    g.data[:, 0, 0] = Qw[:]
    if fit_tail:
        assert statistic == 'Fermion', "no tail fiting for bosonic functions!"
        if fit_tail_like_sigma:
            fit_and_remove_constant_tail(sig, starting_iw=14.0, max_order=5)
            fit_fermionic_sigma_tail(g,
                                     starting_iw=(10.0 if no_loc else 14.0),
                                     no_hartree=True,
                                     no_loc=no_loc)
        else:
            fit_fermionic_gf_tail(
                g)  ############# !!!!!!!!!! add the bosonic option
    gtau << InverseFourier(g)
    return gtau.data[:, 0, 0]
コード例 #7
0
def ph_symmetric_Gweiss_causal_cautionary( data, ntau=5000):   
  assert sorted(data.impurity_struct.keys()) == ['1x1','2x1','2x2'], "not applicable to any other scheme than nested plaquette. impurity_struct: "+str(data.impurity_struct.keys())
  print "######### Checking causality of Gweiss ########"

  data.Gweiss_iw_unfit = data.Gweiss_iw.copy()
  data.Delta_iw = data.Gweiss_iw.copy()
  data.Delta_iw_fit = data.Gweiss_iw.copy()    
  
  gs = []
  for C in data.impurity_struct.keys(): 
      gs.append ( GfImTime(indices = data.impurity_struct[C], beta = data.beta, n_points =ntau, statistic = 'Fermion') )     
  data.Delta_tau = BlockGf(name_list = data.impurity_struct.keys(), block_list = gs, make_copies = False)
  data.Delta_tau_fit = data.Delta_tau.copy()
    
  for C, g in data.Gweiss_iw:
    print ">>>>>>>>>>>>>>>>>> block ",C

    nsites = len(g.data[0,:,0])
    if nsites==4: Nx=Ny=2
    elif nsites==2: Nx,Ny=2,1
    elif nsites==1: Nx=Ny=1
    else: assert False, "wrong number of sites"
 
    H0 = initCubicTBH(Nx, Ny, 1, 0, -0.25, cyclic=False)
    print H0
    data.Delta_iw[C] = get_Delta_from_Gweiss_and_H0(g, H0, data.mus['up'])
   
    for i in range(nsites):
      data.Delta_iw[C].data[:,i,i] -= data.Delta_iw[C].data[:,i,i].real    
    if nsites>1:
      for i,j in ([(0,1)] if nsites==2 else [(0,1),(1,3),(3,2),(2,0)]):        
          data.Delta_iw[C].data[:,i,j] -= data.Delta_iw[C].data[:,i,j].imag    
          data.Delta_iw[C].data[:,j,i] -= data.Delta_iw[C].data[:,j,i].imag  
    if nsites>2:
      for i,j in [(0,3),(1,2)]:        
          data.Delta_iw[C].data[:,i,j] -= data.Delta_iw[C].data[:,i,j].real    
          data.Delta_iw[C].data[:,j,i] -= data.Delta_iw[C].data[:,j,i].real      
    
    impose_real_valued_in_imtime(data.Delta_iw[C])    
       
    #data.dump_general( quantities = ['Delta_iw'], suffix='-check' )

    fit_fermionic_sigma_tail(data.Delta_iw[C])
    data.Delta_tau[C] << InverseFourier(data.Delta_iw[C])

    d2tauDelta = second_derivative(data.Delta_tau[C].data.real,data.beta/ntau)   
    ws = numpy.zeros((ntau-2,nsites))    
    needs_fixing = False
    for taui in range(0,ntau-2):        
        w,v = numpy.linalg.eig(d2tauDelta[taui,:,:].real)
        #print "eigvalues: ", w
        ws[taui,:] = sorted(numpy.real(w))        
    if len([ww for ww in numpy.ravel(ws) if ww>0])>0:
      needs_fixing = True
      print "max eigenvalue: ",numpy.amax(numpy.ravel(ws))
    
    if needs_fixing:
      print "WARNING: Delta_iw[%s] unphysical and needs fixing!!!"%C

    for att in range(3):
      P = 0.01
      epss = []
      Vs = []
      kinds = []
      if nsites==4:
        epss.extend([0.19668414224046424, -0.242286049378347, -0.4851071850062886, 0.6083462424661663])
        Vs.extend([1.111030853547017, 0.95763987021629182, 1.3705081047849843, 0.80333649203756208])
        kinds.extend([0,1,0,1])
      elif nsites<4:
        epss.extend([0.19668414224046424, -0.242286049378347])
        Vs.extend([1.111030853547017, 0.95763987021629182])
        kinds.extend([0,0])

      
      for T in [0.025*nsites]:    
          epss,Vs = fit(data.Delta_iw[C], epss, Vs, kinds, P, n_mats = 5, max_its = 10000, T=T )

          W,V = ph_symm_V_from_params(epss, Vs, kinds, Nsites=nsites)
          
          G_from_params(data.Delta_iw_fit[C], P, W, V)
             
          epss.extend([1.0,1.0])    
          Vs.extend([0.001,0.001])    
          kinds.extend([0,1])
                     
      for T in [0.00025*nsites]:
          stochastic_complete(data.Delta_iw[C], data.Delta_iw_fit[C], [-0.0001,0.0001], [-3.0,3.0], 10000,
                              T = T, max_its=40000, n_mats = 5, printout=None, Nit_print=1000)    

      fit_fermionic_sigma_tail(data.Delta_iw_fit[C])
      data.Delta_tau_fit[C] << InverseFourier(data.Delta_iw_fit[C])

      data.Gweiss_iw[C] = get_Gweiss_from_Delta_and_H0(data.Delta_iw_fit[C], H0, data.mus['up'])  
      impose_real_valued_in_imtime(data.Gweiss_iw[C])    
      fit_fermionic_gf_tail(data.Gweiss_iw[C])
      #data.dump_general( quantities = ['Delta_iw_fit','Gweiss_iw_unfit','Gweiss_iw'], suffix='-check' )
    
      max_diff_Gweiss = numpy.amax(numpy.abs(data.Gweiss_iw[C].data - data.Gweiss_iw_unfit[C].data))
      max_diff_Delta =  numpy.amax(numpy.abs(data.Delta_iw[C].data - data.Delta_iw_fit[C].data))
      print "---- max diff Gweiss: ", max_diff_Gweiss  
      print "---- max diff Delta: ", max_diff_Delta
      if max_diff_Gweiss<2e-3 and max_diff_Delta<2e-3:
        print "---- ---- fit satsfactory!"
        break
      else:
        if att<2:
          print "---- ---- fit not satsfactory! trying again..."
        else:
          print "---- ---- fit not satsfactory! tried already 3 times. better luck next time."
  print "#########           DONE!!!            ########"