From aaffb03925b778e67c8a5aa096eec5a03684a3ae Mon Sep 17 00:00:00 2001 From: alb-carta <49793269+alberto-carta@users.noreply.github.com> Date: Thu, 30 Nov 2023 11:37:15 +0100 Subject: [PATCH] added possibility of updating mu at every impurity iteration --- python/solid_dmft/dmft_cycle.py | 17 +++++++++++++++-- python/solid_dmft/read_config.py | 23 ++++++++++++----------- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/python/solid_dmft/dmft_cycle.py b/python/solid_dmft/dmft_cycle.py index ee542431..ec4e74b8 100755 --- a/python/solid_dmft/dmft_cycle.py +++ b/python/solid_dmft/dmft_cycle.py @@ -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()) @@ -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() @@ -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) diff --git a/python/solid_dmft/read_config.py b/python/solid_dmft/read_config.py index ea9e35b3..d3ddc5fe 100755 --- a/python/solid_dmft/read_config.py +++ b/python/solid_dmft/read_config.py @@ -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': []}, @@ -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},