19
19
from enum import Enum , unique
20
20
from glob import glob
21
21
from hashlib import sha256
22
+ from pathlib import Path
23
+ from shutil import copyfileobj
22
24
from typing import TYPE_CHECKING , NamedTuple , cast
23
25
from zipfile import ZipFile
24
26
39
41
40
42
if TYPE_CHECKING :
41
43
from collections .abc import Iterator
42
- from pathlib import Path
43
44
from typing import Any , ClassVar , Literal
44
45
45
46
from numpy .typing import ArrayLike
@@ -2801,6 +2802,7 @@ def write_input(
2801
2802
make_dir_if_not_present : bool = True ,
2802
2803
cif_name : str | None = None ,
2803
2804
zip_name : str | None = None ,
2805
+ files_to_transfer : dict | None = None ,
2804
2806
) -> None :
2805
2807
"""
2806
2808
Write VASP inputs to a directory.
@@ -2813,7 +2815,11 @@ def write_input(
2813
2815
cif_name (str or None): If a str, the name of the CIF file
2814
2816
to write the POSCAR to (the POSCAR will also be written).
2815
2817
zip_name (str or None): If a str, the name of the zip to
2816
- archive the vasp input set to.
2818
+ archive the VASP input set to.
2819
+ files_to_transfer (dict) : A dictionary of
2820
+ { < input filename >: < output filepath >}.
2821
+ This allows the transfer of < input filename > files from
2822
+ a previous calculation to < output filepath >.
2817
2823
"""
2818
2824
if not os .path .isdir (output_dir ) and make_dir_if_not_present :
2819
2825
os .makedirs (output_dir )
@@ -2840,6 +2846,11 @@ def write_input(
2840
2846
except (FileNotFoundError , PermissionError , IsADirectoryError ):
2841
2847
pass
2842
2848
2849
+ files_to_transfer = files_to_transfer or {}
2850
+ for key , val in files_to_transfer .items ():
2851
+ with zopen (val , "rb" ) as fin , zopen (str (Path (output_dir ) / key ), "wb" ) as fout :
2852
+ copyfileobj (fin , fout )
2853
+
2843
2854
@classmethod
2844
2855
def from_directory (
2845
2856
cls ,
0 commit comments