aiida_cp2k.utils package


aiida_cp2k.utils.datatype_helpers module

AiiDA-CP2K Gaussian Datatype Helpers.


Our unique identifier for gaussian datatypes


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.datatype_helpers.write_basissets(inp, basissets, folder)[source]

Writes the unified BASIS_SETS file with the used basissets

aiida_cp2k.utils.datatype_helpers.write_pseudos(inp, pseudos, folder)[source]

Writes the unified POTENTIAL file with the used pseudos

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>})

Initializing Cp2kInput object

__module__ = 'aiida_cp2k.utils.input_generator'

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


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.


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.


Iterator yielding ((section,section,…,section/keyword), value) tuples


Add restart section to the input dictionary.

aiida_cp2k.utils.parser module

AiiDA-CP2K input plugin.

aiida_cp2k.utils.parser._parse_bands(lines, n_start)[source]

Parse band structure from cp2k output


Parse CP2K output into a dictionary.


Parse CP2K output into a dictionary (ADVANCED: more info parsed @ PRINT_LEVEL MEDIUM).


CP2K trajectory parser.

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 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. The merge_dct is merged into dct. :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]

aiida_cp2k.utils.workchains.resize_unit_cell(struct, resize)[source]

Resize the StructureData according to the resize Dict

Module contents

AiiDA-CP2K utils