Tools

Common functions that do not need aiida

Here commonly used functions that do not need aiida-stuff (i.e. can be tested without a database) are collected.

aiida_kkr.tools.common_functions.angles_to_vec(magnitude, theta, phi)[source]

convert (magnitude, theta, phi) to (x,y,z)

theta/phi need to be in radians!

Input can be single number, list of numpy.ndarray data Returns x,y,z vector

aiida_kkr.tools.common_functions.get_corestates_from_potential(potfile='potential')[source]

Read core states from potential file

aiida_kkr.tools.common_functions.get_ef_from_potfile(potfile)[source]

extract fermi energy from potfile

aiida_kkr.tools.common_functions.get_highest_core_state(nstates, energies, lmoments)[source]

Find highest lying core state from list of core states, needed to find and check energy contour

aiida_kkr.tools.common_functions.interpolate_dos(dospath, return_original=False)[source]

interpolation function copied from complexdos3 fortran code

Principle of DOS here: Two-point contour integration for DOS in the middle of the two points. The input DOS and energy must be complex. Parameter deltae should be of the order of magnitude of eim:

      <-2*deltae->   _
           /\        |     DOS=(n(1)+n(2))/2 + (n(1)-n(2))*eim/deltae
          /  \       |
        (1)  (2)   2*i*eim=2*i*pi*Kb*Tk
        /      \     |
       /        \    |
------------------------ (Real E axis)
Parameters:input – dospath, path where ‘complex.dos’ file can be found
Returns:E_Fermi, numpy array of interpolated dos
Note:output units are in Ry!
aiida_kkr.tools.common_functions.vec_to_angles(vec)[source]

converts vector (x,y,z) to (magnitude, theta, phi)

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 ParameterData node

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

aiida_kkr.tools.common_workfunctions.generate_inputcard_from_structure(parameters, structure, input_filename, parent_calc=None, shapes=None, isvoronoi=False, use_input_alat=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.Kkrcaluation 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.Kkrcaluation

aiida_kkr.tools.common_workfunctions.get_inputs_common(process, code, remote, structure, options, label, description, params, serial)[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)[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_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)[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 calulation giving the remote_data 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:

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

aiida_kkr.tools.common_workfunctions.update_params_wf(*args, **kwargs)[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 ParameterData objects.

Parameters:
  • parameternode – Input aiida ParameterData node cotaining KKR specific parameters
  • updatenode – Input aiida ParameterData 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 = ParameterData(dict={‘nodename’: ‘my_changed_name’, ‘nodedesc’: ‘My description text’, ‘EMIN’: -1, ‘RMAX’: 10.}) new_params_node = update_params_wf(input_node, updated_params)

KKR parameters class

In this module you find the kkrparams class that helps defining the KKR input parameters Also some defaults for the parameters are defined

class aiida_kkr.tools.kkr_params.kkrparams(**kwargs)[source]

Class for creating and handling the parameter input for a KKR calculation Optional keyword arguments are passed to init and stored in values dictionary.

Example usage: params = kkrparams(LMAX=3, BRAVAIS=array([[1,0,0], [0,1,0], [0,0,1]]))

Alternatively values can be set afterwards either individually with
params.set_value(‘LMAX’, 3)
or multiple keys at once with
params.set_multiple_values(EMIN=-0.5, EMAX=1)

Other useful functions: - print the description of a keyword: params.get_description([key]) where [key] is a string for a keyword in params.values - print a list of mandatory keywords: params.get_all_mandatory() - print a list of keywords that are set including their value: params.get_set_values()

Note: KKR-units (e.g. atomic units with energy in Ry, length in a_Bohr) are assumed
except for the keys’<RBLEFT>’, ‘<RBRIGHT>’, ‘ZPERIODL’, and ‘ZPERIODR’ which should be given in Ang. units!
__init__(**kwargs)[source]

Initialize class instance with containing the attribute values that also have a format, mandatory flags (defaults for KKRcode, changed for example via params_type=’voronoi’ keyword) and a description.

__weakref__

list of weak references to the object (if defined)

_check_array_consistency()[source]

Check all keys in __listargs if they match their specification (mostly 1D array, except for special cases e.g. <RBASIS>)

_check_input_consistency(set_lists_only=False)[source]

Check consistency of input, to be done before wrinting to inputcard

_check_mandatory()[source]

Check if all mandatory keywords are set

_check_valuetype(key)[source]

Consistency check if type of value matches expected type from format info

_create_keyword_default_values(**kwargs)[source]

Creates KKR inputcard keywords dictionary and fills entry if value is given in **kwargs

entries of keyword dictionary are: ‘keyword’, [value, format, keyword_mandatory, description]

where

  • ‘value’ can be a single entry or a list of entries
  • ‘format’ contains formatting info
  • ‘keyword_mandatory’ is a logical stating if keyword needs to be defined to run a calculation
  • ‘description’ is a string containgin human redable info about the keyword
_find_value(charkey, txt, line=1, item=1, num=1)[source]

Search charkey in txt and return value string

parameter, input :: charkey string that is search in txt parameter, input :: txt text that is searched (output of readlines) parameter, input, optional :: line index in which line to start reading after key was found parameter, input, optional :: item index which column is read parameter, input, optional :: num number of column that are read

returns :: valtxt string or list of strings depending on num setting

_get_type_from_string(fmtstr)[source]

Helper function of get_type

_update_mandatory()[source]

Check if mandatory flags need to be updated if certain keywords are set

_update_mandatory_voronoi()[source]

Change mandatory flags to match requirements of voronoi code

fill_keywords_to_inputfile(is_voro_calc=False, output='inputcard')[source]

Fill new inputcard with keywords/values automatically check for input consistency if is_voro_calc==True change mandatory list to match voronoi code, default is KKRcode

classmethod get_KKRcalc_parameter_defaults(silent=False)[source]

set defaults (defined in header of this file) and returns dict, kkrparams_version

get_all_mandatory()[source]

Return a list of mandatory keys

get_description(key)[source]

Returns description of keyword ‘key’

get_dict(group=None, subgroup=None)[source]

Returns values dictionary.

Prints values belonging to a certain group only if the ‘group’ argument is one of the following: ‘lattice’, ‘chemistry’, ‘accuracy’,

‘external fields’, ‘scf cycle’, ‘other’

Additionally the subgroups argument allows to print only a subset of all keys in a certain group. The following subgroups are available: in ‘lattice’ group: ‘2D mode’, ‘shape functions’ in ‘chemistry’ group: ‘Atom types’, ‘Exchange-correlation’, ‘CPA mode’,

‘2D mode’
in ‘accuracy’ group: ‘Valence energy contour’, ‘Semicore energy contour’,
‘CPA mode’, ‘Screening clusters’, ‘Radial solver’, ‘Ewald summation’, ‘LLoyd’
get_missing_keys(use_aiida=False)[source]

Find list of mandatory keys that are not yet set

get_set_values()[source]

Return a list of all keys/values that are set (i.e. not None)

get_type(key)[source]

Extract expected type of ‘key’ from format info

get_value(key)[source]

Sets value of keyword ‘key’

is_mandatory(key)[source]

Returns mandatory flag (True/False) for keyword ‘key’

read_keywords_from_inputcard(inputcard='inputcard')[source]

Read list of keywords from inputcard and extract values to keywords dict

Example usage:p = kkrparams(); p.read_keywords_from_inputcard(‘inputcard’)
Note:converts ‘<RBLEFT>’, ‘<RBRIGHT>’, ‘ZPERIODL’, and ‘ZPERIODR’ automatically to Ang. units!
remove_value(key)[source]

Removes value of keyword ‘key’, i.e. resets to None

set_multiple_values(**kwargs)[source]

Set multiple values (in example value1 and value2 of keywords ‘key1’ and ‘key2’) given as key1=value1, key2=value2

set_value(key, value, silent=False)[source]

Sets value of keyword ‘key’

update_to_voronoi()[source]

Update parameter settings to match voronoi specification. Sets self.__params_type and calls _update_mandatory_voronoi()

KKR parser functions

Created on Thu Dec 7 10:09:51 2017

@author: ruess

Note: Here I collect all functions needed to parse the output of a KKR calculation. These functions do not need aiida and are therefore separated from the actual parser file where parse_kkr_outputfile is called

aiida_kkr.tools.kkrparser_functions.check_error_category(err_cat, err_msg, out_dict)[source]

Check if parser error of the non-critical category (err_cat != 1) are actually consistent and may be discarded.

Parameters:
  • err_cat – the error-category of the error message to be investigated
  • err_msg – the error-message
  • out_dict – the dict of results obtained from the parser function
Returns:

True/False if message is an error or warning

aiida_kkr.tools.kkrparser_functions.get_kmeshinfo(outfile_0init, outfile_000)[source]

Extract kmesh info from output.0.txt and output.000.txt

aiida_kkr.tools.kkrparser_functions.get_natom(outfile_0init)[source]

extract NATYP value from output.0.txt

aiida_kkr.tools.kkrparser_functions.get_nspin(outfile_0init)[source]

extract NSPIN value from output.0.txt

aiida_kkr.tools.kkrparser_functions.get_orbmom(outfile, natom)[source]

read orbmom info from outfile and return array (iteration, atom)=orbmom

aiida_kkr.tools.kkrparser_functions.get_single_particle_energies(outfile_000)[source]

extracts single particle energies from outfile_000 (output.000.txt) returns the valence contribution of the single particle energies

aiida_kkr.tools.kkrparser_functions.get_spinmom_per_atom(outfile, natom, nonco_out_file=None)[source]

Extract spin moment information from outfile and nonco_angles_out (if given)

aiida_kkr.tools.kkrparser_functions.parse_kkr_outputfile(out_dict, outfile, outfile_0init, outfile_000, timing_file, potfile_out, nonco_out_file, outfile_2='output.2.txt')[source]

Parser method for the kkr outfile. It returns a dictionary with results

aiida_kkr.tools.kkrparser_functions.use_newsosol(outfile_0init)[source]

extract NEWSOSOL info from output.0.txt

Voronoi parser functions

aiida_kkr.tools.voroparser_functions.check_voronoi_output(potfile, outfile, delta_emin_safety=0.1)[source]

Read output from voronoi code and create guess of energy contour

aiida_kkr.tools.voroparser_functions.get_valence_min(outfile='out_voronoi')[source]

Construct minimum of energy contour (between valence band bottom and core states)

aiida_kkr.tools.voroparser_functions.parse_voronoi_output(out_dict, outfile, potfile, atominfo, radii, inputfile)[source]

Parse output of voronoi calculation and return (success, error_messages_list, out_dict)