aiida_cp2k.utils package¶
Submodules¶
aiida_cp2k.utils.datatype_helpers module¶
AiiDA-CP2K Gaussian Datatype Helpers.
- aiida_cp2k.utils.datatype_helpers._kind_element_from_kind_section(section)[source]¶
Get both kind and chemical symbol from a section, implementing the same auto-detection for chemical symbol/element from a KIND parameter as CP2K does.
- aiida_cp2k.utils.datatype_helpers._parse_name(label, default_type, sep=None)[source]¶
Both BASIS_SET and POTENTIAL values can consist of either a single word or multiple ones, of which the first will be the type (if present). Here we parse it and always return a tuple.
- aiida_cp2k.utils.datatype_helpers._prepare_kind_section(inp, kind)[source]¶
Insert a KIND section for a given ‘StructureData.Kind’. Returns a reference to the newly created KIND section.
- aiida_cp2k.utils.datatype_helpers._unpack(adict)[source]¶
Unpack any lists as values into single elements for the key
- aiida_cp2k.utils.datatype_helpers._validate_gdt_namespace(entries, gdt_cls, attr)[source]¶
Common namespace validator for both basissets and pseudos
- aiida_cp2k.utils.datatype_helpers._write_gdt(inp, entries, folder, key, fname)[source]¶
inject <key>=<fname> into all FORCE_EVAL/DFT sections and write the entries to a file
- aiida_cp2k.utils.datatype_helpers.validate_basissets(inp, basissets, structure)[source]¶
Verify that all referenced basissets are present in the input. Currently supports 2 modes: either all of the basisssets are explicitly listed in a KIND section, or none of them are, at which point they’re verified against the symbols in the structure.
- aiida_cp2k.utils.datatype_helpers.validate_basissets_namespace(basissets, _)[source]¶
A input_namespace validator to ensure passed down basis sets have the correct type.
- aiida_cp2k.utils.datatype_helpers.validate_pseudos(inp, pseudos, structure)[source]¶
Verify that all referenced pseudos are present in the input
- aiida_cp2k.utils.datatype_helpers.validate_pseudos_namespace(pseudos, _)[source]¶
A input_namespace validator to ensure passed down pseudopentials have the correct type.
aiida_cp2k.utils.input_generator module¶
AiiDA-CP2K input generator.
- class aiida_cp2k.utils.input_generator.Cp2kInput(params=None)[source]¶
Bases:
object
Transforms dictionary into CP2K input
- DISCLAIMER = '!!! Generated by AiiDA !!!'¶
- __dict__ = mappingproxy({'__module__': 'aiida_cp2k.utils.input_generator', '__doc__': 'Transforms dictionary into CP2K input', 'DISCLAIMER': '!!! Generated by AiiDA !!!', '__init__': <function Cp2kInput.__init__>, '__getitem__': <function Cp2kInput.__getitem__>, 'add_keyword': <function Cp2kInput.add_keyword>, 'render': <function Cp2kInput.render>, 'param_iter': <function Cp2kInput.param_iter>, '_add_keyword': <staticmethod object>, '_render_section': <staticmethod object>, '__dict__': <attribute '__dict__' of 'Cp2kInput' objects>, '__weakref__': <attribute '__weakref__' of 'Cp2kInput' objects>, '__annotations__': {}})¶
- __module__ = 'aiida_cp2k.utils.input_generator'¶
- __weakref__¶
list of weak references to the object (if defined)
- static _add_keyword(kwpath, value, params, ovrd, cfct)[source]¶
Add keyword into the given nested dictionary
- static _render_section(output, params, indent=0)[source]¶
It takes a dictionary and recurses through.
For key-value pair it checks whether the value is a dictionary and prepends the key with & (CP2K section). It passes the valued to the same function, increasing the indentation. If the value is a list, I assume that this is something the user wants to store repetitively eg: .. highlight:
dict['KEY'] = ['val1', 'val2'] ===> KEY val1 KEY val2 or dict['KIND'] = [{'_': 'Ba', 'ELEMENT':'Ba'}, {'_': 'Ti', 'ELEMENT':'Ti'}, {'_': 'O', 'ELEMENT':'O'}] ====> &KIND Ba ELEMENT Ba &END KIND &KIND Ti ELEMENT Ti &END KIND &KIND O ELEMENT O &END KIND
- add_keyword(kwpath, value, override=True, conflicting_keys=None)[source]¶
Add a value for the given keyword.
Args:
- kwpath: Can be a single keyword, a path with / as divider for sections & key,
or a sequence with sections and key.
value: the value to set the given key to
override: whether to override the key if it is already present in the self._params
conflicting_keys: list of keys that cannot live together with the provided key (SOMETHING1/[..]/SOMETHING2/KEY). In case override is True, all conflicting keys will be removed, if override is False and conflicting_keys are present the new key won’t be added.
- aiida_cp2k.utils.input_generator.add_ext_restart_section(input_dict)[source]¶
Add external restart section to the input dictionary.
aiida_cp2k.utils.parser module¶
AiiDA-CP2K input plugin.
- aiida_cp2k.utils.parser._parse_bands(lines, n_start, cp2k_version)[source]¶
Parse band structure from the CP2K output.
- aiida_cp2k.utils.parser._parse_bands_cp2k_greater_81(lines, line_n)[source]¶
Parse one k-point in the output of CP2K >=8.1
- aiida_cp2k.utils.parser._parse_kpoint_cp2k_lower_81(lines, line_n)[source]¶
Parse one k-point in the output of CP2K <8.1
aiida_cp2k.utils.workchains module¶
AiiDA-CP2K utilities for workchains
- aiida_cp2k.utils.workchains.check_resize_unit_cell(struct, threshold)[source]¶
Returns the multiplication factors for the cell vectors to respect, in every direction: min(perpendicular_width) > threshold.
- aiida_cp2k.utils.workchains.get_input_multiplicity(structure, protocol_settings)[source]¶
Compute the total multiplicity of the structure, by summing the atomic magnetizations: multiplicity = 1 + sum_i ( natoms_i * magnetization_i ), for each atom_type i
- aiida_cp2k.utils.workchains.get_kinds_section(structure, protocol_settings)[source]¶
Write the &KIND sections given the structure and the settings_dict
- aiida_cp2k.utils.workchains.merge_Dict(d1, d2)[source]¶
Make all the data in the second Dict overwrite the corrisponding data in the first Dict
- aiida_cp2k.utils.workchains.merge_dict(dct, merge_dct)[source]¶
Taken from https://gist.github.com/angstwad/bf22d1822c38a92ec0a9 Recursive dict merge. Inspired by :meth:
dict.update()
, instead of updating only top-level keys, merge_dict recurses down into dicts nested to an arbitrary depth, updating keys. Themerge_dct
is merged intodct
. :param dct: dict onto which the merge is executed :param merge_dct: dct merged into dct (overwrites dct data if in both) :return: None
- aiida_cp2k.utils.workchains.ot_has_small_bandgap(cp2k_input, cp2k_output, bandgap_thr_ev)[source]¶
Returns True if the calculation used OT and had a smaller bandgap then the guess needed for the OT. (NOTE: It has been observed also negative bandgap with OT in CP2K!) cp2k_input: dict cp2k_output: dict bandgap_thr_ev: float [eV]
Module contents¶
AiiDA-CP2K utils
- class aiida_cp2k.utils.Cp2kInput(params=None)[source]¶
Bases:
object
Transforms dictionary into CP2K input
- DISCLAIMER = '!!! Generated by AiiDA !!!'¶
- __annotations__ = {}¶
- __dict__ = mappingproxy({'__module__': 'aiida_cp2k.utils.input_generator', '__doc__': 'Transforms dictionary into CP2K input', 'DISCLAIMER': '!!! Generated by AiiDA !!!', '__init__': <function Cp2kInput.__init__>, '__getitem__': <function Cp2kInput.__getitem__>, 'add_keyword': <function Cp2kInput.add_keyword>, 'render': <function Cp2kInput.render>, 'param_iter': <function Cp2kInput.param_iter>, '_add_keyword': <staticmethod object>, '_render_section': <staticmethod object>, '__dict__': <attribute '__dict__' of 'Cp2kInput' objects>, '__weakref__': <attribute '__weakref__' of 'Cp2kInput' objects>, '__annotations__': {}})¶
- __module__ = 'aiida_cp2k.utils.input_generator'¶
- __weakref__¶
list of weak references to the object (if defined)
- static _add_keyword(kwpath, value, params, ovrd, cfct)[source]¶
Add keyword into the given nested dictionary
- static _render_section(output, params, indent=0)[source]¶
It takes a dictionary and recurses through.
For key-value pair it checks whether the value is a dictionary and prepends the key with & (CP2K section). It passes the valued to the same function, increasing the indentation. If the value is a list, I assume that this is something the user wants to store repetitively eg: .. highlight:
dict['KEY'] = ['val1', 'val2'] ===> KEY val1 KEY val2 or dict['KIND'] = [{'_': 'Ba', 'ELEMENT':'Ba'}, {'_': 'Ti', 'ELEMENT':'Ti'}, {'_': 'O', 'ELEMENT':'O'}] ====> &KIND Ba ELEMENT Ba &END KIND &KIND Ti ELEMENT Ti &END KIND &KIND O ELEMENT O &END KIND
- add_keyword(kwpath, value, override=True, conflicting_keys=None)[source]¶
Add a value for the given keyword.
Args:
- kwpath: Can be a single keyword, a path with / as divider for sections & key,
or a sequence with sections and key.
value: the value to set the given key to
override: whether to override the key if it is already present in the self._params
conflicting_keys: list of keys that cannot live together with the provided key (SOMETHING1/[..]/SOMETHING2/KEY). In case override is True, all conflicting keys will be removed, if override is False and conflicting_keys are present the new key won’t be added.
- aiida_cp2k.utils.add_ext_restart_section(input_dict)[source]¶
Add external restart section to the input dictionary.
- aiida_cp2k.utils.add_restart_sections(input_dict)[source]¶
Add restart section to the input dictionary.
- aiida_cp2k.utils.add_wfn_restart_section(input_dict, is_kpoints)[source]¶
Add wavefunction restart section to the input dictionary.
- aiida_cp2k.utils.check_resize_unit_cell(struct, threshold)[source]¶
Returns the multiplication factors for the cell vectors to respect, in every direction: min(perpendicular_width) > threshold.
- aiida_cp2k.utils.get_input_multiplicity(structure, protocol_settings)[source]¶
Compute the total multiplicity of the structure, by summing the atomic magnetizations: multiplicity = 1 + sum_i ( natoms_i * magnetization_i ), for each atom_type i
- aiida_cp2k.utils.get_kinds_section(structure, protocol_settings)[source]¶
Write the &KIND sections given the structure and the settings_dict
- aiida_cp2k.utils.merge_Dict(d1, d2)[source]¶
Make all the data in the second Dict overwrite the corrisponding data in the first Dict
- aiida_cp2k.utils.merge_dict(dct, merge_dct)[source]¶
Taken from https://gist.github.com/angstwad/bf22d1822c38a92ec0a9 Recursive dict merge. Inspired by :meth:
dict.update()
, instead of updating only top-level keys, merge_dict recurses down into dicts nested to an arbitrary depth, updating keys. Themerge_dct
is merged intodct
. :param dct: dict onto which the merge is executed :param merge_dct: dct merged into dct (overwrites dct data if in both) :return: None
- aiida_cp2k.utils.ot_has_small_bandgap(cp2k_input, cp2k_output, bandgap_thr_ev)[source]¶
Returns True if the calculation used OT and had a smaller bandgap then the guess needed for the OT. (NOTE: It has been observed also negative bandgap with OT in CP2K!) cp2k_input: dict cp2k_output: dict bandgap_thr_ev: float [eV]