Skip to content

Commit 2ccc0e2

Browse files
authored
Update public repo from private (#61)
* Bump torch, ase, scipy versions * Remove pynanoflann * Added model compilation * PropertyDefinition improvements * Adaptive supercell creation * Various model implementation improvements * New tests
1 parent 9c7d586 commit 2ccc0e2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+8332
-2666
lines changed

.github/workflows/publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ubuntu-latest
1313
strategy:
1414
matrix:
15-
python-version: ["3.9", "3.10", "3.11", "3.12"]
15+
python-version: ["3.10", "3.11", "3.12"]
1616
if: startsWith(github.ref, 'refs/tags/')
1717
steps:
1818
- uses: actions/checkout@v4
@@ -27,7 +27,7 @@ jobs:
2727
cache-dependency-path: pyproject.toml
2828
- name: Install dependencies
2929
run: |
30-
pip install '.[test]' "pynanoflann@git+https://github.com/dwastberg/pynanoflann#egg=af434039ae14bedcbb838a7808924d6689274168"
30+
pip install '.[test]'
3131
3232
- name: Run tests
3333
run: |

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111
strategy:
1212
matrix:
13-
python-version: ["3.9", "3.10", "3.11", "3.12"]
13+
python-version: ["3.10", "3.11", "3.12"]
1414
steps:
1515
- uses: actions/checkout@v4
1616
- name: Update version
@@ -24,7 +24,7 @@ jobs:
2424
cache-dependency-path: pyproject.toml
2525
- name: Install dependencies
2626
run: |
27-
pip install '.[test]' "pynanoflann@git+https://github.com/dwastberg/pynanoflann#egg=af434039ae14bedcbb838a7808924d6689274168"
27+
pip install '.[test]'
2828
2929
- name: Run tests
3030
run: |

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,3 +160,6 @@ cython_debug/
160160
# and can be added to the global gitignore or merged into this file. For a more nuclear
161161
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
162162
#.idea/
163+
164+
# Private
165+
datasets/

CONTRIBUTING.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
### Tests
1+
### Setting up a development environment
2+
3+
The `orb_models` package uses [Poetry](https://python-poetry.org/) for dependency management. To install the package and its dependencies, run the following command:
4+
5+
```bash
6+
pip install poetry # Install Poetry if you don't have it
7+
poetry install
8+
```
9+
10+
### Running tests
211

312
The `orb_models` package uses `pytest` for testing. To run the tests, navigate to the root directory of the package and run the following command:
413

README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818

1919
```bash
2020
pip install orb-models
21-
pip install "pynanoflann@git+https://github.com/dwastberg/pynanoflann#egg=af434039ae14bedcbb838a7808924d6689274168",
2221
```
23-
Pynanoflann is not available on PyPI, so you must install it from the git repository.
2422

2523
Orb models are expected to work on MacOS and Linux. Windows support is not guaranteed.
2624

@@ -74,9 +72,9 @@ result = orbff.predict(graph)
7472
# Convert to ASE atoms (unbatches the results and transfers to cpu if necessary)
7573
atoms = atomic_system.atom_graphs_to_ase_atoms(
7674
graph,
77-
energy=result["graph_pred"],
78-
forces=result["node_pred"],
79-
stress=result["stress_pred"]
75+
energy=result["energy"],
76+
forces=result["forces"],
77+
stress=result["stress"]
8078
)
8179
```
8280

@@ -94,7 +92,7 @@ orbff = pretrained.orb_v2(device=device) # or choose another model using ORB_PRE
9492
calc = ORBCalculator(orbff, device=device)
9593
atoms = bulk('Cu', 'fcc', a=3.58, cubic=True)
9694

97-
atoms.set_calculator(calc)
95+
atoms.calc = calc
9896
atoms.get_potential_energy()
9997
```
10098

examples/NaClWaterMD.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import torch
2-
import numpy as np
32
from ase.io import read, write
43
from ase.md.velocitydistribution import MaxwellBoltzmannDistribution
54
from ase.md.langevin import Langevin
65
from ase import units
7-
from orb_models.forcefield import atomic_system, pretrained
8-
from ase.calculators.calculator import Calculator, all_properties
9-
from ase.build import molecule, make_supercell
106
from ase.md import MDLogger
7+
8+
from orb_models.forcefield import pretrained
119
from orb_models.forcefield.calculator import ORBCalculator
1210

1311

@@ -34,7 +32,7 @@ def run_md_simulation(
3432
log_interval: int = 1,
3533
):
3634
"""Run molecular dynamics simulation with specified parameters.
37-
35+
3836
Args:
3937
input_file: Path to input XYZ file
4038
cell_size: Size of cubic simulation cell
@@ -47,17 +45,14 @@ def run_md_simulation(
4745
"""
4846
# Set up device
4947
device = setup_device()
50-
48+
5149
# Read in the system from file and set the cell size and pbc
5250
atoms = read(input_file)
5351
atoms.set_cell([cell_size] * 3)
5452
atoms.set_pbc([True] * 3)
5553

5654
# Set the calculator
57-
atoms.calc = ORBCalculator(
58-
model=pretrained.orb_d3_v2(),
59-
device=device
60-
)
55+
atoms.calc = ORBCalculator(model=pretrained.orb_d3_v2(), device=device)
6156

6257
# Set the initial velocities
6358
MaxwellBoltzmannDistribution(atoms, temperature_K=temperature_K)
@@ -67,8 +62,7 @@ def run_md_simulation(
6762

6863
# Define output functions and attach to dynamics
6964
dyn.attach(
70-
lambda: write('NaClWaterMD.xyz', atoms, append=True),
71-
interval=traj_interval
65+
lambda: write("NaClWaterMD.xyz", atoms, append=True), interval=traj_interval
7266
)
7367
dyn.attach(MDLogger(dyn, atoms, "md_nvt.log"), interval=log_interval)
7468

@@ -82,4 +76,4 @@ def main():
8276

8377

8478
if __name__ == "__main__":
85-
main()
79+
main()

0 commit comments

Comments
 (0)