Utility Functions/Classes¶
Custom Datatypes¶
This module defines subclasses of UserDict and UserList to be able to prevent unintended modifications
- masci_tools.util.lockable_containers.LockContainer(lock_object)[source]¶
Contextmanager for temporarily locking a lockable object. Object is unfrozen when exiting with block
- Parameters:
lock_object (
LockableList
[Any
] |LockableDict
[Any
,Any
]) – lockable container (not yet frozen)- Return type:
- class masci_tools.util.lockable_containers.LockableDict(*args, recursive=True, **kwargs)[source]¶
Subclass of UserDict, which can prevent modifications to itself. Raises RuntimeError if modification is attempted.
Use
LockableDict.freeze()
to enforce.LockableDict.get_unlocked()
returns a copy of the locked object with builtin lists and dicts- Parameters:
recursive (
bool
) – bool if True (default) all subitems (lists or dicts) are converted into their lockable counterparts
All other args or kwargs will be passed on to initialize the UserDict
- IMPORTANT NOTE:
This is not a direct subclass of dict. So isinstance(a, dict) will be False if a is an LockableDict
- class masci_tools.util.lockable_containers.LockableList(*args, recursive=True, **kwargs)[source]¶
Subclass of UserList, which can prevent modifications to itself. Raises RuntimeError if modification is attempted.
Use
LockableList.freeze()
to enforce.LockableList.get_unlocked()
returns a copy of the locked object with builtin lists and dicts- Parameters:
recursive (
bool
) – bool if True (default) all subitems (lists or dicts) are converted into their lockable counterparts
All other args or kwargs will be passed on to initialize the UserList
- IMPORTANT NOTE:
This is not a direct subclass of list. So isinstance(a, list) will be False if a is an LockableList
- extend(other)[source]¶
S.extend(iterable) – extend sequence by appending elements from the iterable
- Return type:
- pop(i=-1)[source]¶
return the value at index i (default last) and remove it from list
- Return type:
TypeVar
(T
)
- masci_tools.util.lockable_containers.S¶
Type variable for the key type of the dictionary
alias of TypeVar(‘S’)
- masci_tools.util.lockable_containers.T¶
Type variable for the value type of the list
alias of TypeVar(‘T’)
- masci_tools.util.lockable_containers.T_co¶
Type variable for the value type of the dictionary
alias of TypeVar(‘T_co’, covariant=True)
This module defines a small helper class to make case insensitive dictionary lookups available naturally
- class masci_tools.util.case_insensitive_dict.CaseInsensitiveDict(*args, upper=False, recursive=True, **kwargs)[source]¶
Dict with case insensitive lookup. Used in Schema dicts to make finding paths for tags and attributes easier. Does not preserve the case of the inserted key. Does not support case insensitive lookups in nested dicts Subclass of
masci_tools.util.lockable_containers.LockableDict
. So can be frozen via the`freeze()` method- Parameters:
upper (
bool
) – bool if True the method upper() will be used instead of lower() to normalize keys
All other args or kwargs will be passed on to initialize the UserDict
- IMPORTANT NOTE:
This is not a direct subcalss of dict. So isinstance(a, dict) will be False if a is an CaseInsensitiveDict
- class masci_tools.util.case_insensitive_dict.CaseInsensitiveFrozenSet(iterable=None, upper=False)[source]¶
Frozenset (i.e. immutable set) with case insensitive membership tests. Used in Schema dicts in tag_info entries to make flexible classification easy Preserves the case of the entered keys (original_case() returns the case of the first encounter)
- Parameters:
iterable (
Optional
[Iterable
[TypeVar
(T_co
, covariant=True)]]) – iterable only containing str
- Note:
There might be subtle differences to expected behaviour with the methods __radd__, __ror__, and so on
- difference(*others)[source]¶
Return the difference of two or more sets as a new set.
(i.e. all elements that are in this set but not the others.)
- Return type:
CaseInsensitiveFrozenSet
[TypeVar
(T_co
, covariant=True)]
- intersection(*others)[source]¶
Return the intersection of two sets as a new set.
(i.e. all elements that are in both sets.)
- Return type:
CaseInsensitiveFrozenSet
[TypeVar
(T_co
, covariant=True)]
- symmetric_difference(other)[source]¶
Return the symmetric difference of two sets as a new set.
(i.e. all elements that are in exactly one of the sets.)
- Return type:
CaseInsensitiveFrozenSet
[TypeVar
(T_co
, covariant=True)]
- masci_tools.util.case_insensitive_dict.S¶
Generic Type
alias of TypeVar(‘S’)
- masci_tools.util.case_insensitive_dict.T_co¶
Generic Type
alias of TypeVar(‘T_co’, covariant=True)
This module defines some aliases used in typing
- masci_tools.util.typing.FileLike¶
Type used for functions accepting file-like objects, i.e. handles or file paths
- masci_tools.util.typing.TXPathLike¶
Type for xpath expressions
alias of TypeVar(‘TXPathLike’, bound=
Union
[str
,bytes
,XPath
,XPathBuilder
])
- masci_tools.util.typing.XMLFileLike¶
Type used for functions accepting xml-file-like objects, i.e. handles or file paths or already parsed xml objects
alias of
Union
[_ElementTree
,_Element
,str
,bytes
,Path
,PathLike
,IO
[Any
]]
- masci_tools.util.typing.XMLLike¶
Type used for functions accepting xml objects from lxml
alias of
Union
[_Element
,_ElementTree
]
Common XML utility¶
Common functions for parsing input/output files or XMLschemas from FLEUR
- masci_tools.util.xml.common_functions.T¶
Generic Type
alias of TypeVar(‘T’)
- masci_tools.util.xml.common_functions.abs_to_rel_xpath(xpath, new_root)[source]¶
Convert a given xpath to be relative from a tag appearing in the original xpath.
- masci_tools.util.xml.common_functions.add_tag(xpath, tag)[source]¶
Add tag to xpath
Note
etree.XPath objects could lose context in here, i.e. non-default options passed at init
- masci_tools.util.xml.common_functions.check_complex_xpath(node, base_xpath, complex_xpath)[source]¶
Check that the given complex xpath produces a subset of the results for the simple xpath
- Parameters:
node (
Union
[_Element
,_ElementTree
,XPathElementEvaluator
]) – root node of an etree or an etreebase_xpath (
Union
[str
,bytes
,XPath
,XPathBuilder
]) – str of the xpath without complex syntaxcomplex_xpath (
Union
[str
,bytes
,XPath
,XPathBuilder
]) – str of the xpath to check
- Raises:
ValueError – If the complex_xpath does not produce a subset of the results of the base_xpath
- Return type:
- masci_tools.util.xml.common_functions.clear_xml(tree)[source]¶
Removes comments and executes xinclude tags of an xml tree.
- Parameters:
tree (
_ElementTree
) – an xml-tree which will be processed- Return type:
tuple
[_ElementTree
,set
[str
]]- Returns:
cleared_tree, an xmltree without comments and with replaced xinclude tags
- masci_tools.util.xml.common_functions.contains_tag(xpath, tag)[source]¶
Return whether a given xpath contains a given tag This assumes that predicates of xpaths can’t be nested since otherwise the regex for removing them could fail
This function will only return True if one of the tags exactly matches the tag argument not if one tag contains the given name in it’s name
- masci_tools.util.xml.common_functions.eval_xpath(node, xpath, logger=None, list_return=False, namespaces=None, **variables)[source]¶
Tries to evaluate an xpath expression. If it fails it logs it. If a absolute path is given (starting with ‘/’) and the tag of the node does not match the root. It will try to find the tag in the path and convert it into a relative path
- Parameters:
node – root node of an etree
xpath – xpath expression (relative, or absolute)
logger – logger object for logging warnings, errors, if not provided all errors will be raised
list_return – if True, the returned quantity is always a list even if only one element is in it
namespaces – dict, passed to namespaces argument in xpath call
- Returns:
text, attribute or a node list
- masci_tools.util.xml.common_functions.get_inpgen_comments(xmltree)[source]¶
Get the XML comment element appended after the root of the inp.xml file
These contain at the moment the inpgen command line and the content of the inpgen file
- Parameters:
xmltree (
_ElementTree
) – representation of the inp.xml- Return type:
- Returns:
list of XML comments, which appear after the fleurInput tag
- masci_tools.util.xml.common_functions.get_xml_attribute(node, attributename, logger=None)[source]¶
Get an attribute value from a node.
- masci_tools.util.xml.common_functions.is_valid_tag(tag)[source]¶
Return whether the given string is a valid XML tag name
- masci_tools.util.xml.common_functions.normalize_xmllike(xmllike)[source]¶
Returns the root of the xmltree
- Return type:
- masci_tools.util.xml.common_functions.process_xpath_argument(simple_xpath, complex_xpath, filters)[source]¶
Process the simple and complex Xpath expressions and given filters Used for unifying the logic for all xml setters/evaluators using these arguments
- Parameters:
simple_xpath (
str
|bytes
|XPath
) – THe simple XPath (no predicates) expression to base the paths oncomplex_xpath (
Union
[str
,bytes
,XPath
,XPathBuilder
,None
]) – Optional XPath given with no restrictionsfilters (
Optional
[Dict
[str
,Any
]]) – Dict specifying constraints to apply on the xpath. SeeXPathBuilder
for details
- Return type:
Union
[str
,bytes
,XPath
,XPathBuilder
]- Returns:
Complex XPath expression
- masci_tools.util.xml.common_functions.readd_inpgen_comments(xmltree, comments)[source]¶
Add the given comments after the fleurInput tag of the inp.xml
These contain at the moment the inpgen command line and the content of the inpgen file
- Parameters:
xmltree (
_ElementTree
) – representation of the inp.xml
- Return type:
- masci_tools.util.xml.common_functions.reverse_xinclude(xmltree, schema_dict, included_tags, **kwargs)[source]¶
DEPRECATED ALIAS: Moved to masci_tools.util.schema_dict_util
Split the xmltree back up according to the given included tags. The original xmltree will be returned with the corresponding xinclude tags and the included trees are returned in a dict mapping the inserted filename to the extracted tree
Tags for which no known filename is known are returned under unknown-1.xml, … The following tags have known filenames:
relaxation:
relax.xml
kPointLists:
kpts.xml
symmetryOperations:
sym.xml
atomSpecies:
species.xml
atomGroups:
atoms.xml
Additional mappings can be given in the keyword arguments
- Parameters:
xmltree – an xml-tree which will be processed
schema_dict – Schema dictionary containing all the necessary information
included_tags – Iterable of str, containing the names of the tags to be excluded
- Returns:
xmltree with the inseerted xinclude tags and a dict mapping the filenames to the excluded trees
- Raises:
ValueError – if the tag can not be found in the given xmltree
- masci_tools.util.xml.common_functions.serialize_xml_objects(args, kwargs)[source]¶
Convert every XML element/tree in the given args/kwargs to string using
lxml.etree.tostring()
- masci_tools.util.xml.common_functions.split_off_attrib(xpath)[source]¶
Splits off attribute of the given xpath (part after @)
Note
etree.XPath objects could lose context in here, i.e. non-default options passed at init
- masci_tools.util.xml.common_functions.split_off_tag(xpath)[source]¶
Splits off the last part of the given xpath
Note
etree.XPath objects could lose context in here, i.e. non-default options passed at init
- masci_tools.util.xml.common_functions.validate_xml(xmltree, schema, error_header='File does not validate')[source]¶
Checks a given xmltree against a schema and produces a nice error message with all the validation errors collected
- Parameters:
xmltree (
_ElementTree
) – xmltree of the file to validateschema (
XMLSchema
) – etree.XMLSchema to validate againsterror_header (
str
) – str to lead a evtl error message with
- Raises:
etree.DocumentInvalid if the schema does not validate
- Return type:
Common functions for converting types to and from XML files
- masci_tools.util.xml.converters.convert_fleur_electronconfig(econfig_element)[source]¶
Convert electronConfig tag to eConfig string
- Return type:
- masci_tools.util.xml.converters.convert_fleur_lo(loelements, allow_special_los=True)[source]¶
Converts lo xml elements from the inp.xml file into a lo string for the inpgen
- Return type:
- masci_tools.util.xml.converters.convert_from_fortran_bool(stringbool)[source]¶
Converts a string in this case (‘T’, ‘F’, or ‘t’, ‘f’) to True or False
- masci_tools.util.xml.converters.convert_from_fortran_complex(number_str)[source]¶
Converts a string of the form (float,float) to a complex number
- masci_tools.util.xml.converters.convert_from_xml(xmlstring, schema_dict, name, text=False, constants=None, logger=None, list_return=False)[source]¶
Tries to converts a given string to the types specified in the schema_dict. First succeeded conversion will be returned
If no logger is given and a attribute cannot be converted an error is raised
- Parameters:
stringattribute – str, Attribute to convert.
schema_dict (
SchemaDict
) – Schema dictionary containing all the informationname (
str
) – name of the attribute or elementtext (
bool
) – bool, decides whether to take the definitions for text or attributesconstants (
Optional
[dict
[str
,float
]]) – dict, of constants defined in fleur inputlogger (
Optional
[Logger
]) – logger object for logging warnings if given the errors are logged and the list is returned with the unconverted values otherwise a error is raised, when the first conversion failslist_return (
bool
) – if True, the returned quantity is always a list even if only one element is in it
- Return type:
tuple
[Union
[int
,float
,bool
,str
,complex
,list
[Union
[int
,float
,bool
,str
,complex
]],list
[Union
[int
,float
,bool
,str
,complex
,list
[Union
[int
,float
,bool
,str
,complex
]]]]],bool
]- Returns:
The converted value of the first successful conversion
- masci_tools.util.xml.converters.convert_from_xml_explicit(xmlstring, definitions, constants=None, logger=None, list_return=False)[source]¶
Tries to converts a given string to the types given in definitions. First succeeded conversion will be returned
If no logger is given and a attribute cannot be converted an error is raised
- Parameters:
stringattribute – str, Attribute to convert.
definitions (
list
[AttributeType
]) – list ofAttributeType
definitionsconstants (
Optional
[dict
[str
,float
]]) – dict, of constants defined in fleur inputlogger (
Optional
[Logger
]) – logger object for logging warnings if given the errors are logged and the list is returned with the unconverted values otherwise a error is raised, when the first conversion failslist_return (
bool
) – if True, the returned quantity is always a list even if only one element is in it
- Return type:
tuple
[Union
[int
,float
,bool
,str
,complex
,list
[Union
[int
,float
,bool
,str
,complex
]],list
[Union
[int
,float
,bool
,str
,complex
,list
[Union
[int
,float
,bool
,str
,complex
]]]]],bool
]- Returns:
The converted value of the first successful conversion
- masci_tools.util.xml.converters.convert_from_xml_single_values(xmlstring, possible_types, constants=None, logger=None)[source]¶
Tries to converts a given string attribute to the types given in possible_types. First succeeded conversion will be returned
If no logger is given and a attribute cannot be converted an error is raised
- Parameters:
stringattribute – str, Attribute to convert.
possible_types (
tuple
[Literal
['int'
,'switch'
,'string'
,'float'
,'float_expression'
,'complex'
],...
]) – list of str What types it will try to convert toconstants (
Optional
[dict
[str
,float
]]) – dict, of constants defined in fleur inputlogger (
Optional
[Logger
]) – logger object for logging warnings if given the errors are logged and the list is returned with the unconverted values otherwise a error is raised, when the first conversion failslist_return – if True, the returned quantity is always a list even if only one element is in it
- Return type:
- Returns:
The converted value of the first successful conversion
- masci_tools.util.xml.converters.convert_str_version_number(version_str)[source]¶
Convert the version number as a integer for easy comparisons
- masci_tools.util.xml.converters.convert_to_fortran_bool(boolean)[source]¶
Converts a Boolean as string to the format defined in the input
- masci_tools.util.xml.converters.convert_to_xml(value, schema_dict, name, text=False, logger=None, list_return=False)[source]¶
Tries to converts a given string to the types specified in the schema_dict. First succeeded conversion will be returned
If no logger is given and a attribute cannot be converted an error is raised
- Parameters:
stringattribute – str, Attribute to convert.
schema_dict (
SchemaDict
) – Schema dictionary containing all the informationname (
str
) – name of the attribute or elementtext (
bool
) – bool, decides whether to take the definitions for text or attributesconstants – dict, of constants defined in fleur input
logger (
Optional
[Logger
]) – logger object for logging warnings if given the errors are logged and the list is returned with the unconverted values otherwise a error is raised, when the first conversion failslist_return (
bool
) – if True, the returned quantity is always a list even if only one element is in it
- Return type:
- Returns:
The converted value of the first successful conversion
- masci_tools.util.xml.converters.convert_to_xml_explicit(value, definitions, logger=None, float_format='.10', list_return=False)[source]¶
Tries to convert a given list of values to str for a xml file based on the definitions (length and type). First succeeded conversion will be returned
- Parameters:
textvalue – value to convert
definitions (
list
[AttributeType
]) – list ofAttributeType
definitionslogger (
Optional
[Logger
]) – logger object for logging warnings if given the errors are logged and the list is returned with the unconverted values otherwise a error is raised, when the first conversion failslist_return (
bool
) – if True, the returned quantity is always a list even if only one element is in it
- Return type:
- Returns:
The converted value of the first successful conversion
- masci_tools.util.xml.converters.convert_to_xml_single_values(value, possible_types, logger=None, float_format='.10')[source]¶
Tries to converts a given attributevalue to a string for a xml file according to the types given in possible_types. First succeeded conversion will be returned
- Parameters:
possible_types (
tuple
[Literal
['int'
,'switch'
,'string'
,'float'
,'float_expression'
,'complex'
],...
]) – list of str What types it will try to convert fromlogger (
Optional
[Logger
]) – logger object for logging warnings if given the errors are logged and the list is returned with the unconverted values otherwise a error is raised, when the first conversion failslist_return – if True, the returned quantity is always a list even if only one element is in it
- Return type:
- Returns:
The converted str of the value of the first successful conversion
This module contains Classes for building complex XPath expressions based on general attribute conditions from simple XPath expressions
- masci_tools.util.xml.xpathbuilder.FilterType¶
Type for filters argument for XPathBuilder
- class masci_tools.util.xml.xpathbuilder.XPathBuilder(simple_path, filters=None, compile_path=False, strict=False, **kwargs)[source]¶
Class for building a complex xpath (restricted to adding filters) from a simple xpath expression
Note
passing in an etree.XPath object will not respect the options passed into it. Only the kwargs in __init__ are used to compile the path if compile_path=True
Note
Filters/Constraints (or predicates like they are called for XPaths) can either be added by providing the
filters
argument in the constructor or by calling theadd_filter()
method.The
filters
argument is a dictionary with the tag names, where to apply the condition, as keys and the condition as values while theadd_filter()
method takes these as it’s two arguments. The tag name has to be a part of the original simple xpath expression. The conditition is a dictionary with one key specifying the kind of condition and the value for the condition. The condition can also be the name of an attribute or path, in which case the value can be another condition dictionary. The following conditions operators i.e. keys in the dictionary are supported:=
/==
: equal to!=
: not equal to<
: less than>
: greater than<=
: less than or equal to>=
: greater than or equal tocontains
: attribute/tag contains the given value (case sensitive)not-contains
: attribute/tag does not contains the given valuestarts-with
: attribute/tag starts with the given value (case sensitive)ends-with
: attribute/tag ends with the given value (case sensitive)index
: Select tags based on their index in the parent tag (either explicit index or another condition)has
: Select tags based on the presence of the given attribute/taghas-not
: Select tags based on the absence of the given attribute/tagnumber-nodes
: Compute the number of nodes in the previous path and select based on further criteriaand
: Provide multiple conditions in a list joined byand
or
: Provide multiple conditions in a list joined byor
in
: Select tags if the value of the path is in a given list of valuesnot-in
: Select tags if the value of the path is not in a given list of values<string>
: All other strings are interpreted as paths to attributes/tags specifying conditions on their value<tuple of paths>
: Multiple strings are interpreted as multiple node sets, which are joined with |
Example:
from masci_tools.util.xml.xpathbuilder import XPathBuilder # XPath selecting all lo tags for SCLO type LOs and Iron species xpath = XPathBuilder('/fleurInput/atomSpecies/species/lo', filters = {'species': { 'name': {'contains': 'Fe'}, }, 'lo': { 'type': 'SCLO' } })
- Parameters:
simple_path (
str
|bytes
|XPath
) – basic simple XPath expression to start fromfilters (
Optional
[dict
[str
,Dict
[str
,Any
]]]) – dictionary with filterscompile_path (
bool
) – bool if True the path property will be compiled as etree.XPathstrict (
bool
) – bool if True the __str__ conversion will raise an error
Other Kwargs will be passed on to the etree.XPath compilation if
compile_path=True
- get_predicate(tag, condition, compound=False, path='.', process_path=False)[source]¶
Construct the predicate for the given tag and condition
- Parameters:
tag (
str
) – str name of the tagcondition (
Any
) – condition specified, either dict or single valuecompound (
bool
) – bool if True the enclosing condition is a compound condition, forbidding any other compound conditionpath (
str
|tuple
[str
,...
]) – path, to which to apply the conditionprocess_path (
bool
) – bool if True the path will taken apart into its components and the components will be checked with XPath variables
- Return type:
- property path: str | lxml.etree.XPath¶
Property for constructing the complex Xpath
- process_condition(tag, operator, content, path, process_path=False)[source]¶
Process the condition for the given tag and condition
- Parameters:
tag (
str
) – str name of the tagoperator (
str
) – operator for conditioncontent (
Any
) – content of conditionpath (
str
|tuple
[str
,...
]) – path, to which to apply the conditionprocess_path (
bool
) – bool if True the path will taken apart into its components and the components will be checked with XPath variables
- Return type:
XML Setter functions¶
Functions for modifying the xml input file of Fleur utilizing the schema dict and as little knowledge of the concrete xpaths as possible
- masci_tools.util.xml.xml_setters_names.add_number_to_attrib(xmltree, schema_dict, name, number_to_add, complex_xpath=None, filters=None, mode='absolute', occurrences=None, **kwargs)[source]¶
Adds a given number to the attribute value in a xmltree specified by the name of the attribute and optional further specification If there are no nodes under the specified xpath an error is raised
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – an xmltree that represents inp.xmlschema_dict (
SchemaDict
) – InputSchemaDict containing all information about the structure of the inputname (
str
) – the attribute name to changenumber_to_add (
Any
) – number to add/multiply with the old attribute valuecomplex_xpath (
Union
[str
,bytes
,XPath
,XPathBuilder
,None
]) – an optional xpath to use instead of the simple xpath for the evaluationfilters (
Optional
[Dict
[str
,Any
]]) – Dict specifying constraints to apply on the xpath. SeeXPathBuilder
for detailsmode (
Literal
['abs'
,'absolute'
,'rel'
,'relative'
]) – str (either rel/relative or abs/absolute). rel/relative multiplies the old value with number_to_add abs/absolute adds the old value and number_to_addoccurrences (
Union
[int
,Iterable
[int
],None
]) – int or list of int. Which occurrence of the node to set. By default all are set.
- Kwargs:
- param tag_name:
str, name of the tag where the attribute should be parsed
- param contains:
str, this string has to be in the final path
- param not_contains:
str, this string has to NOT be in the final path
- param exclude:
list of str, here specific types of attributes can be excluded valid values are: settable, settable_contains, other
- Return type:
- Returns:
xmltree with shifted attribute
- masci_tools.util.xml.xml_setters_names.add_number_to_first_attrib(xmltree, schema_dict, name, number_to_add, complex_xpath=None, filters=None, mode='absolute', **kwargs)[source]¶
Adds a given number to the first occurrence of an attribute value in a xmltree specified by the name of the attribute and optional further specification If there are no nodes under the specified xpath an error is raised
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – an xmltree that represents inp.xmlschema_dict (
SchemaDict
) – InputSchemaDict containing all information about the structure of the inputname (
str
) – the attribute name to changenumber_to_add (
Any
) – number to add/multiply with the old attribute valuecomplex_xpath (
Union
[str
,bytes
,XPath
,XPathBuilder
,None
]) – an optional xpath to use instead of the simple xpath for the evaluationmode (
Literal
['abs'
,'absolute'
,'rel'
,'relative'
]) – str (either rel/relative or abs/absolute). rel/relative multiplies the old value with number_to_add abs/absolute adds the old value and number_to_addfilters (
Optional
[Dict
[str
,Any
]]) – Dict specifying constraints to apply on the xpath. SeeXPathBuilder
for details
- Kwargs:
- param tag_name:
str, name of the tag where the attribute should be parsed
- param contains:
str, this string has to be in the final path
- param not_contains:
str, this string has to NOT be in the final path
- param exclude:
list of str, here specific types of attributes can be excluded valid values are: settable, settable_contains, other
- Return type:
- Returns:
xmltree with shifted attribute
- masci_tools.util.xml.xml_setters_names.clone_species(xmltree, schema_dict, species_name, new_name, changes=None)[source]¶
Method to create a new species from an existing one with evtl. modifications
For reference of the changes dictionary look at
set_species()
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – xml etree of the inp.xmlschema_dict (
SchemaDict
) – InputSchemaDict containing all information about the structure of the inputspecies_name (
str
) – string, name of the specie you want to clone Has to correspond to one single species (no ‘all’/’all-<search_string>’)new_name (
str
) – new name of the cloned specieschanges (
Optional
[dict
[str
,Any
]]) – a optional python dict specifying what you want to change.
- Returns xmltree:
xml etree of the new inp.xml
- Return type:
- masci_tools.util.xml.xml_setters_names.create_tag(xmltree, schema_dict, tag, complex_xpath=None, filters=None, create_parents=False, occurrences=None, **kwargs)[source]¶
This method creates a tag with a uniquely identified xpath under the nodes of its parent. If there are no nodes evaluated the subtags can be created with create_parents=True
The tag is always inserted in the correct place if a order is enforced by the schema
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – an xmltree that represents inp.xmlschema_dict (
SchemaDict
) – InputSchemaDict containing all information about the structure of the inputtag (
QName
|str
|_Element
) – str of the tag to create or etree Element or string representing the XML element with the same name to insertcomplex_xpath (
Union
[str
,bytes
,XPath
,XPathBuilder
,None
]) – an optional xpath to use instead of the simple xpath for the evaluationfilters (
Optional
[Dict
[str
,Any
]]) – Dict specifying constraints to apply on the xpath. SeeXPathBuilder
for detailscreate_parents (
bool
) – bool optional (default False), if True and the given xpath has no results the the parent tags are created recursivelyoccurrences (
Union
[int
,Iterable
[int
],None
]) – int or list of int. Which occurrence of the parent nodes to create a tag. By default all nodes are used.
- Kwargs:
- param contains:
str, this string has to be in the final path
- param not_contains:
str, this string has to NOT be in the final path
- Return type:
- Returns:
xmltree with created tags
- masci_tools.util.xml.xml_setters_names.delete_att(xmltree, schema_dict, name, complex_xpath=None, filters=None, occurrences=None, **kwargs)[source]¶
This method deletes a attribute with a uniquely identified xpath.
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – an xmltree that represents inp.xmlschema_dict (
SchemaDict
) – InputSchemaDict containing all information about the structure of the inputname (
str
) – str of the attribute to deletecomplex_xpath (
Union
[str
,bytes
,XPath
,XPathBuilder
,None
]) – an optional xpath to use instead of the simple xpath for the evaluationfilters (
Optional
[Dict
[str
,Any
]]) – Dict specifying constraints to apply on the xpath. SeeXPathBuilder
for detailsoccurrences (
Union
[int
,Iterable
[int
],None
]) – int or list of int. Which occurrence of the parent nodes to delete a attribute. By default all nodes are used.
- Kwargs:
- param tag_name:
str, name of the tag where the attribute should be parsed
- param contains:
str, this string has to be in the final path
- param not_contains:
str, this string has to NOT be in the final path
- param exclude:
list of str, here specific types of attributes can be excluded valid values are: settable, settable_contains, other
- Return type:
- Returns:
xmltree with deleted attributes
- masci_tools.util.xml.xml_setters_names.delete_tag(xmltree, schema_dict, tag_name, complex_xpath=None, filters=None, occurrences=None, **kwargs)[source]¶
This method deletes a tag with a uniquely identified xpath.
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – an xmltree that represents inp.xmlschema_dict (
SchemaDict
) – InputSchemaDict containing all information about the structure of the inputtag – str of the tag to delete
complex_xpath (
Union
[str
,bytes
,XPath
,XPathBuilder
,None
]) – an optional xpath to use instead of the simple xpath for the evaluationfilters (
Optional
[Dict
[str
,Any
]]) – Dict specifying constraints to apply on the xpath. SeeXPathBuilder
for detailsoccurrences (
Union
[int
,Iterable
[int
],None
]) – int or list of int. Which occurrence of the parent nodes to delete a tag. By default all nodes are used.
- Kwargs:
- param contains:
str, this string has to be in the final path
- param not_contains:
str, this string has to NOT be in the final path
- Return type:
- Returns:
xmltree with deleted tags
- masci_tools.util.xml.xml_setters_names.replace_tag(xmltree, schema_dict, tag_name, element, complex_xpath=None, filters=None, occurrences=None, **kwargs)[source]¶
This method deletes a tag with a uniquely identified xpath.
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – an xmltree that represents inp.xmlschema_dict (
SchemaDict
) – InputSchemaDict containing all information about the structure of the inputtag – str of the tag to replace
element (
str
|_Element
) – etree Element or string representing the XML element to replace the tagcomplex_xpath (
Union
[str
,bytes
,XPath
,XPathBuilder
,None
]) – an optional xpath to use instead of the simple xpath for the evaluationfilters (
Optional
[Dict
[str
,Any
]]) – Dict specifying constraints to apply on the xpath. SeeXPathBuilder
for detailsoccurrences (
Union
[int
,Iterable
[int
],None
]) – int or list of int. Which occurrence of the parent nodes to replace a tag. By default all nodes are used.
- Kwargs:
- param contains:
str, this string has to be in the final path
- param not_contains:
str, this string has to NOT be in the final path
- Return type:
- Returns:
xmltree with replaced tags
- masci_tools.util.xml.xml_setters_names.set_atomgroup(xmltree, schema_dict, changes, position=None, species=None, filters=None)[source]¶
Method to set parameters of an atom group of the fleur inp.xml file.
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – xml etree of the inp.xmlschema_dict (
SchemaDict
) – InputSchemaDict containing all information about the structure of the inputchanges (
dict
[str
,Any
]) – a python dict specifying what you want to change.position (
Union
[int
,Literal
['all'
],None
]) – position of an atom group to be changed. If equals to ‘all’, all species will be changedspecies (
Optional
[str
]) – atom groups, corresponding to the given species will be changedfilters (
Optional
[Dict
[str
,Any
]]) – Dict specifying constraints to apply on the xpath. SeeXPathBuilder
for details
- Return type:
- Returns:
xml etree of the new inp.xml
changes is a python dictionary containing dictionaries that specify attributes to be set inside the certain specie. For example, if one wants to set a beta noco parameter it can be done via:
'changes': {'nocoParams': {'beta': val}}
- masci_tools.util.xml.xml_setters_names.set_atomgroup_label(xmltree, schema_dict, atom_label, changes)[source]¶
This method calls
set_atomgroup()
method for a certain atom species that corresponds to an atom with a given label.- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – xml etree of the inp.xmlschema_dict (
SchemaDict
) – InputSchemaDict containing all information about the structure of the inputatom_label (
str
) – string, a label of the atom which specie will be changed. ‘all’ to change all the specieschanges (
dict
[str
,Any
]) – a python dict specifying what you want to change.
- Return type:
- Returns:
xml etree of the new inp.xml
changes is a python dictionary containing dictionaries that specify attributes to be set inside the certain specie. For example, if one wants to set a beta noco parameter it can be done via:
'changes': {'nocoParams': {'beta': val}}
- masci_tools.util.xml.xml_setters_names.set_attrib_value(xmltree, schema_dict, name, value, complex_xpath=None, filters=None, occurrences=None, create=False, **kwargs)[source]¶
Sets an attribute in a xmltree to a given value, specified by its name and further specifications. If there are no nodes under the specified xpath a tag can be created with create=True. The attribute values are converted automatically according to the types of the attribute with
convert_to_xml()
if they are not str already.- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – an xmltree that represents inp.xmlschema_dict (
SchemaDict
) – InputSchemaDict containing all information about the structure of the inputname (
str
) – the attribute name to setvalue (
Any
) – value or list of values to setcomplex_xpath (
Union
[str
,bytes
,XPath
,XPathBuilder
,None
]) – an optional xpath to use instead of the simple xpath for the evaluationfilters (
Optional
[Dict
[str
,Any
]]) – Dict specifying constraints to apply on the xpath. SeeXPathBuilder
for detailsoccurrences (
Union
[int
,Iterable
[int
],None
]) – int or list of int. Which occurrence of the node to set. By default all are set.create (
bool
) – bool optional (default False), if True the tag is created if is missing
- Kwargs:
- param tag_name:
str, name of the tag where the attribute should be parsed
- param contains:
str, this string has to be in the final path
- param not_contains:
str, this string has to NOT be in the final path
- param exclude:
list of str, here specific types of attributes can be excluded valid values are: settable, settable_contains, other
- Return type:
- Returns:
xmltree with set attribute
- masci_tools.util.xml.xml_setters_names.set_complex_tag(xmltree, schema_dict, tag_name, changes, complex_xpath=None, filters=None, create=False, **kwargs)[source]¶
Function to correctly set tags/attributes for a given tag. Goes through the attributedict and decides based on the schema_dict, how the corresponding key has to be handled. The tag is specified via its name and evtl. further specification
Supports:
attributes
tags with text only
simple tags, i.e. only attributes (can be optional single/multiple)
complex tags, will recursively create/modify them
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – an xmltree that represents inp.xmlschema_dict (
SchemaDict
) – InputSchemaDict containing all information about the structure of the inputtag_name (
str
) – name of the tag to setchanges (
dict
[str
,Any
]) – Keys in the dictionary correspond to names of tags and the values are the modifications to do on this tag (attributename, subdict with changes to the subtag, …)complex_xpath (
Union
[str
,bytes
,XPath
,XPathBuilder
,None
]) – an optional xpath to use instead of the simple xpath for the evaluationfilters (
Optional
[Dict
[str
,Any
]]) – Dict specifying constraints to apply on the xpath. SeeXPathBuilder
for detailscreate (
bool
) – bool optional (default False), if True and the path, where the complex tag is set does not exist it is created
- Kwargs:
- param contains:
str, this string has to be in the final path
- param not_contains:
str, this string has to NOT be in the final path
- Return type:
- Returns:
xmltree with changes to the complex tag
- masci_tools.util.xml.xml_setters_names.set_first_attrib_value(xmltree, schema_dict, name, value, complex_xpath=None, filters=None, create=False, **kwargs)[source]¶
Sets the first occurrence of an attribute in a xmltree to a given value, specified by its name and further specifications. If there are no nodes under the specified xpath a tag can be created with create=True. The attribute values are converted automatically according to the types of the attribute with
convert_to_xml()
if they are not str already.- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – an xmltree that represents inp.xmlschema_dict (
SchemaDict
) – InputSchemaDict containing all information about the structure of the inputname (
str
) – the attribute name to setvalue (
Any
) – value or list of values to setcomplex_xpath (
Union
[str
,bytes
,XPath
,XPathBuilder
,None
]) – an optional xpath to use instead of the simple xpath for the evaluationfilters (
Optional
[Dict
[str
,Any
]]) – Dict specifying constraints to apply on the xpath. SeeXPathBuilder
for detailscreate (
bool
) – bool optional (default False), if True the tag is created if is missing
- Kwargs:
- param tag_name:
str, name of the tag where the attribute should be parsed
- param contains:
str, this string has to be in the final path
- param not_contains:
str, this string has to NOT be in the final path
- param exclude:
list of str, here specific types of attributes can be excluded valid values are: settable, settable_contains, other
- Return type:
- Returns:
xmltree with set attribute
- masci_tools.util.xml.xml_setters_names.set_first_text(xmltree, schema_dict, tag_name, text, complex_xpath=None, filters=None, create=False, **kwargs)[source]¶
Sets the text the first occurrence of a tag in a xmltree to a given value, specified by the name of the tag and further specifications. By default the text will be set on all nodes returned for the specified xpath. If there are no nodes under the specified xpath a tag can be created with create=True. The text values are converted automatically according to the types with
convert_to_xml()
if they are not str already.- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – an xmltree that represents inp.xmlschema_dict (
SchemaDict
) – InputSchemaDict containing all information about the structure of the inputtag_name (
str
) – str name of the tag, where the text should be settext (
Any
) – value or list of values to setcomplex_xpath (
Union
[str
,bytes
,XPath
,XPathBuilder
,None
]) – an optional xpath to use instead of the simple xpath for the evaluationfilters (
Optional
[Dict
[str
,Any
]]) – Dict specifying constraints to apply on the xpath. SeeXPathBuilder
for detailscreate (
bool
) – bool optional (default False), if True the tag is created if is missing
- Kwargs:
- param contains:
str, this string has to be in the final path
- param not_contains:
str, this string has to NOT be in the final path
- Return type:
- Returns:
xmltree with set text
- masci_tools.util.xml.xml_setters_names.set_inpchanges(xmltree, schema_dict, changes, path_spec=None)[source]¶
This method sets all the attribute and texts provided in the change_dict.
The first occurrence of the attribute/tag is set
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – xml tree that represents inp.xmlschema_dict (
SchemaDict
) – InputSchemaDict containing all information about the structure of the inputchanges (
dict
[str
,Any
]) – dictionary {attrib_name : value} with all the wanted changes.path_spec (
Optional
[dict
[str
,Any
]]) – dict, with ggf. necessary further specifications for the path of the attribute
An example of changes:
changes = { 'itmax' : 1, 'l_noco': True, 'ctail': False, 'l_ss': True }
- Return type:
- Returns:
an xmltree of the inp.xml file with changes.
- masci_tools.util.xml.xml_setters_names.set_kpath(xmltree, schema_dict, kpath, count, gamma=False)[source]¶
Sets a k-path directly into inp.xml as a alternative kpoint set with purpose ‘bands’
Warning
This method is only supported for input versions before the Max5 release
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – xml tree that represents inp.xmlschema_dict (
SchemaDict
) – InputSchemaDict containing all information about the structure of the inputkpath (
dict
[str
,Iterable
[float
]]) – a dictionary with kpoint name as key and k point coordinate as valuecount (
int
) – number of k-pointsgamma (
bool
) – bool that controls if the gamma-point should be included in the k-point mesh
- Return type:
- Returns:
an xmltree of the inp.xml file with changes.
- masci_tools.util.xml.xml_setters_names.set_kpath_max4(xmltree, schema_dict, kpath, count, gamma=False)[source]¶
Sets a k-path directly into inp.xml as a alternative kpoint set with purpose ‘bands’
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – xml tree that represents inp.xmlschema_dict (
SchemaDict
) – InputSchemaDict containing all information about the structure of the inputkpath (
dict
[str
,Iterable
[float
]]) – a dictionary with kpoint name as key and k point coordinate as valuecount (
int
) – number of k-pointsgamma (
bool
) – bool that controls if the gamma-point should be included in the k-point mesh
- Return type:
- Returns:
an xmltree of the inp.xml file with changes.
- masci_tools.util.xml.xml_setters_names.set_kpointlist(xmltree, schema_dict, kpoints, weights, name=None, kpoint_type='path', special_labels=None, switch=False, overwrite=False, additional_attributes=None)[source]¶
Explicitly create a kPointList from the given kpoints and weights. This routine will add the specified kPointList with the given name.
Warning
For input versions Max4 and older all keyword arguments are not valid (name, kpoint_type, special_labels, switch and overwrite)
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – xml tree that represents inp.xmlschema_dict (
SchemaDict
) – InputSchemaDict containing all information about the structure of the inputkpoints (
Iterable
[Iterable
[float
]]) – list or array containing the relative coordinates of the kpointsweights (
Iterable
[float
]) – list or array containing the weights of the kpointsname (
Optional
[str
]) – str for the name of the list, if not given a default name is generatedkpoint_type (
Literal
['path'
,'mesh'
,'tria'
,'tria-bulk'
,'spex-mesh'
]) – str specifying the type of the kPointList (‘path’, ‘mesh’, ‘spex’, ‘tria’, …)special_labels (
Optional
[dict
[int
,str
]]) – dict mapping indices to labels. The labels will be inserted for the kpoints corresponding to the given indexswitch (
bool
) – bool, if True the kPointlist will be used by Fleur when starting the next calculationoverwrite (
bool
) – bool, if True and a kPointlist with the given name already exists it will be overwritten
- Return type:
- Returns:
an xmltree of the inp.xml file with changes.
- masci_tools.util.xml.xml_setters_names.set_kpointlist_max4(xmltree, schema_dict, kpoints, weights, name=None, kpoint_type='path', special_labels=None, switch=False, overwrite=False, additional_attributes=None)[source]¶
Explicitly create a kPointList from the given kpoints and weights. This routine is specific to input versions Max4 and before and will replace any existing kPointCount, kPointMesh, … with the specified kPointList
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – xml tree that represents inp.xmlschema_dict (
SchemaDict
) – InputSchemaDict containing all information about the structure of the inputkpoints (
Iterable
[Iterable
[float
]]) – list or array containing the relative coordinates of the kpointsweights (
Iterable
[float
]) – list or array containing the weights of the kpoints
- Return type:
- Returns:
an xmltree of the inp.xml file with changes.
- masci_tools.util.xml.xml_setters_names.set_kpointmesh(xmltree, schema_dict, mesh, name=None, use_symmetries=True, switch=False, overwrite=False, shift=None, time_reversal=True, map_to_first_bz=True)[source]¶
Create a kpoint mesh using spglib
for details see
get_stabilized_reciprocal_mesh()
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – xml tree that represents inp.xmlschema_dict (
SchemaDict
) – InputSchemaDict containing all information about the structure of the inputmesh (
Collection
[int
]) – list-like woth three elements, giving the size of the kpoint set in each directionuse_symmetry – bool if True the available symmetry operations in the inp.xml will be used to reduce the kpoint set otherwise only the identity matrix is used
name (
Optional
[str
]) – Name of the created kpoint list. If not given a name is generatedswitch (
bool
) – bool if True the kpoint list is direclty set as the used setoverwrite (
bool
) – if True and a kpoint list of the given name already exists it will be overwrittenshift (
Optional
[Iterable
[float
]]) – shift the center of the kpint settime_reversal (
bool
) – bool if True time reversal symmetry will be used to reduce the kpoint setmap_to_first_bz (
bool
) – bool if True the kpoints are mapped into the [0,1] interval
- Return type:
- Returns:
xmltree with a created kpoint path
- masci_tools.util.xml.xml_setters_names.set_kpointpath(xmltree, schema_dict, path=None, nkpts=None, density=None, name=None, switch=False, overwrite=False, special_points=None)[source]¶
Create a kpoint list for a bandstructure calculation (using ASE kpath generation)
The path can be defined explictly (see
bandpath()
) or derived from the unit cell- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – xml tree that represents inp.xmlschema_dict (
SchemaDict
) – InputSchemaDict containing all information about the structure of the inputpath (
Union
[str
,list
[str
],None
]) – str, list of str or None defines the path to interpolate (for syntaxbandpath()
)density (
Optional
[float
]) – float number of kpoints per Angstroemname (
Optional
[str
]) – Name of the created kpoint list. If not given a name is generatedswitch (
bool
) – bool if True the kpoint list is direclty set as the used setoverwrite (
bool
) – if True and a kpoint list of the given name already exists it will be overwrittenspecial_points (
Optional
[dict
[str
,Iterable
[float
]]]) – dict mapping names to coordinates for special points to use
- Return type:
- Returns:
xmltree with a created kpoint path
- masci_tools.util.xml.xml_setters_names.set_nkpts(xmltree, schema_dict, count, gamma=False)[source]¶
Sets a k-point mesh directly into inp.xml
Warning
This method is only supported for input versions before the Max5 release
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – xml tree that represents inp.xmlschema_dict (
SchemaDict
) – InputSchemaDict containing all information about the structure of the inputcount (
int
) – number of k-pointsgamma (
bool
) – bool that controls if the gamma-point should be included in the k-point mesh
- Return type:
- Returns:
an xmltree of the inp.xml file with changes.
- masci_tools.util.xml.xml_setters_names.set_nkpts_max4(xmltree, schema_dict, count, gamma=False)[source]¶
Sets a k-point mesh directly into inp.xml specific for inputs of version Max4
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – xml tree that represents inp.xmlschema_dict (
SchemaDict
) – InputSchemaDict containing all information about the structure of the inputcount (
int
) – number of k-pointsgamma (
bool
) – bool that controls if the gamma-point should be included in the k-point mesh
- Return type:
- Returns:
an xmltree of the inp.xml file with changes.
- masci_tools.util.xml.xml_setters_names.set_simple_tag(xmltree, schema_dict, tag_name, changes, complex_xpath=None, filters=None, create_parents=False, **kwargs)[source]¶
Sets one or multiple simple tag(s) in an xmltree. A simple tag can only hold attributes and has no subtags. The tag is specified by its name and further specification If the tag can occur multiple times all existing tags are DELETED and new ones are written. If the tag only occurs once it will automatically be created if its missing.
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – an xmltree that represents inp.xmlschema_dict (
SchemaDict
) – InputSchemaDict containing all information about the structure of the inputtag_name (
str
) – str name of the tag to modify/setchanges (
list
[dict
[str
,Any
]] |dict
[str
,Any
]) – list of dicts or dict with the changes. Elements in list describe multiple tags. Keys in the dictionary correspond to {‘attributename’: attributevalue}complex_xpath (
Union
[str
,bytes
,XPath
,XPathBuilder
,None
]) – an optional xpath to use instead of the simple xpath for the evaluationfilters (
Optional
[Dict
[str
,Any
]]) – Dict specifying constraints to apply on the xpath. SeeXPathBuilder
for detailscreate_parents (
bool
) – bool optional (default False), if True and the path, where the simple tags are set does not exist it is created
- Kwargs:
- param contains:
str, this string has to be in the final path
- param not_contains:
str, this string has to NOT be in the final path
- Return type:
- Returns:
xmltree with set simple tags
- masci_tools.util.xml.xml_setters_names.set_species(xmltree, schema_dict, species_name, changes, filters=None, create=False)[source]¶
Method to set parameters of a species tag of the fleur inp.xml file.
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – xml etree of the inp.xmlschema_dict (
SchemaDict
) – InputSchemaDict containing all information about the structure of the inputspecies_name (
str
) – string, name of the specie you want to change Can be name of the species, ‘all’ or ‘all-<string>’ (sets species with the string in the species name)changes (
dict
[str
,Any
]) – a python dict specifying what you want to change.create (
bool
) – bool, if species does not exist create it and all subtags?filters (
Optional
[Dict
[str
,Any
]]) – Dict specifying constraints to apply on the xpath. SeeXPathBuilder
for details
- Raises:
ValueError – if species name is non existent in inp.xml and should not be created. also if other given tags are garbage. (errors from eval_xpath() methods)
- Return xmltree:
xml etree of the new inp.xml
- Return type:
changes is a python dictionary containing dictionaries that specify attributes to be set inside the certain specie. For example, if one wants to set a MT radius it can be done via:
changes = {'mtSphere' : {'radius' : 2.2}}
Another example:
'changes': {'special': {'socscale': 0.0}}
that switches SOC terms on a sertain specie.
mtSphere
,atomicCutoffs
,energyParameters
,lo
,electronConfig
,nocoParams
,ldaU
andspecial
keys are supported. To find possible keys of the inner dictionary please refer to the FLEUR documentation flapw.de
- masci_tools.util.xml.xml_setters_names.set_species_label(xmltree, schema_dict, atom_label, changes, create=False)[source]¶
This method calls
set_species()
method for a certain atom species that corresponds to an atom with a given label- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – xml etree of the inp.xmlschema_dict (
SchemaDict
) – InputSchemaDict containing all information about the structure of the inputatom_label (
str
) – string, a label of the atom which specie will be changed. ‘all’ to change all the specieschanges (
dict
[str
,Any
]) – a python dict specifying what you want to change.create (
bool
) – bool, if species does not exist create it and all subtags?
- Return type:
- Returns:
xml etree of the new inp.xml
- masci_tools.util.xml.xml_setters_names.set_text(xmltree, schema_dict, tag_name, text, complex_xpath=None, filters=None, occurrences=None, create=False, **kwargs)[source]¶
Sets the text on tags in a xmltree to a given value, specified by the name of the tag and further specifications. By default the text will be set on all nodes returned for the specified xpath. If there are no nodes under the specified xpath a tag can be created with create=True. The text values are converted automatically according to the types with
convert_to_xml()
if they are not str already.- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – an xmltree that represents inp.xmlschema_dict (
SchemaDict
) – InputSchemaDict containing all information about the structure of the inputtag_name (
str
) – str name of the tag, where the text should be settext (
Any
) – value or list of values to setcomplex_xpath (
Union
[str
,bytes
,XPath
,XPathBuilder
,None
]) – an optional xpath to use instead of the simple xpath for the evaluationfilters (
Optional
[Dict
[str
,Any
]]) – Dict specifying constraints to apply on the xpath. SeeXPathBuilder
for detailsoccurrences (
Union
[int
,Iterable
[int
],None
]) – int or list of int. Which occurrence of the node to set. By default all are set.create (
bool
) – bool optional (default False), if True the tag is created if is missing
- Kwargs:
- param contains:
str, this string has to be in the final path
- param not_contains:
str, this string has to NOT be in the final path
- Return type:
- Returns:
xmltree with set text
- masci_tools.util.xml.xml_setters_names.set_xcfunctional(xmltree, schema_dict, xc_functional, xc_functional_options=None, libxc=False)[source]¶
Set the Exchange Correlation potential tag
Setting a inbuilt XC functional .. code-block:: python
set_xcfunctional(xmltree, schema_dict, ‘vwn’)
Setting a LibXC XC functional .. code-block:: python
set_xcfunctional(xmltree, schema_dict, {‘exchange’: ‘lda_x’, ‘correlation’:”lda_c_xalpha”}, libxc=True)
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – XML tree that represents inp.xmlschema_dict (
SchemaDict
) – InputSchemaDict containing all information about the structure of the inputxc_functional (
str
|dict
[str
,int
|str
]) – str or dict. If str it is the name of a inbuilt XC functional. If it is a dict it specifies either the name or id for LibXC functionals for the keys ‘exchange’, ‘correlation’, ‘etot_exchange’ and ‘etot_correlation’xc_functional_options (
Optional
[dict
[str
,Any
]]) – dict with further general changes to the xcFunctional taglibxc (
bool
) – bool if True the functional is a LibXC functional
- Return type:
- Returns:
an xmltree with modified xcFunctional tag
- masci_tools.util.xml.xml_setters_names.shift_value(xmltree, schema_dict, changes, mode='absolute', path_spec=None)[source]¶
Shifts numerical values of attributes directly in the inp.xml file.
The first occurrence of the attribute is shifted
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – xml tree that represents inp.xmlschema_dict (
SchemaDict
) – InputSchemaDict containing all information about the structure of the inputchanges (
dict
[str
,Any
]) – a python dictionary with the keys to shift and the shift values.mode (
Literal
['abs'
,'absolute'
,'rel'
,'relative'
]) – str (either rel/relative or abs/absolute). rel/relative multiplies the old value with the given value abs/absolute adds the old value and the given valuepath_spec (
Optional
[dict
[str
,Any
]]) – dict, with ggf. necessary further specifications for the path of the attribute
- Return type:
- Returns:
a xml tree with shifted values
An example of changes:
changes = {'itmax' : 1, 'dVac': -0.123}
- masci_tools.util.xml.xml_setters_names.shift_value_species_label(xmltree, schema_dict, atom_label, attribute_name, number_to_add, mode='absolute', **kwargs)[source]¶
Shifts the value of an attribute on a species by label if atom_label contains ‘all’ then applies to all species
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – xml etree of the inp.xmlschema_dict (
SchemaDict
) – InputSchemaDict containing all information about the structure of the inputatom_label (
str
) – string, a label of the atom which specie will be changed. ‘all’ if set up all speciesattribute_name (
str
) – name of the attribute to changenumber_to_add (
Any
) – value to add or to multiply bymode (
Literal
['abs'
,'absolute'
,'rel'
,'relative'
]) – str (either rel/relative or abs/absolute). rel/relative multiplies the old value with number_to_add abs/absolute adds the old value and number_to_add
- Kwargs if the attribute_name does not correspond to a unique path:
- param contains:
str, this string has to be in the final path
- param not_contains:
str, this string has to NOT be in the final path
- Return type:
- Returns:
xml etree of the new inp.xml
- masci_tools.util.xml.xml_setters_names.switch_kpointset(xmltree, schema_dict, list_name)[source]¶
Switch the used k-point set
Warning
This method is only supported for input versions after the Max5 release
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – xml tree that represents inp.xmlschema_dict (
SchemaDict
) – InputSchemaDict containing all information about the structure of the inputlist_name (
str
) – name of the kPoint set to use
- Return type:
- Returns:
an xmltree of the inp.xml file with changes.
- masci_tools.util.xml.xml_setters_names.switch_kpointset_max4(xmltree, schema_dict, list_name)[source]¶
Sets a k-point mesh directly into inp.xml specific for inputs of version Max4
Warning
This method is only supported for input versions after the Max5 release
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – xml tree that represents inp.xmlschema_dict (
SchemaDict
) – InputSchemaDict containing all information about the structure of the inputlist_name (
str
) – name of the kPoint set to use
- Return type:
- Returns:
an xmltree of the inp.xml file with changes.
- masci_tools.util.xml.xml_setters_names.switch_species(xmltree, schema_dict, new_species_name, position=None, species=None, filters=None, clone=False, changes=None)[source]¶
Method to switch the species of an atom group of the fleur inp.xml file.
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – xml etree of the inp.xmlschema_dict (
SchemaDict
) – InputSchemaDict containing all information about the structure of the inputnew_species_name (
str
) – name of the species to switch toposition (
Union
[int
,Literal
['all'
],None
]) – position of an atom group to be changed. If equals to ‘all’, all species will be changedspecies (
Optional
[str
]) – atom groups, corresponding to the given species will be changedclone (
bool
) – if True and the new species name does not exist and it corresponds to changing from one species the species will be cloned withclone_species()
changes (
Optional
[dict
[str
,Any
]]) – changes to do if the species is clonedfilters (
Optional
[Dict
[str
,Any
]]) – Dict specifying constraints to apply on the xpath. SeeXPathBuilder
for details
- Return type:
- Returns:
xml etree of the new inp.xml
- masci_tools.util.xml.xml_setters_names.switch_species_label(xmltree, schema_dict, atom_label, new_species_name, clone=False, changes=None)[source]¶
Method to switch the species of an atom group of the fleur inp.xml file based on a label of a contained atom
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – xml etree of the inp.xmlschema_dict (
SchemaDict
) – InputSchemaDict containing all information about the structure of the inputatom_label (
str
) – string, a label of the atom which group will be changed. ‘all’ to change all the groupsnew_species_name (
str
) – name of the species to switch toclone (
bool
) – if True and the new species name does not exist and it corresponds to changing from one species the species will be cloned withclone_species()
changes (
Optional
[dict
[str
,Any
]]) – changes to do if the species is cloned
- Return type:
- Returns:
xml etree of the new inp.xml
This module contains useful methods for initializing or modifying a n_mmp_mat file for LDA+U
- class masci_tools.util.xml.xml_setters_nmmpmat.LDAUElement(species: str, orbital: int, group_index: int)[source]¶
Contains the important information needed to locate the associated density matrix blocks
- masci_tools.util.xml.xml_setters_nmmpmat.align_nmmpmat_to_sqa(xmltree, nmmplines, schema_dict, species_name='all', orbital='all', phi_before=0.0, theta_before=0.0, filters=None)[source]¶
Align the density matrix with the given SQA of the associated species
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – an xmltree that represents inp.xmlschema_dict (
SchemaDict
) – InputSchemaDict containing all information about the structure of the inputspecies_name (
str
) – string, name of the species you want to changeorbital (
int
|str
) – integer or string (‘all’), orbital quantum number of the LDA+U procedure to be modifiedphi_before (
float
|list
[float
]) – float or list of floats, angle (radian), values for phi for the previous alignment of the density matrixtheta_before (
float
|list
[float
]) – float or list of floats, angle (radian), values for theta for the previous alignment of the density matrixfilters (
Optional
[Dict
[str
,Any
]]) – Dict specifying constraints to apply on the xpath. SeeXPathBuilder
for details
- Raises:
ValueError – If something in the input is wrong
KeyError – If no LDA+U procedure is found on a species
- Return type:
- Returns:
list with modified nmmplines
- masci_tools.util.xml.xml_setters_nmmpmat.rotate_nmmpmat(xmltree, nmmplines, schema_dict, species_name, orbital, phi, theta, inverse=False, filters=None)[source]¶
Rotate the density matrix with the given angles phi and theta
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – an xmltree that represents inp.xmlschema_dict (
SchemaDict
) – InputSchemaDict containing all information about the structure of the inputspecies_name (
str
) – string, name of the species you want to changeorbital (
int
|str
) – integer or string (‘all’), orbital quantum number of the LDA+U procedure to be modifiedphi (
float
) – float, angle (radian), by which to rotate the density matrixtheta (
float
) – float, angle (radian), by which to rotate the density matrixfilters (
Optional
[Dict
[str
,Any
]]) – Dict specifying constraints to apply on the xpath. SeeXPathBuilder
for details
- Raises:
ValueError – If something in the input is wrong
KeyError – If no LDA+U procedure is found on a species
- Return type:
- Returns:
list with modified nmmplines
- masci_tools.util.xml.xml_setters_nmmpmat.set_nmmpmat(xmltree, nmmplines, schema_dict, species_name, orbital, spin, state_occupations=None, orbital_occupations=None, denmat=None, phi=None, theta=None, inverse=False, align_to_sqa=False, filters=None)[source]¶
Routine sets the block in the n_mmp_mat file specified by species_name, orbital and spin to the desired density matrix
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – an xmltree that represents inp.xmlnmmplines (
Optional
[list
[str
]]) – list of lines in the n_mmp_mat fileschema_dict (
SchemaDict
) – InputSchemaDict containing all information about the structure of the inputspecies_name (
str
) – string, name of the species you want to changeorbital (
int
) – integer, orbital quantum number of the LDA+U procedure to be modifiedspin (
int
) – integer, specifies which spin block should be modifiedstate_occupations (
Optional
[list
[float
]]) – list, sets the diagonal elements of the density matrix and everything else to zerodenmat (
Optional
[ndarray
]) – matrix, specify the density matrix explicitlyphi (
Optional
[float
]) – float, optional angle (radian), by which to rotate the density matrix before writing ittheta (
Optional
[float
]) – float, optional angle (radian), by which to rotate the density matrix before writing itfilters (
Optional
[Dict
[str
,Any
]]) – Dict specifying constraints to apply on the xpath. SeeXPathBuilder
for details
- Raises:
ValueError – If something in the input is wrong
KeyError – If no LDA+U procedure is found on a species
- Return type:
- Returns:
list with modified nmmplines
- masci_tools.util.xml.xml_setters_nmmpmat.validate_nmmpmat(xmltree, nmmplines, schema_dict)[source]¶
Checks that the given nmmp_lines is valid with the given xmltree
Checks that the number of blocks is as expected from the inp.xml and each block does not contain non-zero elements outside their size given by the orbital quantum number in the inp.xml. Additionally the occupations, i.e. diagonal elements are checked that they are in between 0 and the maximum possible occupation
- Parameters:
- Raises:
ValueError – if any of the above checks are violated.
- Return type:
Functions for modifying the xml input file of Fleur with explicit xpath arguments These can still use the schema dict for finding information about the xpath
- masci_tools.util.xml.xml_setters_xpaths.eval_xpath_create(xmltree, schema_dict, xpath, base_xpath, create_parents=False, occurrences=None, number_nodes=1)[source]¶
Evaluates and xpath and creates tag if the result is empty
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – an xmltree that represents inp.xmlschema_dict (
SchemaDict
) – InputSchemaDict containing all information about the structure of the inputxpath (
Union
[str
,bytes
,XPath
,XPathBuilder
]) – a path where to place a new tagbase_xpath (
str
) – path where to place a new tag without complex syntax ([] conditions and so on)create_parents (
bool
) – bool optional (default False), if True also the parents of the tag are created if they are missingoccurrences (
Union
[int
,Iterable
[int
],None
]) – int or list of int. Which occurrence of the parent nodes to create a tag if the tag is missing. By default all nodes are used.list_return – if True, the returned quantity is always a list even if only one element is in it
number_nodes (
int
) – how many identical nodes to create
- Return type:
- Returns:
list of nodes from the result of the xpath expression
- masci_tools.util.xml.xml_setters_xpaths.xml_add_number_to_attrib(xmltree, schema_dict, xpath, base_xpath, name, number_to_add, mode='absolute', occurrences=None)[source]¶
Adds a given number to the attribute value in a xmltree. By default the attribute will be shifted on all nodes returned for the specified xpath. If there are no nodes under the specified xpath an error is raised
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – an xmltree that represents inp.xmlschema_dict (
SchemaDict
) – InputSchemaDict containing all information about the structure of the inputxpath (
Union
[str
,bytes
,XPath
,XPathBuilder
]) – a path where to set the attributesbase_xpath (
str
) – path where to place a new tag without complex syntax ([] conditions and so on)name (
str
) – the attribute name to changenumber_to_add (
Any
) – number to add/multiply with the old attribute valuemode (
Literal
['abs'
,'absolute'
,'rel'
,'relative'
]) – str (either rel/relative or abs/absolute). rel/relative multiplies the old value with number_to_add abs/absolute adds the old value and number_to_addoccurrences (
Union
[int
,Iterable
[int
],None
]) – int or list of int. Which occurrence of the node to set. By default all are set.
- Raises:
ValueError – If the attribute is unknown or cannot be float or int
ValueError – If the evaluation of the old values failed
ValueError – If a float result is written to a integer attribute
- Return type:
- Returns:
xmltree with shifted attribute
- masci_tools.util.xml.xml_setters_xpaths.xml_add_number_to_first_attrib(xmltree, schema_dict, xpath, base_xpath, name, number_to_add, mode='absolute')[source]¶
Adds a given number to the first occurrence of a attribute value in a xmltree. If there are no nodes under the specified xpath an error is raised
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – an xmltree that represents inp.xmlschema_dict (
SchemaDict
) – InputSchemaDict containing all information about the structure of the inputxpath (
Union
[str
,bytes
,XPath
,XPathBuilder
]) – a path where to set the attributesbase_xpath (
str
) – path where to place a new tag without complex syntax ([] conditions and so on)name (
str
) – the attribute name to changenumber_to_add (
Any
) – number to add/multiply with the old attribute valuemode (
Literal
['abs'
,'absolute'
,'rel'
,'relative'
]) – str (either rel/relative or abs/absolute). rel/relative multiplies the old value with number_to_add abs/absolute adds the old value and number_to_add
- Raises:
ValueError – If the attribute is unknown or cannot be float or int
ValueError – If the evaluation of the old values failed
ValueError – If a float result is written to a integer attribute
- Return type:
- Returns:
xmltree with shifted attribute
- masci_tools.util.xml.xml_setters_xpaths.xml_create_tag_schema_dict(xmltree, schema_dict, xpath, base_xpath, element, create_parents=False, number_nodes=1, occurrences=None)[source]¶
This method evaluates an xpath expression and creates a tag in a xmltree under the returned nodes. If there are no nodes evaluated the subtags can be created with create_parents=True
The tag is always inserted in the correct place if a order is enforced by the schema
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – an xmltree that represents inp.xmlschema_dict (
SchemaDict
) – InputSchemaDict containing all information about the structure of the inputxpath (
Union
[str
,bytes
,XPath
,XPathBuilder
]) – a path where to place a new tagbase_xpath (
str
) – path where to place a new tag without complex syntax ([] conditions and so on)element (
QName
|str
|_Element
) – a tag name or etree Element or string representing the XML element to be createdcreate_parents (
bool
) – bool optional (default False), if True and the given xpath has no results the the parent tags are created recursivelyoccurrences (
Union
[int
,Iterable
[int
],None
]) – int or list of int. Which occurrence of the parent nodes to create a tag. By default all nodes are used.number_nodes (
int
) – how many identical nodes to create
- Raises:
ValueError – If the nodes are missing and create_parents=False
- Return type:
- Returns:
xmltree with created tags
- masci_tools.util.xml.xml_setters_xpaths.xml_set_attrib_value(xmltree, schema_dict, xpath, base_xpath, name, value, occurrences=None, create=False)[source]¶
Sets an attribute in a xmltree to a given value. By default the attribute will be set on all nodes returned for the specified xpath. If there are no nodes under the specified xpath a tag can be created with create=True. The attribute values are converted automatically according to the types of the attribute with
convert_to_xml()
if they are not str already.- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – an xmltree that represents inp.xmlschema_dict (
SchemaDict
) – InputSchemaDict containing all information about the structure of the inputxpath (
Union
[str
,bytes
,XPath
,XPathBuilder
]) – a path where to set the attributesbase_xpath (
str
) – path where to place a new tag without complex syntax ([] conditions and so on)name (
str
) – the attribute name to setvalue (
Any
) – value or list of values to setoccurrences (
Union
[int
,Iterable
[int
],None
]) – int or list of int. Which occurrence of the node to set. By default all are set.create (
bool
) – bool optional (default False), if True the tag is created if is missing
- Raises:
ValueError – If the conversion to string failed
ValueError – If the tag is missing and create=False
ValueError – If the name is not allowed on the base_xpath
- Return type:
- Returns:
xmltree with set attribute
- masci_tools.util.xml.xml_setters_xpaths.xml_set_complex_tag(xmltree, schema_dict, xpath, base_xpath, changes, create=False)[source]¶
Recursive function to correctly set tags/attributes for a given tag and it’s subtags. Goes through the changes dictionary and decides based on the schema_dict, how the corresponding key has to be handled.
Supports:
attributes
tags with text only
simple tags, i.e. only attributes (can be optional single/multiple)
complex tags, will recursively create/modify them
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – an xmltree that represents inp.xmlschema_dict (
SchemaDict
) – InputSchemaDict containing all information about the structure of the inputxpath (
Union
[str
,bytes
,XPath
,XPathBuilder
]) – a path where to set the attributesbase_xpath (
str
) – path where to place a new tag without complex syntax ([] conditions and so on)tag_name – name of the tag to set
changes (
dict
[str
,Any
]) – Keys in the dictionary correspond to names of tags and the values are the modifications to do on this tag (attributename, subdict with changes to the subtag, …)create (
bool
) – bool optional (default False), if True and the path, where the complex tag is set does not exist it is created
- Return type:
- Returns:
xmltree with changes to the complex tag
- masci_tools.util.xml.xml_setters_xpaths.xml_set_first_attrib_value(xmltree, schema_dict, xpath, base_xpath, name, value, create=False)[source]¶
Sets the first occurrence attribute in a xmltree to a given value. If there are no nodes under the specified xpath a tag can be created with create=True. The attribute values are converted automatically according to the types of the attribute with
convert_to_xml()
if they are not str already.- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – an xmltree that represents inp.xmlschema_dict (
SchemaDict
) – InputSchemaDict containing all information about the structure of the inputxpath (
Union
[str
,bytes
,XPath
,XPathBuilder
]) – a path where to set the attributebase_xpath (
str
) – path where to place a new tag without complex syntax ([] conditions and so on)name (
str
) – the attribute name to setvalue (
Any
) – value or list of values to setcreate (
bool
) – bool optional (default False), if True the tag is created if is missing
- Raises:
ValueError – If the conversion to string failed
ValueError – If the tag is missing and create=False
ValueError – If the attributename is not allowed on the base_xpath
- Return type:
- Returns:
xmltree with set attribute
- masci_tools.util.xml.xml_setters_xpaths.xml_set_first_text(xmltree, schema_dict, xpath, base_xpath, text, create=False)[source]¶
Sets the text on the first occurrence of a tag in a xmltree to a given value. If there are no nodes under the specified xpath a tag can be created with create=True. The text values are converted automatically according to the types with
convert_to_xml()
if they are not str already.- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – an xmltree that represents inp.xmlschema_dict (
SchemaDict
) – InputSchemaDict containing all information about the structure of the inputxpath (
Union
[str
,bytes
,XPath
,XPathBuilder
]) – a path where to set the textbase_xpath (
str
) – path where to place a new tag without complex syntax ([] conditions and so on)text (
Any
) – value or list of values to setcreate (
bool
) – bool optional (default False), if True the tag is created if is missing
- Raises:
ValueError – If the conversion to string failed
ValueError – If the tag is missing and create=False
- Return type:
- Returns:
xmltree with set text
- masci_tools.util.xml.xml_setters_xpaths.xml_set_simple_tag(xmltree, schema_dict, xpath, base_xpath, tag_name, changes, create_parents=False)[source]¶
Sets one or multiple simple tag(s) in an xmltree. A simple tag can only hold attributes and has no subtags. If the tag can occur multiple times all existing tags are DELETED and new ones are written. If the tag only occurs once it will automatically be created if its missing.
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – an xmltree that represents inp.xmlschema_dict (
SchemaDict
) – InputSchemaDict containing all information about the structure of the inputxpath (
Union
[str
,bytes
,XPath
,XPathBuilder
]) – a path where to set the attributesbase_xpath (
str
) – path where to place a new tag without complex syntax ([] conditions and so on)tag_name (
str
) – name of the tag to setchanges (
list
[dict
[str
,Any
]] |dict
[str
,Any
]) – list of dicts or dict with the changes. Elements in list describe multiple tags. Keys in the dictionary correspond to {‘name’: value}create_parents (
bool
) – bool optional (default False), if True and the path, where the simple tags are set does not exist it is created
- Return type:
- Returns:
xmltree with set simple tags
- masci_tools.util.xml.xml_setters_xpaths.xml_set_text(xmltree, schema_dict, xpath, base_xpath, text, occurrences=None, create=False)[source]¶
Sets the text on tags in a xmltree to a given value. By default the text will be set on all nodes returned for the specified xpath. If there are no nodes under the specified xpath a tag can be created with create=True. The text values are converted automatically according to the types with
convert_to_xml()
if they are not str already.- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – an xmltree that represents inp.xmlschema_dict (
SchemaDict
) – InputSchemaDict containing all information about the structure of the inputxpath (
Union
[str
,bytes
,XPath
,XPathBuilder
]) – a path where to set the textbase_xpath (
str
) – path where to place a new tag without complex syntax ([] conditions and so on)text (
Any
) – value or list of values to setoccurrences (
Union
[int
,Iterable
[int
],None
]) – int or list of int. Which occurrence of the node to set. By default all are set.create (
bool
) – bool optional (default False), if True the tag is created if is missing
- Raises:
ValueError – If the conversion to string failed
ValueError – If the tag is missing and create=False
- Return type:
- Returns:
xmltree with set text
Basic functions for modifying the xml input file of Fleur. These functions DO NOT
have the ability to create missing tags on the fly. This functionality is added on top
in xml_setters_xpaths
since we need the schema dictionary
to do these operations robustly
- masci_tools.util.xml.xml_setters_basic.xml_create_tag(xmltree, xpath, element, place_index=None, tag_order=None, occurrences=None, correct_order=True, several=True)[source]¶
This method evaluates an xpath expression and creates a tag in a xmltree under the returned nodes. If there are no nodes under the specified xpath an error is raised.
The tag is appended by default, but can be inserted at a certain index (place_index) or can be inserted according to a given order of tags
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – an xmltree that represents inp.xmlxpath (
Union
[str
,bytes
,XPath
,XPathBuilder
]) – a path where to place a new tagelement (
QName
|str
|_Element
) – a tag name, etree Element or string representing the XML element to be createdplace_index (
Optional
[int
]) – defines the place where to put a created tagoccurrences (
Union
[int
,Iterable
[int
],None
]) – int or list of int. Which occurrence of the parent nodes to create a tag. By default all nodes are used.correct_order (
bool
) – bool, if True (default) and a tag_order is given, that does not correspond to the given order in the xmltree (only order wrong no unknown tags) it will be corrected and a warning is given This is necessary for some edge cases of the xml schemas of fleurseveral (
bool
) – bool, if True multiple tags od the given name are allowed
- Raises:
ValueError – If the insertion failed in any way (tag_order does not match, failed to insert, …)
- Return type:
- Returns:
xmltree with created tags
- masci_tools.util.xml.xml_setters_basic.xml_delete_att(xmltree, xpath, name, occurrences=None)[source]¶
Deletes an attribute in the XML tree
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – an xmltree that represents inp.xmlxpath (
Union
[str
,bytes
,XPath
,XPathBuilder
]) – a path to the attribute to be deletedname (
str
) – the name of an attribute to deleteoccurrences (
Union
[int
,Iterable
[int
],None
]) – int or list of int. Which occurrence of the parent nodes to create a tag. By default all nodes are used.
- Return type:
- Returns:
xmltree with deleted attribute
- masci_tools.util.xml.xml_setters_basic.xml_delete_tag(xmltree, xpath, occurrences=None)[source]¶
Deletes a tag in the XML tree.
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – an xmltree that represents inp.xmlxpath (
Union
[str
,bytes
,XPath
,XPathBuilder
]) – a path to the tag to be deletedoccurrences (
Union
[int
,Iterable
[int
],None
]) – int or list of int. Which occurrence of the parent nodes to create a tag. By default all nodes are used.
- Return type:
- Returns:
xmltree with deleted tag
- masci_tools.util.xml.xml_setters_basic.xml_replace_tag(xmltree, xpath, element, occurrences=None)[source]¶
Replace XML tags by a given tag on the given XML tree
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – an xmltree that represents inp.xmlxpath (
Union
[str
,bytes
,XPath
,XPathBuilder
]) – a path to the tag to be replacedelement (
str
|_Element
) – an Element or string representing the Element to replace the found tags withoccurrences (
Union
[int
,Iterable
[int
],None
]) – int or list of int. Which occurrence of the parent nodes to create a tag. By default all nodes are used.
- Return type:
- Returns:
xmltree with replaced tag
- masci_tools.util.xml.xml_setters_basic.xml_set_attrib_value_no_create(xmltree, xpath, name, value, occurrences=None)[source]¶
Sets an attribute in a xmltree to a given value. By default the attribute will be set on all nodes returned for the specified xpath.
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – an xmltree that represents inp.xmlxpath (
Union
[str
,bytes
,XPath
,XPathBuilder
]) – a path where to set the attributesname (
str
) – the attribute name to setvalue (
Any
) – value or list of values to set (if not str they will be converted with str(value))occurrences (
Union
[int
,Iterable
[int
],None
]) – int or list of int. Which occurrence of the node to set. By default all are set.
- Raises:
ValueError – If the lengths of attribv or occurrences do not match number of nodes
- Return type:
- Returns:
xmltree with set attribute
- masci_tools.util.xml.xml_setters_basic.xml_set_text_no_create(xmltree, xpath, text, occurrences=None)[source]¶
Sets the text of a tag in a xmltree to a given value. By default the text will be set on all nodes returned for the specified xpath.
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – an xmltree that represents inp.xmlxpath (
Union
[str
,bytes
,XPath
,XPathBuilder
]) – a path where to set the texttext (
Any
) – value or list of values to set (if not str they will be converted with str(value))occurrences (
Union
[int
,Iterable
[int
],None
]) – int or list of int. Which occurrence of the node to set. By default all are set.
- Raises:
ValueError – If the lengths of text or occurrences do not match number of nodes
- Return type:
- Returns:
xmltree with set text
XML Getter functions¶
This module provides functions to extract distinct parts of the fleur xml files for easy versioning and reuse
- masci_tools.util.xml.xml_getters.get_cell(xmltree, schema_dict, logger=None, convert_to_angstroem=True)[source]¶
Get the Bravais matrix from the given fleur xml file. In addition a list determining in, which directions there are periodic boundary conditions in the system.
Warning
Only the explicit definition of the Bravais matrix is supported. Old inputs containing the latnam definitions are not supported
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – etree representing the fleur xml fileschema_dict (
InputSchemaDict
|OutputSchemaDict
) – schema dictionary corresponding to the file version of the xmltreelogger (
Optional
[Logger
]) – logger object for logging warnings, errorsconvert_to_angstroem (
bool
) – bool if True the bravais matrix is converted to angstroem
- Return type:
- Returns:
numpy array of the bravais matrix and list of boolean values for periodic boundary conditions
- masci_tools.util.xml.xml_getters.get_fleur_modes(xmltree, schema_dict, logger=None)[source]¶
Determine the calculation modes of fleur for the given xml file. Calculation modes are things that change the produced files or output in the out.xml files
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – etree representing the fleur xml fileschema_dict (
InputSchemaDict
|OutputSchemaDict
) – schema dictionary corresponding to the file version of the xmltreelogger (
Optional
[Logger
]) – logger object for logging warnings, errors
- Return type:
- Returns:
dictionary with all the extracted calculation modes
The following modes are inspected:
jspin: How many spins are considered in the calculation
noco: Is the calculation non-collinear?
soc: Is spin-orbit coupling included?
relax: Is the calculation a structure relaxation?
spex: Special mode for GW/Spex calculations
force_theorem: Is a Force theorem calculation performed?
film: Is the structure a film system
ldau: Is LDA+U included?
dos: Is it a density of states calculation?
band: Is it a bandstructure calculation?
bz_integration: How is the integration over the Brillouin-Zone performed?
- masci_tools.util.xml.xml_getters.get_kpoints_data(*args, **kwargs)[source]¶
RENAMED TO get_kpointsdata
- masci_tools.util.xml.xml_getters.get_kpointsdata(xmltree, schema_dict, name=None, index=None, only_used=False, logger=None, convert_to_angstroem=True)[source]¶
Get the kpoint sets defined in the given fleur xml file.
Warning
For file versions before Max5 arguments name, index and only_used have no effect
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – etree representing the fleur xml fileschema_dict (
InputSchemaDict
|OutputSchemaDict
) – schema dictionary corresponding to the file version of the xmltreename (
Optional
[str
]) – str, optional, if given only the kpoint set with the given name is returnedindex (
Optional
[int
]) – int, optional, if given only the kpoint set with the given index is returnedonly_used (
bool
) – bool if True only the kpoint list used in the calculation is returnedlogger (
Optional
[Logger
]) – logger object for logging warnings, errorsconvert_to_angstroem (
bool
) – bool if True the bravais matrix is converted to angstroem
- Return type:
tuple
[list
[list
[float
]] |dict
[str
,list
[list
[float
]]],list
[float
] |dict
[str
,list
[float
]],ndarray
,tuple
[bool
,bool
,bool
]]- Returns:
tuple containing the kpoint information
The tuple contains the following entries:
- kpoints:
dict or list (list if there is only one kpoint set), containing the coordinates of the kpoints
- weights:
dict or list (list if there is only one kpoint set), containing the weights of the kpoints
- cell:
numpy array, bravais matrix of the given system
- pbc:
list of booleans, determines in which directions periodic boundary conditions are applicable
- masci_tools.util.xml.xml_getters.get_kpointsdata_max4(xmltree, schema_dict, name=None, index=None, only_used=False, logger=None, convert_to_angstroem=True)[source]¶
Get the kpoint sets defined in the given fleur xml file.
Note
This function is specific to file version before and including the Max4 release of fleur
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – etree representing the fleur xml fileschema_dict (
InputSchemaDict
|OutputSchemaDict
) – schema dictionary corresponding to the file version of the xmltreelogger (
Optional
[Logger
]) – logger object for logging warnings, errorsconvert_to_angstroem (
bool
) – bool if True the bravais matrix is converted to angstroemonly_used (
bool
) – (Has no effect for Max4) bool if True only the kpoint list used in the calculation is returned
- Return type:
tuple
[list
[list
[float
]],list
[float
],ndarray
,tuple
[bool
,bool
,bool
]]- Returns:
tuple containing the kpoint information
The tuple contains the following entries:
- kpoints:
list containing the coordinates of the kpoints
- weights:
list containing the weights of the kpoints
- cell:
numpy array, bravais matrix of the given system
- pbc:
list of booleans, determines in which directions periodic boundary conditions are applicable
- masci_tools.util.xml.xml_getters.get_nkpts(xmltree, schema_dict, logger=None)[source]¶
Get the number of kpoints that will be used in the calculation specified in the given fleur XMl file.
Warning
For file versions before Max5 only kPointList or kPointCount tags will work. However, for kPointCount there is no real guarantee that for every occasion it will correspond to the number of kpoints. So a warning is written out
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – etree representing the fleur xml fileschema_dict (
InputSchemaDict
|OutputSchemaDict
) – schema dictionary corresponding to the file version of the xmltreelogger (
Optional
[Logger
]) – logger object for logging warnings, errors
- Return type:
- Returns:
int with the number of kpoints
- masci_tools.util.xml.xml_getters.get_nkpts_max4(xmltree, schema_dict, logger=None)[source]¶
Get the number of kpoints that will be used in the calculation specified in the given fleur XMl file. Version specific for Max4 versions or older
Warning
For file versions before Max5 only kPointList or kPointCount tags will work. However, for kPointCount there is no real guarantee that for every occasion it will correspond to the number of kpoints. So a warning is written out
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – etree representing the fleur xml fileschema_dict (
InputSchemaDict
|OutputSchemaDict
) – schema dictionary corresponding to the file version of the xmltreelogger (
Optional
[Logger
]) – logger object for logging warnings, errors
- Return type:
- Returns:
int with the number of kpoints
- masci_tools.util.xml.xml_getters.get_parameter_data(*args, **kwargs)[source]¶
RENAMED TO get_parameterdata
- masci_tools.util.xml.xml_getters.get_parameterdata(xmltree, schema_dict, inpgen_ready=True, write_ids=True, extract_econfig=False, allow_special_los=True, logger=None)[source]¶
This routine returns an python dictionary produced from the inp.xml file, which contains all the parameters needed to setup a new inp.xml from a inpgen input file to produce the same input (for parameters that the inpgen can control)
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – etree representing the fleur xml fileschema_dict (
InputSchemaDict
|OutputSchemaDict
) – schema dictionary corresponding to the file version of the xmltreeinpgen_ready (
bool
) – Bool, return a dict which can be inputted into inpgen while setting atomswrite_ids (
bool
) – Bool, if True the atom ids are added to the atom namelistslogger (
Optional
[Logger
]) – logger object for logging warnings, errors
- Return type:
- Returns:
dict, which will lead to the same inp.xml (in case if other defaults, which can not be controlled by input for inpgen, were changed)
- masci_tools.util.xml.xml_getters.get_relaxation_information(xmltree, schema_dict, logger=None)[source]¶
Get the relaxation information from the given fleur XML file. This includes the current displacements, energy and posforce evolution
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – etree representing the fleur xml fileschema_dict (
InputSchemaDict
|OutputSchemaDict
) – schema dictionary corresponding to the file version of the xmltreelogger (
Optional
[Logger
]) – logger object for logging warnings, errors
- Return type:
- Returns:
dict with the relaxation information
- Raises:
ValueError – If no relaxation section is included in the xml tree
- masci_tools.util.xml.xml_getters.get_relaxation_information_pre029(xmltree, schema_dict, logger=None)[source]¶
Get the relaxation information from the given fleur XML file. This includes the current displacements, energy and posforce evolution
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – etree representing the fleur xml fileschema_dict (
InputSchemaDict
|OutputSchemaDict
) – schema dictionary corresponding to the file version of the xmltreelogger (
Optional
[Logger
]) – logger object for logging warnings, errors
- Return type:
- Returns:
dict with the relaxation information
- Raises:
ValueError – If no relaxation section is included in the xml tree
- masci_tools.util.xml.xml_getters.get_special_kpoints(xmltree, schema_dict, name=None, index=None, only_used=False, logger=None)[source]¶
Extract the labeled special kpoints from the given kpointlist
Warning
Only implemented for versions starting with Max5
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – etree representing the fleur xml fileschema_dict (
InputSchemaDict
|OutputSchemaDict
) – schema dictionary corresponding to the file version of the xmltreename (
Optional
[str
]) – str, optional, if given only the kpoint set with the given name is returnedindex (
Optional
[int
]) – int, optional, if given only the kpoint set with the given index is returnedonly_used (
bool
) – bool if True only the kpoint list used in the calculation is returnedlogger (
Optional
[Logger
]) – logger object for logging warnings, errors
- Return type:
- Returns:
list of tuples (index, label) for multiple kpoint sets a dict with the names containing the list of tuples is returned
- masci_tools.util.xml.xml_getters.get_special_kpoints_max4(xmltree, schema_dict, name=None, index=None, only_used=False, logger=None)[source]¶
Extract the labeled special kpoints from the given kpointlist
Warning
Only implemented for versions starting with Max5
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – etree representing the fleur xml fileschema_dict (
InputSchemaDict
|OutputSchemaDict
) – schema dictionary corresponding to the file version of the xmltreename (
Optional
[str
]) – str, optional, if given only the kpoint set with the given name is returnedindex (
Optional
[int
]) – int, optional, if given only the kpoint set with the given index is returnedonly_used (
bool
) – bool if True only the kpoint list used in the calculation is returnedlogger (
Optional
[Logger
]) – logger object for logging warnings, errors
- Return type:
- Returns:
list of tuples (index, label) for multiple kpoint sets a dict with the names containing the list of tuples is returned
- masci_tools.util.xml.xml_getters.get_structure_data(*args, **kwargs)[source]¶
RENAMED TO get_structuredata
- masci_tools.util.xml.xml_getters.get_structuredata(xmltree, schema_dict, include_relaxations=True, convert_to_angstroem=True, normalize_kind_name=True, extract_magnetic_moments=True, logger=None, **kwargs)[source]¶
Get the structure defined in the given fleur xml file.
Warning
Only the explicit definition of the Bravais matrix is supported. Old inputs containing the latnam definitions are not supported
Warning
In versions
0.5.0
or later the output of the atom sites was restructured to be more interoperable with other IO functions (e.g.write_inpgen_file()
) The new format returns a list ofAtomSiteProperties
instead of the list of tuples (position, symbol)For better compatibility this output is not default in
0.5.0
but instead is enabled bysite_namedtuple=True
and a DeprecationWarning is given when this argument isFalse
.Note
In versions
0.5.0
or later the returned atom positions correspond to the relaxed structure if arelaxation
section is present in the xmltree- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – etree representing the fleur xml fileschema_dict (
InputSchemaDict
|OutputSchemaDict
) – schema dictionary corresponding to the file version of the xmltreeinclude_relaxations (
bool
) – bool if True and a relaxation section is included the resulting positions correspond to the relaxed structurelogger (
Optional
[Logger
]) – logger object for logging warnings, errorsconvert_to_angstroem (
bool
) – bool if True the bravais matrix is converted to angstroemextract_magnetic_moments (
bool
) – bool, if True (default) the magnetic moments are also extracted and put onto the atom_data output
- Return type:
tuple
[list
[AtomSiteProperties
],ndarray
,tuple
[bool
,bool
,bool
]]- Returns:
tuple containing the structure information
The tuple contains the following entries:
- atom_data:
list of (named)tuples containing the absolute positions and symbols of the atoms
- cell:
numpy array, bravais matrix of the given system
- pbc:
list of booleans, determines in which directions periodic boundary conditions are applicable
Changed in version 0.7.0: The default for site_namedtuple is set to True
Changed in version 0.10.0: The argument site_namedtuple was deprecated. The old output is no longer supported. If the argument site_namedtuple is passed a deprecation warning is shown
- masci_tools.util.xml.xml_getters.get_symmetry_information(xmltree, schema_dict, logger=None)[source]¶
Get the symmetry information from the given fleur XML file. This includes the rotation matrices and shifts defined in the
symmetryOperations
tag.Note
Only the explicit definition of the used symmetry operations in the xml file is supported.
- Parameters:
xmltree (
Union
[_Element
,_ElementTree
]) – etree representing the fleur xml fileschema_dict (
InputSchemaDict
|OutputSchemaDict
) – schema dictionary corresponding to the file version of the xmltreelogger (
Optional
[Logger
]) – logger object for logging warnings, errors
- Return type:
- Returns:
tuple of the rotations and their respective shifts
- Raises:
ValueError – If no symmetryOperations section is included in the xml tree
Basic IO helper functions¶
Here commonly used functions that do not need aiida-stuff (i.e. can be tested without a database) are collected.
- class masci_tools.io.common_functions.AtomSiteProperties(position: list[float], symbol: str, kind: str, magnetic_moment: Literal['up', 'down'] | float | list[float] | None = None)[source]¶
namedtuple used for input output of atom sites
- masci_tools.io.common_functions._TVectorType¶
Generic type variable for atom position types
alias of TypeVar(‘_TVectorType’, bound=
Union
[Tuple
[float
,float
,float
],List
[float
],ndarray
])
- masci_tools.io.common_functions.abs_to_rel(vector, cell)[source]¶
Converts a position vector in absolute coordinates to relative coordinates.
- masci_tools.io.common_functions.abs_to_rel_f(vector, cell, pbc)[source]¶
Converts a position vector in absolute coordinates to relative coordinates for a film system.
- Parameters:
vector (
TypeVar
(_TVectorType
, bound=Union
[Tuple
[float
,float
,float
],List
[float
],ndarray
])) – list or np.array of length 3, vector to be convertedcell (
list
[list
[float
]] |ndarray
) – Bravais matrix of a crystal 3x3 Array, List of list or np.arraypbc (
tuple
[bool
,bool
,bool
]) – Boundary conditions, List or Tuple of 3 Boolean
- Return type:
TypeVar
(_TVectorType
, bound=Union
[Tuple
[float
,float
,float
],List
[float
],ndarray
])- Returns:
list of length 3 of scaled vector, or False if vector was not length 3
- masci_tools.io.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
- Return type:
- masci_tools.io.common_functions.camel_to_snake(name)[source]¶
Converts camelCase to snake_case variable names Used in the Fleur parser to convert attribute names from the xml files
- Return type:
- masci_tools.io.common_functions.convert_to_fortran_string(string)[source]¶
converts some parameter strings to the format for the inpgen :type string:
str
:param string: some string :rtype:str
:returns: string in right format (extra “” if not already present)
- masci_tools.io.common_functions.convert_to_pystd(value)[source]¶
Recursively convert numpy datatypes to standard python, needed by aiida-core.
- Return type:
- Usage:
converted = convert_to_pystd(to_convert)
where to_convert can be a dict, array, list, or single valued variable
- masci_tools.io.common_functions.filter_out_empty_dict_entries(dict_to_filter)[source]¶
Filter out entries in a given dict that correspond to empty values. At the moment this is empty lists, dicts and None
- masci_tools.io.common_functions.find_symmetry_relation(from_pos, to_pos, rotations, shifts, cell, relative_pos=False, film=False)[source]¶
Find symmetry relation between the given vectors. This functions assumes that a symmetry relation exists otherwise an error is raised
- Parameters:
from_pos (
Union
[Tuple
[float
,float
,float
],List
[float
],ndarray
]) – vector to rotateto_pos (
Union
[Tuple
[float
,float
,float
],List
[float
],ndarray
]) – vector to rotate torotations (
list
[ndarray
]) – list of np.arrays with the given symmetry rotationsshifts (
list
[ndarray
]) – list of np.arrays with the given shifts for the symmetry operationscell (
list
[list
[float
]] |ndarray
) – Bravais matrix of a crystal 3x3 Array, List of list or np.arrayrelative_pos (
bool
) – bool if True the given vectors are assuemd to be in internal coordinatesfilm (
bool
) – bool if True the vectors are assumed to be film coordinates
- Return type:
- Returns:
tuple of rotation and shift mapping
from_pos
toto_pos
- Raises:
ValueError – If no symmetry relation is found
- masci_tools.io.common_functions.get_corestates_from_potential(potfile='potential')[source]¶
Read core states from potential file
- masci_tools.io.common_functions.get_ef_from_potfile(potfile)[source]¶
extract fermi energy from potfile
- Return type:
- masci_tools.io.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
- masci_tools.io.common_functions.get_outfile_txt(outfile)[source]¶
Get the content of a file In case the outfile is a file handle, we just roll it back and read everything in again. For an ordinary file path we open the file in a context manager and then read it.
- masci_tools.io.common_functions.get_pauli_matrix(direction, alpha=0.0, beta=0.0)[source]¶
Get the pauli matrix with additional rotation applied
- masci_tools.io.common_functions.get_spin_rotation(alpha, beta)[source]¶
Get matrix to rotate the spin frame by the given angles alpha/beta
- masci_tools.io.common_functions.get_wigner_matrix(l, alpha, beta, gamma=0.0, inverse=False)[source]¶
Produces the wigner rotation matrix for the density matrix
- masci_tools.io.common_functions.interpolate_dos(dosfile, 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 – either absolute path of ‘complex.dos’ file or file handle to it
- Returns:
E_Fermi, numpy array of interpolated dos
- Note:
output units are in Ry!
- masci_tools.io.common_functions.open_general(filename_or_handle, iomode=None)[source]¶
Open a file directly from a path or use a file handle if that is given. Also take care of closed files by reopenning them. This is intended to be used like this:
with open_general(outfile) as f: txt = f.readlines()
- masci_tools.io.common_functions.rel_to_abs(vector, cell)[source]¶
Converts a position vector in internal coordinates to absolute coordinates in Angstrom.
- masci_tools.io.common_functions.rel_to_abs_f(vector, cell)[source]¶
Converts a position vector in internal coordinates to absolute coordinates in Angstrom for a film structure (2D).
- masci_tools.io.common_functions.skipHeader(seq, n)[source]¶
Iterate over a sequence skipping the first n elements
- Args:
seq (iterable): Iterable sequence n (int): Number of Elements to skip in the beginning of the sequence
- Yields:
item: Elements in seq after the first n elements
- masci_tools.io.common_functions.vec_to_angles(vec)[source]¶
converts vector (x,y,z) to (magnitude, theta, phi)
Small utility functions for inspecting hdf files and converting the complete file structure into a python dictionary
- masci_tools.io.hdf5_util.h5dump(file, group='/')[source]¶
Shows the overall filestructure of an hdf file Goes through all groups and subgroups and prints the attributes or the shape and datatype of the datasets
- Parameters:
filepath – path to the hdf file
- Return type:
- masci_tools.io.hdf5_util.hdfList(name, obj)[source]¶
Print the name of the current object (indented to create a nice tree structure)
Also prints attribute values and dataset shapes and datatypes
- Return type:
- masci_tools.io.hdf5_util.read_groups(hdfdata, flatten=False)[source]¶
Recursive function to read a hdf datastructure and extract the datasets and attributes
- Parameters:
hdfdata (
Group
) – current hdf group to processflatten (
bool
) – bool, if True the dictionary will be flattened (does not check for lost information)
- Return type:
- Returns:
two dictionaries, one with the datasets the other with the attributes in the file
- masci_tools.io.hdf5_util.read_hdf_simple(file, flatten=False)[source]¶
Reads in an hdf file and returns its context in a nested dictionary
- Parameters:
filepath – path or filehandle to the hdf file
flatten (
bool
) – bool, if True the dictionary will be flattened (does not check for lost information)
- Return type:
- Returns:
two dictionaries, one with the datasets the other with the attributes in the file
Non unique group attribute or dataset names will be overwritten in the return dict
Logging Utility¶
This module defines useful utility for logging related functionality
- class masci_tools.util.logging_util.DictHandler(log_dict, ignore_unknown_levels=False, **kwargs)[source]¶
Custom Handler for the logging module inserting logging messages into a given dictionary.
Messages are grouped into list under the names of the error categories. Keyword arguments can be used to modify the keys for the different levels
- class masci_tools.util.logging_util.OutParserLogAdapter(logger, extra=None)[source]¶
This adapter expects the passed in dict-like object to have a ‘iteration’ key, whose value is prepended as [Iteration i] to the message
- process(msg, kwargs)[source]¶
Process the logging message and keyword arguments passed in to a logging call to insert contextual information. You can either manipulate the message itself, the keyword args or both. Return the message and kwargs modified (or not) to suit your needs.
Normally, you’ll only need to override this one method in a LoggerAdapter subclass for your specific needs.
Fleur parser utility¶
This module contains helper functions for extracting information easily from the schema_dicts defined for the Fleur input/output
Also provides convenient functions to use just a attribute name for extracting the attribute from the right place in the given etree
- masci_tools.util.schema_dict_util.attrib_exists(node, schema_dict, name, logger=None, iteration_path=False, filters=None, **kwargs)[source]¶
Evaluates whether the attribute exists in the xmltree based on the given name and additional further specifications with the available type information
- Parameters:
node (
Union
[_Element
,_ElementTree
,XPathElementEvaluator
]) – etree Element, on which to execute the xpath evaluationsschema_dict (
SchemaDict
) – dict, containing all the path information and morename (
str
) – str, name of the attributelogger (
Optional
[Logger
]) – logger object for logging warnings, errors, if not provided all errors will be raisediteration_path (
bool
) – bool if True and the SchemaDict is of an output schema an absolute path into the iteration element is constructedfilters (
Optional
[Dict
[str
,Any
]]) – Dict specifying constraints to apply on the xpath. SeeXPathBuilder
for details
- Kwargs:
- param tag_name:
str, name of the tag where the attribute should be parsed
- param contains:
str, this string has to be in the final path
- param not_contains:
str, this string has to NOT be in the final path
- param exclude:
list of str, here specific types of attributes can be excluded valid values are: settable, settable_contains, other
- Return type:
- Returns:
bool, True if any tag with the attribute exists
- masci_tools.util.schema_dict_util.ensure_relaxation_xinclude(xmltree, schema_dict)[source]¶
Ensure that the xinclude tag for the
relax.xml
is added if norelaxation
is present in theinp.xml
- Parameters:
xmltree (
_ElementTree
) – an xml-tree which will be processedschema_dict (
InputSchemaDict
) – Schema dictionary containing all the necessary information
- Return type:
- Returns:
xmltree, which either contains the relaxation section or a xinclude tag
- masci_tools.util.schema_dict_util.eval_simple_xpath(node, schema_dict, name, logger=None, iteration_path=False, filters=None, list_return=False, **kwargs)[source]¶
Evaluates a simple xpath expression of the tag in the xmltree based on the given name and additional further specifications with the available type information
- Parameters:
node (
Union
[_Element
,_ElementTree
,XPathElementEvaluator
]) – etree Element, on which to execute the xpath evaluationsschema_dict (
SchemaDict
) – dict, containing all the path information and morename (
str
) – str, name of the taglogger (
Optional
[Logger
]) – logger object for logging warnings, errors, if not provided all errors will be raisediteration_path (
bool
) – bool if True and the SchemaDict is of an output schema an absolute path into the iteration element is constructedfilters (
Optional
[Dict
[str
,Any
]]) – Dict specifying constraints to apply on the xpath. SeeXPathBuilder
for detailslist_return (
bool
) – bool, if True a list is always returned
- Kwargs:
- param contains:
str, this string has to be in the final path
- param not_contains:
str, this string has to NOT be in the final path
- masci_tools.util.schema_dict_util.evaluate_attribute(node, schema_dict, name, constants=None, logger=None, complex_xpath=None, filters=None, iteration_path=False, **kwargs)[source]¶
Evaluates the value of the attribute based on the given name and additional further specifications with the available type information
- Parameters:
node (
Union
[_Element
,_ElementTree
,XPathElementEvaluator
]) – etree Element, on which to execute the xpath evaluationsschema_dict (
SchemaDict
) – dict, containing all the path information and morename (
str
) – str, name of the attributeconstants (
Optional
[dict
[str
,float
]]) – dict, contains the defined constantslogger (
Optional
[Logger
]) – logger object for logging warnings, errors, if not provided all errors will be raisedcomplex_xpath (
Union
[str
,bytes
,XPath
,XPathBuilder
,None
]) – an optional xpath to use instead of the simple xpath for the evaluationiteration_path (
bool
) – bool if True and the SchemaDict is of an output schema an absolute path into the iteration element is constructedfilters (
Optional
[Dict
[str
,Any
]]) – Dict specifying constraints to apply on the xpath. SeeXPathBuilder
for details
- Kwargs:
- param tag_name:
str, name of the tag where the attribute should be parsed
- param contains:
str, this string has to be in the final path
- param not_contains:
str, this string has to NOT be in the final path
- param exclude:
list of str, here specific types of attributes can be excluded valid values are: settable, settable_contains, other
- param list_return:
if True, the returned quantity is always a list even if only one element is in it
- param optional:
bool, if True and no logger given none or an empty list is returned
- Return type:
- Returns:
list or single value, converted in convert_xml_attribute
- masci_tools.util.schema_dict_util.evaluate_parent_tag(node, schema_dict, name, constants=None, logger=None, complex_xpath=None, iteration_path=False, filters=None, **kwargs)[source]¶
Evaluates all attributes of the parent tag based on the given name and additional further specifications with the available type information
- Parameters:
node (
Union
[_Element
,_ElementTree
,XPathElementEvaluator
]) – etree Element, on which to execute the xpath evaluationsschema_dict (
SchemaDict
) – dict, containing all the path information and morename (
str
) – str, name of the tagconstants (
Optional
[dict
[str
,float
]]) – dict, contains the defined constantslogger (
Optional
[Logger
]) – logger object for logging warnings, errors, if not provided all errors will be raisedcomplex_xpath (
Union
[str
,bytes
,XPath
,XPathBuilder
,None
]) – an optional xpath to use instead of the simple xpath for the evaluationiteration_path (
bool
) – bool if True and the SchemaDict is of an output schema an absolute path into the iteration element is constructedfilters (
Optional
[Dict
[str
,Any
]]) – Dict specifying constraints to apply on the xpath. SeeXPathBuilder
for details
- Kwargs:
- param contains:
str, this string has to be in the final path
- param not_contains:
str, this string has to NOT be in the final path
- param only_required:
bool (optional, default False), if True only required attributes are parsed
- param ignore:
list of str (optional), attributes not to parse
- param list_return:
if True, the returned quantity is always a list even if only one element is in it
- param strict_missing_error:
if True, and no logger is given an error is raised if any attribute is not found
- Return type:
- Returns:
dict, with attribute values converted via convert_xml_attribute
- masci_tools.util.schema_dict_util.evaluate_single_value_tag(node, schema_dict, name, constants=None, logger=None, complex_xpath=None, **kwargs)[source]¶
Evaluates the value and unit attribute of the tag based on the given name and additional further specifications with the available type information
- Parameters:
node (
Union
[_Element
,_ElementTree
,XPathElementEvaluator
]) – etree Element, on which to execute the xpath evaluationsschema_dict (
SchemaDict
) – dict, containing all the path information and morename (
str
) – str, name of the tagconstants (
Optional
[dict
[str
,float
]]) – dict, contains the defined constantslogger (
Optional
[Logger
]) – logger object for logging warnings, errors, if not provided all errors will be raisedcomplex_xpath (
Union
[str
,bytes
,XPath
,XPathBuilder
,None
]) – an optional xpath to use instead of the simple xpath for the evaluation
- Kwargs:
- param contains:
str, this string has to be in the final path
- param not_contains:
str, this string has to NOT be in the final path
- param only_required:
bool (optional, default False), if True only required attributes are parsed
- param ignore:
list of str (optional), attributes not to parse
- param list_return:
if True, the returned quantity is always a list even if only one element is in it
- param strict_missing_error:
if True, and no logger is given an error is raised if any attribute is not found
- param iteration_path:
bool if True and the SchemaDict is of an output schema an absolute path into the iteration element is constructed
- param filters:
Dict specifying constraints to apply on the xpath. See
XPathBuilder
for details
- Return type:
- Returns:
value and unit, both converted in convert_xml_attribute
- masci_tools.util.schema_dict_util.evaluate_tag(node, schema_dict, name, constants=None, logger=None, subtags=False, text=True, complex_xpath=None, iteration_path=False, filters=None, **kwargs)[source]¶
Evaluates all attributes of the tag based on the given name and additional further specifications with the available type information
- Parameters:
node (
Union
[_Element
,_ElementTree
,XPathElementEvaluator
]) – etree Element, on which to execute the xpath evaluationsschema_dict (
SchemaDict
) – dict, containing all the path information and morename (
str
) – str, name of the tagconstants (
Optional
[dict
[str
,float
]]) – dict, contains the defined constantslogger (
Optional
[Logger
]) – logger object for logging warnings, errors, if not provided all errors will be raisedsubtags (
bool
) – optional bool, if True the subtags of the given tag are evaluatedtext (
bool
) – optional bool, if True the text of the tag is also parsedcomplex_xpath (
Union
[str
,bytes
,XPath
,XPathBuilder
,None
]) – an optional xpath to use instead of the simple xpath for the evaluationiteration_path (
bool
) – bool if True and the SchemaDict is of an output schema an absolute path into the iteration element is constructedfilters (
Optional
[Dict
[str
,Any
]]) – Dict specifying constraints to apply on the xpath. SeeXPathBuilder
for details
- Kwargs:
- param contains:
str, this string has to be in the final path
- param not_contains:
str, this string has to NOT be in the final path
- param only_required:
bool (optional, default False), if True only required attributes are parsed
- param ignore:
list of str (optional), attributes not to parse
- param list_return:
if True, the returned quantity is always a list even if only one element is in it
- param strict_missing_error:
if True, and no logger is given an error is raised if any attribute is not found
- Return type:
- Returns:
dict, with attribute values converted via convert_xml_attribute
- masci_tools.util.schema_dict_util.evaluate_text(node, schema_dict, name, constants=None, logger=None, complex_xpath=None, iteration_path=False, filters=None, **kwargs)[source]¶
Evaluates the text of the tag based on the given name and additional further specifications with the available type information
- Parameters:
node (
Union
[_Element
,_ElementTree
,XPathElementEvaluator
]) – etree Element, on which to execute the xpath evaluationsschema_dict (
SchemaDict
) – dict, containing all the path information and morename (
str
) – str, name of the tagconstants (
Optional
[dict
[str
,float
]]) – dict, contains the defined constantslogger (
Optional
[Logger
]) – logger object for logging warnings, errors, if not provided all errors will be raisedcomplex_xpath (
Union
[str
,bytes
,XPath
,XPathBuilder
,None
]) – an optional xpath to use instead of the simple xpath for the evaluationiteration_path (
bool
) – bool if True and the SchemaDict is of an output schema an absolute path into the iteration element is constructedfilters (
Optional
[Dict
[str
,Any
]]) – Dict specifying constraints to apply on the xpath. SeeXPathBuilder
for details
- Kwargs:
- param contains:
str, this string has to be in the final path
- param not_contains:
str, this string has to NOT be in the final path
- param list_return:
if True, the returned quantity is always a list even if only one element is in it
- param optional:
bool, if True and no logger given none or an empty list is returned
- Return type:
- Returns:
list or single value, converted in convert_xml_text
- masci_tools.util.schema_dict_util.get_number_of_nodes(node, schema_dict, name, logger=None, **kwargs)[source]¶
Evaluates the number of occurrences of the tag in the xmltree based on the given name and additional further specifications with the available type information
- Parameters:
node (
Union
[_Element
,_ElementTree
,XPathElementEvaluator
]) – etree Element, on which to execute the xpath evaluationsschema_dict (
SchemaDict
) – dict, containing all the path information and morename (
str
) – str, name of the taglogger (
Optional
[Logger
]) – logger object for logging warnings, errors, if not provided all errors will be raised
- Kwargs:
- param contains:
str, this string has to be in the final path
- param not_contains:
str, this string has to NOT be in the final path
- param iteration_path:
bool if True and the SchemaDict is of an output schema an absolute path into the iteration element is constructed
- param filters:
Dict specifying constraints to apply on the xpath. See
XPathBuilder
for details
- Return type:
- Returns:
number of nodes for the given tag
- masci_tools.util.schema_dict_util.read_constants(root, schema_dict, logger=None)[source]¶
Reads in the constants defined in the inp.xml and returns them combined with the predefined constants from fleur as a dictionary
- Parameters:
root (
Union
[_Element
,_ElementTree
,XPathElementEvaluator
]) – root of the etree of the inp.xml fileschema_dict (
SchemaDict
) – schema_dictionary of the version of the file to read (inp.xml or out.xml)logger (
Optional
[Logger
]) – logger object for logging warnings, errors
- Return type:
- Returns:
a python dictionary with all defined constants
- masci_tools.util.schema_dict_util.reverse_xinclude(xmltree, schema_dict, included_tags, **kwargs)[source]¶
Split the xmltree back up according to the given included tags. The original xmltree will be returned with the corresponding xinclude tags and the included trees are returned in a dict mapping the inserted filename to the extracted tree
Tags for which no known filename is known are returned under unknown-1.xml, … The following tags have known filenames:
relaxation:
relax.xml
kPointLists:
kpts.xml
symmetryOperations:
sym.xml
atomSpecies:
species.xml
atomGroups:
atoms.xml
Additional mappings can be given in the keyword arguments
- Parameters:
xmltree (
_ElementTree
) – an xml-tree which will be processedschema_dict (
InputSchemaDict
) – Schema dictionary containing all the necessary informationincluded_tags (
Iterable
[str
]) – Iterable of str, containing the names of the tags to be excluded
- Return type:
tuple
[_ElementTree
,dict
[PathLike
|str
,_ElementTree
]]- Returns:
xmltree with the inseerted xinclude tags and a dict mapping the filenames to the excluded trees
- Raises:
ValueError – if the tag can not be found in the given xmltree
- masci_tools.util.schema_dict_util.tag_exists(node, schema_dict, name, logger=None, **kwargs)[source]¶
Evaluates whether the tag exists in the xmltree based on the given name and additional further specifications with the available type information
- Parameters:
node (
Union
[_Element
,_ElementTree
,XPathElementEvaluator
]) – etree Element, on which to execute the xpath evaluationsschema_dict (
SchemaDict
) – dict, containing all the path information and morename (
str
) – str, name of the taglogger (
Optional
[Logger
]) – logger object for logging warnings, errors, if not provided all errors will be raised
- Kwargs:
- param contains:
str, this string has to be in the final path
- param not_contains:
str, this string has to NOT be in the final path
- param iteration_path:
bool if True and the SchemaDict is of an output schema an absolute path into the iteration element is constructed
- param filters:
Dict specifying constraints to apply on the xpath. See
XPathBuilder
for details
- Return type:
- Returns:
bool, True if any nodes with the path exist
This module contains the functions necessary to parse mathematical expressions with predefined constants given in the inp.xml file of Fleur
- exception masci_tools.util.fleur_calculate_expression.MissingConstant[source]¶
Exception raised when a constant appearing in a expression is not defined
- masci_tools.util.fleur_calculate_expression.calculate_expression(expression, constants=None)[source]¶
Recursively evaluates the given expression string with the given defined constants
- masci_tools.util.fleur_calculate_expression.calculate_expression_partial(expression, constants=None, prevCommand=None)[source]¶
Recursively evaluates the given expression string with the given defined constants and returns the unevaluated part of the expression
- Parameters:
expression (
str
|float
|int
) – str containing the expression to be parsedconstants (
Optional
[dict
[str
,float
]]) – dict with all defined constants (predefined in the Fleur code or defined in the inp.xml)prevCommand (
Optional
[str
]) – str, which gives the command before the beginning of the current block if it is given the calculation is stopped, when a command is encountered, which should be exectuted after prevCommand (order of operations)
- Return type:
- Returns:
float value of the given expression string
- masci_tools.util.fleur_calculate_expression.evaluate_bracket(expression, constants)[source]¶
Evaluates the bracket opened at the start of the expression
- masci_tools.util.fleur_calculate_expression.get_first_number(expression)[source]¶
Reads the number in the beginning of the expression string. This number can begin with a sign +-, a number or the decimal point
- masci_tools.util.fleur_calculate_expression.get_first_string(expression)[source]¶
Reads the letter string in the beginning of the expression string.
This module contains custom conversion functions for the outxml_parser, which cannot be handled by the standard parsing framework
- masci_tools.io.parsers.fleur.outxml_conversions.calculate_total_magnetic_moment(out_dict, logger)[source]¶
Calculate the the total magnetic moment per cell
- masci_tools.io.parsers.fleur.outxml_conversions.calculate_walltime(out_dict, logger)[source]¶
Calculate the walltime from start and end time
- masci_tools.io.parsers.fleur.outxml_conversions.convert_forces(out_dict, logger)[source]¶
Convert the parsed forces from a iteration
- masci_tools.io.parsers.fleur.outxml_conversions.convert_htr_to_ev(out_dict, name, converted_name=None, pop=False, add_unit=True, logger=None)[source]¶
Convert value from htr to eV
- masci_tools.io.parsers.fleur.outxml_conversions.convert_ldahia_definitions(out_dict, logger)[source]¶
Convert the parsed information from LDA+U into a more readable dict
ldau_info has keys for each species with LDA+U ({species_name}/{atom_number}) and this in turn contains a dict with the LDA+U definition for the given orbital (spdf)
- masci_tools.io.parsers.fleur.outxml_conversions.convert_ldau_definitions(out_dict, logger)[source]¶
Convert the parsed information from LDA+U into a more readable dict
ldau_info has keys for each species with LDA+U ({species_name}/{atom_number}) and this in turn contains a dict with the LDA+U definition for the given orbital (spdf)
- masci_tools.io.parsers.fleur.outxml_conversions.convert_relax_info(out_dict, logger)[source]¶
Convert the general relaxation information
Functions for expanding/splitting or converting electron configuration strings
- masci_tools.util.econfig.convert_fleur_config_to_econfig(fleurconf_str, keep_spin=False)[source]¶
‘[Kr] (4d3/2) (4d5/2) (4f5/2) (4f7/2)’ -> ‘[Kr] 4d10 4f14’, or ‘[Kr] 4d3/2 4d5/2 4f5/2 4f7/2’
# for now only use for coreconfig, it will fill all orbitals, since it has no information on the filling.
- masci_tools.util.econfig.get_coreconfig(element, full=False)[source]¶
returns the econfiguration as a string of an element.
Basic Fleur Schema parser functions¶
Load all fleur schema related functions
- class masci_tools.io.parsers.fleur_schema.AttributeType(base_type: str, length: int | Literal['unbounded'] | None)[source]¶
Type for describing the types of attributes/text
- exception masci_tools.io.parsers.fleur_schema.IncompatibleSchemaVersions[source]¶
Exception raised when it is known that a given output version and input version cannot be compiled into a complete fleur output xml schema
- class masci_tools.io.parsers.fleur_schema.InputSchemaDict(*args, xmlschema=None, **kwargs)[source]¶
This class contains information parsed from the FleurInputSchema.xsd
The keys contain the following information:
- inp_version:
Version string of the input schema represented in this object
- tag_paths:
simple xpath expressions to all valid tag names Multiple paths or ambiguous tag names are parsed as a list
- _basic_types:
Parsed definitions of all simple Types with their respective base type (int, float, …) and evtl. length restrictions (Only used in the schema construction itself)
- attrib_types:
All possible base types for all valid attributes. If multiple are possible a list, with ‘string’ always last (if possible)
- simple_elements:
All elements with simple types and their type definition with the additional attributes
- unique_attribs:
All attributes and their paths, which occur only once and have a unique path
- unique_path_attribs:
All attributes and their paths, which have a unique path but occur in multiple places
- other_attribs:
All attributes and their paths, which are not in ‘unique_attribs’ or ‘unique_path_attribs’
- omitt_contained_tags:
All tags, which only contain a list of one other tag
- tag_info:
For each tag (path), the valid attributes and tags (optional, several, order, simple, text)
- classmethod fromPath(path)[source]¶
load the FleurInputSchema dict for the specified FleurInputSchema file
- Parameters:
path (
PathLike
) – path to the input schema file- Return type:
- Returns:
InputSchemaDict object with the information for the provided file
- exception masci_tools.io.parsers.fleur_schema.NoPathFound[source]¶
Exception raised when no path is found for a given tag/attribute
- exception masci_tools.io.parsers.fleur_schema.NoUniquePathFound[source]¶
Exception raised when no unique path is found for a given tag/attribute
- class masci_tools.io.parsers.fleur_schema.OutputSchemaDict(*args, xmlschema=None, **kwargs)[source]¶
This object contains information parsed from the FleurOutputSchema.xsd
The keys contain the following information:
- out_version:
Version string of the output schema represented in this class
- input_tag:
Name of the element containing the fleur input
- iteration_tags:
Names of the elements that can contain all iteration tags
- tag_paths:
simple xpath expressions to all valid tag names not in an iteration Multiple paths or ambiguous tag names are parsed as a list
- iteration_tag_paths:
simple relative xpath expressions to all valid tag names inside an iteration. Multiple paths or ambiguous tag names are parsed as a list
- _basic_types:
Parsed definitions of all simple Types with their respective base type (int, float, …) and evtl. length restrictions (Only used in the schema construction itself)
- _input_basic_types:
Part of the parsed definitions of all simple Types with their respective base type (int, float, …) and evtl. length restrictions from the input schema (Only used in the schema construction itself)
- attrib_types:
All possible base types for all valid attributes. If multiple are possible a list, with ‘string’ always last (if possible)
- simple_elements:
All elements with simple types and their type definition with the additional attributes
- unique_attribs:
All attributes and their paths, which occur only once and have a unique path outside of an iteration
- unique_path_attribs:
All attributes and their paths, which have a unique path but occur in multiple places outside of an iteration
- other_attribs:
All attributes and their paths, which are not in ‘unique_attribs’ or ‘unique_path_attribs’ outside of an iteration
- iteration_unique_attribs:
All attributes and their relative paths, which occur only once and have a unique path inside of an iteration
- iteration_unique_path_attribs:
All attributes and their relative paths, which have a unique path but occur in multiple places inside of an iteration
- iteration_other_attribs:
All attributes and their relative paths, which are not in ‘unique_attribs’ or ‘unique_path_attribs’ inside of an iteration
- omitt_contained_tags:
All tags, which only contain a list of one other tag
- tag_info:
For each tag outside of an iteration (path), the valid attributes and tags (optional, several, order, simple, text)
- iteration_tag_info:
For each tag inside of an iteration (relative path), the valid attributes and tags (optional, several, order, simple, text)
- classmethod fromPath(path, inp_path=None, inpschema_dict=None)[source]¶
load the FleurOutputSchema dict for the specified paths
- Parameters:
- Return type:
- Returns:
OutputSchemaDict object with the information for the provided files
- classmethod fromVersion(version, inp_version=None, logger=None, no_cache=False)[source]¶
load the FleurOutputSchema dict for the specified version
- Parameters:
- Return type:
- Returns:
OutputSchemaDict object with the information for the provided versions
- property inp_version: tuple[int, int]¶
Returns the input version as an integer for comparisons (> or <)
- iteration_attrib_xpath(name, contains=None, not_contains=None, exclude=None, tag_name=None, iteration_tag='iteration')[source]¶
Tries to find a unique path from the schema_dict based on the given name of the attribute and additional further specifications in the iteration section of the out.xml and returns the absolute path to it
- Parameters:
name (
str
) – str, name of the attributecontains (
Union
[str
,Iterable
[str
],None
]) – str or list of str, this string has to be in the final pathnot_contains (
Union
[str
,Iterable
[str
],None
]) – str or list of str, this string has to NOT be in the final pathexclude (
Optional
[Iterable
[str
]]) – list of str, here specific types of attributes can be excluded valid values are: settable, settable_contains, othertag_name (
Optional
[str
]) – str, if given this name will be used to find a path to a tag with the same name initeration_tag_xpath()
iteration_tag (
str
) – name of the tag containing the iteration information
- Return type:
- Returns:
str, xpath to the tag with the given attribute
- Raises:
NoPathFound – If no path matching the criteria could be found
NoUniquePathFound – If multiple paths matching the criteria are found
- iteration_tag_xpath(name, contains=None, not_contains=None, iteration_tag='iteration')[source]¶
Tries to find a unique path from the schema_dict based on the given name of the tag and additional further specifications in the iteration section of the out.xml and returns the absolute path to it
- Parameters:
name (
str
) – str, name of the tagcontains (
Union
[str
,Iterable
[str
],None
]) – str or list of str, this string has to be in the final pathnot_contains (
Union
[str
,Iterable
[str
],None
]) – str or list of str, this string has to NOT be in the final pathiteration_tag (
str
) – name of the tag containing the iteration information
- Return type:
- Returns:
str, xpath for the given tag
- Raises:
NoPathFound – If no path matching the criteria could be found
NoUniquePathFound – If multiple paths matching the criteria are found
- property out_version: tuple[int, int]¶
Returns the output version as an integer for comparisons (> or <)
- relative_iteration_attrib_xpath(name, root_tag, contains=None, not_contains=None, exclude=None, tag_name=None, iteration_tag='iteration')[source]¶
Tries to find a unique relative path from the schema_dict based on the given name of the attribute name of the root, from which the path should be relative and additional further specifications
- Parameters:
schema_dict – dict, containing all the path information and more
name (
str
) – str, name of the attributeroot_tag (
str
) – str, name of the tag from which the path should be relativecontains (
Union
[str
,Iterable
[str
],None
]) – str or list of str, this string has to be in the final pathnot_contains (
Union
[str
,Iterable
[str
],None
]) – str or list of str, this string has to NOT be in the final pathexclude (
Optional
[Iterable
[str
]]) – list of str, here specific types of attributes can be excluded valid values are: settable, settable_contains, othertag_name (
Optional
[str
]) – str, if given this name will be used to find a path to a tag with the same name inrelative_iteration_tag_xpath()
iteration_tag (
str
) – name of the tag containing the iteration information
- Return type:
- Returns:
str, xpath for the given tag
- Raises:
NoPathFound – If no path matching the criteria could be found
NoUniquePathFound – If multiple paths matching the criteria are found
- relative_iteration_tag_xpath(name, root_tag, contains=None, not_contains=None, iteration_tag='iteration')[source]¶
Tries to find a unique path from the schema_dict based on the given name of the tag and additional further specifications in the iteration section of the out.xml and returns the absolute path to it
- Parameters:
name (
str
) – str, name of the tagcontains (
Union
[str
,Iterable
[str
],None
]) – str or list of str, this string has to be in the final pathnot_contains (
Union
[str
,Iterable
[str
],None
]) – str or list of str, this string has to NOT be in the final pathiteration_tag (
str
) – name of the tag containing the iteration information
- Return type:
- Returns:
str, xpath for the given tag
- Raises:
NoPathFound – If no path matching the criteria could be found
NoUniquePathFound – If multiple paths matching the criteria are found
- class masci_tools.io.parsers.fleur_schema.SchemaDict(*args, xmlschema=None, **kwargs)[source]¶
Base class for schema dictionaries. Is locked on initialization with
freeze()
. Holds a reference to the xmlSchema for validating files.Also provides interfaces for utility functions
All other arguments are passed on to
LockableDict
- attrib_xpath(name, contains=None, not_contains=None, exclude=None, tag_name=None)[source]¶
Tries to find a unique path from the schema_dict based on the given name of the attribute and additional further specifications
- Parameters:
name (
str
) – str, name of the attributecontains (
Union
[str
,Iterable
[str
],None
]) – str or list of str, this string has to be in the final pathnot_contains (
Union
[str
,Iterable
[str
],None
]) – str or list of str, this string has to NOT be in the final pathexclude (
Optional
[Iterable
[str
]]) – list of str, here specific types of attributes can be excluded valid values are: settable, settable_contains, othertag_name (
Optional
[str
]) – str, if given this name will be used to find a path to a tag with the same name intag_xpath()
- Return type:
- Returns:
str, xpath to the tag with the given attribute
- Raises:
NoPathFound – If no path matching the criteria could be found
NoUniquePathFound – If multiple paths matching the criteria are found
- classmethod clear_cache()[source]¶
Remove all stored entries in the schema dictionary cache
- Return type:
- relative_attrib_xpath(name, root_tag, contains=None, not_contains=None, exclude=None, tag_name=None)[source]¶
Tries to find a unique relative path from the schema_dict based on the given name of the attribute name of the root, from which the path should be relative and additional further specifications
- Parameters:
schema_dict – dict, containing all the path information and more
name (
str
) – str, name of the attributeroot_tag (
str
) – str, name of the tag from which the path should be relativecontains (
Union
[str
,Iterable
[str
],None
]) – str or list of str, this string has to be in the final pathnot_contains (
Union
[str
,Iterable
[str
],None
]) – str or list of str, this string has to NOT be in the final pathexclude (
Optional
[Iterable
[str
]]) – list of str, here specific types of attributes can be excluded valid values are: settable, settable_contains, othertag_name (
Optional
[str
]) – str, if given this name will be used to find a path to a tag with the same name inrelative_tag_xpath()
- Return type:
- Returns:
str, xpath for the given tag
- Raises:
NoPathFound – If no path matching the criteria could be found
NoUniquePathFound – If multiple paths matching the criteria are found
- relative_tag_xpath(name, root_tag, contains=None, not_contains=None)[source]¶
Tries to find a unique relative path from the schema_dict based on the given name of the tag name of the root, from which the path should be relative and additional further specifications
- Parameters:
name (
str
) – str, name of the tagroot_tag (
str
) – str, name of the tag from which the path should be relativecontains (
Union
[str
,Iterable
[str
],None
]) – str or list of str, this string has to be in the final pathnot_contains (
Union
[str
,Iterable
[str
],None
]) – str or list of str, this string has to NOT be in the final path
- Return type:
- Returns:
str, xpath for the given tag
- Raises:
ValueError – If no unique path could be found
- tag_info(name, contains=None, not_contains=None, parent=False)[source]¶
Tries to find a unique path from the schema_dict based on the given name of the tag and additional further specifications and returns the tag_info entry for this tag
- Parameters:
schema_dict – dict, containing all the path information and more
name (
str
) – str, name of the tagcontains (
Union
[str
,Iterable
[str
],None
]) – str or list of str, this string has to be in the final pathnot_contains (
Union
[str
,Iterable
[str
],None
]) – str or list of str, this string has to NOT be in the final pathparent (
bool
) – bool, if True the tag_info for the parent of the tag is returned
- Return type:
- Returns:
dict, tag_info for the found xpath
- tag_xpath(name, contains=None, not_contains=None)[source]¶
Tries to find a unique path from the schema_dict based on the given name of the tag and additional further specifications
- Parameters:
- Return type:
- Returns:
str, xpath for the given tag
- Raises:
NoPathFound – If no path matching the criteria could be found
NoUniquePathFound – If multiple paths matching the criteria are found
- masci_tools.io.parsers.fleur_schema.list_available_versions(output_schema)[source]¶
List the available versions for the schema
- masci_tools.io.parsers.fleur_schema.schema_dict_version_dispatch(output_schema=False)[source]¶
Decorator for creating variations of functions based on the inp/out version of the schema_dict. All functions here need to have the signature:
def f(node, schema_dict, *args, **kwargs): pass
So schema_dict is the second positional argument
Inspired by singledispatch in the functools module
functions to extract information about the fleur schema input or output
- class masci_tools.io.parsers.fleur_schema.fleur_schema_parser_functions.AttributeType(base_type: str, length: int | Literal['unbounded'] | None)[source]¶
Type for describing the types of attributes/text
- class masci_tools.io.parsers.fleur_schema.fleur_schema_parser_functions.TagInfo[source]¶
Dict representing the entries for the tag information.
- masci_tools.io.parsers.fleur_schema.fleur_schema_parser_functions.convert_str_version_number(version_str)[source]¶
Convert the version number as a integer for easy comparisons
- masci_tools.io.parsers.fleur_schema.fleur_schema_parser_functions.eval_single_string_attribute(xmlschema_evaluator, xpath, **variables)[source]¶
Wrapper around the xpath calls in this module. Makes sure the return value is a single string (not cached)
- Parameters:
xmlschema_evaluator – etree.XPathEvaluator for the schema
xpath – str, xpath expression to evaluate
- masci_tools.io.parsers.fleur_schema.fleur_schema_parser_functions.extract_attribute_types(xmlschema_evaluator, **kwargs)[source]¶
Determine the required type of all attributes
- Parameters:
xmlschema_evaluator (
XPathDocumentEvaluator
) – etree.XPathEvaluator for the schema- Return type:
- Returns:
possible types of the attributes in a dictionary, if multiple types are possible a list is inserted for the tag
- masci_tools.io.parsers.fleur_schema.fleur_schema_parser_functions.extract_text_types(xmlschema_evaluator, **kwargs)[source]¶
Determine the required type of all elements with text
- Parameters:
xmlschema_evaluator (
XPathDocumentEvaluator
) – etree.XPathEvaluator for the schema- Return type:
- Returns:
possible types of the attributes in a dictionary, if multiple types are possible a list is inserted for the tag
- masci_tools.io.parsers.fleur_schema.fleur_schema_parser_functions.get_basic_types(xmlschema_evaluator, input_basic_types=None, **kwargs)[source]¶
find all types, which can be traced back directly to a base_type
- Parameters:
xmlschema_evaluator (
XPathDocumentEvaluator
) – etree.XPathEvaluator for the schema- Return type:
dict
[str
,list
[AttributeType
]]- Returns:
dictionary with type names and their corresponding type_definition meaning a dictionary with possible base types and evtl. length restriction
- masci_tools.io.parsers.fleur_schema.fleur_schema_parser_functions.get_input_tag(xmlschema_evaluator, **kwargs)[source]¶
Returns the tag for the input type element of the outxmlschema
- Parameters:
xmlschema_evaluator (
XPathDocumentEvaluator
) – etree.XPathEvaluator for the schema- Return type:
- Returns:
name of the element with the type ‘FleurInputType’
- masci_tools.io.parsers.fleur_schema.fleur_schema_parser_functions.get_iteration_tags(xmlschema_evaluator, **kwargs)[source]¶
Returns the tags that can contain the information from a SCF iteration
- Parameters:
xmlschema_evaluator (
XPathDocumentEvaluator
) – etree.XPathEvaluator for the schema- Return type:
- Returns:
set of tag names that contain elements from the group ‘GeneralIterationType’
- masci_tools.io.parsers.fleur_schema.fleur_schema_parser_functions.get_omittable_tags(xmlschema_evaluator, **kwargs)[source]¶
find tags with no attributes and, which are only used to mask a list of one other possible tag (e.g. atomSpecies)
- Parameters:
xmlschema_evaluator (
XPathDocumentEvaluator
) – etree.XPathEvaluator for the schema- Return type:
- Returns:
list of tags, containing only a sequence of one allowed tag
- masci_tools.io.parsers.fleur_schema.fleur_schema_parser_functions.get_other_attribs(xmlschema_evaluator, **kwargs)[source]¶
Determine all other attributes not contained in settable or settable_contains
- Parameters:
xmlschema_evaluator (
XPathDocumentEvaluator
) – etree.XPathEvaluator for the schema- Return type:
- Returns:
dictionary with all attributes and the corresponding list of paths to the tag
- masci_tools.io.parsers.fleur_schema.fleur_schema_parser_functions.get_root_tag(xmlschema_evaluator, **kwargs)[source]¶
Returns the tag for the root element of the xmlschema
- Parameters:
xmlschema_evaluator (
XPathDocumentEvaluator
) – etree.XPathEvaluator for the schema- Return type:
- Returns:
name of the single element defined in the first level of the schema
- masci_tools.io.parsers.fleur_schema.fleur_schema_parser_functions.get_tag_info(xmlschema_evaluator, **kwargs)[source]¶
- Get all important information about the tags
allowed attributes
contained tags (simple (only attributes), optional (with default values), several, order, text tags)
- Parameters:
xmlschema_evaluator (
XPathDocumentEvaluator
) – etree.XPathEvaluator for the schema- Return type:
- Returns:
dictionary with the tag information
- masci_tools.io.parsers.fleur_schema.fleur_schema_parser_functions.get_tag_paths(xmlschema_evaluator, **kwargs)[source]¶
Determine simple xpaths to all possible tags
- Parameters:
xmlschema_evaluator (
XPathDocumentEvaluator
) – etree.XPathEvaluator for the schema- Return type:
CaseInsensitiveDict
[str
,list
[str
] |str
]- Returns:
possible paths of all tags in a dictionary, if multiple paths are possible a list is inserted for the tag
- masci_tools.io.parsers.fleur_schema.fleur_schema_parser_functions.get_text_tags(xmlschema_evaluator, **kwargs)[source]¶
find all elements, who can contain text
- Parameters:
xmlschema_evaluator (
XPathDocumentEvaluator
) – xmltree representing the schema- Return type:
- Returns:
dictionary with tags and their corresponding type_definition meaning a dictionary with possible base types and evtl. length restriction
- masci_tools.io.parsers.fleur_schema.fleur_schema_parser_functions.get_unique_attribs(xmlschema_evaluator, **kwargs)[source]¶
Determine all attributes, which can be set through set_inpchanges in aiida_fleur Meaning ONE possible path and no tags in the path with maxOccurs!=1
- Parameters:
xmlschema_evaluator (
XPathDocumentEvaluator
) – etree.XPathEvaluator for the schema- Return type:
- Returns:
dictionary with all settable attributes and the corresponding path to the tag
- masci_tools.io.parsers.fleur_schema.fleur_schema_parser_functions.get_unique_path_attribs(xmlschema_evaluator, **kwargs)[source]¶
Determine all attributes, with multiple possible path that do have at least one path with all contained tags maxOccurs!=1
- Parameters:
xmlschema_evaluator (
XPathDocumentEvaluator
) – etree.XPathEvaluator for the schema- Return type:
- Returns:
dictionary with all attributes and the corresponding list of paths to the tag
- masci_tools.io.parsers.fleur_schema.fleur_schema_parser_functions.type_order(type_def)[source]¶
Key function for sorting the type definitions to avoid conflicts
Sorted by base_type first (bool before int, string at the end) and then by length in ascending order (unbounded last)
- Parameters:
type_def (
AttributeType
) – definition to be sorted- Return type:
Defined constants¶
Here we collect physical constants which are used throughout the code. That way we ensure consistency.
Note
For masci-tools versions after v0.4.6, the constants values used in the KKR functions for conversion between
Angstrom and Bohr radius, and electron Volt and Rydberg, have been replaced by the NIST values by default.
Prior to that, two different versions had been in use. If you need to work with KKR calculations / aiida-kkr
workchains performed with these constants versions, you can switch to these older KKR constants versions by
setting the environment variable MASCI_TOOLS_USE_OLD_CONSTANTS
prior to loading masci-tools. During interpreter
runtime, the chosen version cannot be switched.
For KKR constants versions used starting from masci-tools v0.4.7, more specifically starting from commit 66953f8, Apr 28, 2021, do not set
MASCI_TOOLS_USE_OLD_CONSTANTS
.For KKR constants versions used in masci-tools v0.4.0-dev7 - v0.4.6, more specifically starting from commit c171563, Feb 16, 2021, to prior to commit 66953f8, Apr 28, 2021, set
MASCI_TOOLS_USE_OLD_CONSTANTS
to'interim'
.For KKR constants versions used prior to masci-tools v0.4.0-dev7, more specifically prior to commit c171563, Feb 16, 2021, set
MASCI_TOOLS_USE_OLD_CONSTANTS
to'old'
or'True'
.
1# NIST https://physics.nist.gov/cgi-bin/cuu/Value?hrev
2HTR_TO_EV = 27.211386245988 #(53)
3RY_TO_EV = 13.605693122994 #(26)
4BOHR_A = 0.5291772108
5HTR_TO_KELVIN = 315_775.02480407
6#Scipy bohr 5.29177210903e-11 m
7#Scipy htr 27.211386245988 eV
8# NIST BOHR 0.529177210903 #(80)
9#https://physics.nist.gov/cgi-bin/cuu/Value?bohrrada0
10
11#KKR constants versions. See module docstring for details.
12_MASCI_TOOLS_USE_OLD_CONSTANTS = os.environ.get('MASCI_TOOLS_USE_OLD_CONSTANTS', None)
13if _MASCI_TOOLS_USE_OLD_CONSTANTS and _MASCI_TOOLS_USE_OLD_CONSTANTS.lower() in ['old', 'true']:
14 ANG_BOHR_KKR = 1.8897261254578281
15 RY_TO_EV_KKR = 13.605693009
16elif _MASCI_TOOLS_USE_OLD_CONSTANTS and _MASCI_TOOLS_USE_OLD_CONSTANTS.lower() in ['interim']:
17 ANG_BOHR_KKR = 1.8897261249935897
18 RY_TO_EV_KKR = RY_TO_EV
19else:
20 #Set the constants to the NIST values
21 ANG_BOHR_KKR = 1.8897261246257702
22 RY_TO_EV_KKR = RY_TO_EV
23
24#Fleur
25#htr_eV = 27.21138602
26#bohr=0.5291772108
27#bohrtocm=0.529177e-8
28#pymatgen uses scipy.constants
29#ase: Bohr 0.5291772105638411
30#Hartree 27.211386024367243
31#Rydberg 13.605693012183622
32#1/Bohr
33#1.8897261258369282
34#aiida-core units:
35#bohr_to_ang = 0.52917720859
36
37#Predefined constants in the Fleur Code (These are accepted in the inp.xml)
38FLEUR_DEFINED_CONSTANTS = {
39 'Pi': np.pi,
40 'Deg': 2 * np.pi / 360.0,
41 'Ang': 1.8897261247728981,
42 'nm': 18.897261247728981,
43 'pm': 0.018897261247728981,
44 'Bohr': 1.0,
45 'Htr': 1.0,
46 'eV': 1.0 / HTR_TO_EV,
47 'Ry': 0.5
48}
49
50PERIODIC_TABLE_ELEMENTS = {
51 0: { # This is for empty spheres etc.
52 'mass': 1.00000,
53 'name': 'Unknown',
54 'symbol': 'X'
55 },
56 1: {
57 'mass': 1.00794,
58 'name': 'Hydrogen',
59 'symbol': 'H',
60 'econfig': '1s1',
61 'fleur_default_econfig': '| 1s1',
62 'lo': '',
63 'rmt': 0.65,
64 'lmax': '',
65 'jri': 981,
66 'soc': False,
67 'mag': False
68 },
69 2: {
70 'mass': 4.002602,
71 'name': 'Helium',
72 'symbol': 'He',
73 'econfig': '1s2',
74 'fleur_default_econfig': '| 1s2',
75 'lo': '',
76 'rmt': 1.2,
77 'lmax': '',
78 'jri': 981
79 },
80 3: {
81 'mass': 6.941,
82 'name': 'Lithium',
83 'symbol': 'Li',
84 'econfig': '1s2 | 2s1',
85 'fleur_default_econfig': '1s2 | 2s1',
86 'lo': '',
87 'rmt': 2.13,
88 'lmax': '',
89 'jri': 981
90 },
91 4: {
92 'mass': 9.012182,
93 'name': 'Beryllium',
94 'symbol': 'Be',
95 'econfig': '1s2 | 2s2',
96 'fleur_default_econfig': '1s2 | 2s2',
97 'lo': '',
98 'rmt': 1.87,
99 'lmax': '',
100 'jri': 981
101 },
102 5: {
103 'mass': 10.811,
104 'name': 'Boron',
105 'symbol': 'B',
106 'econfig': '1s2 | 2s2 2p1',
107 'fleur_default_econfig': '1s2 | 2s2 2p1',
108 'lo': '',
109 'rmt': 1.4,
110 'lmax': '',
111 'jri': 981
112 },
113 6: {
114 'mass': 12.0107,
115 'name': 'Carbon',
116 'symbol': 'C',
117 'econfig': '[He] 2s2 | 2p2',
118 'fleur_default_econfig': '[He] 2s2 | 2p2',
119 'lo': '',
120 'rmt': 1.2,
121 'lmax': '',
122 'jri': 981
123 },
124 7: {
125 'mass': 14.0067,
126 'name': 'Nitrogen',
127 'symbol': 'N',
128 'econfig': '[He] 2s2 | 2p3',
129 'fleur_default_econfig': '[He] 2s2 | 2p3',
130 'lo': '',
131 'rmt': 1.0,
132 'lmax': '',
133 'jri': 981
134 },
135 8: {
136 'mass': 15.9994,
137 'name': 'Oxygen',
138 'symbol': 'O',
139 'econfig': '[He] 2s2 | 2p4',
140 'fleur_default_econfig': '[He] 2s2 | 2p4',
141 'lo': '',
142 'rmt': 1.1,
143 'lmax': '',
144 'jri': 981
145 },
146 9: {
147 'mass': 18.9984032,
148 'name': 'Fluorine',
149 'symbol': 'F',
150 'econfig': '[He] 2s2 | 2p5',
151 'fleur_default_econfig': '[He] 2s2 | 2p5',
152 'lo': '',
153 'rmt': 1.2,
154 'lmax': '',
155 'jri': 981
156 },
157 10: {
158 'mass': 20.1797,
159 'name': 'Neon',
160 'symbol': 'Ne',
161 'econfig': '[He] 2s2 | 2p6',
162 'fleur_default_econfig': '[He] 2s2 | 2p6',
163 'lo': '',
164 'rmt': 2.1,
165 'lmax': '',
166 'jri': 981
167 },
168 11: {
169 'mass': 22.98977,
170 'name': 'Sodium',
171 'symbol': 'Na',
172 'econfig': '[He] 2s2 | 2p6 3s1',
173 'fleur_default_econfig': '[He] | 2s2 2p6 3s1',
174 'lo': '2s 2p',
175 'rmt': 2.1,
176 'lmax': '',
177 'jri': 981
178 },
179 12: {
180 'mass': 24.305,
181 'name': 'Magnesium',
182 'symbol': 'Mg',
183 'econfig': '[He] 2s2 | 2p6 3s2',
184 'fleur_default_econfig': '[He] 2s2 | 2p6 3s2',
185 'lo': '2p',
186 'rmt': 2.3,
187 'lmax': '',
188 'jri': 981
189 },
190 13: {
191 'mass': 26.981538,
192 'name': 'Aluminium',
193 'symbol': 'Al',
194 'econfig': '[He] 2s2 2p6 | 3s2 3p1',
195 'fleur_default_econfig': '[He] 2s2 2p6 | 3s2 3p1',
196 'lo': '',
197 'rmt': 2.1,
198 'lmax': '',
199 'jri': 981
200 },
201 14: {
202 'mass': 28.0855,
203 'name': 'Silicon',
204 'symbol': 'Si',
205 'econfig': '[He] 2s2 2p6 | 3s2 3p2',
206 'fleur_default_econfig': '[He] 2s2 2p6 | 3s2 3p2',
207 'lo': '',
208 'rmt': 2.0,
209 'lmax': '',
210 'jri': 981
211 },
212 15: {
213 'mass': 30.973761,
214 'name': 'Phosphorus',
215 'symbol': 'P',
216 'econfig': '[He] 2s2 2p6 | 3s2 3p3',
217 'fleur_default_econfig': '[He] 2s2 2p6 | 3s2 3p3',
218 'lo': '',
219 'rmt': 1.9,
220 'lmax': '',
221 'jri': 981
222 },
223 16: {
224 'mass': 32.065,
225 'name': 'Sulfur',
226 'symbol': 'S',
227 'econfig': '[He] 2s2 2p6 | 3s2 3p4',
228 'fleur_default_econfig': '[He] 2s2 2p6 | 3s2 3p4',
229 'lo': '',
230 'rmt': 1.7,
231 'lmax': '',
232 'jri': 981
233 },
234 17: {
235 'mass': 35.453,
236 'name': 'Chlorine',
237 'symbol': 'Cl',
238 'econfig': '[He] 2s2 2p6 | 3s2 3p5',
239 'fleur_default_econfig': '[He] 2s2 2p6 | 3s2 3p5',
240 'lo': '',
241 'rmt': 1.7,
242 'lmax': '',
243 'jri': 981
244 },
245 18: {
246 'mass': 39.948,
247 'name': 'Argon',
248 'symbol': 'Ar',
249 'econfig': '[He] 2s2 2p6 | 3s2 3p6',
250 'fleur_default_econfig': '[He] 2s2 2p6 | 3s2 3p6',
251 'lo': '',
252 'rmt': 1.8,
253 'lmax': '',
254 'jri': 981
255 },
256 19: {
257 'mass': 39.0983,
258 'name': 'Potassium',
259 'symbol': 'K',
260 'econfig': '[Ne] 3s2 | 3p6 4s1',
261 'fleur_default_econfig': '[Ne] | 3s2 3p6 4s1',
262 'lo': '3s 3p',
263 'rmt': 2.0,
264 'lmax': '',
265 'jri': 981
266 },
267 20: {
268 'mass': 40.078,
269 'name': 'Calcium',
270 'symbol': 'Ca',
271 'econfig': '[Ne] 3s2 | 3p6 4s2',
272 'fleur_default_econfig': '[Ne] | 3s2 3p6 4s2',
273 'lo': '3s 3p',
274 'rmt': 2.3,
275 'lmax': '',
276 'jri': 981
277 },
278 21: {
279 'mass': 44.955912,
280 'name': 'Scandium',
281 'symbol': 'Sc',
282 'econfig': '[Ne] 3s2 3p6 | 4s2 3d1',
283 'fleur_default_econfig': '[Ne] | 3s2 3p6 4s2 3d1',
284 'lo': '3s 3p',
285 'rmt': 2.2,
286 'lmax': '',
287 'jri': 981
288 },
289 22: {
290 'mass': 47.867,
291 'name': 'Titanium',
292 'symbol': 'Ti',
293 'econfig': '[Ne] | 3s2 3p6 4s2 3d2',
294 'fleur_default_econfig': '[Ne] | 3s2 3p6 4s2 3d2',
295 'lo': '3s 3p',
296 'rmt': 2.1,
297 'lmax': '',
298 'jri': 981
299 },
300 23: {
301 'mass': 50.9415,
302 'name': 'Vanadium',
303 'symbol': 'V',
304 'econfig': '[Ne] 3s2 3p6 | 4s2 3d3',
305 'fleur_default_econfig': '[Ne] | 3s2 3p6 4s2 3d3',
306 'lo': '3s 3p',
307 'rmt': 1.9,
308 'lmax': '',
309 'jri': 981
310 },
311 24: {
312 'mass': 51.9961,
313 'name': 'Chromium',
314 'symbol': 'Cr',
315 'econfig': '[Ne] 3s2 3p6 | 4s1 3d5',
316 'fleur_default_econfig': '[Ne] | 3s2 3p6 4s1 3d5',
317 'lo': '3s 3p',
318 'rmt': 1.8,
319 'lmax': '',
320 'jri': 981
321 },
322 25: {
323 'mass': 54.938045,
324 'name': 'Manganese',
325 'symbol': 'Mn',
326 'econfig': '[Ne] 3s2 3p6 | 4s2 3d5',
327 'fleur_default_econfig': '[Ne] | 3s2 3p6 4s2 3d5',
328 'lo': '3s 3p',
329 'rmt': 2.0,
330 'lmax': '',
331 'jri': 981
332 },
333 26: {
334 'mass': 55.845,
335 'name': 'Iron',
336 'symbol': 'Fe',
337 'econfig': '[Ne] 3s2 3p6 | 4s2 3d6',
338 'fleur_default_econfig': '[Ne] | 3s2 3p6 4s2 3d6',
339 'lo': '3s 3p',
340 'rmt': 2.00,
341 'lmax': '',
342 'jri': 981
343 },
344 27: {
345 'mass': 58.933195,
346 'name': 'Cobalt',
347 'symbol': 'Co',
348 'econfig': '[Ne] 3s2 3p6 | 4s2 3d7',
349 'fleur_default_econfig': '[Ne] 3s2 | 3p6 4s2 3d7',
350 'lo': '3p',
351 'rmt': 1.9,
352 'lmax': '',
353 'jri': 981
354 },
355 28: {
356 'mass': 58.6934,
357 'name': 'Nickel',
358 'symbol': 'Ni',
359 'econfig': '[Ne] 3s2 3p6 | 4s2 3d8',
360 'fleur_default_econfig': '[Ne] 3s2 | 3p6 4s2 3d8',
361 'lo': '3p',
362 'rmt': 1.9,
363 'lmax': '',
364 'jri': 981
365 },
366 29: {
367 'mass': 63.546,
368 'name': 'Copper',
369 'symbol': 'Cu',
370 'econfig': '[Ne] 3s2 3p6 |4s1 3d10',
371 'fleur_default_econfig': '[Ne] 3s2 | 3p6 4s1 3d10',
372 'lo': '3p',
373 'rmt': 2.1,
374 'lmax': '',
375 'jri': 981
376 },
377 30: {
378 'mass': 65.38,
379 'name': 'Zinc',
380 'symbol': 'Zn',
381 'econfig': '[Ne] 3s2 3p6 | 3d10 4s2',
382 'fleur_default_econfig': '[Ne] 3s2 3p6 | 3d10 4s2',
383 'lo': '3d',
384 'rmt': 2.2,
385 'lmax': '',
386 'jri': 981
387 },
388 31: {
389 'mass': 69.723,
390 'name': 'Gallium',
391 'symbol': 'Ga',
392 'econfig': '[Ne] 3s2 3p6 | 3d10 4s2 4p1',
393 'fleur_default_econfig': '[Ne] 3s2 3p6 | 3d10 4s2 4p1',
394 'lo': '3d',
395 'rmt': 2.1,
396 'lmax': '',
397 'jri': 981
398 },
399 32: {
400 'mass': 72.64,
401 'name': 'Germanium',
402 'symbol': 'Ge',
403 'econfig': '[Ne] 3s2 3p6 | 3d10 4s2 4p2',
404 'fleur_default_econfig': '[Ne] 3s2 3p6 | 3d10 4s2 4p2',
405 'lo': '3d',
406 'rmt': 2.1,
407 'lmax': '',
408 'jri': 981
409 },
410 33: {
411 'mass': 74.9216,
412 'name': 'Arsenic',
413 'symbol': 'As',
414 'econfig': '[Ne] 3s2 3p6 | 3d10 4s2 4p3',
415 'fleur_default_econfig': '[Ne] 3s2 3p6 | 3d10 4s2 4p3',
416 'lo': '3d',
417 'rmt': 2.0,
418 'lmax': '',
419 'jri': 981
420 },
421 34: {
422 'mass': 78.96,
423 'name': 'Selenium',
424 'symbol': 'Se',
425 'econfig': '[Ne] 3s2 3p6 | 3d10 4s2 4p4',
426 'fleur_default_econfig': '[Ne] 3s2 3p6 | 3d10 4s2 4p4',
427 'lo': '3d',
428 'rmt': 2.0,
429 'lmax': '',
430 'jri': 981
431 },
432 35: {
433 'mass': 79.904,
434 'name': 'Bromine',
435 'symbol': 'Br',
436 'econfig': '[Ne] 3s2 3p6 | 3d10 4s2 4p5',
437 'fleur_default_econfig': '[Ne] 3s2 3p6 | 3d10 4s2 4p5',
438 'lo': '3d',
439 'rmt': 2.1,
440 'lmax': '',
441 'jri': 981
442 },
443 36: {
444 'mass': 83.798,
445 'name': 'Krypton',
446 'symbol': 'Kr',
447 'econfig': '[Ne] 3s2 3p6 | 3d10 4s2 4p6',
448 'fleur_default_econfig': '[Ne] 3s2 3p6 | 3d10 4s2 4p6',
449 'lo': '3d',
450 'rmt': 2.2,
451 'lmax': '',
452 'jri': 981
453 },
454 37: {
455 'mass': 85.4678,
456 'name': 'Rubidium',
457 'symbol': 'Rb',
458 'econfig': '[Ar] 3d10 4s2 | 4p6 5s1',
459 'fleur_default_econfig': '[Ar] 3d10 | 4s2 4p6 5s1',
460 'lo': '4s 4p',
461 'rmt': 2.4,
462 'lmax': '',
463 'jri': 981
464 },
465 38: {
466 'mass': 87.62,
467 'name': 'Strontium',
468 'symbol': 'Sr',
469 'econfig': '[Ar] 3d10 4s2 | 4p6 5s2',
470 'fleur_default_econfig': '[Ar] 3d10 | 4s2 4p6 5s2',
471 'lo': '4s 4p',
472 'rmt': 2.4,
473 'lmax': '',
474 'jri': 981
475 },
476 39: {
477 'mass': 88.90585,
478 'name': 'Yttrium',
479 'symbol': 'Y',
480 'econfig': '[Ar] 4s2 3d10 4p6 | 5s2 4d1',
481 'fleur_default_econfig': '[Ar] 3d10 | 4s2 4p6 5s2 4d1',
482 'lo': '4s 4p',
483 'rmt': 2.4,
484 'lmax': '',
485 'jri': 981
486 },
487 40: {
488 'mass': 91.224,
489 'name': 'Zirconium',
490 'symbol': 'Zr',
491 'econfig': '[Ar] 4s2 3d10 4p6 | 5s2 4d2',
492 'fleur_default_econfig': '[Ar] 3d10 | 4s2 4p6 5s2 4d2',
493 'lo': '4s 4p',
494 'rmt': 2.3,
495 'lmax': '',
496 'jri': 981
497 },
498 41: {
499 'mass': 92.90638,
500 'name': 'Niobium',
501 'symbol': 'Nb',
502 'econfig': '[Ar] 4s2 3d10 4p6 | 5s1 4d4',
503 'fleur_default_econfig': '[Ar] 3d10 | 4s2 4p6 5s1 4d4',
504 'lo': '4s 4p',
505 'rmt': 2.1,
506 'lmax': '',
507 'jri': 981
508 },
509 42: {
510 'mass': 95.96,
511 'name': 'Molybdenum',
512 'symbol': 'Mo',
513 'econfig': '[Ar] 4s2 3d10 4p6 | 5s1 4d5',
514 'fleur_default_econfig': '[Ar] 3d10 | 4s2 4p6 5s1 4d5',
515 'lo': '4s 4p',
516 'rmt': 2.0,
517 'lmax': '',
518 'jri': 981
519 },
520 43: {
521 'mass': 98.0,
522 'name': 'Technetium',
523 'symbol': 'Tc',
524 'econfig': '[Ar] 4s2 3d10 4p6 | 5s2 4d5',
525 'fleur_default_econfig': '[Ar] 3d10 | 4s2 4p6 5s2 4d5',
526 'lo': '4s 4p',
527 'rmt': 2.1,
528 'lmax': '',
529 'jri': 981
530 },
531 44: {
532 'mass': 101.07,
533 'name': 'Ruthenium',
534 'symbol': 'Ru',
535 'econfig': '[Ar] 4s2 3d10 4p6 | 5s1 4d7',
536 'fleur_default_econfig': '[Ar] 4s2 3d10 | 4p6 5s1 4d7',
537 'lo': '4p',
538 'rmt': 2.1,
539 'lmax': '',
540 'jri': 981
541 },
542 45: {
543 'mass': 102.9055,
544 'name': 'Rhodium',
545 'symbol': 'Rh',
546 'econfig': '[Ar] 4s2 3d10 4p6 | 5s1 4d8',
547 'fleur_default_econfig': '[Ar] 4s2 3d10 | 4p6 5s1 4d8',
548 'lo': '4p',
549 'rmt': 2.1,
550 'lmax': '',
551 'jri': 981
552 },
553 46: {
554 'mass': 106.42,
555 'name': 'Palladium',
556 'symbol': 'Pd',
557 'econfig': '[Ar] 4s2 3d10 4p6 | 4d10',
558 'fleur_default_econfig': '[Ar] 4s2 3d10 | 4p6 4d10',
559 'lo': '4p',
560 'rmt': 2.1,
561 'lmax': '',
562 'jri': 981
563 },
564 47: {
565 'mass': 107.8682,
566 'name': 'Silver',
567 'symbol': 'Ag',
568 'econfig': '[Ar] 4s2 3d10 4p6 | 5s1 4d10',
569 'fleur_default_econfig': '[Ar] 3d10 | 4s2 4p6 5s1 4d10',
570 'lo': '4s 4p',
571 'rmt': 2.3,
572 'lmax': '',
573 'jri': 981
574 },
575 48: {
576 'mass': 112.411,
577 'name': 'Cadmium',
578 'symbol': 'Cd',
579 'econfig': '[Ar] 4s2 3d10 4p6 | 4d10 5s2',
580 'fleur_default_econfig': '[Ar] 4s2 3d10 4p6 | 4d10 5s2',
581 'lo': '4d',
582 'rmt': 2.4,
583 'lmax': '',
584 'jri': 981
585 },
586 49: {
587 'mass': 114.818,
588 'name': 'Indium',
589 'symbol': 'In',
590 'econfig': '[Ar] 4s2 3d10 4p6 | 4d10 5s2 5p1',
591 'fleur_default_econfig': '[Ar] 4s2 3d10 4p6 | 4d10 5s2 5p1',
592 'lo': '4d',
593 'rmt': 2.2,
594 'lmax': '',
595 'jri': 981
596 },
597 50: {
598 'mass': 118.71,
599 'name': 'Tin',
600 'symbol': 'Sn',
601 'econfig': '[Kr] 4d10 | 5s2 5p2',
602 'fleur_default_econfig': '[Kr] | 4d10 5s2 5p2',
603 'lo': '4d',
604 'rmt': 2.3,
605 'lmax': '',
606 'jri': 981
607 },
608 51: {
609 'mass': 121.76,
610 'name': 'Antimony',
611 'symbol': 'Sb',
612 'econfig': '[Kr] 4d10 | 5s2 5p3',
613 'fleur_default_econfig': '[Kr] | 4d10 5s2 5p3',
614 'lo': '4d',
615 'rmt': 2.3,
616 'lmax': '',
617 'jri': 981
618 },
619 52: {
620 'mass': 127.6,
621 'name': 'Tellurium',
622 'symbol': 'Te',
623 'econfig': '[Kr] 4d10 | 5s2 5p4',
624 'fleur_default_econfig': '[Kr] | 4d10 5s2 5p4',
625 'lo': '4d',
626 'rmt': 2.3,
627 'lmax': '',
628 'jri': 981
629 },
630 53: {
631 'mass': 126.90447,
632 'name': 'Iodine',
633 'symbol': 'I',
634 'econfig': '[Kr] 4d10 | 5s2 5p5',
635 'fleur_default_econfig': '[Kr] | 4d10 5s2 5p5',
636 'lo': '4d',
637 'rmt': 2.2,
638 'lmax': '',
639 'jri': 981
640 },
641 54: {
642 'mass': 131.293,
643 'name': 'Xenon',
644 'symbol': 'Xe',
645 'econfig': '[Kr] 4d10 | 5s2 5p6',
646 'fleur_default_econfig': '[Kr] | 4d10 5s2 5p6',
647 'lo': '4d',
648 'rmt': 2.2,
649 'lmax': '',
650 'jri': 981
651 },
652 55: {
653 'mass': 132.9054519,
654 'name': 'Caesium',
655 'symbol': 'Cs',
656 'econfig': '[Kr] 4d10 5s2 | 5p6 6s1',
657 'fleur_default_econfig': '[Kr] 4d10 | 5s2 5p6 6s1',
658 'lo': '5s 5p',
659 'rmt': 2.4,
660 'lmax': '',
661 'jri': 981
662 },
663 56: {
664 'mass': 137.327,
665 'name': 'Barium',
666 'symbol': 'Ba',
667 'econfig': '[Kr] 4d10 5s2 | 5p6 6s2',
668 'fleur_default_econfig': '[Kr] 4d10 | 5s2 5p6 6s2',
669 'lo': '5s 5p',
670 'rmt': 2.4,
671 'lmax': '',
672 'jri': 981
673 },
674 57: {
675 'mass': 138.90547,
676 'name': 'Lanthanum',
677 'symbol': 'La',
678 'econfig': '[Kr] 4d10 5s2 | 5p6 6s2 5d1',
679 'fleur_default_econfig': '[Kr] 4d10 | 5s2 5p6 6s2 5d1',
680 'lo': '5s 5p',
681 'rmt': 2.2,
682 'lmax': '',
683 'jri': 981
684 },
685 58: {
686 'mass': 140.116,
687 'name': 'Cerium',
688 'symbol': 'Ce',
689 'econfig': '[Kr] 4d10 5s2 5p6 | 6s2 4f1 5d1',
690 'fleur_default_econfig': '[Kr] 4d10 | 5s2 5p6 6s2 4f1 5d1',
691 'lo': '5s 5p',
692 'rmt': 2.2,
693 'lmax': '',
694 'jri': 981
695 },
696 59: {
697 'mass': 140.90765,
698 'name': 'Praseodymium',
699 'symbol': 'Pr',
700 'econfig': '[Kr] 4d10 5s2 5p6 | 6s2 4f3',
701 'fleur_default_econfig': '[Kr] 4d10 | 5s2 5p6 6s2 4f3',
702 'lo': '5s 5p',
703 'rmt': 2.4,
704 'lmax': '',
705 'jri': 981
706 },
707 60: {
708 'mass': 144.242,
709 'name': 'Neodymium',
710 'symbol': 'Nd',
711 'econfig': '[Kr] 4d10 5s2 5p6 | 6s2 4f4',
712 'fleur_default_econfig': '[Kr] 4d10 | 5s2 5p6 6s2 4f4',
713 'lo': '5s 5p',
714 'rmt': 2.1,
715 'lmax': '',
716 'jri': 981
717 },
718 61: {
719 'mass': 145.0,
720 'name': 'Promethium',
721 'symbol': 'Pm',
722 'econfig': '[Kr] 4d10 5s2 5p6 | 6s2 4f5',
723 'fleur_default_econfig': '[Kr] 4d10 | 5s2 5p6 6s2 4f5',
724 'lo': '5s 5p',
725 'rmt': 2.4,
726 'lmax': '',
727 'jri': 981
728 },
729 62: {
730 'mass': 150.36,
731 'name': 'Samarium',
732 'symbol': 'Sm',
733 'econfig': '[Kr] 4d10 5s2 5p6 | 6s2 4f6',
734 'fleur_default_econfig': '[Kr] 4d10 | 5s2 5p6 6s2 4f6',
735 'lo': '5s 5p',
736 'rmt': 2.1,
737 'lmax': '',
738 'jri': 981
739 },
740 63: {
741 'mass': 151.964,
742 'name': 'Europium',
743 'symbol': 'Eu',
744 'econfig': '[Kr] 4d10 | 4f7 5s2 5p6 6s2',
745 'fleur_default_econfig': '[Kr] 4d10 | 5s2 5p6 4f7 6s2',
746 'lo': '5s 5p',
747 'rmt': 2.4,
748 'lmax': '',
749 'jri': 981
750 },
751 64: {
752 'mass': 157.25,
753 'name': 'Gadolinium',
754 'symbol': 'Gd',
755 'econfig': '[Kr] 4d10 5s2 5p6 | 6s2 4f7 5d1',
756 'fleur_default_econfig': '[Kr] 4d10 | 5s2 5p6 6s2 4f7 5d1',
757 'lo': '5s 5p',
758 'rmt': 2.2,
759 'lmax': '',
760 'jri': 981
761 },
762 65: {
763 'mass': 158.92535,
764 'name': 'Terbium',
765 'symbol': 'Tb',
766 'econfig': '[Kr] 4d10 5s2 5p6 | 6s2 4f9',
767 'fleur_default_econfig': '[Kr] 4d10 | 5s2 5p6 6s2 4f8 5d1',
768 'lo': '5s 5p',
769 'rmt': 2.1,
770 'lmax': '',
771 'jri': 981
772 },
773 66: {
774 'mass': 162.5,
775 'name': 'Dysprosium',
776 'symbol': 'Dy',
777 'econfig': '[Kr] 4d10 5s2 5p6 | 6s2 4f10',
778 'fleur_default_econfig': '[Kr] 4d10 | 5s2 5p6 6s2 4f9 5d1',
779 'lo': '5s 5p',
780 'rmt': 2.4,
781 'lmax': '',
782 'jri': 981
783 },
784 67: {
785 'mass': 164.93032,
786 'name': 'Holmium',
787 'symbol': 'Ho',
788 'econfig': '[Kr] 4d10 5s2 5p6 | 6s2 4f11',
789 'fleur_default_econfig': '[Kr] 4d10 | 5s2 5p6 6s2 4f10 5d1',
790 'lo': '5s 5p',
791 'rmt': 2.4,
792 'lmax': '',
793 'jri': 981
794 },
795 68: {
796 'mass': 167.259,
797 'name': 'Erbium',
798 'symbol': 'Er',
799 'econfig': '[Kr] 4d10 5s2 5p6 | 6s2 4f12',
800 'fleur_default_econfig': '[Kr] 4d10 | 5s2 5p6 6s2 4f11 5d1',
801 'lo': '5s 5p',
802 'rmt': 2.5,
803 'lmax': '',
804 'jri': 981
805 },
806 69: {
807 'mass': 168.93421,
808 'name': 'Thulium',
809 'symbol': 'Tm',
810 'econfig': '[Kr] 4d10 5s2 5p6 | 6s2 4f13',
811 'fleur_default_econfig': '[Kr] 4d10 | 5s2 5p6 6s2 4f12 5d1',
812 'lo': '5s 5p',
813 'rmt': 2.4,
814 'lmax': '',
815 'jri': 981
816 },
817 70: {
818 'mass': 173.054,
819 'name': 'Ytterbium',
820 'symbol': 'Yb',
821 'econfig': '[Kr] 4d10 5s2 5p6 | 6s2 4f14',
822 'fleur_default_econfig': '[Kr] 4d10 | 5s2 5p6 6s2 4f13 5d1',
823 'lo': '5s 5p',
824 'rmt': 2.6,
825 'lmax': '',
826 'jri': 981
827 },
828 71: {
829 'mass': 174.9668,
830 'name': 'Lutetium',
831 'symbol': 'Lu',
832 'econfig': '[Kr] 4d10 | 4f14 5s2 5p6 5d1 6s2',
833 'fleur_default_econfig': '[Kr] 4d10 | 5s2 5p6 4f14 6s2 5d1',
834 'lo': '5s 5p',
835 'rmt': 2.5,
836 'lmax': '',
837 'jri': 981
838 },
839 72: {
840 'mass': 178.49,
841 'name': 'Hafnium',
842 'symbol': 'Hf',
843 'econfig': '[Kr] 4d10 | 4f14 5s2 5p6 5d2 6s2',
844 'fleur_default_econfig': '[Kr] 4d10 4f14 | 5s2 5p6 6s2 5d2',
845 'lo': '5s 5p',
846 'rmt': 2.3,
847 'lmax': '',
848 'jri': 981
849 },
850 73: {
851 'mass': 180.94788,
852 'name': 'Tantalum',
853 'symbol': 'Ta',
854 'econfig': '[Kr] 4d10 4f14 | 5s2 5p6 5d3 6s2',
855 'fleur_default_econfig': '[Kr] 4d10 4f14 | 5s2 5p6 6s2 5d3',
856 'lo': '5s 5p',
857 'rmt': 2.2,
858 'lmax': '',
859 'jri': 981
860 },
861 74: {
862 'mass': 183.84,
863 'name': 'Tungsten',
864 'symbol': 'W',
865 'econfig': '[Kr] 5s2 4d10 4f14 | 5p6 6s2 5d4',
866 'fleur_default_econfig': '[Kr] 4d10 4f14 | 5s2 5p6 6s2 5d4',
867 'lo': '5s 5p',
868 'rmt': 2.1,
869 'lmax': '',
870 'jri': 981
871 },
872 75: {
873 'mass': 186.207,
874 'name': 'Rhenium',
875 'symbol': 'Re',
876 'econfig': '[Kr] 4d10 4f14 5p6 | 5s2 6s2 5d5',
877 'fleur_default_econfig': '[Kr] 4d10 4f14 | 5s2 5p6 6s2 5d5',
878 'lo': '5s 5p',
879 'rmt': 2.1,
880 'lmax': '',
881 'jri': 981
882 },
883 76: {
884 'mass': 190.23,
885 'name': 'Osmium',
886 'symbol': 'Os',
887 'econfig': '[Kr] 4d10 4f14 5p6 | 5s2 6s2 5d6',
888 'fleur_default_econfig': '[Kr] 5s2 4d10 4f14 | 5p6 6s2 5d6',
889 'lo': '5p',
890 'rmt': 2.1,
891 'lmax': '',
892 'jri': 981
893 },
894 77: {
895 'mass': 192.217,
896 'name': 'Iridium',
897 'symbol': 'Ir',
898 'econfig': '[Kr] 4d10 4f14 5p6 | 5s2 6s2 5d7',
899 'fleur_default_econfig': '[Kr] 5s2 4d10 4f14 | 5p6 6s2 5d7',
900 'lo': '5p',
901 'rmt': 2.1,
902 'lmax': '',
903 'jri': 981
904 },
905 78: {
906 'mass': 195.084,
907 'name': 'Platinum',
908 'symbol': 'Pt',
909 'econfig': '[Kr] 4d10 4f14 5p6 | 5s2 6s2 5d8',
910 'fleur_default_econfig': '[Kr] 5s2 4d10 4f14 | 5p6 6s2 5d8',
911 'lo': '5p',
912 'rmt': 2.1,
913 'lmax': '',
914 'jri': 981
915 },
916 79: {
917 'mass': 196.966569,
918 'name': 'Gold',
919 'symbol': 'Au',
920 'econfig': '[Kr] 4d10 4f14 5p6 | 5s2 6s2 5d9',
921 'fleur_default_econfig': '[Kr] 4d10 4f14 | 5s2 5p6 6s2 5d9',
922 'lo': '5s 5p',
923 'rmt': 2.2,
924 'lmax': '',
925 'jri': 981
926 },
927 80: {
928 'mass': 200.59,
929 'name': 'Mercury',
930 'symbol': 'Hg',
931 'econfig': '[Kr] 5s2 4d10 4f14 | 5p6 5d10 6s2',
932 'fleur_default_econfig': '[Kr] 5s2 4d10 4f14 5p6 | 5d10 6s2',
933 'lo': '5d',
934 'rmt': 2.4,
935 'lmax': '',
936 'jri': 981
937 },
938 81: {
939 'mass': 204.3833,
940 'name': 'Thallium',
941 'symbol': 'Tl',
942 'econfig': '[Xe] 4f14 | 5d10 6s2 6p1',
943 'fleur_default_econfig': '[Xe] 4f14 | 5d10 6s2 6p1',
944 'lo': '5d',
945 'rmt': 2.4,
946 'lmax': '',
947 'jri': 981
948 },
949 82: {
950 'mass': 207.2,
951 'name': 'Lead',
952 'symbol': 'Pb',
953 'econfig': '[Xe] 4f14 | 5d10 6s2 6p2',
954 'fleur_default_econfig': '[Xe] 4f14 | 5d10 6s2 6p2',
955 'lo': '5d',
956 'rmt': 2.4,
957 'lmax': '',
958 'jri': 981
959 },
960 83: {
961 'mass': 208.9804,
962 'name': 'Bismuth',
963 'symbol': 'Bi',
964 'econfig': '[Xe] 4f14 | 5d10 6s2 6p3',
965 'fleur_default_econfig': '[Xe] 4f14 | 5d10 6s2 6p3',
966 'lo': '5d',
967 'rmt': 2.4,
968 'lmax': '',
969 'jri': 981
970 },
971 84: {
972 'mass': 209.0,
973 'name': 'Polonium',
974 'symbol': 'Po',
975 'econfig': '[Xe] 4f14 | 5d10 6s2 6p4',
976 'fleur_default_econfig': '[Xe] 4f14 | 5d10 6s2 6p4',
977 'lo': '5d',
978 'rmt': 2.2,
979 'lmax': '',
980 'jri': 981
981 },
982 85: {
983 'mass': 210.0,
984 'name': 'Astatine',
985 'symbol': 'At',
986 'econfig': '[Xe] 4f14 | 5d10 6s2 6p5',
987 'fleur_default_econfig': '[Xe] 4f14 | 5d10 6s2 6p5',
988 'lo': '5d',
989 'rmt': 2.2,
990 'lmax': '',
991 'jri': 981
992 },
993 86: {
994 'mass': 222.0,
995 'name': 'Radon',
996 'symbol': 'Rn',
997 'econfig': '[Xe] 4f14 | 5d10 6s2 6p6',
998 'fleur_default_econfig': '[Xe] 4f14 | 5d10 6s2 6p6',
999 'lo': '5d',
1000 'rmt': 2.2,
1001 'lmax': '',
1002 'jri': 981
1003 }, # TODO: after wards not right
1004 87: {
1005 'mass': 223.0,
1006 'name': 'Francium',
1007 'symbol': 'Fr',
1008 'econfig': '[Xe] 4f14 5d10 6s2 | 6p6 7s1',
1009 'fleur_default_econfig': '[Xe] 4f14 5d10 | 6s2 6p6 7s1',
1010 'lo': '6s 6p',
1011 'rmt': 2.2,
1012 'lmax': '',
1013 'jri': 981
1014 },
1015 88: {
1016 'mass': 226.0,
1017 'name': 'Radium',
1018 'symbol': 'Ra',
1019 'econfig': '[Xe] 4f14 5d10 6s2 | 6p6 7s2',
1020 'fleur_default_econfig': '[Xe] 4f14 5d10 | 6s2 6p6 7s2',
1021 'lo': '6s 6p',
1022 'rmt': 2.2,
1023 'lmax': '',
1024 'jri': 981
1025 },
1026 89: {
1027 'mass': 227.0,
1028 'name': 'Actinium',
1029 'symbol': 'Ac',
1030 'econfig': '[Xe] 4f14 5d10 6s2 | 6p6 7s2 6d1',
1031 'fleur_default_econfig': '[Xe] 4f14 5d10 | 6s2 6p6 7s2 6d1',
1032 'lo': '6s 6p',
1033 'rmt': 2.2,
1034 'lmax': '',
1035 'jri': 981
1036 },
1037 90: {
1038 'mass': 232.03806,
1039 'name': 'Thorium',
1040 'symbol': 'Th',
1041 'econfig': '[Xe] 4f14 5d10 6s2 | 6p6 7s2 6d1 5f1',
1042 'fleur_default_econfig': '[Xe] 4f14 5d10 | 6s2 6p6 7s2 6d1 5f1',
1043 'lo': '6s 6p',
1044 'rmt': 2.2,
1045 'lmax': '',
1046 'jri': 981
1047 },
1048 91: {
1049 'mass': 231.03588,
1050 'name': 'Protactinium',
1051 'symbol': 'Pa',
1052 'econfig': '[Xe] 4f14 5d10 6s2 | 6p6 7s2 6d1 5f2',
1053 'fleur_default_econfig': '[Xe] 4f14 5d10 | 6s2 6p6 7s2 6d1 5f2',
1054 'lo': '6s 6p',
1055 'rmt': 2.2,
1056 'lmax': '',
1057 'jri': 981
1058 },
1059 92: {
1060 'mass': 238.02891,
1061 'name': 'Uranium',
1062 'symbol': 'U',
1063 'econfig': '[Xe] 4f14 5d10 6s2 6p6| 7s2 5f4',
1064 'fleur_default_econfig': '[Xe] 4f14 5d10 | 6s2 6p6 7s2 5f4',
1065 'lo': '6s 6p',
1066 'rmt': 2.3,
1067 'lmax': '',
1068 'jri': 981
1069 },
1070 93: {
1071 'mass': 237.0,
1072 'name': 'Neptunium',
1073 'symbol': 'Np',
1074 'econfig': '[Xe] 4f14 5d10 6s2 6p6 | 7s2 5f5',
1075 'fleur_default_econfig': '[Xe] 4f14 5d10 | 6s2 6p6 7s2 5f5',
1076 'lo': '6s 6p',
1077 'rmt': 2.1,
1078 'lmax': '',
1079 'jri': 981
1080 },
1081 94: {
1082 'mass': 244.0,
1083 'name': 'Plutonium',
1084 'symbol': 'Pu',
1085 'econfig': '[Xe] 4f14 5d10 6s2 6p6 | 7s2 5f6',
1086 'fleur_default_econfig': '[Xe] 4f14 5d10 | 6s2 6p6 7s2 5f6',
1087 'lo': '6s 6p',
1088 'rmt': 2.2,
1089 'lmax': '',
1090 'jri': 981
1091 },
1092 95: {
1093 'mass': 243.0,
1094 'name': 'Americium',
1095 'symbol': 'Am',
1096 'econfig': '[Xe] 4f14 5d10 6s2 6p6 | 7s2 5f7',
1097 'fleur_default_econfig': '[Xe] 4f14 5d10 | 6s2 6p6 7s2 5f7',
1098 'lo': '6s 6p',
1099 'rmt': 2.4,
1100 'lmax': '',
1101 'jri': 981
1102 },
1103 96: {
1104 'mass': 247.0,
1105 'name': 'Curium',
1106 'symbol': 'Cm',
1107 'econfig': '[Xe] 4f14 5d10 6s2 6p6 | 7s2 5f8',
1108 'fleur_default_econfig': '[Xe] 4f14 5d10 | 6s2 6p6 7s2 5f8',
1109 'lo': '6s 6p',
1110 'rmt': 2.4,
1111 'lmax': '',
1112 'jri': 981
1113 },
1114 97: {
1115 'mass': 247.0,
1116 'name': 'Berkelium',
1117 'symbol': 'Bk',
1118 'econfig': '[Xe] 4f14 5d10 6s2 6p6 | 7s2 5f9',
1119 'fleur_default_econfig': '[Xe] 4f14 5d10 | 6s2 6p6 7s2 5f9',
1120 'lo': '6s 6p',
1121 'rmt': 2.4,
1122 'lmax': '',
1123 'jri': 981
1124 },
1125 98: {
1126 'mass': 251.0,
1127 'name': 'Californium',
1128 'symbol': 'Cf',
1129 'econfig': '[Xe] 4f14 5d10 6s2 6p6 | 7s2 5f10',
1130 'fleur_default_econfig': '[Xe] 4f14 5d10 | 6s2 6p6 7s2 5f10',
1131 'lo': '6s 6p',
1132 'rmt': 2.4,
1133 'lmax': '',
1134 'jri': 981
1135 },
1136 99: {
1137 'mass': 252.0,
1138 'name': 'Einsteinium',
1139 'symbol': 'Es',
1140 'econfig': '[Xe] 4f14 5d10 6s2 6p6 | 7s2 5f11',
1141 'fleur_default_econfig': '[Xe] 4f14 5d10 | 6s2 6p6 7s2 5f11',
1142 'lo': '6s 6p',
1143 'rmt': 2.4,
1144 'lmax': '',
1145 'jri': 981
1146 },
1147 100: {
1148 'mass': 257.0,
1149 'name': 'Fermium',
1150 'symbol': 'Fm',
1151 'econfig': '[Xe] 4f14 5d10 6s2 6p6 | 7s2 5f12',
1152 'fleur_default_econfig': '[Xe] 4f14 5d10 | 6s2 6p6 7s2 5f12',
1153 'lo': '6s 6p',
1154 'rmt': 2.4,
1155 'lmax': '',
1156 'jri': 981
1157 },
1158 101: {
1159 'mass': 258.0,
1160 'name': 'Mendelevium',
1161 'symbol': 'Md',
1162 'econfig': '[Xe] 4f14 5d10 6s2 6p6 | 7s2 5f13',
1163 'fleur_default_econfig': '[Xe] 4f14 5d10 | 6s2 6p6 7s2 5f13',
1164 'lo': '6s 6p',
1165 'rmt': 2.4,
1166 'lmax': '',
1167 'jri': 981
1168 },
1169 102: {
1170 'mass': 259.0,
1171 'name': 'Nobelium',
1172 'symbol': 'No',
1173 'econfig': '[Xe] 4f14 5d10 6s2 6p6 | 7s2 5f14',
1174 'fleur_default_econfig': '[Xe] 4f14 5d10 | 6s2 6p6 7s2 5f14',
1175 'lo': '6s 6p',
1176 'rmt': 2.4,
1177 'lmax': '',
1178 'jri': 981
1179 },
1180 103: {
1181 'mass': 262.0,
1182 'name': 'Lawrencium',
1183 'symbol': 'Lr',
1184 'econfig': '[Xe] 4f14 5d10 6s2 6p6 | 7s2 5f14 6d1',
1185 'fleur_default_econfig': '[Xe] 4f14 5d10 | 6s2 6p6 7s2 5f14 6d1',
1186 'lo': '6s 6p 5f',
1187 'rmt': 2.4,
1188 'lmax': '',
1189 'jri': 981
1190 },
1191 104: {
1192 'mass': 267.0,
1193 'name': 'Rutherfordium',
1194 'symbol': 'Rf',
1195 'econfig': '[Xe] 4f14 5d10 6s2 6p6 | 7s2 5f14 6d2',
1196 'fleur_default_econfig': '[Xe] 4f14 5d10 6s2 6p6 | 7s2 5f14 6d2',
1197 'lo': '6p 5f',
1198 'rmt': 2.4,
1199 'lmax': '',
1200 'jri': 981
1201 },
1202 105: {
1203 'mass': 268.0,
1204 'name': 'Dubnium',
1205 'symbol': 'Db',
1206 'econfig': '[Xe] 4f14 5d10 6s2 6p6 | 7s2 5f14 6d3',
1207 'fleur_default_econfig': '[Xe] 4f14 5d10 6s2 | 6p6 7s2 5f14 6d3',
1208 'lo': '6p 5f',
1209 'rmt': 2.4,
1210 'lmax': '',
1211 'jri': 981
1212 },
1213 106: {
1214 'mass': 271.0,
1215 'name': 'Seaborgium',
1216 'symbol': 'Sg',
1217 'econfig': '[Xe] 4f14 5d10 6s2 6p6 | 7s2 5f14 6d4',
1218 'fleur_default_econfig': '[Xe] 4f14 5d10 6s2 | 6p6 7s2 5f14 6d4',
1219 'lo': '6p 5f',
1220 'rmt': 2.4,
1221 'lmax': '',
1222 'jri': 981
1223 },
1224 107: {
1225 'mass': 272.0,
1226 'name': 'Bohrium',
1227 'symbol': 'Bh',
1228 'econfig': '[Rn] 7s2 5f14 | 6d5',
1229 'fleur_default_econfig': '[Xe] 4f14 5d10 6s2 6p6 5f14 | 7s2 6d5',
1230 'lo': '',
1231 'rmt': 2.4,
1232 'lmax': '',
1233 'jri': 981
1234 },
1235 108: {
1236 'mass': 270.0,
1237 'name': 'Hassium',
1238 'symbol': 'Hs',
1239 'econfig': '[Rn] 7s2 5f14 | 6d6',
1240 'fleur_default_econfig': '[Rn] 5f14 | 7s2 6d6',
1241 'lo': '',
1242 'rmt': 2.4,
1243 'lmax': '',
1244 'jri': 981
1245 },
1246 109: {
1247 'mass': 276.0,
1248 'name': 'Meitnerium',
1249 'symbol': 'Mt',
1250 'econfig': '[Rn] 7s2 5f14 | 6d7',
1251 'fleur_default_econfig': '[Rn] 5f14 | 7s2 6d7',
1252 'lo': '',
1253 'rmt': 2.4,
1254 'lmax': '',
1255 'jri': 981
1256 },
1257 110: {
1258 'mass': 281.0,
1259 'name': 'Darmstadtium',
1260 'symbol': 'Ds',
1261 'econfig': '[Rn] 7s2 5f14 | 6d8',
1262 'fleur_default_econfig': '[Rn] 5f14 | 7s2 6d8',
1263 'lo': '',
1264 'rmt': 2.4,
1265 'lmax': '',
1266 'jri': 981
1267 },
1268 111: {
1269 'mass': 280.0,
1270 'name': 'Roentgenium',
1271 'symbol': 'Rg',
1272 'econfig': '[Rn] 7s2 5f14 | 6d9',
1273 'fleur_default_econfig': '[Rn] 5f14 | 7s2 6d9',
1274 'lo': '',
1275 'rmt': 2.4,
1276 'lmax': '',
1277 'jri': 981
1278 },
1279 112: {
1280 'mass': 285.0,
1281 'name': 'Copernicium',
1282 'symbol': 'Cn',
1283 'econfig': '[Rn] 7s2 5f14 | 6d10',
1284 'fleur_default_econfig': '[Rn] 5f14 | 7s2 6d10',
1285 'lo': '6d',
1286 'rmt': 2.4,
1287 'lmax': '',
1288 'jri': 981
1289 },
1290 113: {
1291 'mass': 285.0,
1292 'name': 'Nihomium',
1293 'symbol': 'Nh',
1294 'econfig': '[Rn] 7s2 5f14 | 6d10 7p1',
1295 'fleur_default_econfig': '[Rn] 7s2 5f14 | 6d10 7p1',
1296 'lo': '6d',
1297 'rmt': 2.4,
1298 'lmax': '',
1299 'jri': 981
1300 },
1301 114: {
1302 'mass': 289.0,
1303 'name': 'Flerovium',
1304 'symbol': 'Fl',
1305 'econfig': '[Rn] 7s2 5f14 | 6d10 7p2',
1306 'fleur_default_econfig': '[Rn] 7s2 5f14 | 6d10 7p2',
1307 'lo': '6d',
1308 'rmt': 2.4,
1309 'lmax': '',
1310 'jri': 981
1311 },
1312 115: {
1313 'mass': 0.0,
1314 'name': 'Mascovium',
1315 'symbol': 'Mc',
1316 'econfig': '[Rn] 7s2 5f14 | 6d10 7p3',
1317 'fleur_default_econfig': '[Rn] 7s2 5f14 | 6d10 7p3',
1318 'lo': '6d',
1319 'rmt': 2.4,
1320 'lmax': '',
1321 'jri': 981
1322 },
1323 116: {
1324 'mass': 293.0,
1325 'name': 'Livermorium',
1326 'symbol': 'Lv',
1327 'econfig': '[Rn] 7s2 5f14 | 6d10 7p4',
1328 'fleur_default_econfig': '[Rn] 7s2 5f14 | 6d10 7p4',
1329 'lo': '6d',
1330 'rmt': 2.4,
1331 'lmax': '',
1332 'jri': 981
1333 },
1334 117: {
1335 'mass': 0.0,
1336 'name': 'Tennessine',
1337 'symbol': 'Ts',
1338 'econfig': '[Rn] 7s2 5f14 | 6d10 7p5',
1339 'fleur_default_econfig': '[Rn] 7s2 5f14 | 6d10 7p5',
1340 'lo': '6d',
1341 'rmt': 2.4,
1342 'lmax': '',
1343 'jri': 981
1344 },
1345 118: {
1346 'mass': 0.0,
1347 'name': 'Oganesson',
1348 'symbol': 'Og',
1349 'econfig': '[Rn] 7s2 5f14 | 6d10 7p6',
1350 'fleur_default_econfig': '[Rn] 7s2 5f14 | 6d10 7p6',
1351 'lo': '6d',
1352 'rmt': 2.4,
1353 'lmax': '',
1354 'jri': 981
1355 }
1356}
1357
1358ATOMIC_NUMBERS = {data['symbol']: num for num, data in PERIODIC_TABLE_ELEMENTS.items()}