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

Ep/ensemble calc #537

Open
wants to merge 61 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 55 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
594cb64
Changed header levels, reformatted yaml for docs
mgastegger Dec 16, 2022
079d3a1
Added materials tutorial to docs index
mgastegger Dec 16, 2022
a047947
tutorial doc
jnsLs Mar 13, 2023
5d17963
added ensemble
jnsLs Mar 14, 2023
d038e1c
optimizer uses doubles now
jnsLs Mar 15, 2023
2aa5cf8
fixed model loading, in LBGFS no epsilon is added, div. by zero is po…
jnsLs Mar 20, 2023
937c6cb
matmul to dot in update function
jnsLs Mar 20, 2023
01f4d79
removed history refresh
jnsLs Mar 21, 2023
7174386
Merge branch 'master' of https://github.com/jnsLs/schnetpack into bat…
jnsLs Mar 21, 2023
d730a85
Merge pull request #513 from jnsLs/batchwise_opt_w_calc
jnsLs Mar 21, 2023
ac4c011
detach before storing previous inputs in skin nbh list
jnsLs Apr 6, 2023
7481f62
Merge branch 'master' into jl/batchwise-and-ensemble
jnsLs Apr 6, 2023
f3c0165
removed property_map from calculator
jnsLs Apr 6, 2023
8cd736f
separated single bw_calculator and ensemble bw_calculator
jnsLs Apr 6, 2023
38a5517
fixed small bug in ensemble bw_calculator
jnsLs Apr 6, 2023
bd82249
Merge branch 'jl/fix_pl' into jl/batchwise-and-ensemble
jnsLs Apr 6, 2023
32912a1
this should allow to also use higher lammps versions. (not tested yet)
stefaanhessmann Apr 17, 2023
1c2d979
update installation command for creating environment
stefaanhessmann Apr 21, 2023
27f33c4
updated docstrings and added TODOs
jnsLs Apr 21, 2023
569a3a5
Merge branch 'master' of https://github.com/atomistic-machine-learnin…
jnsLs Apr 21, 2023
5d7b43a
revised doc strings and property keys
jnsLs Apr 21, 2023
81248c0
Merge pull request #1 from epens94/sh-jl/update_lammps
epens94 Apr 26, 2023
05e55dc
Merge pull request #2 from epens94/mg/docs_tut05
epens94 Apr 26, 2023
d2a21a4
Merge pull request #3 from epens94/jl/batchwise-and-ensemble
epens94 Apr 26, 2023
0d89984
Add Ensemble Calculator Class
epens94 Apr 26, 2023
3ac4e0d
change detach to cpu direct in calculate function
epens94 May 13, 2023
d2d83d9
ensemble calculator inherit direct from
epens94 May 13, 2023
1fd71f4
add functionality to pass preloaded model to
epens94 May 13, 2023
80bc48d
updates
epens94 May 14, 2023
27d2d70
updates
epens94 May 14, 2023
9584770
Merge branch 'atomistic-machine-learning:master' into ep/ensemble_calc
epens94 May 14, 2023
e8be2e0
remove scripts
epens94 May 14, 2023
87b0c6c
clean up
epens94 May 14, 2023
05fa713
Merge pull request #535 from epens94/ep/ensemble_calc
epens94 May 14, 2023
4e3ded6
set calculator durch mol.calc ersetzt
epens94 May 14, 2023
57a77b4
Merge pull request #536 from epens94/ep/ensemble_calc
epens94 May 14, 2023
47d8cc3
cleaned up
jnsLs May 15, 2023
43b9f0b
ensemble calculator works for single structures
jnsLs May 16, 2023
5f17aa8
cleaned up
jnsLs May 16, 2023
901950c
added test_qm9.db again
jnsLs May 16, 2023
345c134
cleaned up how to ensemble script
jnsLs May 16, 2023
6b2c1b9
removed model_results
jnsLs May 16, 2023
16fedda
EnsembleCalculator working, now working on batchwise calculator
jnsLs May 17, 2023
239a512
BatchwiseEnsembleCalculator is working
jnsLs May 17, 2023
3d503fa
EnsembleCalculator inherits from SpkCalculator
jnsLs May 17, 2023
bc05c93
Implemented BatchwiseCalculator
jnsLs May 17, 2023
04c9010
added new ethanol model and working on howto_batchwise_relaxations.ipynb
jnsLs May 17, 2023
07d8f64
reorganized files and using howto notebooks for testing
jnsLs May 17, 2023
083fc2c
ensemble average strategy made more general
epens94 May 18, 2023
88b74d8
Merge pull request #541 from epens94/ep/ensemble_calc
epens94 May 18, 2023
f6cfdb1
fixed model type issue in calculator (double/single precision)
jnsLs May 19, 2023
62776a5
cleaned up format
jnsLs May 19, 2023
434a92f
cleaned up notebooks
jnsLs May 19, 2023
3f9f0a3
improved doc strings and more modular calculator classes
jnsLs May 19, 2023
90ca5e6
reorganized files a bit
jnsLs May 19, 2023
f25d032
fixed stress format bug
jnsLs Jun 7, 2023
4fb2705
renamed ensemble strategies
jnsLs Jun 7, 2023
6d43fc8
add simple mean and std as
epens94 Jun 11, 2023
9338723
Merge pull request #547 from epens94/ep/ensemble_calc
epens94 Jun 11, 2023
9dd357a
improved howto notebook and fixed small bugs in the ensemble strategies
jnsLs Jun 13, 2023
5893cd3
added second ethanol model and input_dtype and output_dtype can be sp…
jnsLs Jul 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,4 @@ interfaces/lammps/examples/*/deployed_model

# batchwise optimizer examples
examples/howtos/howto_batchwise_relaxations_outputs/*
examples/howtos/howto_ensemble_relaxations_outputs/*
144 changes: 144 additions & 0 deletions examples/howtos/01_howto_ensemble_calculations.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "e16f3450",
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"import torch\n",
"import random\n",
"import shutil\n",
"import time\n",
"import numpy as np\n",
"from tqdm import tqdm \n",
"from matplotlib import pyplot as plt\n",
"from typing import Optional, List, Union, Dict\n",
"\n",
"import ase\n",
"from ase.io import read, write\n",
"from ase import Atoms\n",
"from ase.optimize.lbfgs import LBFGS\n",
"from ase.optimize import QuasiNewton\n",
"\n",
"import schnetpack as spk\n",
"from schnetpack import properties\n",
"from schnetpack.interfaces.ase_interface import SpkEnsembleCalculator, SpkCalculator\n",
"from schnetpack.interfaces.batchwise_optimization import ASEBatchwiseLBFGS, BatchwiseCalculator"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ea8ec623",
"metadata": {},
"outputs": [],
"source": [
"# TODO: Markdown comments, uncertainty evaluation example"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "58a19166",
"metadata": {},
"outputs": [],
"source": [
"model_path_0 = \"/home/jonas/Documents/schnetpack/tests/testdata/md_ethanol.model\"\n",
"model_path_1 = \"/home/jonas/Documents/schnetpack/tests/testdata/md_ethanol.model\"\n",
"\n",
"# set device\n",
"device = torch.device(\"cuda\")\n",
"\n",
"# define neighbor list\n",
"cutoff = 5.0\n",
"nbh_list=spk.transform.MatScipyNeighborList(cutoff=cutoff)\n",
"\n",
"# Set up calculator\n",
"calculator = SpkEnsembleCalculator(\n",
" model=[model_path_0, model_path_1],\n",
" neighbor_list=nbh_list,\n",
" energy_unit=\"kcal/mol\",\n",
" position_unit=\"Angstrom\",\n",
" device=device,\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "34d4bce9",
"metadata": {},
"outputs": [],
"source": [
"input_structure_file = \"../../tests/testdata/md_ethanol.xyz\"\n",
"random.seed(42)\n",
"\n",
"# Setup directory\n",
"if not os.path.exists('howto_ensemble_relaxations_outputs'):\n",
" os.makedirs('howto_ensemble_relaxations_outputs')\n",
"working_dir = \"howto_ensemble_relaxations_outputs/relax\"\n",
"if os.path.exists(working_dir):\n",
" shutil.rmtree(working_dir)\n",
"os.makedirs(working_dir)\n",
"\n",
"# load initial structure\n",
"mol = read(input_structure_file)\n",
"pos = mol.get_positions()\n",
"# distort the structure\n",
"for n in range(pos.shape[0]):\n",
" pos[n] = pos[n] * random.uniform(0.95,1.05)\n",
"molecule = Atoms(positions=pos, numbers=mol.get_atomic_numbers())\n",
"molecule.calc = calculator"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c6ebb93d",
"metadata": {},
"outputs": [],
"source": [
"# run relaxation\n",
"optimize_file = os.path.join(working_dir, \"optimization\")\n",
"optimizer = LBFGS(\n",
" molecule,\n",
" trajectory=\"{:s}.traj\".format(optimize_file),\n",
" restart=\"{:s}.pkl\".format(optimize_file),\n",
")\n",
"optimizer.run(fmax=0.001, steps=1000)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "790e15aa",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.13"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading