Skip to content

Commit

Permalink
added possibility of updating mu at every impurity iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
alberto-carta committed Feb 20, 2024
1 parent ff820b9 commit aaffb03
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
17 changes: 15 additions & 2 deletions python/solid_dmft/dmft_cycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,11 @@ def _dmft_step(sum_k, solvers, it, general_params,
for icrsh in range(sum_k.n_inequiv_shells):
# copy the block of G_loc into the corresponding instance of the impurity solver
# TODO: why do we set solvers.G_freq? Isn't that simply an output of the solver?
###

if general_params['update_mu_each_imp']:
G_loc_all = sum_k.extract_G_loc(iw_or_w='iw')

solvers[icrsh].G_freq << G_loc_all[icrsh]

density_shell_pre[icrsh] = np.real(solvers[icrsh].G_freq.total_density())
Expand Down Expand Up @@ -687,6 +692,14 @@ def _dmft_step(sum_k, solvers, it, general_params,
mpi.report('Actual time for solver: {:.2f} s'.format(timer() - start_time))

# some printout of the obtained density matrices and some basic checks from the unsymmetrized solver output

###new
if general_params['update_mu_each_imp']:
sum_k.put_Sigma([solvers[i].Sigma_freq for i in range(sum_k.n_inequiv_shells)])
sum_k = manipulate_mu.update_mu(general_params, sum_k, it, archive)



density_shell[icrsh] = np.real(solvers[icrsh].G_freq_unsym.total_density())
density_tot += density_shell[icrsh]*shell_multiplicity[icrsh]
density_mat_unsym[icrsh] = solvers[icrsh].G_freq_unsym.density()
Expand Down Expand Up @@ -715,10 +728,10 @@ def _dmft_step(sum_k, solvers, it, general_params,
#solvers = gf_mixer.mix_sigma(general_params, sum_k.n_inequiv_shells, solvers, Sigma_freq_previous)

if 'Sigma'in general_params['mix_quantity']:
if it > 1:
if it > 0:
mpi.report(f"XXXXXXX Calling {general_params['mix_type']} mixing on {general_params['mix_quantity']}")
for icrsh in range(sum_k.n_inequiv_shells):
solvers[icrsh] = gf_mixer.mix_general(general_params, icrsh, solvers[icrsh], Sigma_freq_previous[icrsh], F_type='Sigma', it=it,
solvers[icrsh] = gf_mixer.mix_general(general_params, icrsh, solvers[icrsh], Sigma_freq_previous[icrsh], F_type='Sigma', it=it+1,
deg_shell=sum_k.deg_shells[icrsh], archive=archive)


Expand Down
23 changes: 12 additions & 11 deletions python/solid_dmft/read_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,10 @@ def TRY_INT_PARSER(s):
'afm_order': {'converter': BOOL_PARSER,
'used': lambda params: params['general']['magnetic'],
'default': False},


'update_mu_each_imp': {'converter': BOOL_PARSER,
'used': True, 'default': False},

'mix_quantity': {'converter': lambda s: list(map(str, s.split(','))),
'used': True,
'default': []},
Expand All @@ -578,16 +581,14 @@ def TRY_INT_PARSER(s):
'broy_max_it': {'converter': int, 'valid for': lambda x, _: x >= 1 or x==-1 ,
'used': True, 'default': 2},

'sigma_mix': {'converter': float,
'valid for': lambda x, params: x >= 0 and (np.isclose(params['general']['g0_mix'], 1)
or np.isclose(x, 1)),
'used': True, 'default': 1.0},

'g0_mix': {'converter': float, 'valid for': lambda x, _: x >= 0,
'used': True, 'default': 1.0},

'g0_mix_type': {'valid for': lambda x, _: x in ('linear', 'broyden'),
'used': True, 'default': 'linear'},
#'sigma_mix': {'converter': float,
# 'valid for': lambda x, params: x > 0 and (np.isclose(params['general']['g0_mix'], 1)
# or np.isclose(x, 1)),
# 'used': True, 'default': 1.0},
#'g0_mix': {'converter': float, 'valid for': lambda x, _: x > 0,
# 'used': True, 'default': 1.0},
#'g0_mix_type': {'valid for': lambda x, _: x in ('linear', 'broyden'),
# 'used': True, 'default': 'linear'},


'calc_energies': {'converter': BOOL_PARSER, 'used': True, 'default': False},
Expand Down

0 comments on commit aaffb03

Please sign in to comment.