Skip to content

Commit

Permalink
VaspInputSet couldn't write cif structures (#2721)
Browse files Browse the repository at this point in the history
* cleanup fix for 'AttributeError: 'PosixPath' object has no attribute 'lower'

* add missing arguments to doc strings

Co-authored-by: Janosh Riebesell <janosh.riebesell@gmail.com>
  • Loading branch information
JiQi535 and janosh committed Nov 8, 2022
1 parent c7fe7f5 commit d17a0f4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion pymatgen/io/vasp/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1908,7 +1908,8 @@ def from_symbol_and_functional(symbol: str, functional: str = None):
psingle = PotcarSingle.from_file(p)
return psingle
raise OSError(
f"You do not have the right POTCAR with functional {functional} and label {symbol} in your VASP_PSP_DIR"
f"You do not have the right POTCAR with functional {functional} and label {symbol} "
f"in your VASP_PSP_DIR. Paths tried: {paths_to_try}"
)

@property
Expand Down
12 changes: 8 additions & 4 deletions pymatgen/io/vasp/sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,11 @@ def write_input(
vinput = self.get_vasp_input()
vinput.write_input(output_dir, make_dir_if_not_present=make_dir_if_not_present)

cifname = ""
cif_name = ""
if include_cif:
s = vinput["POSCAR"].structure
cifname = Path(output_dir) / (re.sub(r"\s", "", s.formula) + ".cif")
s.to(filename=cifname)
cif_name = f"{output_dir}/{s.formula.replace(' ', '')}.cif"
s.to(filename=cif_name)

if zip_output:
filename = type(self).__name__ + ".zip"
Expand All @@ -204,7 +204,7 @@ def write_input(
"KPOINTS",
"POTCAR",
"POTCAR.spec",
cifname,
cif_name,
]:
try:
zip.write(os.path.join(output_dir, file), arcname=file)
Expand Down Expand Up @@ -734,6 +734,7 @@ def write_input(
not have a license to specific Potcar files. Given a "POTCAR.spec",
the specific POTCAR file can be re-generated using pymatgen with the
"generate_potcar" function in the pymatgen CLI.
zip_output (bool): Whether to zip each VASP input file written to the output directory.
"""
super().write_input(
output_dir=output_dir,
Expand All @@ -755,6 +756,7 @@ def calculate_ng(self, max_prime_factor: int = 7, must_inc_2: bool = True) -> tu
max_prime_factor (int): the valid prime factors of the grid size in each direction
VASP has many different setting for this to handle many compiling options.
For typical MPI options all prime factors up to 7 are allowed
must_inc_2 (bool): Whether 2 must be a prime factor of the result. Defaults to True.
"""
# TODO throw error for Ultrasoft potentials

Expand Down Expand Up @@ -3225,8 +3227,10 @@ def incar(self):
def override_from_prev_calc(self, prev_calc_dir=".", **kwargs):
"""
Update the input set to include settings from a previous calculation.
Args:
prev_calc_dir (str): The path to the previous calculation directory.
Returns:
The input set with the settings (structure, k-points, incar, etc)
updated using the previous VASP run.
Expand Down

0 comments on commit d17a0f4

Please sign in to comment.