Skip to content

Commit

Permalink
Merge branch 'STM-BdG' into develop-STM
Browse files Browse the repository at this point in the history
  • Loading branch information
Raff-physics committed May 29, 2024
2 parents fe72bfa + 47baf2c commit f4b6518
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
25 changes: 12 additions & 13 deletions aiida_kkr/tools/tools_STM_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,14 @@ def offset_clust2(clust1, clust2, host_structure, add_position):
return clust2_offset


def get_imp_info_add_position(host_calc, imp_info, add_position):
def get_imp_info_add_position(add_position, host_structure, imp_info):
"""
Create combined impurity info node for the original
imp cluster + an additional (STM tip) position
"""

# extract host structure
host_structure = find_parent_structure(host_calc)
# host_structure = find_parent_structure(host_calc)

# convert imp info to cls form
imp_info_cls, clust1 = convert_to_imp_cls(host_structure, imp_info)
Expand All @@ -138,14 +138,14 @@ def get_imp_info_add_position(host_calc, imp_info, add_position):


@engine.calcfunction
def get_imp_info_add_position_cf(host_remote, imp_info, add_position):
def get_imp_info_add_position_cf(add_position, host_structure, imp_info):
"""
Create a new impurty info node that combines the impurity cluster
of an original calculation and an STM scanning position.
"""

# then combine the imp info
imp_info_combined = get_imp_info_add_position(host_remote, imp_info, add_position)
imp_info_combined = get_imp_info_add_position(add_position, host_structure, imp_info)

return imp_info_combined

Expand All @@ -154,7 +154,7 @@ def get_imp_info_add_position_cf(host_remote, imp_info, add_position):
# combine potentials


def extract_host_potential(add_position, host_remote):
def extract_host_potential(add_position, host_calc):
"""
Extract the potential of the position in the host that matches the additional position
"""
Expand All @@ -163,7 +163,7 @@ def extract_host_potential(add_position, host_remote):
ilayer = add_position['ilayer']

# get host calculation from remote
host_calc = host_remote.get_incoming(node_class=orm.CalcJobNode).first().node
#host_calc = host_remote.get_incoming(node_class=orm.CalcJobNode).first().node

# read potential from host's retrieved node
with host_calc.outputs.retrieved.open('out_potential') as _f:
Expand All @@ -183,12 +183,12 @@ def extract_host_potential(add_position, host_remote):
return pot_add


def add_host_potential_to_imp(add_position, host_remote, imp_potential_node):
def add_host_potential_to_imp(add_position, host_calc, imp_potential_node):
"""
combine host potential with impurity potential
"""
# get add potential from host
pot_add = extract_host_potential(add_position, host_remote)
pot_add = extract_host_potential(add_position, host_calc)

# get impurity potential and convert to list
pot_imp = imp_potential_node.get_content().split('\n')
Expand All @@ -200,15 +200,15 @@ def add_host_potential_to_imp(add_position, host_remote, imp_potential_node):
return pot_combined


def create_combined_potential_node(add_position, host_remote, imp_potential_node):
def create_combined_potential_node(add_position, host_calc, imp_potential_node):
"""
Combine impurity potential with an additional potential from the host for
the STM tip position (additional position)
"""
import io

# combine potential texts
pot_combined = add_host_potential_to_imp(add_position, host_remote, imp_potential_node)
pot_combined = add_host_potential_to_imp(add_position, host_calc, imp_potential_node)

# convert to byte string and put into SinglefilData node
pot_combined_string = ''
Expand All @@ -218,14 +218,13 @@ def create_combined_potential_node(add_position, host_remote, imp_potential_node

return pot_combined_node


@engine.calcfunction
def create_combined_potential_node_cf(add_position, host_remote, imp_potential_node):
def create_combined_potential_node_cf(add_position, host_calc, imp_potential_node):
"""
Calcfunction that combines the impurity potential with an addition potential site from the host
"""

pot_combined_node = create_combined_potential_node(add_position, host_remote, imp_potential_node)
pot_combined_node = create_combined_potential_node(add_position, host_calc, imp_potential_node)

return pot_combined_node

Expand Down
8 changes: 7 additions & 1 deletion aiida_kkr/workflows/kkr_STM.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def combine_potentials(self, host_structure, impurity_to_combine, da, db):
imp_info = self.inputs.imp_info #(impurity to combine)
#host_remote = self.inputs.host_remote

combined_imp_info = get_imp_info_add_position(tip_position, host_structure, imp_info)
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

Expand Down Expand Up @@ -425,6 +425,9 @@ def STM_lmdos_run(self):
# Check if the kkrflex files are already given in the outputs
if 'kkrflex_files' in self.inputs:
builder.gf_dos_remote = self.inputs.kkrflex_files
message = f'Remote host function is given in the outputs from the node: {self.inputs.kkrflex_files}'
print(message)
self.report(message)
else:
builder.kkr = self.inputs.kkr # needed to evaluate the kkr_flex files in the DOS step

Expand Down Expand Up @@ -484,6 +487,9 @@ def STM_lmdos_run(self):
calc = self.submit(builder)
message = f"""INFO: running DOS step for an STM measurement (pk: {calc.pk}) at position
(ilayer: {self.inputs.tip_position['ilayer']}, da: {x}, db: {y} )"""

if self.inputs.BdG.params_kkr_overwrite:
message = f"""INFO: runnig DOS step (pk: {calc.pk}) BdG is present"""

print(message)
self.report(message)
Expand Down

0 comments on commit f4b6518

Please sign in to comment.