Skip to content

Commit

Permalink
Merge a53744e into 9953bbe
Browse files Browse the repository at this point in the history
  • Loading branch information
rkingsbury committed May 14, 2021
2 parents 9953bbe + a53744e commit 6e3fd1f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
24 changes: 12 additions & 12 deletions pymatgen/analysis/tests/test_pourbaix_diagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,17 @@ def test_get_decomposition(self):
ph, v = np.meshgrid(np.linspace(0, 14), np.linspace(-3, 3))
self.pbx.get_decomposition_energy(entry, ph, v)

# Test custom ions
entries = self.test_data["C-Na-Sn"]
ion = IonEntry(Ion.from_formula("NaO28H80Sn12C24+"), -161.676)
custom_ion_entry = PourbaixEntry(ion, entry_id="my_ion")
pbx = PourbaixDiagram(
entries + [custom_ion_entry],
filter_solids=True,
comp_dict={"Na": 1, "Sn": 12, "C": 24},
)
self.assertAlmostEqual(pbx.get_decomposition_energy(custom_ion_entry, 5, 2), 2.1209002582, 1)

def test_get_stable_entry(self):
entry = self.pbx.get_stable_entry(0, 0)
self.assertEqual(entry.entry_id, "ion-0")
Expand Down Expand Up @@ -284,18 +295,7 @@ def test_mpr_pipeline(self):
pbx = PourbaixDiagram(data, filter_solids=True, conc_dict={"Ag": 1e-8, "Te": 1e-8})
self.assertEqual(len(pbx.stable_entries), 29)
test_entry = pbx.find_stable_entry(8, 2)
self.assertAlmostEqual(test_entry.energy, 2.3894017960000009, 1)

# Test custom ions
entries = mpr.get_pourbaix_entries(["Sn", "C", "Na"])
ion = IonEntry(Ion.from_formula("NaO28H80Sn12C24+"), -161.676)
custom_ion_entry = PourbaixEntry(ion, entry_id="my_ion")
pbx = PourbaixDiagram(
entries + [custom_ion_entry],
filter_solids=True,
comp_dict={"Na": 1, "Sn": 12, "C": 24},
)
self.assertAlmostEqual(pbx.get_decomposition_energy(custom_ion_entry, 5, 2), 2.1209002582, 1)
self.assertEqual(sorted(test_entry.entry_id), ["ion-10", "mp-499"])

# Test against ion sets with multiple equivalent ions (Bi-V regression)
entries = mpr.get_pourbaix_entries(["Bi", "V"])
Expand Down
10 changes: 8 additions & 2 deletions pymatgen/ext/matproj.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,10 @@ def get_entries(
if compatible_only:
from pymatgen.entries.compatibility import MaterialsProject2020Compatibility

entries = MaterialsProject2020Compatibility().process_entries(entries)
# suppress the warning about missing oxidation states
with warnings.catch_warnings():
warnings.filterwarnings("ignore", message="Failed to guess oxidation states.*")
entries = MaterialsProject2020Compatibility().process_entries(entries, clean=True)
if sort_by_e_above_hull:
entries = sorted(entries, key=lambda entry: entry.data["e_above_hull"])
return entries
Expand Down Expand Up @@ -629,7 +632,10 @@ def get_pourbaix_entries(self, chemsys, solid_compat="MaterialsProject2020Compat
message="You did not provide the required O2 and H2O energies.",
)
compat = MaterialsProjectAqueousCompatibility(solid_compat=self.solid_compat)
ion_ref_entries = compat.process_entries(ion_ref_entries)
# suppress the warning about missing oxidation states
with warnings.catch_warnings():
warnings.filterwarnings("ignore", message="Failed to guess oxidation states.*")
ion_ref_entries = compat.process_entries(ion_ref_entries)
ion_ref_pd = PhaseDiagram(ion_ref_entries)

# position the ion energies relative to most stable reference state
Expand Down
2 changes: 1 addition & 1 deletion test_files/pourbaix_test_data.json

Large diffs are not rendered by default.

0 comments on commit 6e3fd1f

Please sign in to comment.