Skip to content

Commit

Permalink
Merge branch 'materialsproject:main' into add_lobster_mp_workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
naik-aakash authored Jan 26, 2024
2 parents 9ab6320 + c3f126b commit c095bd9
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 26 deletions.
2 changes: 1 addition & 1 deletion docs/user/fireworks.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ lpad = LaunchPad.auto_load()
lpad.add_wf(wf)
```

Additional details about interfacing Jobflow-based packages with FireWorks can be found in the [Running Jobflow with FireWorks](fw_guide) guide.
Additional details about interfacing Jobflow-based packages with FireWorks can be found in the [Running Jobflow with FireWorks][fw_guide] guide.

[fireworks]: https://materialsproject.github.io/fireworks/
[fireworks_instructions]: https://materialsproject.github.io/jobflow/install_fireworks.html
Expand Down
22 changes: 9 additions & 13 deletions src/atomate2/vasp/sets/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,28 +94,24 @@ def write_input(
if make_dir:
os.makedirs(directory, exist_ok=True)

inputs = {
"INCAR": self.incar,
"KPOINTS": self.kpoints,
"POSCAR": self.poscar,
}
inputs = {"INCAR": self.incar, "KPOINTS": self.kpoints, "POSCAR": self.poscar}
inputs.update(self.optional_files)

if isinstance(self.potcar, Potcar):
inputs["POTCAR"] = self.potcar
else:
inputs["POTCAR.spec"] = "\n".join(self.potcar)

for k, v in inputs.items():
if v is not None and (overwrite or not (directory / k).exists()):
with zopen(directory / k, "wt") as f:
if isinstance(v, Poscar):
for key, val in inputs.items():
if val is not None and (overwrite or not (directory / key).exists()):
with zopen(directory / key, mode="wt") as file:
if isinstance(val, Poscar):
# write POSCAR with more significant figures
f.write(v.get_string(significant_figures=16))
file.write(val.get_str(significant_figures=16))
else:
f.write(v.__str__())
elif not overwrite and (directory / k).exists():
raise FileExistsError(f"{directory / k} already exists.")
file.write(val.__str__())
elif not overwrite and (directory / key).exists():
raise FileExistsError(f"{directory / key} already exists.")

@staticmethod
def from_directory(
Expand Down
19 changes: 8 additions & 11 deletions tests/cp2k/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def fake_run_cp2k(
input_settings: Sequence[str] = (),
check_inputs: Sequence[Literal["cp2k.inp"]] = _VFILES,
clear_inputs: bool = True,
):
) -> None:
"""
Emulate running CP2K and validate CP2K input files.
Expand Down Expand Up @@ -171,16 +171,16 @@ def fake_run_cp2k(

@pytest.fixture()
def check_input():
def _check_input(ref_path, user_input):
from pymatgen.io.cp2k.inputs import Cp2kInput
from pymatgen.io.cp2k.inputs import Cp2kInput

ref = Cp2kInput.from_file(ref_path / "inputs" / "cp2k.inp")
def _check_input(ref_path, user_input: Cp2kInput):
ref_input = Cp2kInput.from_file(ref_path / "inputs" / "cp2k.inp")
user_input.verbosity(verbosity=False)
ref.verbosity(verbosity=False)
user_string = " ".join(user_input.get_string().lower().split())
ref_input.verbosity(verbosity=False)
user_string = " ".join(user_input.get_str().lower().split())
user_hash = md5(user_string.encode("utf-8")).hexdigest()

ref_string = " ".join(ref.get_string().lower().split())
ref_string = " ".join(ref_input.get_str().lower().split())
ref_hash = md5(ref_string.encode("utf-8")).hexdigest()

if ref_hash != user_hash:
Expand All @@ -190,10 +190,7 @@ def _check_input(ref_path, user_input):


def clear_cp2k_inputs():
for cp2k_file in (
"cp2k.inp",
"cp2k.out",
):
for cp2k_file in ("cp2k.inp", "cp2k.out"):
if Path(cp2k_file).exists():
Path(cp2k_file).unlink()
logger.info("Cleared cp2k inputs")
Expand Down
2 changes: 1 addition & 1 deletion tests/vasp/lobster/schemas/test_lobster.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def test_lobster_task_document_non_gzip(lobster_test_dir, tmp_path):
assert doc.chemsys == "As-Ga"


def test_lobstertaskdocument_saved_jsons(lobster_test_dir):
def test_lobster_task_doc_saved_jsons(lobster_test_dir):
"""
Test if jsons saved are valid
"""
Expand Down

0 comments on commit c095bd9

Please sign in to comment.