Skip to content

Commit

Permalink
Minor improvements
Browse files Browse the repository at this point in the history
- allow to set shapefun in voronoi calculation from input
- set kkrflex_llyfac from wfac_renorm
- minor bugfix in gf_writeout which can now also start from a voronoi run
  • Loading branch information
PhilippRue committed Jul 8, 2024
1 parent e5ad8bf commit 66e4e39
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 23 deletions.
38 changes: 28 additions & 10 deletions aiida_kkr/calculations/kkrimp.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
__copyright__ = (u'Copyright (c), 2018, Forschungszentrum Jülich GmbH, '
'IAS-1/PGI-1, Germany. All rights reserved.')
__license__ = 'MIT license, see LICENSE.txt file'
__version__ = '0.10.1'
__version__ = '0.10.2'
__contributors__ = (u'Philipp Rüßmann', u'Fabian Bertoldo')

#TODO: implement 'ilayer_center' consistency check
Expand Down Expand Up @@ -786,6 +786,10 @@ def _initialize_kkrimp_params(self, params_host, parameters, GFhost_folder, temp
# take care of LLYsimple (i.e. Lloyd in host system)
if 'LLOYD' in runopts:
runflag = self._use_lloyd(runflag, GFhost_folder, tempfolder)
# alternative to Lloyd mode: renormalization factor of energy integration weights
if params_host.get_value('WFAC_RENORM') is not None:
if params_host.get_value('WFAC_RENORM'):
runflag = self._use_lloyd(runflag, GFhost_folder, tempfolder, True)

# now set runflags
params_kkrimp.set_value('RUNFLAG', runflag)
Expand Down Expand Up @@ -823,19 +827,33 @@ def _set_nosoc(self, params_host, GFhost_folder, tempfolder):
for socscl in socscale:
kkrflex_socfac.write(f' {socscl}\n')

def _use_lloyd(self, runflag, GFhost_folder, tempfolder):
def _use_lloyd(self, runflag, GFhost_folder, tempfolder, wfac_renorm=False):
"""Use the LLYsimple version of KKRimp code with the average renormalization factor from the host calculation"""

# add runflag for imp code
runflag.append('LLYsimple')
# also extract renormalization factor and create kkrflex_llyfac file (contains one value only)
with GFhost_folder.open('output.000.txt') as f:
txt = f.readlines()

# find renormalization factor
if wfac_renorm:
# option 1: found wfac_renorm in Kkrhost parent's input parameters
with GFhost_folder.open('inputcard') as f:
txt = f.readlines()
iline = search_string('WFAC_RENORM', txt)
else:
# option 2: host parent is a Lloyd calculation
# extract renormalization factor and create kkrflex_llyfac file (contains one value only)
with GFhost_folder.open('output.000.txt') as f:
txt = f.readlines()
iline = search_string('RENORM_LLY: Renormalization factor of total charge', txt)
if iline >= 0:
llyfac = txt[iline].split()[-1]
# now write kkrflex_llyfac to tempfolder where later on config file is also written
with tempfolder.open(self._KKRFLEX_LLYFAC, 'w') as f2:
f2.writelines([llyfac])

if iline >= 0:
llyfac = txt[iline].split()[-1]
else:
raise ValueError('Failed to extract llyfac in KkrimpCalculation')

# now write kkrflex_llyfac to tempfolder where later on config file is also written
with tempfolder.open(self._KKRFLEX_LLYFAC, 'w') as f2:
f2.writelines([llyfac])
return runflag

def _activate_jij_calc(self, runflag, params_kkrimp, GFhost_folder, tempfolder):
Expand Down
12 changes: 12 additions & 0 deletions aiida_kkr/calculations/voro.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ def define(cls, spec):
required=False,
help='Use a node that specifies the potential which is used instead of the voronoi output potential'
)
spec.input(
'shapefun_overwrite',
valid_type=SinglefileData,
required=False,
help='Use a node that specifies the shapefun which is used instead of the voronoi output'
)
# define outputs
spec.output('output_parameters', valid_type=Dict, required=True, help='results of the calculation')
spec.default_output_node = 'output_parameters'
Expand Down Expand Up @@ -193,6 +199,12 @@ def prepare_for_submission(self, tempfolder):
filename = self._POTENTIAL_IN_OVERWRITE
local_copy_list.append((outfolder.uuid, file1, filename))

# add shapefun to overwrite
if 'shapefun_overwrite' in self.inputs:
shapefun_overwrite = self.inputs.shapefun_overwrite
filename = shapefun_overwrite.filename
local_copy_list.append((shapefun_overwrite.uuid, filename, 'shapefun_overwrite'))

# Prepare CalcInfo to be returned to aiida
calcinfo = CalcInfo()
calcinfo.uuid = self.uuid
Expand Down
27 changes: 14 additions & 13 deletions aiida_kkr/workflows/gf_writeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,19 +334,20 @@ def set_params_flex(self):
self.report(f'INFO: RUNOPT set to: {runopt}')

if 'wf_parameters' in self.inputs:
# extract Fermi energy in Ry
remote_data_parent = self.inputs.remote_data
parent_calc = remote_data_parent.get_incoming(link_label_filter='remote_folder').first().node
ef = parent_calc.outputs.output_parameters.get_dict().get('fermi_energy')
# check if ef needs to be taken from a voronoi parent
if ef is None:
objects = parent_calc.outputs.retrieved.list_object_names()
fname = VoronoiCalculation._OUT_POTENTIAL_voronoi
if fname in objects:
with parent_calc.outputs.retrieved.open(fname) as _f:
ef = get_ef_from_potfile(_f)
if ef is None:
return self.exit_codes.ERROR_NO_EF_FOUND # pylint: disable=no-member
if self.ctx.dos_run or self.ctx.ef_shift != 0:
# extract Fermi energy in Ry
remote_data_parent = self.inputs.remote_data
parent_calc = remote_data_parent.get_incoming(link_label_filter='remote_folder').first().node
ef = parent_calc.outputs.output_parameters.get_dict().get('fermi_energy')
# check if ef needs to be taken from a voronoi parent
if ef is None:
objects = parent_calc.outputs.retrieved.list_object_names()
fname = VoronoiCalculation._OUT_POTENTIAL_voronoi
if fname in objects:
with parent_calc.outputs.retrieved.open(fname) as _f:
ef = get_ef_from_potfile(_f)
if ef is None:
return self.exit_codes.ERROR_NO_EF_FOUND # pylint: disable=no-member

if self.ctx.dos_run:
# possibly remove keys which are overwritten from DOS params
Expand Down
2 changes: 2 additions & 0 deletions aiida_kkr/workflows/kkr_STM.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,10 @@ def STM_lmdos_run(self):
# The bigger the scanning position, the greater it must be set.
if 'gf_writeout' in self.inputs:
if 'params_kkr_overwrite' in self.inputs.gf_writeout:
self.report('set "params_kkr_overwrite" input to "builder.gf_writeout"')
builder.gf_writeout.params_kkr_overwrite = self.inputs.gf_writeout.params_kkr_overwrite # pylint: disable=no-member
if 'options' in self.inputs.gf_writeout:
self.report('set "options" input to "builder.gf_writeout"')
builder.gf_writeout.options = self.inputs.gf_writeout.options # pylint: disable=no-member
else:
# This is a big value of NSHELD to make sure that most calculations work
Expand Down

0 comments on commit 66e4e39

Please sign in to comment.