TestData

pydantic model atomate2.utils.testing.vasp.TestData[source]

Utility class to group VASP testing data.

This is the base class, for creating an archive of test data, use VaspTestData.from_directory on a valid VASP calculation directory.

This class also defines methods to establish appropriate directory structure for VASP test data, without user intervention:

base_dir :
  • inputs
    • INCAR

    • KPOINTS (optional)

    • POSCAR

    • POTCAR.spec

  • outputs
    • INCAR

    • KPOINTS (optional)

    • POSCAR

    • POTCAR.spec

    • CONTCAR

    • OUTCAR

    • vasprun.xml

Validators:
  • serialize_from_str » all fields

static flatten_dict(dct, separator='.')[source]

Flatten an input dict with a nested structure.

Parameters:
  • dct (dict)

  • separator (str = ".") –

    The separator to use to flatten keys, e.g.:

    x = {“a”: {“b”: 1}}

    would get flattened into

    x = {“a.b”: 1}

Return type:

Flattened dict

classmethod from_directory(dir_name, suffix=None, **kwargs)[source]

Create an instance of TestData recursively from a directory.

If a subclass includes nested TestData subclasses, they will also call from_directory recursively. This permits an appropriate input / output directory structure to be created automatically.

This class also removes copyright-protected POTCAR data and converts it to a POTCAR.spec object.

Note that any field names with “_” characters have these replaced by “.” when parsing.

Parameters:
  • dir_name (str or Path) – Path to where the VASP files are located

  • suffix (str or None (default)) – suffix of files, like “.orig” if inclusign original inputs.

Return type:

Self

to_dict(prefix=None, suffix=None)[source]

Convert the current test data to a JSON-able dict.

Parameters:
  • prefix (str or None (default)) – Hierarchical prefix, e.g., “inputs” or “outputs”

  • suffix (str or None (default)) – Optional file suffix, e.g., “.orig”

Returns:

dict[str,str]

Return type:

JSON-able dict

to_file(file_name)[source]

Dump the dict representation of the test data to a file.

Parameters:

file_name (str or Path)

Return type:

None

reconstruct(out_path=None, copy_input=True)[source]

Write the files with correct directory structure to a directory.

Parameters:
  • out_path (str, Path, or None) – Optional output base directory to write files to. Defaults to “.”

  • copy_input (bool = True (default)) – Whether to copy all input files to the “output” directory. This is the default behavior for VASP test data.

Return type:

None