Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/JuDFTteam/aiida-kkr into…
Browse files Browse the repository at this point in the history
… develop
  • Loading branch information
Raff-physics committed May 23, 2024
2 parents 906017e + deeb2f8 commit 0f99474
Show file tree
Hide file tree
Showing 5 changed files with 148 additions and 5 deletions.
11 changes: 11 additions & 0 deletions aiida_kkr/tools/tools_STM_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,17 @@ def STM_pathfinder(host_structure):
"""This function is used to help visualize the scanned positions
and the symmetries that are present in the system """
"""
<<<<<<< HEAD
inputs::
host_struture : RemoteData : The Remote data contains all the information needed to create the path to scan
outputs::
=======
inputs:
host_struture : RemoteData : The Remote data contains all the information needed to create the path to scan
outputs:
>>>>>>> deeb2f88313d293946f7657d00f7dcac0bc22d12
struc_info : Dict : Dictionary containing the structural information of the film
matrices : Array : Array containing the matrices that generate the symmetries of the system
Expand Down Expand Up @@ -341,10 +348,14 @@ def lattice_generation(x_len, y_len, rot, vec):

for i in range(-x_len, x_len + 1):
for j in range(-y_len, y_len + 1):
<<<<<<< HEAD
if (
(lattice_points[i][j][0] > 0 or math.isclose(lattice_points[i][j][0],0, abs_tol=1e-3)) and
(lattice_points[i][j][1] > 0 or math.isclose(lattice_points[i][j][1],0, abs_tol=1e-3))
):
=======
if lattice_points[i][j][0] >= 0 and lattice_points[i][j][1] >= 0:
>>>>>>> deeb2f88313d293946f7657d00f7dcac0bc22d12
for element in rot[1:]:
point = np.dot(element, lattice_points[i][j])
if point[0] >= 0 and point[1] >= 0:
Expand Down
2 changes: 1 addition & 1 deletion aiida_kkr/workflows/_combine_imps.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ def create_big_cluster(self): # pylint: disable=inconsistent-return-statements
):
if (offset, ilayer) == (imp_offset_index, imp2_ilayer):
self.report(
f"ERROR: The new impurity is overlaping with the existing impurities. Change the 'ilayer_certer': {ilayer} or 'offset_index'{offset}."
f"ERROR: The new impurity is overlaping with the existing impurities. Change the 'ilayer_center': {ilayer} or 'offset_index'{offset}."
)
return self.exit_codes.ERROR_SOMETHING_WENT_WRONG # pylint: disable=no-member

Expand Down
130 changes: 130 additions & 0 deletions aiida_kkr/workflows/kkr_STM.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@ class kkr_STM_wc(WorkChain):
:param wf_parameters: (Dict), parameters that are used to run the workflow
:param kkr: (Code), KKR host code for the writing out kkrflex files
:param kkrimp: (Code), KKR impurity code for the normal state impurity scf and BdG impurity DOS calculation
<<<<<<< HEAD
:param gf_writeout.params_kkr_overwrite (Dict), overwrite parameters for the GF calculation
:param kkr_imp_sub.params_kkr_overwrite (Dict), overwrite parameters for the impurity calculation
=======
>>>>>>> deeb2f88313d293946f7657d00f7dcac0bc22d12
returns::
Expand Down Expand Up @@ -81,21 +84,35 @@ def define(cls, spec):
super(kkr_STM_wc, cls).define(spec)

spec.input('kkr', valid_type=Code, required=False, help='KKRhost code, needed if gf_dos_remote is not given.')
<<<<<<< HEAD
spec.input('kkrimp', valid_type=Code, required=True, help='KKRimp code, always needed.')
=======

spec.input('kkrimp', valid_type=Code, required=True, help='KKRimp code, always needed.')

>>>>>>> deeb2f88313d293946f7657d00f7dcac0bc22d12
spec.input(
'options',
valid_type=Dict,
required=False,
default=lambda: Dict(dict=cls._options_default),
help='Computer options (resources, quene name, etc.).'
)
<<<<<<< HEAD
=======

>>>>>>> deeb2f88313d293946f7657d00f7dcac0bc22d12
spec.input(
'wf_parameters',
valid_type=Dict,
required=False,
default=lambda: Dict(dict=cls._wf_default),
help='Workflow parameter (see `kkr_dos_wc.get_wf_defaults()`).'
)
<<<<<<< HEAD
=======

>>>>>>> deeb2f88313d293946f7657d00f7dcac0bc22d12
spec.input(
'tip_position',
valid_type=Dict,
Expand All @@ -110,40 +127,66 @@ def define(cls, spec):
# nx is the number of (symmetric) steps that we take in the x-direction starting from the impurity
# ny is the number of (symmetric) steps that we take in the y-direction starting from the impurity
# (0,0) correspond to calculate the DOS only on the impurity site
<<<<<<< HEAD
help=
'How many sites will be scanned in the da and db direction (Bravais Lattice). And the layer that is being scanned.'
)
=======
help='How many sites will be scanned in the x and y direction. And the layer that is being scanned.'
)

>>>>>>> deeb2f88313d293946f7657d00f7dcac0bc22d12
spec.input(
'imp_info',
valid_type=Dict,
required=True,
help='Information of the impurity like position in the unit cell, screening cluster, atom type.'
)
<<<<<<< HEAD
=======

>>>>>>> deeb2f88313d293946f7657d00f7dcac0bc22d12
spec.input(
'host_calc',
valid_type=RemoteData,
required=False,
help='The information about the clean host structure is required in order to continue the cluster'
'Inside a bigger host structure with empty sites.'
)
<<<<<<< HEAD
=======

>>>>>>> deeb2f88313d293946f7657d00f7dcac0bc22d12
spec.input(
'host_remote',
valid_type=RemoteData,
required=True,
help='Remote Data containing the remote folder from the outputs of the host calculation',
)
<<<<<<< HEAD
=======

>>>>>>> deeb2f88313d293946f7657d00f7dcac0bc22d12
spec.input(
'imp_potential_node',
valid_type=SinglefileData,
required=True,
help='Impurity potential node',
)
<<<<<<< HEAD
=======

>>>>>>> deeb2f88313d293946f7657d00f7dcac0bc22d12
spec.input(
'remote_data',
valid_type=RemoteData,
required=False,
help='Remote data from a converged kkr calculation, required for the gf writeout step',
)
<<<<<<< HEAD
=======

>>>>>>> deeb2f88313d293946f7657d00f7dcac0bc22d12
spec.input(
'kkrflex_files',
valid_type=RemoteData,
Expand All @@ -155,6 +198,7 @@ def define(cls, spec):
# One parameter which is crucial is the NSHELD, which determines the impurity cluster radius.
spec.expose_inputs(kkr_flex_wc, namespace='gf_writeout', include=('params_kkr_overwrite'))

<<<<<<< HEAD
# Here we expose the BdG calculations from the kkr_imp_dos_wc
spec.expose_inputs(kkr_imp_sub_wc, namespace='BdG', include=('params_overwrite'))
spec.expose_inputs(kkr_imp_sub_wc, include=('initial_noco_angles', 'rimpshift'))
Expand All @@ -166,6 +210,21 @@ def define(cls, spec):
#spec.output('workflow_info', valid_type=Dict)
spec.output('kkrflexfiles', valid_type=RemoteData)
spec.output('combined_imp_info', valid_type=Dict)
=======
# Specify the possible outputs
spec.output('tip_position', valid_type=Dict)

spec.output('STM_dos_data', valid_type=XyData, required=True)

spec.output('STM_dos_data_lmdos', valid_type=XyData, required=True)

#spec.output('workflow_info', valid_type=Dict)

spec.output('kkrflexfiles', valid_type=RemoteData)

spec.output('combined_imp_info', valid_type=Dict)

>>>>>>> deeb2f88313d293946f7657d00f7dcac0bc22d12
spec.output('combined_imp_potential', valid_type=SinglefileData)

# Define all possible error messages
Expand Down Expand Up @@ -193,17 +252,32 @@ def define(cls, spec):
cls.results
)

<<<<<<< HEAD
def combine_potentials(self, host_structure, impurity_to_combine, da, db):
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
"""
=======
def combine_potentials(self, impurity_to_combine, da, db):
from aiida_kkr.tools.tools_STM_scan import get_imp_info_add_position_cf
"""
Here we want to combine the impurity information and the host information
"""

imp_info = self.inputs.imp_info #(impurity to combine)
host_remote = self.inputs.host_remote

# Since the objects in AiiDA are immutable we have to create a new dictionary and then convert
# it to the right AiiDA type
>>>>>>> deeb2f88313d293946f7657d00f7dcac0bc22d12
tip_position = {}

tip_position['ilayer'] = self.inputs.tip_position['ilayer']
tip_position['da'] = da
tip_position['db'] = db
<<<<<<< HEAD
#print(impurity_to_combine.get_dict())
imp_info = self.inputs.imp_info #(impurity to combine)
#host_remote = self.inputs.host_remote
Expand All @@ -217,13 +291,24 @@ def combine_potentials(self, host_structure, impurity_to_combine, da, db):
if 'imp_cls' in impurity_to_combine:

for key in impurity_to_combine.keys():
=======

combined_imp_info = get_imp_info_add_position_cf(tip_position, host_remote, imp_info)
# Add check to see if imp_cls is there
if 'imp_cls' in impurity_to_combine:

new_combined_imp_info = {}

for key, value in impurity_to_combine.items():
>>>>>>> deeb2f88313d293946f7657d00f7dcac0bc22d12
if key == 'Zimp':
#print(impurity_to_combine[key])
impurity_to_combine[key].append(combined_imp_info[key][-1])
#if key == 'Rimp_rel':
# np.append(impurity_to_combine[key], [combined_imp_info[key][-1]], axis=0)
# print(impurity_to_combine[key])
else:
<<<<<<< HEAD
#print(combined_imp_info[key][-1])
impurity_to_combine[key] = np.append(impurity_to_combine[key], [combined_imp_info[key][-1]], axis=0)
#print(impurity_to_combine[key])
Expand All @@ -242,31 +327,58 @@ def combine_potentials(self, host_structure, impurity_to_combine, da, db):

# Convert to an AiiDA Dictionary
new_combined_imp_info = impurity_to_combine
=======
# Here we have lists of list that we need to confront
new_combined_imp_info[key] = impurity_to_combine[key]
set_tmp = [set(row) for row in impurity_to_combine[key]]

new_combined_imp_info[key] += [row for row in combined_imp_info[key] if set(row) not in set_tmp]

new_combined_imp_info = orm.Dict(dict=new_combined_imp_info)
>>>>>>> deeb2f88313d293946f7657d00f7dcac0bc22d12

else:

new_combined_imp_info = combined_imp_info

return new_combined_imp_info

<<<<<<< HEAD
def combine_nodes(self, host_calc, node_to_combine, da, db):
from aiida_kkr.tools.tools_STM_scan import create_combined_potential_node
=======
def combine_nodes(self, node_to_combine, da, db):
from aiida_kkr.tools.tools_STM_scan import create_combined_potential_node_cf
>>>>>>> deeb2f88313d293946f7657d00f7dcac0bc22d12
"""
Here we create a combined potential node from the host potential (no impurity)
and from the impurity potential
"""
#imp_potential_node = self.inputs.imp_potential_node # (node_to_combine).
<<<<<<< HEAD
#host_remote = self.inputs.host_remote # the remote host structure remains the same.
=======
host_remote = self.inputs.host_remote # the remote host structure remains the same.
>>>>>>> deeb2f88313d293946f7657d00f7dcac0bc22d12

# 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 = {}
<<<<<<< HEAD
tip_position['ilayer'] = self.inputs.tip_position['ilayer'] # for now we require that the z position remains the same.
tip_position['da'] = da
tip_position['db'] = db

combined_node = create_combined_potential_node(tip_position, host_calc, node_to_combine)
=======
tip_position['ilayer'] = self.inputs.tip_position['ilayer'
] # for now we require that the z position remains the same.
tip_position['da'] = da
tip_position['db'] = db

combined_node = create_combined_potential_node_cf(tip_position, host_remote, node_to_combine)
>>>>>>> deeb2f88313d293946f7657d00f7dcac0bc22d12
return combined_node

def start(self):
Expand Down Expand Up @@ -372,7 +484,10 @@ def validate_input(self):

def impurity_cluster_evaluation(self):
from aiida_kkr.tools import tools_STM_scan
<<<<<<< HEAD
from aiida_kkr.tools import find_parent_structure
=======
>>>>>>> deeb2f88313d293946f7657d00f7dcac0bc22d12

# Here we create an impurity cluster that has inside all the positions on which the STM will scan

Expand All @@ -384,10 +499,13 @@ def impurity_cluster_evaluation(self):
impurity_info = self.inputs.imp_info # for the first step we combine the impurity info from the input
imp_potential_node = self.inputs.imp_potential_node # for the first step we combine the impurity node from the input

<<<<<<< HEAD
host_remote = self.inputs.host_remote
host_calc = host_remote.get_incoming(node_class=CalcJobNode).first().node
host_structure = find_parent_structure(host_remote)

=======
>>>>>>> deeb2f88313d293946f7657d00f7dcac0bc22d12
# Information of the host structure
struc_info, symm_matrices = tools_STM_scan.STM_pathfinder(host_remote)

Expand All @@ -400,7 +518,11 @@ def impurity_cluster_evaluation(self):
coeff = tools_STM_scan.find_linear_combination_coefficients(struc_info['plane_vectors'], used_pos)

for element in coeff:
<<<<<<< HEAD
tmp_imp_info = self.combine_potentials(host_structure, impurity_info, element[0], element[1])
=======
tmp_imp_info = self.combine_potentials(impurity_info, element[0], element[1])
>>>>>>> deeb2f88313d293946f7657d00f7dcac0bc22d12
impurity_info = tmp_imp_info

# Aggregation the impurity nodes
Expand Down Expand Up @@ -435,11 +557,14 @@ def STM_lmdos_run(self):
else:
# This is a big value of NSHELD to make sure that most calculations work
builder.gf_writeout.params_kkr_overwrite = Dict(dict={'NSHELD': 1500})
<<<<<<< HEAD

# Update the BdG parameters if they are inserted in the workflow
if 'BdG' in self.inputs:
if 'params_kkr_overwrite' in self.inputs.BdG:
builder.BdG.params_overwrite = self.inputs.BdG.params_kkr_overwrite
=======
>>>>>>> deeb2f88313d293946f7657d00f7dcac0bc22d12

self.ctx.kkrimp_params_dict = Dict(
dict={
Expand All @@ -460,7 +585,12 @@ def STM_lmdos_run(self):
# Finally we overwrite the number of energy points to 1
# This is because we want many epoints around the impurity position

<<<<<<< HEAD
self.ctx.kkrimp_params_dict['dos_params']['nepts'] = 7 # Here 7 because of the interpolated files that aren't generated
=======
self.ctx.kkrimp_params_dict['dos_params'][
'nepts'] = 7 # Here 7 because of the interpolated files that aren't generated
>>>>>>> deeb2f88313d293946f7657d00f7dcac0bc22d12

#builder.metadata.label = label_imp # pylint: disable=no-member
#builder.metadata.description = description_imp # pylint: disable=no-member
Expand Down
8 changes: 5 additions & 3 deletions aiida_kkr/workflows/kkr_imp_dos.py
Original file line number Diff line number Diff line change
Expand Up @@ -786,12 +786,14 @@ def parse_impdosfiles(folder, natom, nspin, ef, use_lmdos):
dosnode.set_x(dos[:, :, 0], 'E-EF', 'eV')

name = ['tot', 's', 'p', 'd', 'f', 'g']
name = name[:len(dos[0, 0, 1:]) - 1] + ['ns']

if use_lmdos.value:
name = [
'tot', 's', 'p1', 'p2', 'p3', 'd1', 'd2', 'd3', 'd4', 'd5', 'f1', 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'g1',
'g2', 'g3', 'g4', 'g5', 'g6', 'g7', 'g8', 'g9'
's', 'p1', 'p2', 'p3', 'd1', 'd2', 'd3', 'd4', 'd5', 'f1', 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'g1', 'g2',
'g3', 'g4', 'g5', 'g6', 'g7', 'g8', 'g9'
]
name = name[:len(dos[0, 0, 1:]) - 1] + ['ns']
name = name[:len(dos[0, 0, 1:])]

ylists = [[], [], []]
for l in range(len(name)):
Expand Down
2 changes: 1 addition & 1 deletion aiida_kkr/workflows/voro_start.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ def run_voronoi(self):
kkr_para.set_value('EMIN', emin_new)
self.report(f'INFO: setting EMIN to {emin_new} (DOS check showed that EMIN is too high)')
if 'ef_set' in update_list:
kkr_para.set_value('EFSET', self.ctx.ef_set)
kkr_para.set_value('EF_SET', self.ctx.ef_set)
self.report(f'INFO: setting Fermi level of stating potential to {self.ctx.ef_set}')

updatenode = orm.Dict(dict=kkr_para.get_dict())
Expand Down

0 comments on commit 0f99474

Please sign in to comment.