Skip to content

Commit 9b21038

Browse files
committed
New parameters [bse] flag_Xloc, flag_X0q (skip_Xloc, skip_X0q_if_exists are deprecated)
1 parent 0af3b8e commit 9b21038

File tree

2 files changed

+24
-14
lines changed

2 files changed

+24
-14
lines changed

src/dcore/dcore_bse.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,10 @@ def to_str(x):
4242
return x
4343

4444

45-
def compare_str_list(list1, list2):
46-
if len(list1) != len(list2):
47-
return False
45+
def _compare_str_list(list1, list2):
46+
assert len(list1) == len(list2), f"len({list1}) != len({list2})"
4847
for x, y in zip(list1, list2):
49-
if to_str(x) != to_str(y):
50-
return False
51-
return True
48+
assert to_str(x) == to_str(y), f"{to_str(x)} != {to_str(y)}"
5249

5350

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

276273
# NOTE: change the order of spins in HDF5 to meet SumkDFTChi
277-
self.block2 = IndexPair2(list(range(n_corr_shells)), sorted(spin_names), only_diagonal1=only_diagonal)
274+
self.block2 = IndexPair2(list(range(n_corr_shells)), spin_names, only_diagonal1=only_diagonal)
278275
self.inner2 = IndexPair(list(range(n_inner)), convert_to_int=True)
279276
print(" block2 namelist =", self.block2.namelist)
280277
print(" inner2 namelist =", self.inner2.namelist)
@@ -284,8 +281,8 @@ def __init__(self, h5_file, bse_info, n_corr_shells, n_flavors, use_spin_orbit,
284281
self.h5bse = h5BSE(h5_file, bse_grp)
285282
if bse_info == 'check':
286283
# check equivalence of info
287-
#assert compare_str_list(h5bse.get(key=('block_name',)), self.block2.namelist)
288-
#assert compare_str_list(h5bse.get(key=('inner_name',)), self.inner2.namelist)
284+
_compare_str_list(self.h5bse.get(key=('block_name',)), self.block2.namelist)
285+
_compare_str_list(self.h5bse.get(key=('inner_name',)), self.inner2.namelist)
289286
assert self.h5bse.get(key=('beta',)) == beta
290287
elif bse_info == 'save':
291288
# save info
@@ -406,7 +403,7 @@ def _calc_bse_x0q(self):
406403
Calc X_0(q)
407404
"""
408405
print("\n--- dcore_bse - X_0(q)")
409-
if self._params['bse']['skip_X0q_if_exists'] and os.path.exists(self._params['bse']['h5_output_file']):
406+
if self._params['bse']['flag_X0q'] == False:
410407
print(" skip")
411408
return
412409

@@ -452,10 +449,16 @@ def calc_num_flavors(_ish):
452449
# init for saving data into HDF5
453450
#
454451
print("\n--- dcore_bse - invoking h5BSE...")
452+
453+
if os.path.isfile(self._params['bse']['h5_output_file']):
454+
bse_info = 'check'
455+
else:
456+
bse_info = 'save'
457+
455458
bse = SaveBSE(
456459
n_corr_shells=self._n_corr_shells,
457460
h5_file=os.path.abspath(self._params['bse']['h5_output_file']),
458-
bse_info='check',
461+
bse_info=bse_info,
459462
nonlocal_order_parameter=False,
460463
use_spin_orbit=self._use_spin_orbit,
461464
beta=self._beta,
@@ -478,7 +481,7 @@ def calc_num_flavors(_ish):
478481
# X_loc
479482
#
480483
print("\n--- dcore_bse - X_loc")
481-
if self._params['bse']['skip_Xloc']:
484+
if self._params['bse']['flag_Xloc'] == False:
482485
print(" skip")
483486
return
484487

src/dcore/program_options.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,10 @@ def create_parser(target_sections=None):
154154
parser.add_option("bse", "num_wb", int, 1, "Number of bosonic frequencies (>0)")
155155
parser.add_option("bse", "num_wf", int, 10, "Number of fermionic frequencies (>0)")
156156
parser.add_option("bse", "h5_output_file", str, 'dmft_bse.h5', "Output HDF5 file for bse data")
157-
parser.add_option("bse", "skip_X0q_if_exists", bool, False, "Skip X_0(q) calc if file already exists")
158-
parser.add_option("bse", "skip_Xloc", bool, False, "Skip X_loc calc (for RPA)")
157+
parser.add_option("bse", "skip_X0q_if_exists", bool, False, "[NOT USED] Skip X_0(q) calc if file already exists", OptionStatus.RETIRED)
158+
parser.add_option("bse", "skip_Xloc", bool, False, "[DEPRECATED] Skip X_loc calc (for RPA)", OptionStatus.DEPRECATED)
159+
parser.add_option("bse", "flag_X0q", bool, True, "Whether X_0(q) is calculated.")
160+
parser.add_option("bse", "flag_Xloc", bool, True, "Whether X_loc is calculated. Set False for RPA")
159161
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.")
160162
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.")
161163

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

251+
if 'bse' in params:
252+
# skip_Xloc is dreprecated.
253+
if params['bse']['skip_Xloc'] == True:
254+
params['bse']['flag_Xloc'] = False
255+
249256

250257
def parse_knode(knode_string):
251258
"""

0 commit comments

Comments
 (0)