Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development of STM workchain #156

Merged
merged 50 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
ee45cf0
Add files via upload
Raff-physics Mar 8, 2024
74425e9
Latest STM workflow with Bdg and STM tools
Raff-physics May 23, 2024
e664c2d
Latest version of the STM workflow with the BdG settings
Raff-physics May 23, 2024
72af668
Functioning BdG version of the workflow
Raff-physics May 24, 2024
8f2c1f5
Merge branch 'develop' into develop-STM
PhilippRue May 29, 2024
56f8469
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 29, 2024
fe72bfa
Small change to STM pathfinder and remove unused STM.py file
PhilippRue May 29, 2024
47baf2c
working version of the STM_wf
Raff-physics May 29, 2024
f4b6518
Merge branch 'STM-BdG' into develop-STM
Raff-physics May 29, 2024
093c343
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 29, 2024
b9ac704
Fix BdG call before assignment in submission
Raff-physics May 29, 2024
9d595b4
Small bugfixes and speed up imp cluster construction
PhilippRue May 29, 2024
3cb63e4
Improvements and bug fixes
PhilippRue May 31, 2024
11dfe38
Bugfix label length and add 'scan_positions' input possibility
PhilippRue May 31, 2024
784aff9
Small bugfix
PhilippRue May 31, 2024
6fc9ed0
Add timing output to report
PhilippRue May 31, 2024
8492fcc
Speed up impurity cluster generation
PhilippRue May 31, 2024
e183835
Add setting of options for gf_writeout.options if give as inputs.gf_w…
PhilippRue May 31, 2024
ac56918
Latest version of the kkr_STM workflow
Raff-physics Jun 5, 2024
3bc36e1
New version of the Pathfinder tool, now it uses the pymatgen library …
Raff-physics Jun 11, 2024
1e68dc4
Fixed one error concerning the size of the in-plane vectors
Raff-physics Jun 11, 2024
7989f44
Fixed parser for impurity calculations in dos mode
Raff-physics Jul 4, 2024
e5ad8bf
this version of the kkr_imp_sub workflow works with the changes in th…
Raff-physics Jul 5, 2024
66e4e39
Minor improvements
PhilippRue Jul 8, 2024
a7724d6
Fixed a small bug in combine imps. convert_to_imp_cls didn't return t…
Raff-physics Jul 11, 2024
bd70dd5
Various improvement for the kkr_STM workflow. Now it is able to corre…
Raff-physics Jul 13, 2024
ef89db1
Merge branch 'develop' into develop-STM
PhilippRue Oct 2, 2024
5998fa6
Commit is broken, small fix,but latest version from my part
Raff-physics Oct 2, 2024
eae066c
Merge branch 'develop-STM-v2' into develop-STM
Raff-physics Oct 2, 2024
e0e7f2a
Small improvement for exit code handling in gf_writeout workflow
PhilippRue Oct 2, 2024
f8c7370
Updated version of the STM_tools, know all the helpers functions have…
Raff-physics Oct 2, 2024
c823109
Fixes for more complicated system (Fe trimer)
PhilippRue Oct 4, 2024
77c0757
Merge branch 'develop-STM' of https://github.com/JuDFTteam/aiida-kkr …
Raff-physics Oct 4, 2024
02b1aaf
Solved a small issue where there was a conflict between the old and n…
Raff-physics Oct 4, 2024
8610289
Small bugfixes
PhilippRue Oct 7, 2024
b9906e4
This version of the STM workflow should allow to submit a calculation…
Raff-physics Oct 21, 2024
2ae32ce
Merge pull request #168 from JuDFTteam/develop
PhilippRue Nov 21, 2024
5ccb1a7
Fix kkrimp parser test
PhilippRue Nov 21, 2024
1ba776e
activate second kkr_imp_wc test
PhilippRue Nov 21, 2024
9016d72
Add test for shapefun_overwrite feature
PhilippRue Nov 21, 2024
0b56724
Small bugfix
PhilippRue Nov 21, 2024
9ea6d04
Changes to make STM workchain work for bulk systems + add tests
PhilippRue Nov 25, 2024
d90ac3e
activate STM test in CI
PhilippRue Nov 25, 2024
9f37e40
Update jij tests + small bugfix
PhilippRue Nov 25, 2024
660735c
Update combine_imps tests + small bugfixes
PhilippRue Nov 25, 2024
a19aca9
small bugfix
PhilippRue Nov 25, 2024
d4f6640
activate combine imps test in CI
PhilippRue Nov 25, 2024
3b3652c
Add imp_BdG test + small bugfixes
PhilippRue Nov 28, 2024
3ac468d
Add use_left option to decimation workchain
PhilippRue Nov 28, 2024
bf3bbdd
Add Raffaele's STM tutorial
PhilippRue Nov 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions aiida_kkr/calculations/kkr.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
'IAS-1/PGI-1, Germany. All rights reserved.')
__license__ = 'MIT license, see LICENSE.txt file'

__version__ = '0.13.1'
__version__ = '0.13.2'

__contributors__ = ('Jens Bröder', 'Philipp Rüßmann')

Expand Down Expand Up @@ -1063,8 +1063,8 @@
f'Error: theta value out of range (0..180): iatom={iatom}, theta={theta}'
)
# convert fix_dir to boolean if given as integer
if not isinstance(fix_dir, bool):
fix_dir = (fix_dir == 1)
if not isinstance(fix_dir[iatom], bool):
fix_dir[iatom] = (fix_dir[iatom] == 1)

Check warning on line 1067 in aiida_kkr/calculations/kkr.py

View check run for this annotation

Codecov / codecov/patch

aiida_kkr/calculations/kkr.py#L1066-L1067

Added lines #L1066 - L1067 were not covered by tests
# write line
noco_angle_file.write(f' {theta} {phi} {fix_dir[iatom]}\n')

Expand Down
40 changes: 30 additions & 10 deletions aiida_kkr/calculations/kkrimp.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@
_OUT_LMDOS_INTERPOL = u'out_lmdos.interpol.atom=*'
_OUT_MAGNETICMOMENTS = u'out_magneticmoments'
_OUT_ORBITALMOMENTS = u'out_orbitalmoments'
_LDAUPOT = 'ldaupot'
_LDAUPOT = u'ldaupot'

_TEST_RHO2NS = u'test_rho2ns'

# template.product entry point defined in setup.json
_default_parser = u'kkr.kkrimpparser'
Expand Down Expand Up @@ -787,6 +789,10 @@
# 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)

Check warning on line 795 in aiida_kkr/calculations/kkrimp.py

View check run for this annotation

Codecov / codecov/patch

aiida_kkr/calculations/kkrimp.py#L794-L795

Added lines #L794 - L795 were not covered by tests

# now set runflags
params_kkrimp.set_value('RUNFLAG', runflag)
Expand Down Expand Up @@ -824,19 +830,33 @@
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:

Check warning on line 840 in aiida_kkr/calculations/kkrimp.py

View check run for this annotation

Codecov / codecov/patch

aiida_kkr/calculations/kkrimp.py#L840

Added line #L840 was not covered by tests
# 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)

Check warning on line 844 in aiida_kkr/calculations/kkrimp.py

View check run for this annotation

Codecov / codecov/patch

aiida_kkr/calculations/kkrimp.py#L842-L844

Added lines #L842 - L844 were not covered by tests
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()

Check warning on line 849 in aiida_kkr/calculations/kkrimp.py

View check run for this annotation

Codecov / codecov/patch

aiida_kkr/calculations/kkrimp.py#L848-L849

Added lines #L848 - L849 were not covered by tests
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]

Check warning on line 853 in aiida_kkr/calculations/kkrimp.py

View check run for this annotation

Codecov / codecov/patch

aiida_kkr/calculations/kkrimp.py#L852-L853

Added lines #L852 - L853 were not covered by tests
else:
raise ValueError('Failed to extract llyfac in KkrimpCalculation')

Check warning on line 855 in aiida_kkr/calculations/kkrimp.py

View check run for this annotation

Codecov / codecov/patch

aiida_kkr/calculations/kkrimp.py#L855

Added line #L855 was not covered by tests

# 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])

Check warning on line 859 in aiida_kkr/calculations/kkrimp.py

View check run for this annotation

Codecov / codecov/patch

aiida_kkr/calculations/kkrimp.py#L858-L859

Added lines #L858 - L859 were not covered by tests
return runflag

def _activate_jij_calc(self, runflag, params_kkrimp, GFhost_folder, tempfolder):
Expand Down
15 changes: 8 additions & 7 deletions aiida_kkr/calculations/voro.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
__copyright__ = (u'Copyright (c), 2017, Forschungszentrum Jülich GmbH, '
'IAS-1/PGI-1, Germany. All rights reserved.')
__license__ = 'MIT license, see LICENSE.txt file'
__version__ = '0.5.3'
__version__ = '0.5.4'
__contributors__ = ('Jens Broeder', 'Philipp Rüßmann')


Expand Down Expand Up @@ -182,7 +182,8 @@ def prepare_for_submission(self, tempfolder):
# Decide what files to copy
local_copy_list = []
if overwrite_potential:
# copy the right files #TODO check first if file, exists and throw
# copy the right files
#TODO check first if file, exists and throw
# warning, now this will throw an error
if found_parent and self._is_KkrCalc(parent_calc):
outfolder = parent_calc.outputs.retrieved # copy from remote folder
Expand All @@ -199,11 +200,11 @@ def prepare_for_submission(self, tempfolder):
filename = self._POTENTIAL_IN_OVERWRITE
local_copy_list.append((outfolder.uuid, file1, filename)) # pylint: disable=possibly-used-before-assignment

# 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'))
# 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()
Expand Down
25 changes: 19 additions & 6 deletions aiida_kkr/parsers/kkrimp.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import tarfile
import os
from aiida import __version__ as aiida_core_version
from aiida.orm import Dict
from aiida.common.exceptions import InputValidationError, NotExistent
from aiida.orm import Dict, CalcJobNode
from aiida.common.exceptions import InputValidationError, NotExistent, NotExistentAttributeError
from aiida.parsers.parser import Parser
from aiida_kkr.calculations.kkrimp import KkrimpCalculation
from aiida_kkr.tools.context import open_files_in_context
Expand All @@ -21,8 +21,8 @@
__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.6.0'
__contributors__ = ('Philipp Rüßmann')
__version__ = '0.6.2'
__contributors__ = (u'Philipp Rüßmann', u'Raffaele Aliberti')


class KkrimpParser(Parser):
Expand All @@ -42,7 +42,7 @@

# pylint: disable=protected-access
# pylint: disable=unexpected-keyword-arg
def parse(self, debug=False, ignore_nan=True, **kwargs):
def parse(self, debug=False, ignore_nan=True, doscalc=None, **kwargs):
"""
Parse output data folder, store results in database.

Expand All @@ -64,6 +64,19 @@
file_errors = []
files = {}

# Get the node of the parent calculation (useful for the imp calculations)
calc = out_folder.get_incoming(node_class=CalcJobNode).first().node

# figure out if this is a DOS calculation (if not specified in the input already)
if doscalc is None:
parent_host_calc = calc.inputs.host_Greenfunction_folder.get_incoming(node_class=CalcJobNode).first().node
# This parameter discriminates if it is a DOS calc or not
npol = parent_host_calc.inputs.parameters.get_dict().get('NPOL', 1)
doscalc = (npol == 0)

if debug:
print('doscalc = ', doscalc)

Check warning on line 78 in aiida_kkr/parsers/kkrimp.py

View check run for this annotation

Codecov / codecov/patch

aiida_kkr/parsers/kkrimp.py#L78

Added line #L78 was not covered by tests

# Parse output files of KKRimp calculation

# first get path to files and catch errors if files are not present
Expand Down Expand Up @@ -113,7 +126,7 @@

# now we can parse the output files
success, msg_list, out_dict = KkrimpParserFunctions().parse_kkrimp_outputfile(
out_dict, named_file_handles, debug=debug, ignore_nan=ignore_nan
out_dict, named_file_handles, debug=debug, ignore_nan=ignore_nan, doscalc=doscalc
)

out_dict['parser_errors'] = msg_list
Expand Down
2 changes: 1 addition & 1 deletion aiida_kkr/tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from .common_workfunctions import (
update_params_wf, prepare_VCA_structure_wf, prepare_2Dcalc_wf, test_and_get_codenode, get_inputs_kkr,
get_inputs_kkrimporter, get_inputs_voronoi, get_inputs_kkrimp, get_parent_paranode,
generate_inputcard_from_structure, check_2Dinput_consistency, structure_from_params, vca_check
generate_inputcard_from_structure, check_2Dinput_consistency, structure_from_params, vca_check, truncate_string
)
from .find_cluster_radius import find_cluster_radius
from .plot_kkr import plot_kkr
Expand Down
4 changes: 0 additions & 4 deletions aiida_kkr/tools/combine_imps.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ def get_host_structure(impurity_workflow_or_calc):
extract host structure from impurity
"""
#TODO extract host parent no from input but take into account calculation of host GF from inside kkrimp full workflow
print(
f'This is line in the combine impurity tool files at:: /opt/aiida-kkr/aiida_kkr/tools for deburging the line',
end=' '
)
print(f'impurity_workflow_or_calc: {impurity_workflow_or_calc}')
if impurity_workflow_or_calc.process_class == KkrimpCalculation:
host_parent = impurity_workflow_or_calc.inputs.host_Greenfunction_folder
Expand Down
13 changes: 12 additions & 1 deletion aiida_kkr/tools/common_workfunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,16 @@
return builder


def truncate_string(string, max_length):
"""
Truncate the length of a string to max_length-3 entries.
The last three characters '...' to indicate the truncation.
"""
if len(string) > max_length:
string = string[:max_length - 3] + '...'

Check warning on line 345 in aiida_kkr/tools/common_workfunctions.py

View check run for this annotation

Codecov / codecov/patch

aiida_kkr/tools/common_workfunctions.py#L345

Added line #L345 was not covered by tests
return string


def get_inputs_common(
calculation,
code,
Expand Down Expand Up @@ -381,7 +391,8 @@
inputs.metadata.description = ''

if label:
inputs.metadata.label = label
# Attention: max label length is 255 characters
inputs.metadata.label = truncate_string(label, 255)
else:
inputs.metadata.label = ''

Expand Down
25 changes: 16 additions & 9 deletions aiida_kkr/tools/imp_cluster_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,22 @@
:return: scoef array (positions [x,y,z], layer index, distance to first position in imp cluster)
:type: numpy.array
"""
impinfo = impinfo_node.get_dict()
Rcut = impinfo.get('Rcut', None)
hcut = impinfo.get('hcut', -1.)
cylinder_orient = impinfo.get('cylinder_orient', [0., 0., 1.])
ilayer_center = impinfo.get('ilayer_center', 0)

clust = create_scoef_array(host_structure, Rcut, hcut, cylinder_orient, ilayer_center)
# sort after distance
clust = clust[(clust[:, -1]).argsort()]
# check if we can read it from a node extra
if 'imp_cls' not in impinfo_node.extras:
impinfo = impinfo_node.get_dict()
Rcut = impinfo.get('Rcut', None)
hcut = impinfo.get('hcut', -1.)
cylinder_orient = impinfo.get('cylinder_orient', [0., 0., 1.])
ilayer_center = impinfo.get('ilayer_center', 0)

Check warning on line 54 in aiida_kkr/tools/imp_cluster_tools.py

View check run for this annotation

Codecov / codecov/patch

aiida_kkr/tools/imp_cluster_tools.py#L50-L54

Added lines #L50 - L54 were not covered by tests

clust = create_scoef_array(host_structure, Rcut, hcut, cylinder_orient, ilayer_center)

Check warning on line 56 in aiida_kkr/tools/imp_cluster_tools.py

View check run for this annotation

Codecov / codecov/patch

aiida_kkr/tools/imp_cluster_tools.py#L56

Added line #L56 was not covered by tests
# sort after distance
clust = clust[(clust[:, -1]).argsort()]

Check warning on line 58 in aiida_kkr/tools/imp_cluster_tools.py

View check run for this annotation

Codecov / codecov/patch

aiida_kkr/tools/imp_cluster_tools.py#L58

Added line #L58 was not covered by tests

# save as extra for second run
impinfo_node.set_extra('imp_cls', clust)

Check warning on line 61 in aiida_kkr/tools/imp_cluster_tools.py

View check run for this annotation

Codecov / codecov/patch

aiida_kkr/tools/imp_cluster_tools.py#L61

Added line #L61 was not covered by tests
else:
clust = np.array(impinfo_node.extras['imp_cls'])

return clust

Expand Down
Loading
Loading