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

Debug changes from lwave and stability calculations #99

Merged
merged 5 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
6 changes: 5 additions & 1 deletion gaspy/fireworks_helper_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,11 @@ def get_atoms_from_fw(fw, index=-1):
atoms `ase.Atoms` instance from the Firework you provided
'''
# Get the `ase.Atoms` object from FireWork's results
atoms_trajhex = fw.launches[-1].action.stored_data['opt_results'][1]
try:
atoms_trajhex = fw.launches[-1].action.stored_data['opt_results'][1]
except IndexError:
atoms_trajhex = fw.archived_launches[-1].action.stored_data['opt_results'][1]
warnings.warn('Getting atoms from an archive Fireworks launch', RuntimeWarning)
atoms = decode_trajhex_to_atoms(atoms_trajhex, index=index)

# Get the Firework task that was meant to convert the original hexstring to
Expand Down
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
16 changes: 10 additions & 6 deletions gaspy/tasks/calculation_finders.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,10 @@ def _load_attributes(self):
self.fw_query = {'name.calculation_type': 'gas phase optimization',
'name.gasname': self.gas_name}
for key, value in self.vasp_settings.items():
self.gasdb_query['fwname.vasp_settings.%s' % key] = value
self.fw_query['name.vasp_settings.%s' % key] = value
# We don't care if these VASP settings change
if key not in set(['nsw', 'isym', 'symprec', 'lwave', 'lcharg']):
self.gasdb_query['fwname.vasp_settings.%s' % key] = value
self.fw_query['name.vasp_settings.%s' % key] = value
self.dependency = MakeGasFW(self.gas_name, self.vasp_settings)


Expand Down Expand Up @@ -253,8 +255,10 @@ def _load_attributes(self):
self.fw_query = {'name.calculation_type': 'unit cell optimization',
'name.mpid': self.mpid}
for key, value in self.vasp_settings.items():
self.gasdb_query['fwname.vasp_settings.%s' % key] = value
self.fw_query['name.vasp_settings.%s' % key] = value
# We don't care if these VASP settings change
if key not in set(['nsw', 'isym', 'symprec', 'lwave', 'lcharg']):
self.gasdb_query['fwname.vasp_settings.%s' % key] = value
self.fw_query['name.vasp_settings.%s' % key] = value
self.dependency = MakeBulkFW(self.mpid, self.vasp_settings)


Expand Down Expand Up @@ -363,7 +367,7 @@ def _load_attributes(self):

for key, value in self.vasp_settings.items():
# We don't care if these VASP settings change
if key not in set(['nsw', 'isym', 'symprec']):
if key not in set(['nsw', 'isym', 'symprec', 'lwave', 'lcharg']):
self.gasdb_query['fwname.vasp_settings.%s' % key] = value
self.fw_query['name.vasp_settings.%s' % key] = value

Expand Down Expand Up @@ -485,7 +489,7 @@ def _load_attributes(self):
# Parse the VASP settings
for key, value in self.vasp_settings.items():
# We don't care if these VASP settings change
if key != 'isym':
if key not in set(['isym', 'lwave', 'lcharg']):
self.gasdb_query['fwname.vasp_settings.%s' % key] = value
self.fw_query['name.vasp_settings.%s' % key] = value

Expand Down
6 changes: 4 additions & 2 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,11 @@ 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
expected_stabilities = {'mp-126': 0.884, # Pt
'mp-81': 0.0} # Au
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)
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
6 changes: 5 additions & 1 deletion gaspy/tests/tasks_tests/calculation_finders_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,11 @@ def _assert_vasp_settings(doc, vasp_settings):

# If we're looking at a slab, then we don't care about certain
# vasp settings
elif doc['fwname']['calculation_type'] == 'slab+adsorbat optimizatione' and key in set(['isym']):
elif doc['fwname']['calculation_type'] == 'surface energy optimization' and key in set(['isym']):
pass

# We never really care if the electronic files are saved or not
elif key in set(['lwave', 'lcharg']):
pass

else:
Expand Down