TRIQS / dft_tools

Interface to DFT codes
https://triqs.github.io/dft_tools
Other
40 stars 38 forks source link

SumK assumes beta=40 and n_iw=1025 #157

Closed the-hampel closed 2 years ago

the-hampel commented 3 years ago

When no Sigma is set in a fresh SumK object, and one directly calculates the chemical potential one can not control for which temperature or for how many matsubara frequencies this is done. Only when prior to calculating the chemical potential a Sigma is set with an appropiate mesh. This is because the total_density function in SumK called by calc_mu sets up a lattice gf with default values when no Sigma is set. This process is very in-transparent and leads to two problems:

  1. calc_mu is evaluated at beta=40 by default without any obvious control parameter for the user
  2. SumK now internally has a gf_lattice object initialized with this Gf mesh at beta=40 and 1025 Matsubara frequencies, if one afterwards sets a Sigma with a different temperature it will not work. Calling extract_G_loc even after another sigma is set will give spurious results without crashing.
  3. This also hints to a problem in triqs, which does not throws an error when a Gf is filled from a Gf with a different mesh!

Example:

sum_k = SumkDFT('svo.input.h5')                                                                        

dft_mu = sum_k.calc_mu(precision=0.0001,                                                               
                       iw_or_w='iw')                                                                 

# increasing n_iw from 1025 to 1030 is enough to show the problem!
zero_Sigma_iw = [sum_k.block_structure.create_gf(ish=iineq, beta=40,n_points = 1030)                  
                         for iineq in range(sum_k.n_inequiv_shells)]                                   
sum_k.put_Sigma(zero_Sigma_iw)                                                                         

G_loc_all_dft = sum_k.extract_G_loc(with_Sigma=True)                                           

density_shell_dft = G_loc_all_dft[0].total_density()                                           
mpi.report('total density rom DFT: {:10.6f}'.format(np.real(density_shell_dft)))

This script will output some weird numbers for the uncorrelated G_loc with -20 as occupation! However, this version works as expected:

sum_k = SumkDFT('svo.input.h5')                                                                        

zero_Sigma_iw = [sum_k.block_structure.create_gf(ish=iineq, beta=40,n_points = 1030)                  
                         for iineq in range(sum_k.n_inequiv_shells)]                                   
sum_k.put_Sigma(zero_Sigma_iw)      

dft_mu = sum_k.calc_mu(precision=0.0001,                                                               
                       iw_or_w='iw')                                                                   

G_loc_all_dft = sum_k.extract_G_loc(with_Sigma=True)                                           

density_shell_dft = G_loc_all_dft[0].total_density()                                           
mpi.report('total density rom DFT: {:10.6f}'.format(np.real(density_shell_dft)))

Should be fixed both in dft_tools by init some default Sigma maybe? Or by specifing the temperature or something and in triqs.

the-hampel commented 3 years ago

The problem is still persisting. We need to allow the user to pass parameters on creation of the Sumk object to init:

the-hampel commented 2 years ago

This should be fixed now with #177 being merged into unstable.