Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bulk_stability calculation unit test fixed #100

Merged
merged 2 commits into from
Jun 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion gaspy/gasdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from pymongo import MongoClient
from pymongo.collection import Collection
from pymatgen.ext.matproj import MPRester
from pymatgen.analysis.pourbaix_diagram import PourbaixDiagram, ELEMENTS_HO, PourbaixPlotter
from pymatgen.analysis.pourbaix_diagram import PourbaixDiagram, ELEMENTS_HO
from . import defaults
from .utils import read_rc
from .fireworks_helper_scripts import get_launchpad
Expand Down Expand Up @@ -812,6 +812,7 @@ def purge_adslabs(fwids):
with get_mongo_collection('adsorption') as collection:
collection.delete_many({'fwids.slab+adsorbate': {'$in': fwids}})


def get_electrochemical_stability(mpid, pH, potential):
'''
A wrapper for pymatgen to construct Pourbaix amd calculate electrochemical
Expand Down
9 changes: 6 additions & 3 deletions gaspy/tests/gasdb_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
get_electrochemical_stability)

# Things we need to do the tests
import math
import pytest
import warnings
import copy
Expand Down Expand Up @@ -507,10 +508,12 @@ def test_get_low_coverage_ml_docs(adsorbate, model_tag):
low_cov_energy = low_coverage_docs_by_surface[surface]['energy']
assert low_cov_energy <= energy


def test_get_electrochemical_stability():
# at pH=0, V=0.9
expected_stabilities = {'mp-126':0.884, # Pt
'mp-81': 0.0} # Au
expected_stabilities = {'mp-126': 0.861, # Pt
'mp-81': 0.0, # Au
'mp-2723': 0.0} #IrO2
for mpid, expected_stability in expected_stabilities.items():
stability = get_electrochemical_stability(mpid, 0, 0.9)
assert stability == expected_stability
assert math.isclose(stability, expected_stability, rel_tol=1e-6)