Skip to content

Commit

Permalink
New parameters [bse] flag_Xloc, flag_X0q (skip_Xloc, skip_X0q_if_exis…
Browse files Browse the repository at this point in the history
…ts are deprecated)
  • Loading branch information
j-otsuki committed May 14, 2024
1 parent 0af3b8e commit 9b21038
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
27 changes: 15 additions & 12 deletions src/dcore/dcore_bse.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,10 @@ def to_str(x):
return x


def compare_str_list(list1, list2):
if len(list1) != len(list2):
return False
def _compare_str_list(list1, list2):
assert len(list1) == len(list2), f"len({list1}) != len({list2})"
for x, y in zip(list1, list2):
if to_str(x) != to_str(y):
return False
return True
assert to_str(x) == to_str(y), f"{to_str(x)} != {to_str(y)}"


def calc_g2_in_impurity_model(solver_name, solver_params, mpirun_command, basis_rot, Umat, gf_struct, beta, n_iw,
Expand Down Expand Up @@ -274,7 +271,7 @@ def __init__(self, h5_file, bse_info, n_corr_shells, n_flavors, use_spin_orbit,
assert n_block == len(spin_names)

# NOTE: change the order of spins in HDF5 to meet SumkDFTChi
self.block2 = IndexPair2(list(range(n_corr_shells)), sorted(spin_names), only_diagonal1=only_diagonal)
self.block2 = IndexPair2(list(range(n_corr_shells)), spin_names, only_diagonal1=only_diagonal)
self.inner2 = IndexPair(list(range(n_inner)), convert_to_int=True)
print(" block2 namelist =", self.block2.namelist)
print(" inner2 namelist =", self.inner2.namelist)
Expand All @@ -284,8 +281,8 @@ def __init__(self, h5_file, bse_info, n_corr_shells, n_flavors, use_spin_orbit,
self.h5bse = h5BSE(h5_file, bse_grp)
if bse_info == 'check':
# check equivalence of info
#assert compare_str_list(h5bse.get(key=('block_name',)), self.block2.namelist)
#assert compare_str_list(h5bse.get(key=('inner_name',)), self.inner2.namelist)
_compare_str_list(self.h5bse.get(key=('block_name',)), self.block2.namelist)
_compare_str_list(self.h5bse.get(key=('inner_name',)), self.inner2.namelist)
assert self.h5bse.get(key=('beta',)) == beta
elif bse_info == 'save':
# save info
Expand Down Expand Up @@ -406,7 +403,7 @@ def _calc_bse_x0q(self):
Calc X_0(q)
"""
print("\n--- dcore_bse - X_0(q)")
if self._params['bse']['skip_X0q_if_exists'] and os.path.exists(self._params['bse']['h5_output_file']):
if self._params['bse']['flag_X0q'] == False:
print(" skip")
return

Expand Down Expand Up @@ -452,10 +449,16 @@ def calc_num_flavors(_ish):
# init for saving data into HDF5
#
print("\n--- dcore_bse - invoking h5BSE...")

if os.path.isfile(self._params['bse']['h5_output_file']):
bse_info = 'check'
else:
bse_info = 'save'

bse = SaveBSE(
n_corr_shells=self._n_corr_shells,
h5_file=os.path.abspath(self._params['bse']['h5_output_file']),
bse_info='check',
bse_info=bse_info,
nonlocal_order_parameter=False,
use_spin_orbit=self._use_spin_orbit,
beta=self._beta,
Expand All @@ -478,7 +481,7 @@ def calc_num_flavors(_ish):
# X_loc
#
print("\n--- dcore_bse - X_loc")
if self._params['bse']['skip_Xloc']:
if self._params['bse']['flag_Xloc'] == False:
print(" skip")
return

Expand Down
11 changes: 9 additions & 2 deletions src/dcore/program_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,10 @@ def create_parser(target_sections=None):
parser.add_option("bse", "num_wb", int, 1, "Number of bosonic frequencies (>0)")
parser.add_option("bse", "num_wf", int, 10, "Number of fermionic frequencies (>0)")
parser.add_option("bse", "h5_output_file", str, 'dmft_bse.h5', "Output HDF5 file for bse data")
parser.add_option("bse", "skip_X0q_if_exists", bool, False, "Skip X_0(q) calc if file already exists")
parser.add_option("bse", "skip_Xloc", bool, False, "Skip X_loc calc (for RPA)")
parser.add_option("bse", "skip_X0q_if_exists", bool, False, "[NOT USED] Skip X_0(q) calc if file already exists", OptionStatus.RETIRED)
parser.add_option("bse", "skip_Xloc", bool, False, "[DEPRECATED] Skip X_loc calc (for RPA)", OptionStatus.DEPRECATED)
parser.add_option("bse", "flag_X0q", bool, True, "Whether X_0(q) is calculated.")
parser.add_option("bse", "flag_Xloc", bool, True, "Whether X_loc is calculated. Set False for RPA")
parser.add_option("bse", "use_temp_file", bool, False, "Whether or not temporary file is used in computing X0_q. This option will reduce the memory footprints.")
parser.add_option("bse", "X0q_qpoints_saved", str, 'quadrant', "Specifies for which q points X0q are saved in a HDF file. quadrant or path to a q_path.dat file.")

Expand Down Expand Up @@ -246,6 +248,11 @@ def parse_parameters(params):
if params['tool']['n_pade_max'] < 0:
params['tool']['n_pade_max'] = params['system']['n_iw']

if 'bse' in params:
# skip_Xloc is dreprecated.
if params['bse']['skip_Xloc'] == True:
params['bse']['flag_Xloc'] = False


def parse_knode(knode_string):
"""
Expand Down

0 comments on commit 9b21038

Please sign in to comment.