Source code for vaspparser.vasp.parser.report

# Copyright (c) Max-Planck-Institut für Eisenforschung GmbH - Computational Materials Design (CM) Department
# Distributed under the terms of "New BSD License", see the LICENSE file.

from typing import Dict

import numpy as np
from scipy.integrate import cumulative_trapezoid

__author__ = "Sudarsan Surendralal"
__copyright__ = (
    "Copyright 2021, Max-Planck-Institut für Eisenforschung GmbH - "
    "Computational Materials Design (CM) Department"
)
__version__ = "1.0"
__maintainer__ = "Sudarsan Surendralal"
__email__ = "surendralal@mpie.de"
__status__ = "production"
__date__ = "Mar 1, 2020"


[docs] class Report: """ This module is used to parse VASP REPORT files """
[docs] def __init__(self) -> None: self.parse_dict: Dict[str, np.ndarray] = dict()
[docs] def from_file(self, filename: str = "REPORT") -> None: """ Reads values from files and stores it in the `parse_dict` attribute Args: filename (str): Path to the file that needs to be parsed """ with open(filename, errors="ignore") as f: lines = f.readlines() rel_lines = [ lines[i + 2] for i, line in enumerate(lines) if "Blue_moon" in line ] if len(rel_lines) > 0: [lam, _, _, _] = list(np.genfromtxt(rel_lines, usecols=[1, 2, 3, 4]).T) rel_lines = [line for i, line in enumerate(lines) if "cc>" in line] cv = np.genfromtxt(rel_lines, usecols=[2]) fe = cumulative_trapezoid(lam, cv) self.parse_dict["cv_full"] = cv self.parse_dict["derivative"] = lam self.parse_dict["cv"] = cv[:-1] self.parse_dict["free_energy"] = fe