Tools

Here the tools provided by aiida_kkr are described.

Common (work)functions that need aiida

Here workfunctions and normal functions using aiida-stuff (typically used within workfunctions) are collected.

aiida_kkr.tools.common_workfunctions.check_2Dinput_consistency(structure, parameters)[source]

Check if structure and parameter data are complete and matching.

Parameters:
  • input – structure, needs to be a valid aiida StructureData node
  • input – parameters, needs to be valid aiida Dict node

returns (False, errormessage) if an inconsistency has been found, otherwise return (True, ‘2D consistency check complete’)

aiida_kkr.tools.common_workfunctions.extract_potname_from_remote(parent_calc_folder)[source]

extract the bname of the output potential from a RemoteData folder

aiida_kkr.tools.common_workfunctions.find_cluster_radius(structure, nclsmin, n_max_box=50, nbins=100)[source]

Takes structure information (cell and site positions) and computes the minimal cluster radius needed such that all clusters around all atoms contain more than nclsmin atoms.

Note:

Here we assume spherical clusters around the atoms!

Parameters:
  • structure – input structure for which the clusters are analyzed
  • nclsmin – minimal number of atoms in the screening cluster
  • n_max_box – maximal number of supercells in 3D volume
  • nbins – number of bins in which the cluster number is analyzed
Returns:

minimal cluster radius needed in Angstroem

Returns:

minimal cluster radius needed in units of the lattice constant

aiida_kkr.tools.common_workfunctions.generate_inputcard_from_structure(parameters, structure, input_filename, parent_calc=None, shapes=None, isvoronoi=False, use_input_alat=False, vca_structure=False)[source]

Takes information from parameter and structure data and writes input file ‘input_filename’

Parameters:
  • parameters – input parameters node containing KKR-related input parameter
  • structure – input structure node containing lattice information
  • input_filename – input filename, typically called ‘inputcard’

optional arguments :param parent_calc: input parent calculation node used to determine if EMIN

parameter is automatically overwritten (from voronoi output) or not
Parameters:
  • shapes – input shapes array (set automatically by aiida_kkr.calculations.Kkrcalculation and shall not be overwritten)
  • isvoronoi – tell whether or not the parameter set is for a voronoi calculation or kkr calculation (have different lists of mandatory keys)
  • use_input_alat – True/False, determines whether the input alat value is taken or the new alat is computed from the Bravais vectors
Note:

assumes valid structure and parameters, i.e. for 2D case all necessary information has to be given. This is checked with function ‘check_2D_input’ called in aiida_kkr.calculations.Kkrcalculation

aiida_kkr.tools.common_workfunctions.get_inputs_common(calculation, code, remote, structure, options, label, description, params, serial, imp_info=None, host_GF=None, imp_pot=None, kkrimp_remote=None, host_GF_Efshift=None, **kwargs)[source]

Base function common in get_inputs_* functions for different codes

aiida_kkr.tools.common_workfunctions.get_inputs_kkr(code, remote, options, label='', description='', parameters=None, serial=False, imp_info=None)[source]

Get the input for a voronoi calc. Wrapper for KkrProcess setting structure, code, options, label, description etc. :param code: a valid KKRcode installation (e.g. input from Code.get_from_string(‘codename@computername’)) :param remote: remote directory of parent calculation (Voronoi or previous KKR calculation)

aiida_kkr.tools.common_workfunctions.get_inputs_kkrimp(code, options, label='', description='', parameters=None, serial=False, imp_info=None, host_GF=None, imp_pot=None, kkrimp_remote=None, host_GF_Efshift=None)[source]

Get the input for a kkrimp calc. Wrapper for KkrimpProcess setting structure, code, options, label, description etc. :param code: a valid KKRimpcode installation (e.g. input from Code.get_from_string(‘codename@computername’)) TBD

aiida_kkr.tools.common_workfunctions.get_inputs_kkrimporter(code, remote, options, label='', description='', parameters=None, serial=False)[source]

Get the input for a voronoi calc. Wrapper for KkrProcess setting structure, code, options, label, description etc.

aiida_kkr.tools.common_workfunctions.get_inputs_voronoi(code, structure, options, label='', description='', params=None, serial=True, parent_KKR=None)[source]

Get the input for a voronoi calc. Wrapper for VoronoiProcess setting structure, code, options, label, description etc.

aiida_kkr.tools.common_workfunctions.get_parent_paranode(remote_data)[source]

Return the input parameter of the parent calculation giving the remote_data node

aiida_kkr.tools.common_workfunctions.kick_out_corestates(potfile, potfile_out, emin)[source]

Read potential file and kick out all core states that lie higher than emin. If no core state lies higher than emin then the output potential will be the same as the input potential :param potfile: input potential :param potfile_out: output potential where some core states are kicked out :param emin: minimal energy above which all core states are kicked out from potential :returns: number of lines that have been deleted

aiida_kkr.tools.common_workfunctions.kick_out_corestates_wf(potential_sfd, emin)[source]

Workfunction that kicks out all core states from single file data potential that are higher than emin. :param potential_sfd: SinglefileData type of potential :param emin: Energy threshold above which all core states are removed from potential (Float) :returns: potential without core states higher than emin (SinglefileData)

aiida_kkr.tools.common_workfunctions.neworder_potential_wf(settings_node, parent_calc_folder, **kwargs)[source]

Workfunction to create database structure for aiida_kkr.tools.modify_potential.neworder_potential function A temporary file is written in a Sandbox folder on the computer specified via the input computer node before the output potential is stored as SinglefileData in the Database.

Parameters:
  • settings_node – settings for the neworder_potential function (Dict)
  • parent_calc_folder – parent calculation remote folder node where the input potential is retreived from (RemoteData)
  • parent_calc_folder2optional, parent calculation remote folder node where the second input potential is retreived from in case ‘pot2’ and ‘replace_newpos’ are also set in settings_node (RemoteData)
  • debugoptional, contol wether or not debug information is written out (aiida.orm.Bool)
Returns:

output_potential node (SinglefileData)

Note

The settings_node dictionary needs to be of the following form:

settings_dict = {'neworder': [list of intended order in output potential]}

Optional entries are:

'out_pot': '<filename_output_potential>'  name of the output potential file, defaults to 'potential_neworder' if not specified   
'pot1': '<filename_input_potential>'      if not given we will try to find it from the type of the parent remote folder
'pot2': '<filename_second_input_file>'
'replace_newpos': [[position in neworder list which is replace with potential from pot2, position in pot2 that is chosen for replacement]]
'switch_spins': [indices of atom for which spins are exchanged] (indices refer to position in neworder input list)
'label': 'label_for_output_node'
'description': 'longer_description_for_output_node'
aiida_kkr.tools.common_workfunctions.structure_from_params(parameters)[source]

Construct aiida structure out of kkr parameter set (if ALATBASIS, RBASIS, ZATOM etc. are given)

Parameters:input – parameters, kkrparams object with structure information set (e.g. extracted from read_inputcard function)
Returns:success, boolean to determine if structure creatoin was successful
Returns:structure, an aiida StructureData object
aiida_kkr.tools.common_workfunctions.test_and_get_codenode(codenode, expected_code_type, use_exceptions=False)[source]

Pass a code node and an expected code (plugin) type. Check that the code exists, is unique, and return the Code object.

Parameters:
  • codenode – the name of the code to load (in the form label@machine)
  • expected_code_type – a string with the plugin that is expected to be loaded. In case no plugins exist with the given name, show all existing plugins of that type
  • use_exceptions – if True, raise a ValueError exception instead of calling sys.exit(1)
Returns:

a Code object

Example usage:

from kkr_scf workflow:

if ‘voronoi’ in inputs:
try:

test_and_get_codenode(inputs.voronoi, ‘kkr.voro’, use_exceptions=True)

except ValueError:
error = (“The code you provided for voronoi does not “

“use the plugin kkr.voro”)

self.control_end_wc(error)

aiida_kkr.tools.common_workfunctions.update_params(node, nodename=None, nodedesc=None, **kwargs)[source]

Update parameter node given with the values given as kwargs. Returns new node.

Parameters:
  • node – Input parameter node (needs to be valid KKR input parameter node).
  • **kwargs

    Input keys with values as in kkrparams.

  • linkname – Input linkname string. Give link from old to new node a name . If no linkname is given linkname defaults to ‘updated parameters’
Returns:

parameter node

Example usage:

OutputNode = KkrCalculation.update_params(InputNode, EMIN=-1, NSTEPS=30)

Note:

Keys are set as in kkrparams class. Check documentation of kkrparams for further information.

Note:

If kwargs contain the key add_direct, then no kkrparams instance is used and no checks are performed but the dictionary is filled directly!

Note:

By default nodename is ‘updated KKR parameters’ and description contains list of changed

aiida_kkr.tools.common_workfunctions.update_params_wf(parameternode, updatenode, **link_inputs)[source]

Work function to update a KKR input parameter node. Stores new node in database and creates a link from old parameter node to new node Returns updated parameter node using update_params function

Note:

Input nodes need to be valid aiida Dict objects.

Parameters:
  • parameternode – Input aiida Dict node cotaining KKR specific parameters
  • updatenode – Input aiida Dict node containing a dictionary with the parameters that are supposed to be changed.
Note:

If ‘nodename’ is contained in dict of updatenode the string corresponding to this key will be used as nodename for the new node. Otherwise a default name is used

Note:

Similar for ‘nodedesc’ which gives new node a description

Example:

updated_params = Dict(dict={‘nodename’: ‘my_changed_name’, ‘nodedesc’: ‘My description text’, ‘EMIN’: -1, ‘RMAX’: 10.}) new_params_node = update_params_wf(input_node, updated_params)

aiida_kkr.tools.common_workfunctions.vca_check(structure, parameters)[source]

KKRimp tools

Tools for the impurity caluclation plugin and its workflows

aiida_kkr.tools.tools_kkrimp.create_scoef_array(structure, radius, h=-1, vector=[0.0, 0.0, 1.0], i=0, alat_input=None)[source]

Creates the arrays that should be written into the ‘scoef’ file for a certain structure. Needed to conduct an impurity KKR calculation.

Parameters:
  • structure – input structure of the StructureData type.
  • radius – input cutoff radius in Ang. units.
  • h – height of the cutoff cylinder (negative for spherical cluster shape). For negative values, clust_shape will be automatically assumed as ‘spherical’. If there will be given a h > 0, the clust_shape will be ‘cylindrical’.
  • vector – orientation vector of the cylinder (just for clust_shape=’cylindrical’).
  • i – atom index around which the cluster should be centered. Default: 0 (first atom in the structure).
  • alat_input – input lattice constant in Ang. If None use the lattice constant that is automatically found. Otherwise rescale everything.
aiida_kkr.tools.tools_kkrimp.find_neighbors(structure, structure_array, i, radius, clust_shape='spherical', h=0.0, vector=[0.0, 0.0, 1.0])[source]

Applies periodic boundary conditions and obtains the distances between the selected atom i in the cell and all other atoms that lie within a cutoff radius r_cut. Afterwards an numpy array with all those atoms including atom i (x_res) will be returned.

Parameters:
  • structure – input parameter of the StructureData type containing the three bravais lattice cell vectors
  • structure_array – input numpy structure array containing all the structure related data
  • i – centered atom at which the origin lies (same one as in select_reference)
  • radius – Specifies the radius of the cylinder or of the sphere, depending on clust_shape. Input in units of the lattice constant.
  • clust_shape – specifies the shape of the cluster that is used to determine the neighbors for the ‘scoef’ file. Default value is ‘spherical’. Other possible forms are ‘cylindrical’ (‘h’ and ‘orient’ needed), … .
  • h – needed for a cylindrical cluster shape. Specifies the height of the cylinder. Default=0. Input in units of the lattice constant.
  • vector – needed for a cylindrical cluster shape. Specifies the orientation vector of the cylinder. Default: z-direction.
Returns:

array with all the atoms within the cutoff (x_res)

ToDo:
  • dynamical box construction (r_cut determines which values n1, n2, n3 have)
  • different cluster forms (spherical, cylinder, …), add default parameters, better solution for ‘orient’
aiida_kkr.tools.tools_kkrimp.get_distance(structure_array, i, j)[source]

Calculates and returns the distances between to atoms i and j in the given structure_array

Parameters:structure_array – input numpy array of the cell containing all the atoms ((# of atoms) x 6-matrix)
Params i, j:indices of the atoms for which the distance should be calculated (indices again start at 0)
Returns:distance between atoms i and j in units of alat
Note:
aiida_kkr.tools.tools_kkrimp.get_structure_data(structure)[source]

Function to take data from AiiDA’s StructureData type and store it into a single numpy array of the following form: a = [[x-Position 1st atom, y-Position 1st atom, z-Position 1st atom, index 1st atom, charge 1st atom, 0.],

[x-Position 2nd atom, y-Position 2nd atom, z-Position 2nd atom, index 2nd atom, charge 1st atom, 0.], […, …, …, …, …, …], … ]
Parameters:structure – input structure of the type StructureData
Returns:numpy array a[# of atoms in the unit cell][5] containing the structure related data (positions in units of the unit cell length)
Note:
aiida_kkr.tools.tools_kkrimp.make_scoef(structure, radius, path, h=-1.0, vector=[0.0, 0.0, 1.0], i=0, alat_input=None)[source]

Creates the ‘scoef’ file for a certain structure. Needed to conduct an impurity KKR calculation.

Parameters:
  • structure – input structure of the StructureData type.
  • radius – input cutoff radius in Ang. units.
  • h – height of the cutoff cylinder (negative for spherical cluster shape). For negative values, clust_shape will be automatically assumed as ‘spherical’. If there will be given a h > 0, the clust_shape will be ‘cylindrical’.
  • vector – orientation vector of the cylinder (just for clust_shape=’cylindrical’).
  • i – atom index around which the cluster should be centered. Default: 0 (first atom in the structure).
  • alat_input – input lattice constant in Ang. If None use the lattice constant that is automatically found. Otherwise rescale everything.
class aiida_kkr.tools.tools_kkrimp.modify_potential[source]

Class for old modify potential script, ported from modify_potential script, initially by D. Bauer

__weakref__

list of weak references to the object (if defined)

neworder_potential(potfile_in, potfile_out, neworder, potfile_2=None, replace_from_pot2=None, debug=False)[source]

Read potential file and new potential using a list describing the order of the new potential. If a second potential is given as input together with an index list, then the corresponding of the output potential are overwritten with positions from the second input potential.

Parameters:
  • potfile_in (str) – absolute path to input potential
  • potfile_out (str) – absolute path to output potential
  • neworder (list) – list after which output potential is constructed from input potential
  • potfile_2 (str) – optional, absolute path to second potential file if positions in new list of potentials shall be replaced by positions of second potential, requires replace_from_pot to be given as well
  • replace_from_pot (list) – optional, list containing tuples of (position in newlist that is to be replaced, position in pot2 with which position is replaced)
Usage:
  1. modify_potential().neworder_potential(<path_to_input_pot>, <path_to_output_pot>, [])
shapefun_from_scoef(scoefpath, shapefun_path, atom2shapes, shapefun_new)[source]

Read shapefun and create impurity shapefun using scoef info and shapes array

Parameters:
  • scoefpath – absolute path to scoef file
  • shapefun_path – absolute path to input shapefun file
  • shapes – shapes array for mapping between atom index and shapefunction index
  • shapefun_new – absolute path to output shapefun file to which the new shapefunction will be written
aiida_kkr.tools.tools_kkrimp.rotate_onto_z(structure, structure_array, vector)[source]

Rotates all positions of a structure array of orientation ‘orient’ onto the z-axis. Needed to implement the cylindrical cutoff shape.

Parameters:
  • structure – input structure of the type StructureData
  • structure_array – input structure array, obtained by select_reference for the referenced system.
  • vector – reference vector that has to be mapped onto the z-axis.
Returns:

rotated system, now the ‘orient’-axis is aligned with the z-axis

aiida_kkr.tools.tools_kkrimp.select_reference(structure_array, i)[source]

Function that references all of the atoms in the cell to one particular atom i in the cell and calculates the distance from the different atoms to atom i. New numpy array will have the form: x = [[x-Position 1st atom, y-Position 1st atom, z-Position 1st atom, index 1st atom, charge 1st atom,

distance 1st atom to atom i],
[x-Position 2nd atom, y-Position 2nd atom, z-Position 2nd atom, index 2nd atom, charge 1st atom,
distance 1st atom to atom i],

[…, …, …, …, …, …], … ]

Parameters:
  • structure_array – input array of the cell containing all the atoms (obtained from get_structure_data)
  • i – index of the atom which should be the new reference
Returns:

new structure array with the origin at the selected atom i (for KKRimp: impurity atom)

Note:

the first atom in the structure_array is labelled with 0, the second with 1, …

aiida_kkr.tools.tools_kkrimp.write_scoef(x_res, path)[source]

Sorts the data from find_neighbors with respect to the distance to the selected atom and writes the data correctly formatted into the file ‘scoef’. Additionally the total number of atoms in the list is written out in the first line of the file.

Parameters:x_res – array of atoms within the cutoff radius obtained by find_neighbors (unsorted)
Output:returns scoef file with the total number of atoms in the first line, then with the formatted positions, indices, charges and distances in the subsequent lines.
aiida_kkr.tools.tools_kkrimp.write_scoef_full_imp_cls(imp_info_node, path, rescale_alat=None)[source]

write scoef file from imp_cls info in imp_info_node

Plotting tools

contains plot_kkr class for node visualization

aiida_kkr.tools.plot_kkr._check_tk_gui(static)[source]

check if tk gui can be openen, otherwise reset static to False this is only needed if we are not inside a notebook

aiida_kkr.tools.plot_kkr._has_ase_notebook()[source]

Helper function to check if ase_notebook is installed

aiida_kkr.tools.plot_kkr._in_notebook()[source]

Helper function to check if code is executed from within a jupyter notebook this is used to change to a different default visualization

aiida_kkr.tools.plot_kkr.plot_imp_cluster(kkrimp_calc_node, **kwargs)[source]

Plot impurity cluster from KkrimpCalculation node

These kwargs can be used to control the behavior of the plotting tool:

kwargs = {
static = False, # make gui or static (svg) images canvas_size = (300, 300), # size of the canvas zoom = 1.0, # zoom, set to >1 (<1) to zoom in (out) atom_opacity = 0.95, # set opacity level of the atoms, useful for overlapping atoms rotations = “-80x,-20y,-5z”, # rotation in degrees around x,y,z axes show_unit_cell = True, # show the unit cell of the host filename = ‘plot_kkr_out_impstruc.svg’ # filename used for the export of a static svg image

}

class aiida_kkr.tools.plot_kkr.plot_kkr(nodes=None, **kwargs)[source]

Class grouping all functionality to plot typical nodes (calculations, workflows, …) of the aiida-kkr plugin.

Parameters:nodes – node identifier which is to be visualized

optional arguments:

Parameters:
  • silent (bool) – print information about input node including inputs and outputs (default: False)
  • strucplot (bool) – plot structure using ase’s view function (default: False)
  • interpol (bool) – use interpolated data for DOS plots (default: True)
  • all_atoms (bool) – plot all atoms in DOS plots (default: False, i.e. plot total DOS only)
  • l_channels (bool) – plot l-channels in addition to total DOS (default: True, i.e. plot all l-channels)
  • sum_spins (bool) – sum up both spin channels or plot both? (default: False, i.e. plot both spin channels)
  • logscale – plot rms and charge neutrality curves on a log-scale (default: True)
  • switch_xy (bool) – (default: False)
  • iatom (list) – list of atom indices which are supposed to be plotted (default: [], i.e. show all atoms)

additional keyword arguments are passed onto the plotting function which allows, for example, to change the markers used in a DOS plot to crosses via marker=’x’

Usage:plot_kkr(nodes, **kwargs)

where nodes is a node identifier (the node itself, it’s pk or uuid) or a list of node identifiers.

Note:If nodes is a list of nodes then the plots are grouped together if possible.
__init__(nodes=None, **kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

__weakref__

list of weak references to the object (if defined)

classify_and_plot_node(node, return_name_only=False, **kwargs)[source]

Find class of the node and call plotting function.

dosplot(d, natoms, nofig, all_atoms, l_channels, sum_spins, switch_xy, switch_sign_spin2, **kwargs)[source]

plot dos from xydata node

get_node(node)[source]

Get node from pk or uuid

get_rms_kkrcalc(node, title=None)[source]

extract rms etc from kkr Calculation. Works for both finished and still running Calculations.

group_nodes(nodes)[source]

Go through list of nodes and group them together.

make_kkrimp_rmsplot(rms_all, stot_all, pks_all, rms_goal, ptitle, **kwargs)[source]

plot rms and total spin moment of kkrimp calculation or series of kkrimp calculations

plot_group(groupname, nodesgroups, **kwargs)[source]

Visualize all nodes of one group.

plot_kkr_calc(node, **kwargs)[source]

plot things for a kkr Calculation node

plot_kkr_dos(node, **kwargs)[source]

plot outputs of a kkr_dos_wc workflow

plot_kkr_eos(node, **kwargs)[source]

plot outputs of a kkr_eos workflow

plot_kkr_scf(node, **kwargs)[source]

plot outputs of a kkr_scf_wc workflow

plot_kkr_single_node(node, **kwargs)[source]

TODO docstring

plot_kkr_startpot(node, **kwargs)[source]

plot output of kkr_startpot_wc workflow

plot_kkrimp_calc(node, return_rms=False, return_stot=False, plot_rms=True, **kwargs)[source]

plot things from a kkrimp Calculation node

plot_kkrimp_dos_wc(node, **kwargs)[source]

plot things from a kkrimp_dos workflow node

plot_kkrimp_sub_wc(node, **kwargs)[source]

plot things from a kkrimp_sub_wc workflow

plot_kkrimp_wc(node, **kwargs)[source]

plot things from a kkrimp_wc workflow

plot_struc(node, **kwargs)[source]

visualize structure using ase’s view function

plot_voro_calc(node, **kwargs)[source]

plot things for a voro Calculation node

print_clean_inouts(node)[source]

print inputs and outputs of nodes without showing ‘CALL’ and ‘CREATE’ links in workflows.

rmsplot(rms, neutr, nofig, ptitle, logscale, only=None, rename_second=None, **kwargs)[source]

plot rms and charge neutrality

aiida_kkr.tools.plot_kkr.save_fig_to_file(kwargs, filename0='plot_kkr_out.png')[source]

save the figure as a png file look for filename and static in kwargs save only if static is True after _check_tk_gui check to make it work in the command line script

aiida_kkr.tools.plot_kkr.strucplot_ase_notebook(struc, **kwargs)[source]

plotting function for aiida structure using ase_notebook visulaization