Skip to content

Commit fc65810

Browse files
Add tests for logging (#3082)
1 parent f4f7129 commit fc65810

File tree

5 files changed

+81
-6
lines changed

5 files changed

+81
-6
lines changed

CHANGELOG.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,24 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project generally adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [1.1.1]
8+
9+
### Added
10+
11+
- Added logging to the `Vasp` calculator to report which pseudopotentials are used as well as the VASP command
12+
713
## [1.1.0]
814

9-
### Fixed
15+
### Changed
1016

11-
- Fixed handling of VASP pseudopotentials for the original no suffix version
17+
- Using `.original` as the `potpaw_PBE` suffix for the original pseudopotential set provided by VASP
1218

1319
## [1.0.9]
1420

1521
### Changed
1622

1723
- Made ASE 3.27.0 the minimum allowed version
18-
- Ensured the default pseudopotentials for the VASP presets are set in accordance with the instructions in ASE 3.27.0
24+
- Explicitly set `pp_version="64"` for the default VASP presets as well as `pp_version="54"` for the `QMOFSet` and the OMC/OMat recipes. When going from Atomate2 to ASE input sets, the `pp_version` is now set
1925

2026
## [1.0.8]
2127

@@ -47,6 +53,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
4753
## [1.0.5]
4854

4955
### Fixed
56+
5057
- Fixed bug when trying to use Custodian to run a single-point VASP calculation on an Atoms object with constraints
5158
- Fixed various type hints
5259

@@ -110,7 +117,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
110117

111118
### Changed
112119

113-
- The default `BulkSet.yaml` will be removed and replaced with `DefaultSetPBE.yaml`. The two are extremely similar. Updates include: ALGO = Fast --> ALGO = Normal, GGA_COMPAT = False, and changing the default Yb and Eu pseudopotentials from _2 to _3.
120+
- The default `BulkSet.yaml` will be removed and replaced with `DefaultSetPBE.yaml`. The two are extremely similar. Updates include: ALGO = Fast --> ALGO = Normal, GGA_COMPAT = False, and changing the default Yb and Eu pseudopotentials from \_2 to \_3.
114121
- The `SlabSet.yaml` will be removed and replaced with `SlabSetPBE.yaml` to ensure internal consistency with the base `DefaultSetPBE.yaml`.
115122
- The `VASP_PRESET_MAG_DEFAULT` setting has been changed from a default of 1.0 to 0.5 to prevent accidental convergence to erroneous radical states, particularly in molecular systems.
116123
- The Materials Project recipes were updated to match the newer MP24 settings

src/quacc/calculators/vasp/vasp.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,22 @@ def _manage_environment(self) -> str:
182182
# Set the VASP pseudopotential directory
183183
if self._settings.VASP_PP_PATH:
184184
os.environ["VASP_PP_PATH"] = str(self._settings.VASP_PP_PATH)
185-
LOGGER.info(
186-
f"Using pp_version='{self.user_calc_params.get('pp_version', '')}' pseudopotentials in VASP_PP_PATH={self._settings.VASP_PP_PATH.resolve()}"
185+
potpaw_prefix = (
186+
"potpaw_LDA"
187+
if (
188+
self.user_calc_params.get("xc", "PW91").lower() == "lda"
189+
or self.user_calc_params.get("pp", "PBE").lower() == "lda"
190+
)
191+
else "potpaw_PBE"
187192
)
193+
if self.user_calc_params.get("pp_version", None):
194+
potpaw_suffix = f".{self.user_calc_params['pp_version']}"
195+
else:
196+
potpaw_suffix = ""
197+
potpaw_path = (
198+
self._settings.VASP_PP_PATH / f"{potpaw_prefix}{potpaw_suffix}"
199+
).resolve()
200+
LOGGER.info(f"Using PAW pseudopotentials: {potpaw_path}")
188201

189202
# Set the ASE_VASP_VDW environment variable
190203
if self._settings.VASP_VDW:

tests/core/calculators/vasp/test_vasp.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,6 +1503,56 @@ def test_command():
15031503
assert Vasp(atoms, kspacing=0.1).command.strip() == "vasp_std"
15041504

15051505

1506+
@pytest.mark.skipif(os.name == "nt", reason="Path handling is meant for Linux")
1507+
def test_logger(caplog):
1508+
atoms = bulk("Cu")
1509+
with change_settings({"VASP_PP_PATH": "/path/to/pseudos"}):
1510+
with caplog.at_level(INFO):
1511+
Vasp(atoms)
1512+
assert "/path/to/pseudos/potpaw_PBE" in caplog.text
1513+
caplog.clear()
1514+
1515+
with caplog.at_level(INFO):
1516+
Vasp(atoms, xc="lda")
1517+
assert "/path/to/pseudos/potpaw_LDA" in caplog.text
1518+
caplog.clear()
1519+
1520+
with caplog.at_level(INFO):
1521+
Vasp(atoms, xc="lda", pp_version="64")
1522+
assert "/path/to/pseudos/potpaw_LDA.64" in caplog.text
1523+
caplog.clear()
1524+
1525+
with caplog.at_level(INFO):
1526+
Vasp(atoms, xc="PBE", pp_version=None)
1527+
assert "/path/to/pseudos/potpaw_PBE" in caplog.text
1528+
caplog.clear()
1529+
1530+
with caplog.at_level(INFO):
1531+
Vasp(atoms, xc="PBE", pp_version="")
1532+
assert "/path/to/pseudos/potpaw_PBE" in caplog.text
1533+
caplog.clear()
1534+
1535+
with caplog.at_level(INFO):
1536+
Vasp(atoms, preset="QMOFSet")
1537+
assert "/path/to/pseudos/potpaw_PBE.54" in caplog.text
1538+
caplog.clear()
1539+
1540+
with caplog.at_level(INFO):
1541+
Vasp(atoms, preset="DefaultSetGGA")
1542+
assert "/path/to/pseudos/potpaw_PBE.64" in caplog.text
1543+
caplog.clear()
1544+
1545+
with caplog.at_level(INFO):
1546+
Vasp(atoms, xc="pbe", pp_version="54")
1547+
assert "/path/to/pseudos/potpaw_PBE.54" in caplog.text
1548+
caplog.clear()
1549+
1550+
with caplog.at_level(INFO):
1551+
Vasp(atoms, xc="pbe", pp_version="original")
1552+
assert "/path/to/pseudos/potpaw_PBE.original" in caplog.text
1553+
caplog.clear()
1554+
1555+
15061556
@pytest.mark.skipif(which(get_settings().VASP_CMD), reason="VASP is installed")
15071557
def test_run(monkeypatch, tmp_path):
15081558
monkeypatch.chdir(tmp_path)

tests/core/recipes/espresso_recipes/test_phonons.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ def test_phonon_calculation_si_spin_orbit(tmp_path, monkeypatch, caplog):
419419
si_relax_results = relax_job(si_atoms, **si_relax_params)
420420

421421
assert "The occupations are set to 'fixed'" in caplog.text
422+
caplog.clear()
422423

423424
si_phonon_params = {
424425
"input_data": {
@@ -502,6 +503,7 @@ def test_phonon_induced_renormalization(tmp_path, monkeypatch, caplog):
502503
with caplog.at_level(WARNING):
503504
c_ph_results = phonon_job(c_scf_results["dir_name"], **c_ph_params)
504505
assert "Overwriting key 'fildyn'" in caplog.text
506+
caplog.clear()
505507

506508
q2r_params = {
507509
"input_data": {
@@ -534,6 +536,7 @@ def test_phonon_induced_renormalization(tmp_path, monkeypatch, caplog):
534536
assert "Overwriting key 'fildyn'" in caplog.text
535537
assert "Overwriting key 'wpot_dir'" in caplog.text
536538
assert "Overwriting key 'prefix'" in caplog.text
539+
caplog.clear()
537540

538541
assert (
539542
dvscf_q2r_results["parameters"]["input_data"]["input"]["fildyn"] == "matdyn"

tests/core/runners/test_ase.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,13 @@ def test_bad_runs(tmp_path, monkeypatch, caplog):
241241
with caplog.at_level(WARNING):
242242
Runner(atoms, EMT(), copy_files={Path(): "test_file.txt"}).run_calc()
243243
assert "Cannot find file" in caplog.text
244+
caplog.clear()
244245

245246
# No file again
246247
with caplog.at_level(WARNING):
247248
Runner(atoms, EMT(), copy_files={Path(): "test_file.txt"}).run_opt()
248249
assert "Cannot find file" in caplog.text
250+
caplog.clear()
249251

250252
# No trajectory kwarg
251253
with pytest.raises(

0 commit comments

Comments
 (0)