Skip to content

Commit

Permalink
Merge a8c6783 into 8a4b1af
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Boes committed Nov 13, 2018
2 parents 8a4b1af + a8c6783 commit af5dc45
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 23 deletions.
11 changes: 7 additions & 4 deletions catkit/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ def bulk(name, crystalstructure=None, primitive=False, **kwargs):
def surface(
elements,
size,
crystal='fcc',
miller=(1, 1, 1),
termination=0,
fixed=0,
Expand All @@ -55,8 +54,6 @@ def surface(
or an atoms object representing the bulk structure to use.
size : list (3,)
Number of time to expand the x, y, and z primitive cell.
crystal : str
The bulk crystal structure to pass to the ase bulk builder.
miller : list (3,) or (4,)
The miller index to cleave the surface structure from. If 4 values
are used, assume Miller-Bravis convention.
Expand All @@ -77,7 +74,13 @@ def surface(
if isinstance(elements, ase.Atoms):
atoms = elements
else:
atoms = ase.build.bulk(elements, crystal, cubic=True, **kwargs)
bkwargs = kwargs.copy()
keys = ['crystalstructure', 'a', 'c', 'covera',
'u', 'orthorhombic', 'cubic']
for key in kwargs:
if key not in keys:
del bkwargs[key]
atoms = ase.build.bulk(elements, **bkwargs)

generator = catkit.gen.surface.SlabGenerator(
bulk=atoms,
Expand Down
5 changes: 1 addition & 4 deletions catkit/gen/adsorption.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,10 +596,7 @@ def _single_adsorption(
atoms.translate(-atoms.positions[bond])

if auto_construct:
root = None
for i, branch in enumerate(branches):
root = catkit.gen.molecules._branch_molecule(
atoms, branch, root, adsorption=True)
atoms = catkit.gen.molecules.get_3D_positions(atoms, bond)

# Align with the adsorption vector
atoms.rotate([0, 0, 1], vector)
Expand Down
11 changes: 6 additions & 5 deletions catkit/gen/surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,12 +500,13 @@ def set_size(self, slab, size):
metrics += [[d.sum(), angle, M]]

if metrics:
order = [0, 1]
if defaults.get('orthogonal'):
matrix = sorted(metrics,
key=lambda x: (x[1], x[0]))[0][-1]
else:
matrix = sorted(metrics,
key=lambda x: (x[0], x[1]))[0][-1]
order = [1, 0]

matrix = sorted(metrics,
key=lambda x: (
x[order[0]], x[order[1]]))[0][-1]
supercell = transform_ab(supercell, matrix)

elif isinstance(size, (list, tuple, np.ndarray)):
Expand Down
2 changes: 2 additions & 0 deletions catkit/hub/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import warnings
warnings.warn("The cathub module will be moved from catkit.hub.* to cathub.* in a future release.", DeprecationWarning)
2 changes: 1 addition & 1 deletion catkit/hub/ase_tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def get_chemical_formula(atoms, mode='metal'):

def symbols(atoms):
formula = get_chemical_formula(atoms)
symbols = ase.atoms.string2symbols(formula)
symbols = ase.symbols.string2symbols(formula)
return ''.join(symbols)


Expand Down
13 changes: 7 additions & 6 deletions catkit/hub/ase_tools/gas_phase_references.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import numpy as np
import optparse
import pprint
from ase.symbols import string2symbols


def molecules2symbols(molecules, add_hydrogen=True):
Expand All @@ -11,10 +12,10 @@ def molecules2symbols(molecules, add_hydrogen=True):
"""
symbols = sorted(
list(set(
ase.atoms.string2symbols(''.join(
string2symbols(''.join(
map(
lambda _x:
''.join(ase.atoms.string2symbols(_x)), molecules)
''.join(string2symbols(_x)), molecules)
))
)),
key=lambda _y: ase.data.atomic_numbers[_y])
Expand Down Expand Up @@ -61,7 +62,7 @@ def construct_reference_system(
for symbol in symbols:
added_symbols.append(symbol)
for candidate in candidates:
_symbols = ase.atoms.string2symbols(candidate)
_symbols = string2symbols(candidate)

# Add partial adsorbate species
# is subset of reference species
Expand Down Expand Up @@ -93,7 +94,7 @@ def construct_reference_system(
# only adds one one additional species in each step
while references:
for i, reference in enumerate(references):
if len(set(ase.atoms.string2symbols(reference[1])) -
if len(set(string2symbols(reference[1])) -
set(x[0] for x in sorted_references)) == 1:
sorted_references.append(references.pop(i))
break
Expand All @@ -116,7 +117,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):
stoichiometry[i, key_index[symbol]] += 1
istoichiometry = np.linalg.inv(stoichiometry)
Expand All @@ -133,7 +134,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
2 changes: 1 addition & 1 deletion catkit/hub/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import six
import collections
from tabulate import tabulate
from ase.atoms import string2symbols
from ase.symbols import string2symbols
from ase.cli import main
from . import query
from . import make_folders_template
Expand Down
5 changes: 3 additions & 2 deletions catkit/hub/organize.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import ase.utils
import ase.io
import numpy as np
from ase.symbols import string2symbols


# local imports
Expand Down Expand Up @@ -215,7 +216,7 @@ def fuzzy_match(structures, options):
try:
subtractions = ''.join(
sorted(
ase.atoms.string2symbols(
string2symbols(
subtractions)))
except Exception as e:
if options.verbose:
Expand All @@ -224,7 +225,7 @@ def fuzzy_match(structures, options):
try:
additions = ''.join(
sorted(
ase.atoms.string2symbols(
string2symbols(
additions)))
except Exception as e:
if options.verbose:
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
git+https://gitlab.com/ase/ase.git@d441dd6a1c71a2e1a925043e6974a9b3ae961854
cathub>=0.1.0
numpy>=1.14
networkx>=2.1
spglib>=1.10
Expand Down

0 comments on commit af5dc45

Please sign in to comment.