Skip to content

Commit

Permalink
Update tests (new, stable entry for Na2FePO4F on new MP API)
Browse files Browse the repository at this point in the history
  • Loading branch information
kavanase committed Jul 31, 2024
1 parent 48f7a4d commit a39e292
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion doped/chemical_potentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ def get_MP_summary_docs(
**kwargs,
}
else:
assert chemsys is not None
assert chemsys is not None # typing
summary_search_kwargs = {"chemsys": _get_all_chemsyses("-".join(chemsys)), **kwargs}

with MPRester(api_key) as mpr:
Expand Down
27 changes: 14 additions & 13 deletions tests/test_chemical_potentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,21 +203,22 @@ def test_unstable_host(self, api_key):
with warnings.catch_warnings(record=True) as w:
cp = chemical_potentials.CompetingPhases(**cp_settings)
print([str(warning.message) for warning in w]) # for debugging
assert len([warning for warning in w if "You are using" not in str(warning.message)]) == 1
for sub_message in [
"Note that the Materials Project (MP) database entry for Na2FePO4F is not stable with "
"respect to competing phases, having an energy above hull of 0.1701 eV/atom.",
"Formally, this means that the host material is unstable and so has no chemical "
"potential limits; though in reality there may be errors in the MP energies",
"Here we downshift the host compound entry to the convex hull energy, and then "
"determine the possible competing phases with the same approach as usual",
]:
print(sub_message)
assert any(sub_message in str(warning.message) for warning in w)
if len(api_key) != 32: # recalculated energy for Na2FePO4F on new MP API, now on hull
assert len([warning for warning in w if "You are using" not in str(warning.message)]) == 1
for sub_message in [
"Note that the Materials Project (MP) database entry for Na2FePO4F is not stable with "
"respect to competing phases, having an energy above hull of 0.1701 eV/atom.",
"Formally, this means that the host material is unstable and so has no chemical "
"potential limits; though in reality there may be errors in the MP energies",
"Here we downshift the host compound entry to the convex hull energy, and then "
"determine the possible competing phases with the same approach as usual",
]:
print(sub_message)
assert any(sub_message in str(warning.message) for warning in w)
if cp_settings.get("full_phase_diagram"):
assert len(cp.entries) == 128
assert len(cp.entries) in {128, 173} # legacy, new MP APIs
else:
assert len(cp.entries) == 50
assert len(cp.entries) in {50, 68} # legacy, new MP APIs
self.check_O2_entry(cp)

def test_unknown_host(self):
Expand Down

0 comments on commit a39e292

Please sign in to comment.