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

Trajdata method #84

Merged
merged 9 commits into from
Nov 15, 2018
2 changes: 1 addition & 1 deletion .slugignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/apps/catlearn/models/metals_catlearn_gp.pkl

2 changes: 1 addition & 1 deletion apps/catlearn/atomistic.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def predict_catkit_demo(images):
try:
initial_state = [model_ref[s] for s in
ase.atoms.string2symbols(
atoms.info['key_value_pairs']['species'])]
atoms.info['key_value_pairs']['species'])]
except KeyError:
return {}
display_ref.append(
Expand Down
2 changes: 1 addition & 1 deletion apps/upload/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
log = logging.getLogger(__name__)
log.setLevel(logging.DEBUG)

ADMIN_EMAILS = ['maxjh@stanford.edu', 'winther@stanford.edu']
ADMIN_EMAILS = ['winther@stanford.edu', 'bajdich@stanford.edu']
FRONTEND_URL = 'https://www.catalysis-hub.org'

upload = flask.Blueprint('upload', __name__)
Expand Down
11 changes: 6 additions & 5 deletions apps/utils/gas_phase_references.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import numpy as np
from numpy import array

from ase.atoms import string2symbols

def molecules2symbols(molecules, add_hydrogen=True):
"""
Expand All @@ -12,8 +13,8 @@ def molecules2symbols(molecules, add_hydrogen=True):

symbols = sorted(
list(set(
ase.atoms.string2symbols(''.join(
map(lambda _x: ''.join(ase.atoms.string2symbols(_x)), molecules)
string2symbols(''.join(
map(lambda _x: ''.join(string2symbols(_x)), molecules)
))
)),
key=lambda _y: ase.data.atomic_numbers[_y])
Expand All @@ -38,7 +39,7 @@ def construct_reference_system(symbols, candidates=['H2', 'H2O', 'NH3', 'CH4', '
for symbol in symbols:
added_symbols.append(symbol)
for candidate in candidates:
symbols = ase.atoms.string2symbols(candidate)
symbols = string2symbols(candidate)

if set(added_symbols) == set(list(references.keys()) + symbols):
references[symbol] = candidate
Expand Down Expand Up @@ -69,7 +70,7 @@ def get_atomic_stoichiometry(references):
species = species.split('_')[0]

key_index[key] = i
composition = ase.atoms.string2symbols(species)
composition = string2symbols(species)
for j, symbol in enumerate(composition):
if symbol == key:
stoichiometry[i, i] += 1
Expand Down Expand Up @@ -97,7 +98,7 @@ def get_stoichiometry_factors(adsorbates, references):
stoichiometry = get_atomic_stoichiometry(references)
stoichiometry_factors = {}
for adsorbate in adsorbates:
for symbol in ase.atoms.string2symbols(adsorbate):
for symbol in string2symbols(adsorbate):
symbol_index = list(
map(lambda _x: _x[0], references)).index(symbol)

Expand Down
29 changes: 13 additions & 16 deletions models.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import ase.atoms
from ase.constraints import dict2constraint
from ase.calculators.singlepoint import SinglePointCalculator
from ase.calculators.calculator import Calculator
import ase.db.sqlite
import ase.db.core
import ase.io
Expand Down Expand Up @@ -240,7 +241,6 @@ def _toatoms(self, include_results=False):
cell=self.cell,
pbc=(self.pbc & np.array([1, 2, 4])).astype(bool),
)

if self.constraints:
constraints = json.loads(self.constraints)
if len(constraints[0]['kwargs']['indices']) > 0:
Expand All @@ -251,38 +251,35 @@ def _toatoms(self, include_results=False):
self.positions,
cell=self.cell,
pbc=(self.pbc & np.array([1, 2, 4])).astype(bool),
magmoms=self.magmoms,
charges=self.charges,
magmoms=self.initial_magmoms,
charges=self.initial_charges,
tags=self.tags,
masses=self.masses,
momenta=self.momenta,
constraint=constraints)
atoms.info = {}
atoms.info['unique_id'] = self.unique_id
atoms.info['key_value_pairs'] = self.key_value_pairs

data = self.data
if data:
atoms.info['data'] = data

if not self.calculator == "unknown":
params = self.get('calculator_parameters', {})
atoms.calc = get_calculator(self.calculator)(**params)
params = self.calculator_parameters
atoms.calc = Calculator(self.calculator, **params)
atoms.calc.name = self.calculator
else:
all_properties = ['energy', 'forces', 'stress', 'dipole',
'charges', 'magmom', 'magmoms', 'free_energy']
results = {}
#print(getattr(self, 'energy'))
for prop in all_properties:
result = getattr(self, prop, None)
if result is not None:
results[prop] = result
# print(results)
if results:
atoms.calc = SinglePointCalculator(atoms, **results)
atoms.calc.name = getattr(self, 'calculator', 'unknown')

atoms.info = {}
atoms.info['unique_id'] = self.unique_id
atoms.info['key_value_pairs'] = self.key_value_pairs

data = self.data
if data:
atoms.info['data'] = data

return atoms

@hybrid_property
Expand Down
4 changes: 2 additions & 2 deletions requirements.template
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# DO NOT EDIT requirements.txt DIRECTLY OR ADD IT TO VERSION CONTROL
# It will be overwritten in the install progress
# Add new packages in requirements.template instead.
ase==3.16.0
ase==3.16.2
backports.functools-lru-cache==1.4
catkit>=0.5.3
git+https://github.com/SUNCAT-Center/CatLearn.git@06bbfd370306ae6ecbfee50fd48b5f0a6ff5ef31#egg=catlearn
Expand Down Expand Up @@ -53,4 +53,4 @@ SQLAlchemy==1.1.14
typing==3.6.2
tqdm==4.19.5
urwid==1.3.1
Werkzeug==0.12.2
Werkzeug==0.12.2