-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding OpenMM as an optional MD engine (#55)
Added experimental interface to OpenMM. Currently works only for MACE and runs in the local directory. * Initial OpenMM MD engine * Guard against incorrect usage * Added OpenMM usage and warning to README
- Loading branch information
Showing
11 changed files
with
533 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,8 @@ dependencies: | |
- scipy | ||
- xtb | ||
# MACE dependencies | ||
- pytorch | ||
- pytorch=2.0 | ||
- openmm-torch=1.1 | ||
- torchvision | ||
- torchaudio | ||
- torch-ema | ||
|
@@ -34,4 +35,6 @@ dependencies: | |
# so needs to be installed together. | ||
- e3nn | ||
- mace@git+https://github.com/ACEsuit/[email protected] | ||
# The upstream PR to openmm-ml has not been merged yet: https://github.com/openmm/openmm-ml/pull/61) | ||
- openmmml@git+https://github.com/sef43/openmm-ml@mace | ||
- ase@git+https://gitlab.com/ase/ase@f2615a6e9a # for Plumed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import mlptrain as mlt | ||
|
||
mlt.Config.n_cores = 1 | ||
|
||
|
||
if __name__ == '__main__': | ||
system = mlt.System(mlt.Molecule('water.xyz'), box=None) | ||
|
||
mace = mlt.potentials.MACE('water', system=system) | ||
|
||
mace.al_train( | ||
method_name='xtb', | ||
temp=500, | ||
max_active_iters=2, | ||
max_active_time=50, | ||
n_configs_iter=3, | ||
md_program='OpenMM', | ||
) | ||
|
||
# Run some dynamics with the potential | ||
trajectory = mlt.md_openmm.run_mlp_md_openmm( | ||
configuration=system.random_configuration(), | ||
mlp=mace, | ||
fs=2000, | ||
temp=300, | ||
dt=0.5, | ||
interval=100, | ||
) | ||
|
||
trajectory.save(filename='water_trajectory.xyz') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"id": "98up6lvBEmaE" | ||
}, | ||
"source": [ | ||
"# MLP-Train Water with OpenMM on Colab\n", | ||
"\n", | ||
"You can run this notebook in Google Colab: [![Open On Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/sef43/mlp-train/blob/main/examples/water_openmm_colab.ipynb)\n", | ||
"\n", | ||
"MLP-Train basic example that runs on Colab and uses OpenMM as the MD engine." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"colab": { | ||
"base_uri": "https://localhost:8080/", | ||
"height": 1000 | ||
}, | ||
"id": "Cb_3edQEEyxx", | ||
"outputId": "b02b5b81-db06-49e1-81d2-780f0e72079b" | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"# Installation on Colab\n", | ||
"!pip install -q condacolab\n", | ||
"import condacolab\n", | ||
"\n", | ||
"condacolab.install_mambaforge()\n", | ||
"# https://github.com/openmm/openmm-torch/issues/88\n", | ||
"%env CONDA_OVERRIDE_CUDA=12.0\n", | ||
"!mamba install -c conda-forge openmm-torch=1.1 pytorch=2.0 xtb cython rdkit\n", | ||
"\n", | ||
"# Only have python 3.10 available on Colab so cannot install autodE from\n", | ||
"# conda-forge as there are no py3.10 builds for autode=v1.1.*\n", | ||
"!git clone --branch v1.1.3 https://github.com/duartegroup/autodE.git\n", | ||
"!cd autodE && python setup.py install\n", | ||
"!cd ..\n", | ||
"!pip install ./autodE\n", | ||
"!pip install git+https://github.com/rosswhitfield/ase.git\n", | ||
"!pip install git+https://github.com/ACEsuit/mace.git\n", | ||
"!pip install git+https://github.com/sef43/openmm-ml@mace\n", | ||
"!pip install git+https://github.com/sef43/mlp-train" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"colab": { | ||
"base_uri": "https://localhost:8080/" | ||
}, | ||
"id": "jInwylB5aU3x", | ||
"outputId": "efa7baaf-5ee2-469a-e131-a2616dde5890" | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"# Get the example input\n", | ||
"!wget https://raw.githubusercontent.com/sef43/mlp-train/main/examples/water.xyz" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"colab": { | ||
"base_uri": "https://localhost:8080/" | ||
}, | ||
"id": "rdjXObniFynd", | ||
"outputId": "1ae4d16c-f2db-4f23-d42c-7115091fc3ad" | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"import mlptrain as mlt\n", | ||
"\n", | ||
"mlt.Config.n_cores = 1\n", | ||
"\n", | ||
"system = mlt.System(mlt.Molecule('water.xyz'), box=None)\n", | ||
"\n", | ||
"mace = mlt.potentials.MACE('water', system=system)\n", | ||
"\n", | ||
"mace.al_train(\n", | ||
" method_name='xtb',\n", | ||
" temp=500,\n", | ||
" max_active_iters=2,\n", | ||
" max_active_time=50,\n", | ||
" n_configs_iter=3,\n", | ||
" md_program='OpenMM',\n", | ||
")\n", | ||
"\n", | ||
"# Run some dynamics with the potential\n", | ||
"trajectory = mlt.md_openmm.run_mlp_md_openmm(\n", | ||
" configuration=system.random_configuration(),\n", | ||
" mlp=mace,\n", | ||
" fs=2000,\n", | ||
" temp=300,\n", | ||
" dt=0.5,\n", | ||
" interval=100,\n", | ||
")\n", | ||
"\n", | ||
"trajectory.save(filename='water_trajectory.xyz')" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"colab": { | ||
"provenance": [] | ||
}, | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"name": "python" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.