Pymatgen I/O Validation

0.1.2 · active · verified Thu Apr 16

Pymatgen-io-validation is a Python library, currently at version 0.1.2, that extends the pymatgen framework to provide comprehensive I/O validation for electronic structure calculations. It primarily focuses on ensuring VASP calculations are compliant with the stringent standards required for integration with the Materials Project database. The library helps identify discrepancies between a calculation and a provided input set, flags known bugs related to parameter combinations, and performs other critical checks. Its release cadence typically involves minor updates to address dependencies and improve validation logic.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to instantiate `VaspValidator` from a VASP calculation directory and check its validity, reasons for invalidation, and any warnings. The `from_directory` class method automatically parses the necessary VASP input and output files to perform the checks. The `valid`, `reasons`, and `warnings` attributes of the returned `validation_doc` object provide a comprehensive report.

import os
from pymatgen.io.validation import VaspValidator

# Assuming 'path_to_vasp_calculation_directory' contains VASP input/output files (e.g., INCAR, KPOINTS, POSCAR, OUTCAR)
# For a runnable example, we'll create a dummy directory and files.
# In a real scenario, this path would point to your actual VASP calculation directory.

dummy_vasp_dir = "./dummy_vasp_calc"
os.makedirs(dummy_vasp_dir, exist_ok=True)

with open(os.path.join(dummy_vasp_dir, "INCAR"), "w") as f:
    f.write("ENCUT = 520\nISIF = 2\nISYM = 2\nPREC = Accurate\nALGO = Fast\n")
with open(os.path.join(dummy_vasp_dir, "POSCAR"), "w") as f:
    f.write("Dummy structure\n1.0\n1.0 0.0 0.0\n0.0 1.0 0.0\n0.0 0.0 1.0\nFe\n1\nDirect\n0.0 0.0 0.0\n")
# Add other necessary dummy files (KPOINTS, POTCAR) for a full run if needed, 
# but the example focuses on VaspValidator usage structure.

# Validate a VASP calculation from its directory
validation_doc = VaspValidator.from_directory(dummy_vasp_dir)

print(f"Calculation is valid: {validation_doc.valid}")
if not validation_doc.valid:
    print("Reasons for invalidation:")
    for reason in validation_doc.reasons:
        print(f"- {reason}")
if validation_doc.warnings:
    print("Warnings:")
    for warning in validation_doc.warnings:
        print(f"- {warning}")

# Clean up dummy files
os.remove(os.path.join(dummy_vasp_dir, "INCAR"))
os.remove(os.path.join(dummy_vasp_dir, "POSCAR"))
os.rmdir(dummy_vasp_dir)

view raw JSON →