Skip to content

Commit

Permalink
Merge branch 'main' into solvents
Browse files Browse the repository at this point in the history
  • Loading branch information
mshuaibii committed Jun 10, 2024
2 parents a86eb58 + 5ffb598 commit 1572696
Show file tree
Hide file tree
Showing 18 changed files with 190 additions and 126 deletions.
70 changes: 0 additions & 70 deletions .circleci/config.yml

This file was deleted.

25 changes: 25 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: lint

on:
push:
workflow_dispatch:

jobs:
lint:
runs-on: ubuntu-latest
strategy:
max-parallel: 6

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[dev]
- name: black
run: |
black --color ocdata
50 changes: 50 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: test
on:
push:
branches: [main]
pull_request:
workflow_call:

jobs:
test:
runs-on: ubuntu-latest
strategy:
max-parallel: 10
matrix:
python_version: ['3.9', '3.10', '3.11']

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python_version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python_version }}

- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Install dependencies and package
# this can be added along with a dependabot config to run tests with latest versions
# pip install -r requirements.txt
# pip install -r requirements-optional.txt
run: |
python -m pip install --upgrade pip
pip install -e .[dev]
- name: Test with pytest
run: |
pytest tests -vv --cov-report=xml --cov=ocpdata
- if: ${{ matrix.python_version == '3.11' }}
name: codecov-report
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: false # optional (default = false)
files: ./coverage.xml
token: ${{ secrets.CODECOV_TOKEN }} # required
verbose: true # optional (default = false)
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# THIS REPOSITORY HAS BEEN MOVED TO [http://github.com/fair-chem/fairchem/tree/main/src/fairchem/data/oc](http://github.com/fair-chem/fairchem/tree/main/src/fairchem/data/oc)

[![CircleCI](https://dl.circleci.com/status-badge/img/gh/Open-Catalyst-Project/Open-Catalyst-Dataset/tree/main.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/gh/Open-Catalyst-Project/Open-Catalyst-Dataset/tree/main)
[![codecov](https://codecov.io/gh/Open-Catalyst-Project/Open-Catalyst-Dataset/branch/main/graph/badge.svg?token=IZ7J729L6S)](https://codecov.io/gh/Open-Catalyst-Project/Open-Catalyst-Dataset/tree/main)

Expand Down
9 changes: 9 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
coverage:
status:
project:
default:
informational: true
patch:
default:
informational: true
github_checks: false
Empty file removed ocdata/configs/__init__.py
Empty file.
14 changes: 0 additions & 14 deletions ocdata/configs/paths.py

This file was deleted.

4 changes: 2 additions & 2 deletions ocdata/core/adsorbate.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import pickle
from typing import Any, Dict, Tuple
import warnings
from typing import Any, Dict, Tuple

import ase
import numpy as np

from ocdata.configs.paths import ADSORBATES_PKL_PATH
from ocdata.databases.pkls import ADSORBATES_PKL_PATH


class Adsorbate:
Expand Down
4 changes: 2 additions & 2 deletions ocdata/core/bulk.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import os
import pickle
from typing import Any, Dict, List
import warnings
from typing import Any, Dict, List

import ase
import numpy as np

from ocdata.configs.paths import BULK_PKL_PATH
from ocdata.core.slab import Slab
from ocdata.databases.pkls import BULK_PKL_PATH


class Bulk:
Expand Down
41 changes: 29 additions & 12 deletions ocdata/core/slab.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class Slab:
"""
Initializes a slab object, i.e. a particular slab tiled along xyz, in
one of 2 ways:
- Pass in a Bulk object and a slab 4-tuple containing
(atoms, miller, shift, top).
- Pass in a Bulk object and a slab 5-tuple containing
(atoms, miller, shift, top, oriented bulk).
- Pass in a Bulk object and randomly sample a slab.
Arguments
Expand All @@ -48,6 +48,7 @@ def __init__(
millers: tuple = None,
shift: float = None,
top: bool = None,
oriented_bulk: Structure = None,
min_ab: float = 0.8,
):
assert bulk is not None
Expand All @@ -57,6 +58,7 @@ def __init__(
self.millers = millers
self.shift = shift
self.top = top
self.oriented_bulk = oriented_bulk

assert (
Composition(self.atoms.get_chemical_formula()).reduced_formula
Expand Down Expand Up @@ -87,10 +89,12 @@ def from_bulk_get_random_slab(
max_miller=max_miller,
)
slab_idx = np.random.randint(len(untiled_slabs))
unit_slab_struct, millers, shift, top = untiled_slabs[slab_idx]
unit_slab_struct, millers, shift, top, oriented_bulk = untiled_slabs[
slab_idx
]
slab_atoms = tile_and_tag_atoms(unit_slab_struct, bulk.atoms, min_ab=min_ab)

return cls(bulk, slab_atoms, millers, shift, top)
return cls(bulk, slab_atoms, millers, shift, top, oriented_bulk)

@classmethod
def from_bulk_get_specific_millers(
Expand Down Expand Up @@ -123,10 +127,11 @@ def from_bulk_get_specific_millers(
s[1],
s[2],
s[3],
s[4],
)
)

return [cls(bulk, s[0], s[1], s[2], s[3]) for s in slabs]
return [cls(bulk, s[0], s[1], s[2], s[3], s[4]) for s in slabs]

@classmethod
def from_bulk_get_all_slabs(
Expand All @@ -141,7 +146,13 @@ def from_bulk_get_all_slabs(
slabs = []
for s in untiled_slabs:
slabs.append(
(tile_and_tag_atoms(s[0], bulk.atoms, min_ab=min_ab), s[1], s[2], s[3])
(
tile_and_tag_atoms(s[0], bulk.atoms, min_ab=min_ab),
s[1],
s[2],
s[3],
s[4],
)
)

# if path is provided, save out the pkl
Expand All @@ -150,7 +161,7 @@ def from_bulk_get_all_slabs(
with open(save_path, "wb") as f:
pickle.dump(slabs, f)

return [cls(bulk, s[0], s[1], s[2], s[3]) for s in slabs]
return [cls(bulk, s[0], s[1], s[2], s[3], s[4]) for s in slabs]

@classmethod
def from_precomputed_slabs_pkl(
Expand All @@ -173,7 +184,7 @@ def from_precomputed_slabs_pkl(
return slabs
else:
assert np.all(np.array([s[1] for s in slabs]) <= max_miller)
return [cls(bulk, s[0], s[1], s[2], s[3]) for s in slabs]
return [cls(bulk, s[0], s[1], s[2], s[3], s[4]) for s in slabs]

@classmethod
def from_atoms(cls, atoms: ase.Atoms = None, bulk=None, **kwargs):
Expand All @@ -193,6 +204,7 @@ def get_metadata_dict(self):
"millers": self.millers,
"shift": self.shift,
"top": self.top,
"oriented_bulk": self.oriented_bulk,
},
}

Expand All @@ -211,6 +223,7 @@ def __eq__(self, other):
and self.millers == other.millers
and self.shift == other.shift
and self.top == other.top
and self.oriented_bulk == other.oriented_bulk
)


Expand Down Expand Up @@ -496,8 +509,9 @@ def compute_slabs(
Returns
-------
all_slabs_info: list
A list of 4-tuples containing pymatgen structure objects for enumerated
slabs, the Miller indices, floats for the shifts, and booleans for top.
A list of 5-tuples containing pymatgen structure objects for enumerated
slabs, the Miller indices, floats for the shifts, booleans for top, and
the oriented bulk structure.
"""
assert bulk_atoms is not None
bulk_struct = standardize_bulk(bulk_atoms)
Expand Down Expand Up @@ -527,13 +541,16 @@ def compute_slabs(
# want to consider them too.
if len(slabs) != 0:
flipped_slabs_info = [
(flip_struct(slab), millers, slab.shift, False)
(flip_struct(slab), millers, slab.shift, False, slab.oriented_unit_cell)
for slab in slabs
if is_structure_invertible(slab) is False
]

# Concatenate all the results together
slabs_info = [(slab, millers, slab.shift, True) for slab in slabs]
slabs_info = [
(slab, millers, slab.shift, True, slab.oriented_unit_cell)
for slab in slabs
]
all_slabs_info.extend(slabs_info + flipped_slabs_info)

return all_slabs_info
Expand Down
4 changes: 2 additions & 2 deletions ocdata/databases/pkls/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import os

BULK_PKL = os.path.join(__path__[0], "bulks.pkl")
ADSORBATE_PKL = os.path.join(__path__[0], "adsorbates.pkl")
BULK_PKL_PATH = os.path.join(__path__[0], "bulks.pkl")
ADSORBATES_PKL_PATH = os.path.join(__path__[0], "adsorbates.pkl")
3 changes: 0 additions & 3 deletions ocdata/databases/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
Script for updating ase pkl and db files from v3.19 to v3.21.
Run it with ase v3.19.
"""


import pickle
from collections import defaultdict

import ase.io
from ase.atoms import Atoms
Expand Down
Loading

0 comments on commit 1572696

Please sign in to comment.