Skip to content

Commit

Permalink
Deploying to gh-pages from @ f66ed51 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
janash committed May 15, 2024
1 parent 58d8e04 commit 991cb8a
Show file tree
Hide file tree
Showing 11 changed files with 927 additions and 73 deletions.
13 changes: 7 additions & 6 deletions _sources/energy_calculations.md.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ These XYZ files come from a [database of water cluster minima](https://sites.uw.

## Energy Calculation and Benchmarking Script

Open the script `xyz/energy_calculations.py` to see the starting code for this section.
Open the script `energy/energy_calculations.py` to see the starting code for this section.
The starting code includes functions for caluculating the energy of a system using ANI and Psi4.

:::{tab-set}

````{tab-item} xyz/energy_calculations.py
```python
"""
Retrieve xyz from a URL and calculate the energy using ANI
Calculate energies using Psi4 and ANI2x for water clusters.
"""

import glob
Expand Down Expand Up @@ -142,7 +142,7 @@ def calculate_Psi4_energy(xyz_file, name=None):

if __name__ == "__main__":

xyz_files = glob.glob("scaling/*.xyz")
xyz_files = glob.glob("xyz/scaling/*.xyz")

energies = []
times = []
Expand Down Expand Up @@ -205,6 +205,7 @@ if __name__ == "__main__":
plt.legend()

plt.savefig("timing.png")

```
````
:::
Expand All @@ -213,7 +214,7 @@ Run this script by opening the MDI Mechanic container in interactive mode.

:::{tab-set}

````{tab-item} ANI Energy Calculation
````{tab-item} bash
```bash
mdi interactive
```
Expand All @@ -224,9 +225,9 @@ Next, `cd` to the `xyz` directory and run the script.

:::{tab-set}

````{tab-item} ANI Energy Calculation
````{tab-item} bash
```bash
cd xyz
cd energy
python energy_calculations.py
```
````
Expand Down
95 changes: 95 additions & 0 deletions _sources/mdimechanic.md.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Using MDIMechanic

:::{admonition} Prerequisites
:class: note

Before completing this section, make sure you have completed the setup instructions in the [previous section](setup.md).
:::

In this tutorial, we will use the MDIMechanic package to run our code.
MDIMechanic is a Python package that provides an interface for running environments and MDI Engines.
It orchestrates Docker containers using a streamlined set up process.

The file `mdimechanic.yml` contains the configuration for the MDIMechanic environment.


To get started, execute the following command in your terminal:

:::{tab-set}

````{tab-item} bash

```bash
mdimechanic build
```
````
:::

While your image is building, we can examine the `mdimechanic.yaml` file to see what is happening.
Looking at the file, you will see the following:

```yaml
code_name: 'mdi-ani-tutorial'
docker:
image_name: 'mdi-ani-tutorial'

build_image:
- apt-get update && apt-get install -y curl
- curl "http://vergil.chemistry.gatech.edu/psicode-download/Psi4conda-1.9.1-py311-Linux-x86_64.sh" -o Psi4conda-1.9.1-py311-Linux-x86_64.sh --keepalive-time 2
- bash Psi4conda-1.9.1-py311-Linux-x86_64.sh -b -p $HOME/psi4conda
- echo $'. $HOME/psi4conda/etc/profile.d/conda.sh\nconda activate' >> ~/.bashrc
- source ~/.bashrc
- /root/psi4conda/bin/pip install pymdi
- /root/psi4conda/bin/pip install numpy
- /root/psi4conda/bin/pip install torch --index-url https://download.pytorch.org/whl/cpu
- /root/psi4conda/bin/pip install torchani
- /root/psi4conda/bin/pip install matplotlib
- /root/psi4conda/bin/pip install tabulate
- /root/psi4conda/bin/pip cache purge
```

This file specifies the name of the code, the Docker image to use, and the commands to run to build the image.
The Docker image is built from a base image for MDI that has compilers and other necessary software installed.
The `build_image` section specifies the commands to run to install the necessary software for the tutorial.
We are installing Psi4, pymdi, numpy, torch, torchani, and matplotlib.
Notice that this container is configured to install the CPU version of PyTorch (to save space and improve build time).

## Using the Image

MDIMechanic has a command called `mdimechanic interactive` that will mount your local directory as a volume in the container and open a shell in the container.
Execute MDIMechanic interactive with the following command:

:::{tab-set}

````{tab-item} bash

```bash
mdimechanic interactive
```
````
:::

You are now in the container and can use the software installed.
Check the directory contents using `ls` and confirm that it is the same as your local directory.

Open a Python interpreter and confirm that you can import torch and Psi4:

:::{tab-set}

````{tab-item} python

```python
import torch
import psi4
```
````
:::

If you can import these packages, you have successfully set up your environment and are ready to run the tutorial.

The other important section in `mdimechanic.yml` is the `run_scripts` section.
In that section, you will see commands for launching LAMMPS as well as the MDI Driver we will be writing.
If you are familiar with Docker, you may be interested to know that this section is used to specify a configuration for Docker Compose.
It will be discussed further in the [Driver Tutorial](driver_tutorial.md).

In the next section, we will use MDI Mechanic and the `mdimechanic interactive` mode to run Psi4 and ANI for energy calculations.
34 changes: 24 additions & 10 deletions driver_tutorial.html
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,15 @@


<li class="nav-item">
<a class="nav-link nav-internal" href="energy_calculations.html">
Calculating Molecular Energies
<a class="nav-link nav-internal" href="mdimechanic.html">
Using MDIMechanic
</a>
</li>


<li class="nav-item current active">
<a class="nav-link nav-internal" href="#">
MDI Driver Tutorial
<li class="nav-item">
<a class="nav-link nav-internal" href="energy_calculations.html">
Calculating Molecular Energies
</a>
</li>

Expand All @@ -176,6 +176,13 @@
</button>
<ul id="pst-nav-more-links" class="dropdown-menu">

<li class="nav-item current active">
<a class="nav-link dropdown-item nav-internal" href="#">
MDI Driver Tutorial
</a>
</li>


<li class="nav-item">
<a class="nav-link dropdown-item nav-external" href="https://molssi.org">
MolSSI
Expand Down Expand Up @@ -303,15 +310,15 @@


<li class="nav-item">
<a class="nav-link nav-internal" href="energy_calculations.html">
Calculating Molecular Energies
<a class="nav-link nav-internal" href="mdimechanic.html">
Using MDIMechanic
</a>
</li>


<li class="nav-item current active">
<a class="nav-link nav-internal" href="#">
MDI Driver Tutorial
<li class="nav-item">
<a class="nav-link nav-internal" href="energy_calculations.html">
Calculating Molecular Energies
</a>
</li>

Expand All @@ -321,6 +328,13 @@
</button>
<ul id="pst-nav-more-links-2" class="dropdown-menu">

<li class="nav-item current active">
<a class="nav-link dropdown-item nav-internal" href="#">
MDI Driver Tutorial
</a>
</li>


<li class="nav-item">
<a class="nav-link dropdown-item nav-external" href="https://molssi.org">
MolSSI
Expand Down
57 changes: 36 additions & 21 deletions energy_calculations.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="MDI Driver Tutorial" href="driver_tutorial.html" />
<link rel="prev" title="Set Up" href="setup.html" />
<link rel="prev" title="Using MDIMechanic" href="mdimechanic.html" />
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="docsearch:language" content="en"/>
</head>
Expand Down Expand Up @@ -159,16 +159,16 @@
</li>


<li class="nav-item current active">
<a class="nav-link nav-internal" href="#">
Calculating Molecular Energies
<li class="nav-item">
<a class="nav-link nav-internal" href="mdimechanic.html">
Using MDIMechanic
</a>
</li>


<li class="nav-item">
<a class="nav-link nav-internal" href="driver_tutorial.html">
MDI Driver Tutorial
<li class="nav-item current active">
<a class="nav-link nav-internal" href="#">
Calculating Molecular Energies
</a>
</li>

Expand All @@ -178,6 +178,13 @@
</button>
<ul id="pst-nav-more-links" class="dropdown-menu">

<li class="nav-item">
<a class="nav-link dropdown-item nav-internal" href="driver_tutorial.html">
MDI Driver Tutorial
</a>
</li>


<li class="nav-item">
<a class="nav-link dropdown-item nav-external" href="https://molssi.org">
MolSSI
Expand Down Expand Up @@ -304,16 +311,16 @@
</li>


<li class="nav-item current active">
<a class="nav-link nav-internal" href="#">
Calculating Molecular Energies
<li class="nav-item">
<a class="nav-link nav-internal" href="mdimechanic.html">
Using MDIMechanic
</a>
</li>


<li class="nav-item">
<a class="nav-link nav-internal" href="driver_tutorial.html">
MDI Driver Tutorial
<li class="nav-item current active">
<a class="nav-link nav-internal" href="#">
Calculating Molecular Energies
</a>
</li>

Expand All @@ -323,6 +330,13 @@
</button>
<ul id="pst-nav-more-links-2" class="dropdown-menu">

<li class="nav-item">
<a class="nav-link dropdown-item nav-internal" href="driver_tutorial.html">
MDI Driver Tutorial
</a>
</li>


<li class="nav-item">
<a class="nav-link dropdown-item nav-external" href="https://molssi.org">
MolSSI
Expand Down Expand Up @@ -457,14 +471,14 @@ <h2>Water Cluster Configurations<a class="headerlink" href="#water-cluster-confi
</section>
<section id="energy-calculation-and-benchmarking-script">
<h2>Energy Calculation and Benchmarking Script<a class="headerlink" href="#energy-calculation-and-benchmarking-script" title="Link to this heading">#</a></h2>
<p>Open the script <code class="docutils literal notranslate"><span class="pre">xyz/energy_calculations.py</span></code> to see the starting code for this section.
<p>Open the script <code class="docutils literal notranslate"><span class="pre">energy/energy_calculations.py</span></code> to see the starting code for this section.
The starting code includes functions for caluculating the energy of a system using ANI and Psi4.</p>
<div class="sd-tab-set docutils">
<input checked="checked" id="sd-tab-item-0" name="sd-tab-set-0" type="radio">
</input><label class="sd-tab-label" for="sd-tab-item-0">
xyz/energy_calculations.py</label><div class="sd-tab-content docutils">
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">Retrieve xyz from a URL and calculate the energy using ANI</span>
<span class="sd">Calculate energies using Psi4 and ANI2x for water clusters.</span>
<span class="sd">&quot;&quot;&quot;</span>

<span class="kn">import</span> <span class="nn">glob</span>
Expand Down Expand Up @@ -584,7 +598,7 @@ <h2>Energy Calculation and Benchmarking Script<a class="headerlink" href="#energ

<span class="k">if</span> <span class="vm">__name__</span> <span class="o">==</span> <span class="s2">&quot;__main__&quot;</span><span class="p">:</span>

<span class="n">xyz_files</span> <span class="o">=</span> <span class="n">glob</span><span class="o">.</span><span class="n">glob</span><span class="p">(</span><span class="s2">&quot;scaling/*.xyz&quot;</span><span class="p">)</span>
<span class="n">xyz_files</span> <span class="o">=</span> <span class="n">glob</span><span class="o">.</span><span class="n">glob</span><span class="p">(</span><span class="s2">&quot;xyz/scaling/*.xyz&quot;</span><span class="p">)</span>

<span class="n">energies</span> <span class="o">=</span> <span class="p">[]</span>
<span class="n">times</span> <span class="o">=</span> <span class="p">[]</span>
Expand Down Expand Up @@ -647,6 +661,7 @@ <h2>Energy Calculation and Benchmarking Script<a class="headerlink" href="#energ
<span class="n">plt</span><span class="o">.</span><span class="n">legend</span><span class="p">()</span>

<span class="n">plt</span><span class="o">.</span><span class="n">savefig</span><span class="p">(</span><span class="s2">&quot;timing.png&quot;</span><span class="p">)</span>

</pre></div>
</div>
</div>
Expand All @@ -655,7 +670,7 @@ <h2>Energy Calculation and Benchmarking Script<a class="headerlink" href="#energ
<div class="sd-tab-set docutils">
<input checked="checked" id="sd-tab-item-1" name="sd-tab-set-1" type="radio">
</input><label class="sd-tab-label" for="sd-tab-item-1">
ANI Energy Calculation</label><div class="sd-tab-content docutils">
bash</label><div class="sd-tab-content docutils">
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>mdi<span class="w"> </span>interactive
</pre></div>
</div>
Expand All @@ -665,8 +680,8 @@ <h2>Energy Calculation and Benchmarking Script<a class="headerlink" href="#energ
<div class="sd-tab-set docutils">
<input checked="checked" id="sd-tab-item-2" name="sd-tab-set-2" type="radio">
</input><label class="sd-tab-label" for="sd-tab-item-2">
ANI Energy Calculation</label><div class="sd-tab-content docutils">
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="nb">cd</span><span class="w"> </span>xyz
bash</label><div class="sd-tab-content docutils">
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="nb">cd</span><span class="w"> </span>energy
python<span class="w"> </span>energy_calculations.py
</pre></div>
</div>
Expand Down Expand Up @@ -741,12 +756,12 @@ <h2>Exercise 3: Evaluating the Accuracy of ANI for Benzene<a class="headerlink"

<div class="prev-next-area">
<a class="left-prev"
href="setup.html"
href="mdimechanic.html"
title="previous page">
<i class="fa-solid fa-angle-left"></i>
<div class="prev-next-info">
<p class="prev-next-subtitle">previous</p>
<p class="prev-next-title">Set Up</p>
<p class="prev-next-title">Using MDIMechanic</p>
</div>
</a>
<a class="right-next"
Expand Down
Loading

0 comments on commit 991cb8a

Please sign in to comment.