vasp_log — Source-based detailed API notes
This page preserves the full implementation analysis supplied in the Japanese manual for vasp_log. Function signatures, source locations, call graphs, explicit exceptions, return expressions, and branch conditions are retained. Japanese source docstrings and comments are quoted verbatim rather than represented as English translations. These observations are static and are not runtime guarantees.
Source file: vasp_log(3).py。公開・非公開の定義を含みます。以下の条件分岐、戻り値式、例外は AST から機械的に抽出したもので、実行時の挙動を検証したものではありません。
class VaspLog
VASP の出力ファイルを計算後に整理・解析するクラス
__init__
def __init__(self, logger: Optional[XLogger]=None) -> None
Original docstring (source language)
Args:
logger (XLogger): 全てのインスタンスが同じ XLogger()
Calls (static AST extraction): XLogger
Instance attributes assigned directly: self._logger
Source location: L24–L32(添付版)。
_exists_either
@staticmethod
Original docstring (source language)
通常 or .gz のどちらかが存在するか
Calls (static AST extraction): path.exists, path.with_suffix, path.with_suffix(path.suffix + '.gz').exists
Return expressions (static extraction): path.exists() or path.with_suffix(path.suffix + '.gz').exists()
Source location: L39–L43(添付版)。
_copy_either
def _copy_either(self, src: Path, dst: Path) -> None
Original docstring (source language)
通常 or .gz を copy。必要に応じて .gz 拡張子を付与
Calls (static AST extraction): Path, gzsrc.exists, self._logger.info, shutil.copyfile, src.exists, src.with_suffix, str
Principal conditions (static extraction): src.exists(); gzsrc.exists()
Source location: L45–L59(添付版)。
_move_either
def _move_either(self, src: Path, dst: Path) -> None
Original docstring (source language)
通常 or .gz を move。必要に応じて .gz 拡張子を付与
Calls (static AST extraction): Path, gzsrc.exists, self._logger.info, shutil.move, src.exists, src.with_suffix, str
Principal conditions (static extraction): src.exists(); gzsrc.exists()
Source location: L61–L75(添付版)。
vcopy
def vcopy(self, suffix: str) -> None
Original docstring (source language)
Vcopy と同等の整理処理を実行(Vcopy2 は未実装)。
Args:
suffix (str): 付与する接尾辞(例: "A1" など)
Calls (static AST extraction): FileNotFoundError, Path, Path('OUTCAR').exists, Path('OUTCAR.gz').exists, contcar.exists, contcar.with_suffix, contcar_gz.exists, gzip.open, name.lower, open, os.chmod, os.getpid, poscar_backup.exists, self._copy_either, self._exists_either, self._logger.info, self._move_either, shutil.copyfile, shutil.copyfileobj
Explicitly raised exceptions: FileNotFoundError('STOP: OUTCAR and OUTCAR.gz file not found.')
Principal conditions (static extraction): not (Path('OUTCAR').exists() or Path('OUTCAR.gz').exists()); self._exists_either(dst); contcar.exists() or contcar_gz.exists(); src_path.suffix == '.gz'; poscar_backup.exists()
Source location: L77–L157(添付版)。
get_E0
@staticmethod
Original docstring (source language)
OSZICAR から E0 を取り出して、ファイル保存する
(廃止予定)
Args:
input_filename:
output_filename:
key:
Returns:
Calls (static AST extraction): f.readlines, open, outfile.writelines, print
Principal conditions (static extraction): key in line
Source location: L161–L187(添付版)。
collect_result
def collect_result(self)
Original docstring (source language)
VASPのログからひつようなじょうほうをとりだして、保存する
This function is used to grep energy from OUTCAR file.
Calls (static AST extraction): self._logger.info, self.get_E0
Source location: L189–L195(添付版)。
backup_result
def backup_result(self, log_dir: str='log') -> bool
Original docstring (source language)
Copy VASP log files to the specified directory.
Args:
log_dir (str): Directory to copy the log files to.
Calls (static AST extraction): os.makedirs, os.path.exists, self._logger.info, shutil.copy
Return expressions (static extraction): True
Principal conditions (static extraction): not os.path.exists(log_dir); os.path.exists(file_name)
Source location: L197–L233(添付版)。
remove_file
def remove_file(self, filename: str) -> None
Original docstring (source language)
存在するファイルを削除
Calls (static AST extraction): os.path.exists, os.remove, self._logger.info
Principal conditions (static extraction): os.path.exists(filename)
Source location: L235–L239(添付版)。
remove_pattern
def remove_pattern(self, pattern: str) -> None
Original docstring (source language)
ワイルドカードパターンで一致するファイルを削除
Calls (static AST extraction): glob.glob, os.remove, self._logger.info
Source location: L241–L248(添付版)。
clean
def clean(self, suffixes: List[str]=None) -> None
Original docstring (source language)
Args:
suffixes (str):
Returns:
Calls (static AST extraction): f.lower, f.upper, self.remove_file, self.remove_pattern
Principal conditions (static extraction): not suffixes
Source location: L250–L330(添付版)。