-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix make file, add README, add CI check (#25)
* add contrib info * run pre-commit hooks * remove make.bat * update structure relax * update notebook * glob and update notebook
- Loading branch information
Showing
7 changed files
with
237 additions
and
637 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: pre-commit | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: [main] | ||
|
||
jobs: | ||
pre-commit: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-python@v3 | ||
- uses: pre-commit/[email protected] |
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,195 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/basf/mlipx/blob/main/docs/source/notebooks/combine.ipynb)\n", | ||
"\n", | ||
"# Combine Multiple Nodes\n", | ||
"\n", | ||
"The `mlipx` command line interface provides you with recipes for specific tasks.\n", | ||
"In this notebook, we will write a script to include different aspects from different recipes into a single workflow." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Only install the packages if they are not already installed\n", | ||
"!pip show mlipx > /dev/null 2>&1 || pip install mlipx\n", | ||
"!pip show rdkit2ase > /dev/null 2>&1 || pip install rdkit2ase" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# We will create a GIT and DVC repository in a temporary directory\n", | ||
"import os\n", | ||
"import tempfile\n", | ||
"\n", | ||
"temp_dir = tempfile.TemporaryDirectory()\n", | ||
"os.chdir(temp_dir.name)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Like all `mlipx` Nodes we will use a GIT and DVC repository to run experiments.\n", | ||
"To make our custom code available, we structure our project like\n", | ||
"\n", | ||
"```\n", | ||
"relaxation/\n", | ||
" ├── .git/\n", | ||
" ├── .dvc/\n", | ||
" ├── src/__init__.py\n", | ||
" ├── src/relaxation.py\n", | ||
" ├── models.py\n", | ||
" └── main.py\n", | ||
"```\n", | ||
"\n", | ||
"to allow us to import our code `from src.relaxation import Relax`.\n", | ||
"Alternatively, you can package your code and import it like any other Python package." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"!git init\n", | ||
"!dvc init --quiet" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Let us configure now configure a workflow, creating a structure from `SMILES`, relax it, run molecular dynamics and compute the homonuclear diatomics." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import mlipx\n", | ||
"\n", | ||
"project = mlipx.Project()\n", | ||
"\n", | ||
"emt = mlipx.GenericASECalculator(\n", | ||
" module=\"ase.calculators.emt\",\n", | ||
" class_name=\"EMT\",\n", | ||
")\n", | ||
"\n", | ||
"with project.group(\"initialize\"):\n", | ||
" confs = mlipx.Smiles2Conformers(smiles=\"CCCC\", num_confs=1)\n", | ||
"\n", | ||
"with project.group(\"structure-optimization\"):\n", | ||
" struct_optim = mlipx.StructureOptimization(\n", | ||
" data=confs.frames, data_id=-1, optimizer=\"LBFGS\", model=emt\n", | ||
" )\n", | ||
"\n", | ||
"thermostat = mlipx.LangevinConfig(\n", | ||
" timestep=0.5,\n", | ||
" temperature=300,\n", | ||
" friction=0.001,\n", | ||
")\n", | ||
"\n", | ||
"with project.group(\"molecular-dynamics\"):\n", | ||
" md = mlipx.MolecularDynamics(\n", | ||
" data=struct_optim.frames,\n", | ||
" data_id=-1,\n", | ||
" model=emt,\n", | ||
" thermostat=thermostat,\n", | ||
" steps=1000,\n", | ||
" )\n", | ||
"\n", | ||
"with project.group(\"homonuclear-diatomics\"):\n", | ||
" ev = mlipx.HomonuclearDiatomics(\n", | ||
" data=confs.frames,\n", | ||
" model=emt,\n", | ||
" n_points=100,\n", | ||
" min_distance=0.75,\n", | ||
" max_distance=2.0,\n", | ||
" elements=[],\n", | ||
" )\n", | ||
"\n", | ||
"project.repro()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Once the graph has been executed, we can look at the resulting structures." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"struct_optim.figures[\"energy_vs_steps\"]" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"md.figures[\"energy\"]" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"print(ev.figures.keys())\n", | ||
"ev.figures[\"C-C bond\"]" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"temp_dir.cleanup()" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "mlipx", | ||
"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.11.10" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
Oops, something went wrong.