Skip to content

Commit

Permalink
renaming kcw subsubblocks to mirror the kcw.x input file
Browse files Browse the repository at this point in the history
  • Loading branch information
nscolonna committed Jul 2, 2024
1 parent 9bb66a6 commit dbb2ee1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
20 changes: 10 additions & 10 deletions src/koopmans/workflows/_koopmans_dfpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ def __init__(self, scf_kgrid=None, *args, **kwargs):
if val is not None:
tols[key] = val
self.bands = Bands(n_bands=[len(f) for f in filling], n_spin=2,
spin_polarized=self.parameters.spin_polarized,
filling=filling, groups=self.parameters.orbital_groups, tolerances=tols)
spin_polarized=self.parameters.spin_polarized,
filling=filling, groups=self.parameters.orbital_groups, tolerances=tols)
else:
nocc = pseudopotentials.nelec_from_pseudos(
self.atoms, self.pseudopotentials, self.parameters.pseudo_directory) // 2
Expand All @@ -142,7 +142,7 @@ def __init__(self, scf_kgrid=None, *args, **kwargs):

# Populating kpoints if absent
if not all(self.atoms.pbc):
for key in ['pw', 'kc_screen']:
for key in ['pw', 'kcw_screen']:
self.calculator_parameters[key].kpts = [1, 1, 1]

self._perform_ham_calc: bool = True
Expand Down Expand Up @@ -217,7 +217,7 @@ def _run(self):
# Convert from wannier to KC
self.print('Conversion to Koopmans format', style='subheading')
wann2kc_calc = self.new_calculator(
'wann2kc', spin_component=spin_component)
'kcw_wannier', spin_component=spin_component)
if self.parameters.spin_polarized:
wann2kc_calc.directory /= f'spin_{spin_component}'
self.run_calculator(wann2kc_calc)
Expand All @@ -236,7 +236,7 @@ def _run(self):
# If there is no orbital grouping, do all orbitals in one calculation
# 1) Create the calculator
kc_screen_calc = self.new_calculator(
'kc_screen', spin_component=spin_component)
'kcw_screen', spin_component=spin_component)
if self.parameters.spin_polarized:
kc_screen_calc.directory /= f'spin_{spin_component}'

Expand All @@ -250,7 +250,7 @@ def _run(self):
for band in self.bands.to_solve:
# 1) Create the calculator (in a subdirectory)
kc_screen_calc = self.new_calculator(
'kc_screen', i_orb=band.index, spin_component=spin_component)
'kcw_screen', i_orb=band.index, spin_component=spin_component)
if self.parameters.spin_polarized:
kc_screen_calc.directory /= f'spin_{spin_component}'
kc_screen_calc.directory /= f'band_{band.index}'
Expand All @@ -276,7 +276,7 @@ def _run(self):
if self._perform_ham_calc:
self.print('Construction of the Hamiltonian', style='heading')
kc_ham_calc = self.new_calculator(
'kc_ham', kpts=self.kpoints.path, spin_component=spin_component)
'kcw_ham', kpts=self.kpoints.path, spin_component=spin_component)
if self.parameters.spin_polarized:
kc_ham_calc.directory /= f'spin_{spin_component}'

Expand Down Expand Up @@ -317,7 +317,7 @@ def plot_bandstructure(self):
super().plot_bandstructure(bs.subtract_reference())

def new_calculator(self, calc_presets, **kwargs):
if calc_presets not in ['kc_ham', 'kc_screen', 'wann2kc']:
if calc_presets not in ['kcw_ham', 'kcw_screen', 'kcw_wannier']:
raise ValueError(
f'Invalid choice calc_presets={calc_presets} in {self.__class__.__name__}.new_calculator()')

Expand All @@ -334,12 +334,12 @@ def new_calculator(self, calc_presets, **kwargs):
for k, v in kwargs.items():
setattr(calc.parameters, k, v)

if calc_presets == 'wann2kc':
if calc_presets == 'kcw_wannier':
if all(self.atoms.pbc):
calc.directory = 'wannier'
else:
calc.directory = 'init'
elif calc_presets == 'kc_screen':
elif calc_presets == 'kcw_screen':
calc.directory = 'screening'
# If eps_inf is not provided in the kc_wann:screen subdictionary but there is a value provided in the
# workflow parameters, adopt that value
Expand Down
24 changes: 12 additions & 12 deletions src/koopmans/workflows/_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,11 +628,11 @@ def new_calculator(self,
calc_class = calculators.Wann2KCPCalculator
elif calc_type.startswith('ui'):
calc_class = calculators.UnfoldAndInterpolateCalculator
elif calc_type == 'wann2kc':
elif calc_type == 'kcw_wannier':
calc_class = calculators.Wann2KCCalculator
elif calc_type == 'kc_screen':
elif calc_type == 'kcw_screen':
calc_class = calculators.KoopmansScreenCalculator
elif calc_type == 'kc_ham':
elif calc_type == 'kcw_ham':
calc_class = calculators.KoopmansHamCalculator
elif calc_type == 'ph':
calc_class = calculators.PhCalculator
Expand Down Expand Up @@ -1056,8 +1056,8 @@ def _fromjsondct(cls, bigdct: Dict[str, Any], override: Dict[str, Any] = {}):
calcdict[f'ui_{key}'] = calcdict['ui']

# Third, flatten the kcw subdicts
kcw_blocks = calcdict.pop('kcw', {'kc_ham': {}, 'kc_screen': {}, 'wann2kc': {}})
calcdict.update(**kcw_blocks)
kcw_blocks = calcdict.pop('kcw', {'ham': {}, 'screen': {}, 'wannier': {}})
calcdict.update(**{'kcw_' + k: v for k, v in kcw_blocks.items()})

# Finally, generate a SettingsDict for every single kind of calculator, regardless of whether or not there was
# a corresponding block in the json file
Expand Down Expand Up @@ -1261,7 +1261,7 @@ def toinputjson(self) -> Dict[str, Dict[str, Any]]:
calcdct[code][key] = {k: v for k, v in dict(
block).items() if v is not None}

elif code in ['pw2wannier', 'wann2kc', 'kc_screen', 'kc_ham', 'projwfc', 'wann2kcp', 'ph']:
elif code in ['pw2wannier', 'kcw_wannier', 'kcw_screen', 'kcw_ham', 'projwfc', 'wann2kcp', 'ph']:
calcdct[code] = params_dict
elif code.startswith('ui_'):
calcdct['ui'][code.split('_')[-1]] = params_dict
Expand Down Expand Up @@ -1492,8 +1492,8 @@ def generate_default_calculator_parameters() -> Dict[str, settings.SettingsDict]
# Dictionary to be used as the default value for 'calculator_parameters' when initializing a workflow
# We create this dynamically in order for the .directory attributes to make sense
return {'kcp': settings.KoopmansCPSettingsDict(),
'kc_ham': settings.KoopmansHamSettingsDict(),
'kc_screen': settings.KoopmansScreenSettingsDict(),
'kcw_ham': settings.KoopmansHamSettingsDict(),
'kcw_screen': settings.KoopmansScreenSettingsDict(),
'ph': settings.PhSettingsDict(),
'projwfc': settings.ProjwfcSettingsDict(),
'pw': settings.PWSettingsDict(),
Expand All @@ -1502,7 +1502,7 @@ def generate_default_calculator_parameters() -> Dict[str, settings.SettingsDict]
'ui': settings.UnfoldAndInterpolateSettingsDict(),
'ui_occ': settings.UnfoldAndInterpolateSettingsDict(),
'ui_emp': settings.UnfoldAndInterpolateSettingsDict(),
'wann2kc': settings.Wann2KCSettingsDict(),
'kcw_wannier': settings.Wann2KCSettingsDict(),
'w90': settings.Wannier90SettingsDict(),
'w90_up': settings.Wannier90SettingsDict(),
'w90_down': settings.Wannier90SettingsDict(),
Expand All @@ -1511,9 +1511,9 @@ def generate_default_calculator_parameters() -> Dict[str, settings.SettingsDict]

# Define which function to use to read each block
settings_classes = {'kcp': settings.KoopmansCPSettingsDict,
'kc_ham': settings.KoopmansHamSettingsDict,
'kc_screen': settings.KoopmansScreenSettingsDict,
'wann2kc': settings.Wann2KCSettingsDict,
'kcw_ham': settings.KoopmansHamSettingsDict,
'kcw_screen': settings.KoopmansScreenSettingsDict,
'kcw_wannier': settings.Wann2KCSettingsDict,
'ph': settings.PhSettingsDict,
'projwfc': settings.ProjwfcSettingsDict,
'pw': settings.PWSettingsDict,
Expand Down

0 comments on commit dbb2ee1

Please sign in to comment.