Skip to content

Commit

Permalink
Fixed parser for impurity calculations in dos mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Raff-physics committed Jul 4, 2024
1 parent 1e68dc4 commit 7989f44
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
21 changes: 17 additions & 4 deletions aiida_kkr/parsers/kkrimp.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import tarfile
import os
from aiida import __version__ as aiida_core_version
from aiida.orm import Dict
from aiida.orm import Dict, CalcJobNode
from aiida.common.exceptions import InputValidationError, NotExistent
from aiida.parsers.parser import Parser
from aiida_kkr.calculations.kkrimp import KkrimpCalculation
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.1'
__contributors__ = (u'Philipp Rüßmann', u'Raffaele Aliberti')


class KkrimpParser(Parser):
Expand Down Expand Up @@ -64,6 +64,19 @@ def parse(self, debug=False, ignore_nan=True, **kwargs):
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
parent_host_calc = calc.inputs.host_Greenfunction_folder.get_incoming(node_class=CalcJobNode).first().node
npol = parent_host_calc.inputs.parameters.get_dict().get(
'NPOL', 1
) # This parameter discriminates if it is a DOS calc or not
doscalc = (npol == 0)

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

# 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 @@ def parse(self, debug=False, ignore_nan=True, **kwargs):

# 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
4 changes: 3 additions & 1 deletion aiida_kkr/tools/tools_STM_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ def get_imp_info_add_position(add_position, host_structure, imp_info):
# combine cluster information
pos_exists_in_imp1, _ = pos_exists_already(clust1, clust2)
if pos_exists_in_imp1:
raise ValueError('Additional position exists already in impurity cluster.')
# If the position exists already we simply skip the addition of the new scanning position
return None
#raise ValueError('Additional position exists already in impurity cluster.')
cluster_combined, rimp_rel_combined, _, _ = combine_clusters(clust1, clust2_offset, False, debug=False)
# combine the zimp arrays
zimp_combined = imp_info['Zimp'] + imp_info2['Zimp']
Expand Down
11 changes: 7 additions & 4 deletions aiida_kkr/workflows/kkr_STM.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,18 +195,21 @@ def combine_potentials(self, host_structure, impurity_to_combine, da, db):
"""
Here we want to combine the impurity information and the host information
"""
tip_position = {}
tip_position = {
} # Since the objects in AiiDA are immutable we have to create a new dictionary and then convert
# it to the right AiiDA type

tip_position['ilayer'] = self.inputs.tip_position['ilayer']
tip_position['da'] = da
tip_position['db'] = db
imp_info = self.inputs.imp_info #(impurity to combine)

combined_imp_info = get_imp_info_add_position(Dict(tip_position), host_structure, imp_info)
# Since the objects in AiiDA are immutable we have to create a new dictionary and then convert
# it to the right AiiDA type

#new_combined_imp_info = {}
# If the position already exists we simply return the old dictionary
if combined_imp_info is None:
return impurity_to_combine

# Add check to see if imp_cls is there
if 'imp_cls' in impurity_to_combine:

Expand Down

0 comments on commit 7989f44

Please sign in to comment.