2014-11-18 11:30:26 +01:00
|
|
|
from pytriqs.applications.dft.sumk_dft import *
|
2013-08-07 16:40:18 +02:00
|
|
|
from pytriqs.applications.dft.converters.wien2k_converter import *
|
2014-01-21 16:49:04 +01:00
|
|
|
from pytriqs.applications.impurity_solvers.hubbard_I.hubbard_solver import Solver
|
2013-08-07 16:40:18 +02:00
|
|
|
|
2015-08-14 15:12:35 +02:00
|
|
|
|
|
|
|
import os
|
|
|
|
dft_filename = os.getcwd().rpartition('/')[2]
|
|
|
|
|
2014-03-28 23:29:06 +01:00
|
|
|
beta = 40
|
|
|
|
U_int = 6.00
|
|
|
|
J_hund = 0.70
|
2015-03-18 20:54:07 +01:00
|
|
|
Loops = 5 # Number of DMFT sc-loops
|
2013-08-07 16:40:18 +02:00
|
|
|
Mix = 0.7 # Mixing factor in QMC
|
|
|
|
DC_type = 0 # 0...FLL, 1...Held, 2... AMF, 3...Lichtenstein
|
2015-03-18 20:54:07 +01:00
|
|
|
chemical_potential_init=0.0 # initial chemical potential
|
2013-08-07 16:40:18 +02:00
|
|
|
|
2015-08-14 15:12:35 +02:00
|
|
|
HDFfilename = dft_filename+'.h5'
|
2013-08-07 16:40:18 +02:00
|
|
|
|
|
|
|
# Convert DMFT input:
|
2015-08-14 15:12:35 +02:00
|
|
|
Converter = Wien2kConverter(filename=filename)
|
2014-12-09 12:26:00 +01:00
|
|
|
Converter.convert_dft_input()
|
2015-08-14 15:12:35 +02:00
|
|
|
mpi.barrier()
|
2013-08-07 16:40:18 +02:00
|
|
|
|
|
|
|
#check if there are previous runs:
|
|
|
|
previous_runs = 0
|
|
|
|
previous_present = False
|
|
|
|
if mpi.is_master_node():
|
2015-08-14 15:12:35 +02:00
|
|
|
f = HDFArchive(filename+'.h5','a')
|
|
|
|
if 'dmft_output' in f:
|
|
|
|
ar = f['dmft_output']
|
|
|
|
if 'iterations' in ar:
|
|
|
|
previous_present = True
|
|
|
|
previous_runs = ar['iterations']
|
|
|
|
else:
|
|
|
|
f.create_group('dmft_output')
|
|
|
|
del f
|
2013-08-07 16:40:18 +02:00
|
|
|
previous_runs = mpi.bcast(previous_runs)
|
|
|
|
previous_present = mpi.bcast(previous_present)
|
|
|
|
|
|
|
|
# Init the SumK class
|
2015-08-14 15:12:35 +02:00
|
|
|
SK=SumkDFT(hdf_file=dft_filename+'.h5',use_dft_blocks=False)
|
2013-08-07 16:40:18 +02:00
|
|
|
|
2014-11-26 16:24:02 +01:00
|
|
|
Norb = SK.corr_shells[0]['dim']
|
|
|
|
l = SK.corr_shells[0]['l']
|
2013-08-07 16:40:18 +02:00
|
|
|
|
2015-03-18 20:54:07 +01:00
|
|
|
# Init the Hubbard-I solver:
|
2014-03-28 23:29:06 +01:00
|
|
|
S = Solver(beta = beta, l = l)
|
2013-08-07 16:40:18 +02:00
|
|
|
|
2015-03-18 20:54:07 +01:00
|
|
|
chemical_potential=chemical_potential_init
|
|
|
|
# load previous data: old self-energy, chemical potential, DC correction
|
2015-08-14 15:12:35 +02:00
|
|
|
if previous_present:
|
|
|
|
if mpi.is_master_node():
|
|
|
|
S.Sigma << HDFArchive(dft_filename+'.h5','a')['dmft_output']['Sigma']
|
|
|
|
chemical_potential,dc_imp,dc_energ = SK.load(['chemical_potential','dc_imp','dc_energ'])
|
|
|
|
S.Sigma << mpi.bcast(S.Sigma)
|
|
|
|
SK.set_mu(chemical_potential)
|
|
|
|
SK.set_dc(dc_imp,dc_energ)
|
|
|
|
|
2013-08-07 16:40:18 +02:00
|
|
|
|
|
|
|
# DMFT loop:
|
2015-08-14 15:12:35 +02:00
|
|
|
for iteration_number in range(1,Loops+1):
|
2013-08-07 16:40:18 +02:00
|
|
|
|
2015-08-14 15:12:35 +02:00
|
|
|
itn = iteration_number + previous_runs
|
2013-08-07 16:40:18 +02:00
|
|
|
|
|
|
|
# put Sigma into the SumK class:
|
2014-01-21 16:49:04 +01:00
|
|
|
SK.put_Sigma(Sigma_imp = [ S.Sigma ])
|
2013-08-07 16:40:18 +02:00
|
|
|
|
|
|
|
# Compute the SumK, possibly fixing mu by dichotomy
|
2015-08-14 15:12:35 +02:00
|
|
|
chemical_potential = SK.calc_mu( precision = 0.000001 )
|
|
|
|
|
2013-08-07 16:40:18 +02:00
|
|
|
# Density:
|
2015-03-18 20:54:07 +01:00
|
|
|
S.G <<= SK.extract_G_loc()[0]
|
2013-08-07 16:40:18 +02:00
|
|
|
mpi.report("Total charge of Gloc : %.6f"%S.G.total_density())
|
|
|
|
|
2015-03-18 20:54:07 +01:00
|
|
|
# calculated DC at the first run to have reasonable initial non-interacting atomic level positions
|
2015-08-14 15:12:35 +02:00
|
|
|
if ((iteration_number==1)and(previous_present==False)):
|
2015-03-18 20:54:07 +01:00
|
|
|
dc_value_init=U_int/2.0
|
|
|
|
dm=S.G.density()
|
2015-08-14 15:12:35 +02:00
|
|
|
SK.calc_dc( dm, U_interact = U_int, J_hund = J_hund, orb = 0, use_dc_formula = DC_type, use_dc_value=dc_value_init)
|
2013-08-07 16:40:18 +02:00
|
|
|
|
2015-03-18 20:54:07 +01:00
|
|
|
# calculate non-interacting atomic level positions:
|
2013-08-07 16:40:18 +02:00
|
|
|
eal = SK.eff_atomic_levels()[0]
|
|
|
|
S.set_atomic_levels( eal = eal )
|
|
|
|
|
|
|
|
# solve it:
|
2014-03-28 23:29:06 +01:00
|
|
|
S.solve(U_int = U_int, J_hund = J_hund, verbosity = 1)
|
2013-08-07 16:40:18 +02:00
|
|
|
|
2015-08-14 15:12:35 +02:00
|
|
|
# Now mix Sigma and G with factor Mix, if wanted:
|
|
|
|
if (iteration_number>1 or previous_present):
|
|
|
|
if (mpi.is_master_node() and (sigma_mix<1.0)):
|
|
|
|
ar = HDFArchive(dft_filename+'.h5','a')['dmft_output']
|
|
|
|
mpi.report("Mixing Sigma and G with factor %s"%sigma_mix)
|
|
|
|
S.Sigma << sigma_mix * S.Sigma + (1.0-sigma_mix) * ar['Sigma']
|
|
|
|
S.G << sigma_mix * S.G + (1.0-sigma_mix) * ar['G']
|
2015-03-18 20:54:07 +01:00
|
|
|
del ar
|
2015-08-14 15:12:35 +02:00
|
|
|
S.G << mpi.bcast(S.G)
|
|
|
|
S.Sigma << mpi.bcast(S.Sigma)
|
|
|
|
|
2013-08-07 16:40:18 +02:00
|
|
|
|
|
|
|
# after the Solver has finished, set new double counting:
|
|
|
|
dm = S.G.density()
|
2015-03-18 20:54:07 +01:00
|
|
|
SK.calc_dc( dm, U_interact = U_int, J_hund = J_hund, orb = 0, use_dc_formula = DC_type )
|
|
|
|
|
2013-08-07 16:40:18 +02:00
|
|
|
# correlation energy calculations:
|
|
|
|
correnerg = 0.5 * (S.G * S.Sigma).total_density()
|
|
|
|
mpi.report("Corr. energy = %s"%correnerg)
|
2015-03-18 20:54:07 +01:00
|
|
|
|
|
|
|
# store the impurity self-energy, GF as well as correlation energy in h5
|
2015-08-14 15:12:35 +02:00
|
|
|
if mpi.is_master_node():
|
|
|
|
ar = HDFArchive(dft_filename+'.h5','a')['dmft_output']
|
|
|
|
if previous_runs: iteration_number += previous_runs
|
|
|
|
ar['iterations'] = iteration_number
|
|
|
|
ar['G'] = S.G
|
|
|
|
ar['Sigma'] = S.Sigma
|
2013-08-07 16:40:18 +02:00
|
|
|
del ar
|
|
|
|
|
2015-03-18 20:54:07 +01:00
|
|
|
#Save essential SumkDFT data:
|
2015-08-14 15:12:35 +02:00
|
|
|
SK.save(['chemical_potential','dc_imp','dc_energ','correnerg'])
|
2013-08-07 16:40:18 +02:00
|
|
|
if (mpi.is_master_node()):
|
2015-03-18 20:54:07 +01:00
|
|
|
print 'DC after solver: ',SK.dc_imp[0]
|
2013-08-07 16:40:18 +02:00
|
|
|
|
2015-03-18 20:54:07 +01:00
|
|
|
# print out occupancy matrix of Ce 4f
|
2013-08-07 16:40:18 +02:00
|
|
|
mpi.report("Orbital densities of impurity Green function:")
|
2015-03-18 20:54:07 +01:00
|
|
|
for s in dm:
|
2013-08-07 16:40:18 +02:00
|
|
|
mpi.report("Block %s: "%s)
|
2015-03-18 20:54:07 +01:00
|
|
|
for ii in range(len(dm[s])):
|
2013-08-07 16:40:18 +02:00
|
|
|
str = ''
|
2015-03-18 20:54:07 +01:00
|
|
|
for jj in range(len(dm[s])):
|
|
|
|
if (dm[s][ii,jj].real>0):
|
|
|
|
str += " %.4f"%(dm[s][ii,jj].real)
|
2013-08-07 16:40:18 +02:00
|
|
|
else:
|
2015-03-18 20:54:07 +01:00
|
|
|
str += " %.4f"%(dm[s][ii,jj].real)
|
2013-08-07 16:40:18 +02:00
|
|
|
mpi.report(str)
|
|
|
|
mpi.report("Total charge of impurity problem : %.6f"%S.G.total_density())
|
|
|
|
|
|
|
|
|
|
|
|
# find exact chemical potential
|
2015-08-14 15:12:35 +02:00
|
|
|
SK.chemical_potential = SK.calc_mu( precision = 0.000001 )
|
2015-03-18 20:54:07 +01:00
|
|
|
|
|
|
|
# calculate and save occupancy matrix in the Bloch basis for Wien2k charge denity recalculation
|
2015-08-14 15:12:35 +02:00
|
|
|
dN,d = SK.calc_density_correction(filename = dft_filename+'.qdmft')
|
2013-08-07 16:40:18 +02:00
|
|
|
|
|
|
|
mpi.report("Trace of Density Matrix: %s"%d)
|
|
|
|
|
2015-03-18 20:54:07 +01:00
|
|
|
# store correlation energy contribution to be read by Wien2ki and then included to DFT+DMFT total energy
|
2013-08-07 16:40:18 +02:00
|
|
|
if (mpi.is_master_node()):
|
|
|
|
correnerg -= DCenerg[0]
|
2015-08-14 15:12:35 +02:00
|
|
|
f=open(dft_filename+'.qdmft','a')
|
2013-08-07 16:40:18 +02:00
|
|
|
f.write("%.16f\n"%correnerg)
|
|
|
|
f.close()
|