mirror of
https://github.com/triqs/dft_tools
synced 2025-01-03 01:55:56 +01:00
More changes to template file.
This commit is contained in:
parent
54827163ce
commit
59837c68b2
@ -16,12 +16,11 @@ delta_mix = 1.0 # Mixing factor of Delta as input for the AIM
|
|||||||
dc_type = 0 # DC type: 0 FLL, 1 Held, 2 AMF
|
dc_type = 0 # DC type: 0 FLL, 1 Held, 2 AMF
|
||||||
use_blocks = True # use bloc structure from DFT input
|
use_blocks = True # use bloc structure from DFT input
|
||||||
prec_mu = 0.0001
|
prec_mu = 0.0001
|
||||||
|
h_field = 0.0
|
||||||
|
|
||||||
# Solver parameters
|
# Solver parameters
|
||||||
p = {}
|
p = {}
|
||||||
p["max_time"] = -1
|
p["max_time"] = -1
|
||||||
p["random_name"] = ""
|
|
||||||
p["random_seed"] = 123 * mpi.rank + 567
|
|
||||||
p["length_cycle"] = 50
|
p["length_cycle"] = 50
|
||||||
p["n_warmup_cycles"] = 50
|
p["n_warmup_cycles"] = 50
|
||||||
p["n_cycles"] = 5000
|
p["n_cycles"] = 5000
|
||||||
@ -44,88 +43,92 @@ if mpi.is_master_node():
|
|||||||
del f
|
del f
|
||||||
previous_runs = mpi.bcast(previous_runs)
|
previous_runs = mpi.bcast(previous_runs)
|
||||||
previous_present = mpi.bcast(previous_present)
|
previous_present = mpi.bcast(previous_present)
|
||||||
# if previous runs are present, no need for recalculating the bloc structure:
|
|
||||||
calc_blocs = use_blocks and (not previous_present)
|
|
||||||
|
|
||||||
SK=SumkDFT(hdf_file=dft_filename+'.h5',use_dft_blocks=calc_blocs)
|
SK=SumkDFT(hdf_file=dft_filename+'.h5',use_dft_blocks=use_blocks,h_field=h_field)
|
||||||
|
|
||||||
n_orb = SK.corr_shells[0]['dim']
|
n_orb = SK.corr_shells[0]['dim']
|
||||||
l = SK.corr_shells[0]['l']
|
l = SK.corr_shells[0]['l']
|
||||||
spin_names = ["up","down"]
|
spin_names = ["up","down"]
|
||||||
orb_names = ["%s"%i for i in range(num_orbitals)]
|
orb_names = [i for i in range(n_orb)]
|
||||||
orb_hybridized = False
|
|
||||||
|
|
||||||
# Construct U matrix for density-density calculations
|
# Use GF structure determined by DFT blocks
|
||||||
gf_struct = set_operator_structure(spin_names,orb_names,orb_hybridized)
|
gf_struct = SK.gf_struct_solver[0]
|
||||||
# Construct U matrix for density-density calculations
|
# Construct U matrix for density-density calculations
|
||||||
Umat, Upmat = U_matrix_kanamori(n_orb=n_orb, U_int=U, J_hund=J)
|
Umat, Upmat = U_matrix_kanamori(n_orb=n_orb, U_int=U, J_hund=J)
|
||||||
# Construct Hamiltonian and solver
|
# Construct Hamiltonian and solver
|
||||||
H = h_loc_density(spin_names, orb_names, orb_hybridized, U=Umat, Uprime=Upmat, H_dump="H.txt")
|
h_loc = h_loc_density(spin_names, orb_names, map_operator_structure=SK.sumk_to_solver[0], U=Umat, Uprime=Upmat, H_dump="H.txt")
|
||||||
S = Solver(beta=beta, gf_struct=gf_struct)
|
S = Solver(beta=beta, gf_struct=gf_struct)
|
||||||
|
|
||||||
if (previous_present):
|
if previous_present:
|
||||||
if (mpi.is_master_node()):
|
if mpi.is_master_node():
|
||||||
S.Sigma_iw << HDFArchive(dft_filename+'.h5','a')['dmft_output']['Sigma_iw']
|
S.Sigma_iw << HDFArchive(dft_filename+'.h5','a')['dmft_output']['Sigma_iw']
|
||||||
S.Sigma_iw = mpi.bcast(S.Sigma_iw)
|
chemical_potential,dc_imp,dc_energ = SK.load(['chemical_potential','dc_imp','dc_energ'])
|
||||||
|
S.Sigma_iw << mpi.bcast(S.Sigma_iw)
|
||||||
|
SK.set_mu(chemical_potential)
|
||||||
|
SK.set_dc(dc_imp,dc_energ)
|
||||||
|
|
||||||
for iteration_number in range(1,loops+1):
|
for iteration_number in range(1,loops+1):
|
||||||
if mpi.is_master_node(): print "Iteration = ", i
|
if mpi.is_master_node(): print "Iteration = ", iteration_number
|
||||||
|
|
||||||
SK.symm_deg_gf(S.Sigma_iw,orb=0) # symmetrise Sigma
|
SK.symm_deg_gf(S.Sigma_iw,orb=0) # symmetrise Sigma
|
||||||
SK.put_Sigma(Sigma_imp = [ S.Sigma_iw ]) # put Sigma into the SumK class
|
SK.put_Sigma(Sigma_imp = [ S.Sigma_iw ]) # put Sigma into the SumK class
|
||||||
chemical_potential = SK.calc_mu( precision = prec_mu ) # find the chemical potential for the given density
|
chemical_potential = SK.calc_mu( precision = prec_mu ) # find the chemical potential for given density
|
||||||
S.G_iw << SK.extract_G_loc()[0] # extract the local Green function
|
S.G_iw << SK.extract_G_loc()[0] # calc the local Green function
|
||||||
mpi.report("Total charge of Gloc : %.6f"%S.G_iw.total_density())
|
mpi.report("Total charge of Gloc : %.6f"%S.G_iw.total_density())
|
||||||
|
|
||||||
if ((iteration_number==1)and(previous_present==False)):
|
# Init the DC term and the real part of Sigma, if no previous runs found:
|
||||||
# Init the DC term and the real part of Sigma, if no previous run was found:
|
if (iteration_number==1 and previous_present==False):
|
||||||
dm = S.G_iw.density()
|
dm = S.G_iw.density()
|
||||||
SK.calc_dc(dm, U_interact = U, J_hund = J, orb = 0, use_dc_formula = dc_type)
|
SK.calc_dc(dm, U_interact = U, J_hund = J, orb = 0, use_dc_formula = dc_type)
|
||||||
S.Sigma_iw << SK.dc_imp[0]['up'][0,0]
|
S.Sigma_iw << SK.dc_imp[0]['up'][0,0]
|
||||||
|
|
||||||
# now calculate new G0_iw to input into the solver:
|
# Calculate new G0_iw to input into the solver:
|
||||||
if (mpi.is_master_node()):
|
if mpi.is_master_node():
|
||||||
# We can do a mixing of Delta in order to stabilize the DMFT iterations:
|
# We can do a mixing of Delta in order to stabilize the DMFT iterations:
|
||||||
S.G0_iw << S.Sigma_iw + inverse(S.G_iw)
|
S.G0_iw << S.Sigma_iw + inverse(S.G_iw)
|
||||||
ar = HDFArchive(dft_filename+'.h5','a')['dmft_output']
|
ar = HDFArchive(dft_filename+'.h5','a')['dmft_output']
|
||||||
if ((iteration_number>1) or (previous_present)):
|
if (iteration_number>1 or previous_present):
|
||||||
mpi.report("Mixing input Delta with factor %s"%delta_mix)
|
mpi.report("Mixing input Delta with factor %s"%delta_mix)
|
||||||
Delta = (delta_mix * delta(S.G0_iw)) + (1.0-delta_mix) * ar['Delta_iw']
|
Delta = (delta_mix * delta(S.G0_iw)) + (1.0-delta_mix) * ar['Delta_iw']
|
||||||
S.G0_iw << S.G0_iw + delta(S.G0_iw) - Delta
|
S.G0_iw << S.G0_iw + delta(S.G0_iw) - Delta
|
||||||
|
|
||||||
ar['Delta_iw'] = delta(S.G0_iw)
|
ar['Delta_iw'] = delta(S.G0_iw)
|
||||||
S.G0_iw << inverse(S.G0_iw)
|
S.G0_iw << inverse(S.G0_iw)
|
||||||
del ar
|
del ar
|
||||||
|
|
||||||
S.G0_iw = mpi.bcast(S.G0_iw)
|
S.G0_iw << mpi.bcast(S.G0_iw)
|
||||||
|
|
||||||
# Solve the impurity problem:
|
# Solve the impurity problem:
|
||||||
S.solve(h_loc=h_loc, **p)
|
S.solve(h_loc=h_loc, **p)
|
||||||
|
|
||||||
# solution done, do the post-processing:
|
# Solved. Now do post-processing:
|
||||||
mpi.report("Total charge of impurity problem : %.6f"%S.G_iw.total_density())
|
mpi.report("Total charge of impurity problem : %.6f"%S.G_iw.total_density())
|
||||||
|
|
||||||
# Now mix Sigma and G with factor sigma_mix, if wanted:
|
# Now mix Sigma and G with factor sigma_mix, if wanted:
|
||||||
if ((iteration_number>1) or (previous_present)):
|
if (iteration_number>1 or previous_present):
|
||||||
if (mpi.is_master_node()):
|
if mpi.is_master_node():
|
||||||
ar = HDFArchive(dft_filename+'.h5','a')['dmft_output']
|
ar = HDFArchive(dft_filename+'.h5','a')['dmft_output']
|
||||||
mpi.report("Mixing Sigma and G with factor %s"%sigma_mix)
|
mpi.report("Mixing Sigma and G with factor %s"%sigma_mix)
|
||||||
S.Sigma_iw << sigma_mix * S.Sigma_iw + (1.0-sigma_mix) * ar['Sigma_iw']
|
S.Sigma_iw << sigma_mix * S.Sigma_iw + (1.0-sigma_mix) * ar['Sigma_iw']
|
||||||
S.G_iw << sigma_mix * S.G_iw + (1.0-sigma_mix) * ar['G_iw']
|
S.G_iw << sigma_mix * S.G_iw + (1.0-sigma_mix) * ar['G_iw']
|
||||||
del ar
|
del ar
|
||||||
S.G_iw = mpi.bcast(S.G_iw)
|
S.G_iw << mpi.bcast(S.G_iw)
|
||||||
S.Sigma_iw = mpi.bcast(S.Sigma_iw)
|
S.Sigma_iw << mpi.bcast(S.Sigma_iw)
|
||||||
|
|
||||||
# Write the final Sigma and G to the hdf5 archive:
|
# Write the final Sigma and G to the hdf5 archive:
|
||||||
if (mpi.is_master_node()):
|
if mpi.is_master_node():
|
||||||
ar = HDFArchive(dft_filename+'.h5','a')
|
ar = HDFArchive(dft_filename+'.h5','a')['dmft_output']
|
||||||
ar['iterations'] = previous_runs + iteration_number
|
if previous_runs: iteration_number += previous_runs
|
||||||
ar['Sigma_iw'] = S.Sigma_iw
|
ar['iterations'] = iteration_number
|
||||||
|
ar['G_tau'] = S.G_tau
|
||||||
ar['G_iw'] = S.G_iw
|
ar['G_iw'] = S.G_iw
|
||||||
|
ar['Sigma_iw'] = S.Sigma_iw
|
||||||
|
ar['G0-%s'%(iteration_number)] = S.G0_iw
|
||||||
|
ar['G-%s'%(iteration_number)] = S.G_iw
|
||||||
|
ar['Sigma-%s'%(iteration_number)] = S.Sigma_iw
|
||||||
del ar
|
del ar
|
||||||
|
|
||||||
|
# Set the new double counting:
|
||||||
dm = S.G_iw.density() # compute the density matrix of the impurity problem
|
dm = S.G_iw.density() # compute the density matrix of the impurity problem
|
||||||
# Set the double counting
|
|
||||||
SK.calc_dc(dm, U_interact = U, J_hund = J, orb = 0, use_dc_formula = dc_type)
|
SK.calc_dc(dm, U_interact = U, J_hund = J, orb = 0, use_dc_formula = dc_type)
|
||||||
|
|
||||||
# Save stuff into the dft_output group of hdf5 archive in case of rerun:
|
# Save stuff into the dft_output group of hdf5 archive in case of rerun:
|
||||||
@ -133,5 +136,6 @@ for iteration_number in range(1,loops+1):
|
|||||||
|
|
||||||
if mpi.is_master_node():
|
if mpi.is_master_node():
|
||||||
ar = HDFArchive("dftdmft.h5",'w')
|
ar = HDFArchive("dftdmft.h5",'w')
|
||||||
|
ar["G_tau"] = S.G_tau
|
||||||
ar["G_iw"] = S.G_iw
|
ar["G_iw"] = S.G_iw
|
||||||
ar["Sigma_iw"] = S.Sigma_iw
|
ar["Sigma_iw"] = S.Sigma_iw
|
||||||
|
Loading…
Reference in New Issue
Block a user