-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes for more complicated system (Fe trimer)
- fix offset position (removed modulo 1 in `tools/tools_STM_scan.py`->`get_r_offset`) - removed code duplication by `self.get_tip_position_dict(da, db)` in `workflows/kkr_STM.py` - corrected confusing names of functions (combine_potentials`->`combine_imp_info` and `combine_nodes`->`combine_potentials`) - corrected deduplication checking of cluster positions (`pos_exists_already` needed `clust_offset` input instead of position without layer offset)
- Loading branch information
1 parent
e0e7f2a
commit c823109
Showing
2 changed files
with
45 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -188,19 +188,13 @@ def define(cls, spec): | |
cls.results | ||
) | ||
|
||
def combine_potentials(self, host_structure, impurity_to_combine, da, db): | ||
def combine_imp_info(self, host_structure, impurity_to_combine, da, db): | ||
This comment has been minimized.
Sorry, something went wrong.
PhilippRue
Author
Member
|
||
from aiida_kkr.tools.tools_STM_scan import get_imp_info_add_position | ||
import numpy as np # TO DO: optimize this call, only need append from numpy | ||
""" | ||
Here we want to combine the impurity information and the host information | ||
""" | ||
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 | ||
tip_position = self.get_tip_position_dict(da, 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) | ||
|
@@ -227,23 +221,25 @@ def combine_potentials(self, host_structure, impurity_to_combine, da, db): | |
|
||
return new_combined_imp_info | ||
|
||
def combine_nodes(self, host_calc, node_to_combine, da, db): | ||
def combine_potentials(self, host_calc, node_to_combine, da, db): | ||
This comment has been minimized.
Sorry, something went wrong.
PhilippRue
Author
Member
|
||
from aiida_kkr.tools.tools_STM_scan import create_combined_potential_node | ||
""" | ||
Here we create a combined potential node from the host potential (no impurity) | ||
and from the impurity potential | ||
""" | ||
|
||
# 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 = self.get_tip_position_dict(da, db) | ||
combined_potential_node = create_combined_potential_node(tip_position, host_calc, node_to_combine) | ||
return combined_potential_node | ||
|
||
def get_tip_position_dict(self, da, db): | ||
# 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 = {} | ||
# for now we require that the z position remains the same. | ||
tip_position['ilayer'] = self.inputs.tip_position['ilayer'] | ||
tip_position['da'] = da | ||
tip_position['db'] = db | ||
|
||
combined_node = create_combined_potential_node(tip_position, host_calc, node_to_combine) | ||
return combined_node | ||
return tip_position | ||
|
||
def start(self): | ||
""" | ||
|
@@ -344,11 +340,11 @@ def impurity_cluster_evaluation(self): | |
from aiida_kkr.tools.imp_cluster_tools import pos_exists_already | ||
from aiida_kkr.tools.tools_STM_scan import get_imp_cls_add, convert_to_imp_cls, offset_clust2 | ||
|
||
#if _VERBOSE_: | ||
# from time import time | ||
# | ||
# # measure time at start | ||
# t_start = time() | ||
if _VERBOSE_: | ||
from time import time | ||
|
||
# measure time at start | ||
t_start = time() | ||
|
||
# Here we create an impurity cluster that has inside all the positions on which the STM will scan | ||
|
||
|
@@ -362,9 +358,9 @@ def impurity_cluster_evaluation(self): | |
# now find all the positions we need to scan | ||
coeff = self.get_scanning_positions(host_remote) | ||
|
||
#if _VERBOSE_: | ||
# # timing counters | ||
# t_imp_info, t_pot = 0., 0. | ||
if _VERBOSE_: | ||
# timing counters | ||
t_imp_info, t_pot = 0., 0. | ||
|
||
_, imp_clust = convert_to_imp_cls(host_structure, impurity_info) | ||
|
||
|
@@ -380,52 +376,45 @@ def impurity_cluster_evaluation(self): | |
|
||
for element in coeff: | ||
|
||
#if _VERBOSE_: | ||
# t0 = time() | ||
if _VERBOSE_: | ||
t0 = time() | ||
|
||
# Check if the position is already in the cluster | ||
tmp_pos = {} | ||
tmp_pos['ilayer'] = self.inputs.tip_position['ilayer'] | ||
tmp_pos['da'] = element[0] | ||
tmp_pos['db'] = element[1] | ||
|
||
message = f'position to be embedded {tmp_pos}' | ||
|
||
# for this we need to first get the position | ||
tmp_pos = self.get_tip_position_dict(element[0], element[1]) | ||
_, tmp_clust = get_imp_cls_add(host_structure, tmp_pos) | ||
#clust_offset = offset_clust2(imp_clust, tmp_clust, host_structure, Dict(tmp_pos)) | ||
clust_offset = offset_clust2(imp_clust, tmp_clust, host_structure, Dict(tmp_pos)) | ||
|
||
#if _VERBOSE_: | ||
# t_cluster_offset += time()-t0 | ||
if _VERBOSE_: | ||
t_cluster_offset += time() - t0 | ||
|
||
if pos_exists_already(imp_clust, tmp_clust)[0]: | ||
message = f'The position {tmp_pos} is already present in the system' | ||
if pos_exists_already(imp_clust[:, :3], clust_offset[:, :3])[0]: | ||
This comment has been minimized.
Sorry, something went wrong.
PhilippRue
Author
Member
|
||
message = f'INFO: The position {tmp_pos} is already present in the system, skipping it' | ||
self.report(message) | ||
continue # If the position exists already skip the embedding | ||
else: | ||
# Aggregation of the impurity potential | ||
tmp_imp_info = self.combine_potentials(host_structure, impurity_info_aux, element[0], element[1]) | ||
tmp_imp_info = self.combine_imp_info(host_structure, impurity_info_aux, element[0], element[1]) | ||
impurity_info_aux = tmp_imp_info | ||
|
||
message = 'imp info has been embedded' | ||
self.report(message) | ||
|
||
#if _VERBOSE_: | ||
# t_imp_info += time() - t0 | ||
# t0 = time() | ||
if _VERBOSE_: | ||
self.report('imp info has been embedded') | ||
t_imp_info += time() - t0 | ||
t0 = time() | ||
|
||
# Aggregation the impurity nodes | ||
tmp_imp_pot = self.combine_nodes(host_calc, imp_potential_node_aux, element[0], element[1]) | ||
tmp_imp_pot = self.combine_potentials(host_calc, imp_potential_node_aux, element[0], element[1]) | ||
imp_potential_node_aux = tmp_imp_pot | ||
|
||
message = 'imp pot has been embedded' | ||
self.report(message) | ||
|
||
#if _VERBOSE_: | ||
# t_pot += time() - t0 | ||
if _VERBOSE_: | ||
self.report('imp potential has been added') | ||
t_pot += time() - t0 | ||
|
||
#if _VERBOSE_: | ||
# # report elapsed time for cluster generation | ||
# self.report(f'time for cluster generation (s): {time()-t_start}, cluster generation={t_cluster_offset}, imp_info={t_imp_info}, pot={t_pot}') | ||
if _VERBOSE_: | ||
# report elapsed time for cluster generation | ||
self.report( | ||
f'time for cluster generation (s): {time()-t_start}, cluster generation={t_cluster_offset}, imp_info={t_imp_info}, pot={t_pot}' | ||
) | ||
|
||
return impurity_info_aux, imp_potential_node_aux | ||
|
||
|
these lines lead to the breakdown of the workflow for a more complicated unit cell (Fe trimer system)