Skip to content

Commit

Permalink
Improve wording across example Colab notebooks (#343)
Browse files Browse the repository at this point in the history
Also fixes some small bugs introduced in #342 in one of the notebooks.
  • Loading branch information
pabloferz authored Oct 31, 2024
1 parent e059321 commit 5f5bfc7
Show file tree
Hide file tree
Showing 24 changed files with 143 additions and 153 deletions.
28 changes: 13 additions & 15 deletions examples/Advanced_Sampling_Introduction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
"\n",
"# Setting up the environment\n",
"\n",
"First, we set up our environment. We use an already compiled and packaged installation of HOOMD-blue and the hoomd-dlext plugin.\n",
"We download it from Google Drive and make it visible to the running python process in this Colab instance.\n"
"First, we set up our environment. We will be using a pre-compiled and packaged installation of HOOMD-blue and the hoomd-dlext plugin.\n",
"It will be downloaded from Google Drive and made accessible to the Python process running in this Colab instance.\n"
]
},
{
Expand Down Expand Up @@ -130,7 +130,7 @@
"\n",
"## PySAGES\n",
"\n",
"The next step is to install PySAGES. First, we need to install JAX. Fortunately, Colab already ships with JAX pre-installed (to learn how to install it you can look at the [JAX documentation](https://jax.readthedocs.io) for more details). To install PySAGES, we retrieve the latest version from GitHub and add its dependecies via `pip`.\n"
"The next step is to install PySAGES. First, we need to install JAX. Fortunately, Colab already ships with JAX pre-installed (to learn how to install it you can look at the [JAX documentation](https://jax.readthedocs.io) for more details). To install PySAGES, we retrieve the latest version from GitHub and add its dependencies via `pip`.\n"
]
},
{
Expand Down Expand Up @@ -183,7 +183,7 @@
"\n",
"- Protein folding\n",
"- Protein-ligand binding\n",
"- Liqid membrane fusion"
"- Liquid membrane fusion"
]
},
{
Expand Down Expand Up @@ -285,7 +285,7 @@
"\n",
"Let's examine such a system via computer simulations.\n",
"\n",
"- fast to integration\n",
"- fast to integrate\n",
"- custom bond potential to shape the free-energy landscape\n",
"\n",
"$$P(r) = Ar^2 + A(1-e^{-r^2})\\cos(r p \\pi)$$\n"
Expand Down Expand Up @@ -1073,7 +1073,7 @@
"\n",
"We want to find the free-energy profile along a given path in the space for collective variables. Usually, this path can be multidimensional.\n",
"\n",
"Example dihedral angles of Alanine Dipeptide. [PySAGES Alanine Dipentide examples](https://colab.research.google.com/github/SSAGESLabs/PySAGES/blob/main/examples/openmm/Harmonic_Bias.ipynb)\n",
"Example dihedral angles of Alanine Dipeptide. [PySAGES Alanine Dipeptide examples](https://colab.research.google.com/github/SSAGESLabs/PySAGES/blob/main/examples/openmm/Harmonic_Bias.ipynb)\n",
"\n",
"<img src=https://cdn.ncbi.nlm.nih.gov/pmc/blobs/a1dd/4715807/e8dece12c024/nihms-706794-f0001.jpg width=500>\n",
"\n",
Expand Down Expand Up @@ -1459,7 +1459,7 @@
"General Idea:\n",
"\n",
"Move the string (path) along the perpendicular component $\\Delta V^\\perp$ at each discretized point $v_i = - \\Delta V^\\perp$. (Gradient descent)\n",
"The parallel component would move the discretized point just along the path and end up in the minima.\n",
"The parallel component would move the discretized point just along the path and end up in a minimum.\n",
"\n",
"Problem 1:\n",
"\n",
Expand Down Expand Up @@ -1489,20 +1489,18 @@
"\n",
"### Improved string method\n",
"\n",
"Using the perpendicular component directly does not lead to good convergences.\n",
"Using the perpendicular component directly does not lead to good convergence.\n",
"Instead, we can use the improved string method.\n",
"\n",
"Iterate:\n",
"\n",
"1. Calculate $\\Delta V|_{t_i}$\n",
"2. Move string $\\xi_0(t_i)$ += $\\alpha \\Delta V|_{t_i}$\n",
"3. Calculate spline $\\xi_0^s(t)$\n",
"4. Re-parametrize the string points.\n",
" > Such that $|\\xi*0^s(t_i) - \\xi_0^s(t*{i+1})| = $const.\n",
" >\n",
" > - cancels out parallel force component\n",
" > - well-discretized string\n",
" > - requires a norm in $\\xi$ space. For example $L^2$ norm in $\\xi$ space.\n",
"4. Re-parametrize the string points such that $|\\xi_0^s(t_i) - \\xi_0^s(t_{i+1})| = const$.\n",
" - cancels out parallel force component\n",
" - well-discretized string\n",
" - requires a norm in $\\xi$ space. For example $L^2$ norm in $\\xi$ space.\n",
"\n",
"Stop iteration if converged and test $\\Delta V^\\perp = 0$.\n",
"\n",
Expand All @@ -1514,7 +1512,7 @@
"\n",
"Let us define a committor probability.\n",
"\n",
"For a given point $r_i$ we can define the probability that a simulation started from this point ends in minima $B$ first before it moves through $B$.\n",
"For a given point $r_i$ we can define the probability that a simulation started from this point ends in minimum $B$ first before it moves through $B$.\n",
"$$\\text{commitor probability B: } p_B(r_i)$$\n",
"\n",
"This is a probability since we can have multiple realizations of $r_i$ in momentum space (Maxwell-Boltzmann distribution). Each of these realizations has its path and we simulate them and measure if they arrive in $A$ or $B$ first."
Expand Down
28 changes: 13 additions & 15 deletions examples/Advanced_Sampling_Introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ The University of Chicago

# Setting up the environment

First, we set up our environment. We use an already compiled and packaged installation of HOOMD-blue and the hoomd-dlext plugin.
We download it from Google Drive and make it visible to the running python process in this Colab instance.
First, we set up our environment. We will be using a pre-compiled and packaged installation of HOOMD-blue and the hoomd-dlext plugin.
It will be downloaded from Google Drive and made accessible to the Python process running in this Colab instance.

<!-- #endregion -->

Expand Down Expand Up @@ -76,7 +76,7 @@ We'll also need some additional python dependencies

## PySAGES

The next step is to install PySAGES. First, we need to install JAX. Fortunately, Colab already ships with JAX pre-installed (to learn how to install it you can look at the [JAX documentation](https://jax.readthedocs.io) for more details). To install PySAGES, we retrieve the latest version from GitHub and add its dependecies via `pip`.
The next step is to install PySAGES. First, we need to install JAX. Fortunately, Colab already ships with JAX pre-installed (to learn how to install it you can look at the [JAX documentation](https://jax.readthedocs.io) for more details). To install PySAGES, we retrieve the latest version from GitHub and add its dependencies via `pip`.

<!-- #endregion -->

Expand Down Expand Up @@ -106,7 +106,7 @@ Many systems have rugged free-energy landscapes, where different basins are divi

- Protein folding
- Protein-ligand binding
- Liqid membrane fusion
- Liquid membrane fusion
<!-- #endregion -->

<!-- #region id="mHOcKW-fXoK5" -->
Expand Down Expand Up @@ -189,7 +189,7 @@ $$p \propto e^{-\beta \Delta E} \ll 1$$

Let's examine such a system via computer simulations.

- fast to integration
- fast to integrate
- custom bond potential to shape the free-energy landscape

$$P(r) = Ar^2 + A(1-e^{-r^2})\cos(r p \pi)$$
Expand Down Expand Up @@ -645,7 +645,7 @@ Can we bias simulations in these regions too, to improve sampling coverage?

We want to find the free-energy profile along a given path in the space for collective variables. Usually, this path can be multidimensional.

Example dihedral angles of Alanine Dipeptide. [PySAGES Alanine Dipentide examples](https://colab.research.google.com/github/SSAGESLabs/PySAGES/blob/main/examples/openmm/Harmonic_Bias.ipynb)
Example dihedral angles of Alanine Dipeptide. [PySAGES Alanine Dipeptide examples](https://colab.research.google.com/github/SSAGESLabs/PySAGES/blob/main/examples/openmm/Harmonic_Bias.ipynb)

<img src=https://cdn.ncbi.nlm.nih.gov/pmc/blobs/a1dd/4715807/e8dece12c024/nihms-706794-f0001.jpg width=500>

Expand Down Expand Up @@ -916,7 +916,7 @@ The normal component of the force $\Rightarrow \Delta V^\perp = 0$ is zero.
General Idea:

Move the string (path) along the perpendicular component $\Delta V^\perp$ at each discretized point $v_i = - \Delta V^\perp$. (Gradient descent)
The parallel component would move the discretized point just along the path and end up in the minima.
The parallel component would move the discretized point just along the path and end up in a minimum.

Problem 1:

Expand Down Expand Up @@ -946,20 +946,18 @@ $\Rightarrow$ smooth path $\xi_0^s(t)$ with $\xi_0^s(t) = \xi(t_i)$.

### Improved string method

Using the perpendicular component directly does not lead to good convergences.
Using the perpendicular component directly does not lead to good convergence.
Instead, we can use the improved string method.

Iterate:

1. Calculate $\Delta V|_{t_i}$
2. Move string $\xi_0(t_i)$ += $\alpha \Delta V|_{t_i}$
3. Calculate spline $\xi_0^s(t)$
4. Re-parametrize the string points.
> Such that $|\xi*0^s(t_i) - \xi_0^s(t*{i+1})| = $const.
>
> - cancels out parallel force component
> - well-discretized string
> - requires a norm in $\xi$ space. For example $L^2$ norm in $\xi$ space.
4. Re-parametrize the string points such that $|\xi_0^s(t_i) - \xi_0^s(t_{i+1})| = const$.
- cancels out parallel force component
- well-discretized string
- requires a norm in $\xi$ space. For example $L^2$ norm in $\xi$ space.

Stop iteration if converged and test $\Delta V^\perp = 0$.

Expand All @@ -971,7 +969,7 @@ With the converged path, calculate the free-energy profile using umbrella integr

Let us define a committor probability.

For a given point $r_i$ we can define the probability that a simulation started from this point ends in minima $B$ first before it moves through $B$.
For a given point $r_i$ we can define the probability that a simulation started from this point ends in minimum $B$ first before it moves through $B$.
$$\text{commitor probability B: } p_B(r_i)$$

This is a probability since we can have multiple realizations of $r_i$ in momentum space (Maxwell-Boltzmann distribution). Each of these realizations has its path and we simulate them and measure if they arrive in $A$ or $B$ first.
Expand Down
4 changes: 2 additions & 2 deletions examples/Installing_a_PySAGES_Environment.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@
"\n",
"## Building and Installing the HOOMD-dlext Plugin\n",
"\n",
"Now we can install the `dlext` plugin for HOOMD-blue. But, we need to get some dependecies first.\n"
"Now we can install the `dlext` plugin for HOOMD-blue. But, we need to get some dependencies first.\n"
]
},
{
Expand Down Expand Up @@ -320,7 +320,7 @@
"\n",
"# Adding OpenMM Support\n",
"\n",
"Having previously set our the environment, we can now just simply install some required dependencies and build and install OpenMM.\n",
"Having previously set up the environment, we can now just simply install some required dependencies and build and install OpenMM.\n",
"\n",
"Again, installing dependencies will be different depending on your operating system and python environment."
]
Expand Down
4 changes: 2 additions & 2 deletions examples/Installing_a_PySAGES_Environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ cmake --build $BUILD_PATH --target install -j8 > /dev/null

## Building and Installing the HOOMD-dlext Plugin

Now we can install the `dlext` plugin for HOOMD-blue. But, we need to get some dependecies first.
Now we can install the `dlext` plugin for HOOMD-blue. But, we need to get some dependencies first.

<!-- #endregion -->

Expand Down Expand Up @@ -191,7 +191,7 @@ import hoomd.dlext

# Adding OpenMM Support

Having previously set our the environment, we can now just simply install some required dependencies and build and install OpenMM.
Having previously set up the environment, we can now just simply install some required dependencies and build and install OpenMM.

Again, installing dependencies will be different depending on your operating system and python environment.
<!-- #endregion -->
Expand Down
20 changes: 9 additions & 11 deletions examples/hoomd-blue/ann/Butane_ANN.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"source": [
"# Setting up the environment\n",
"\n",
"First, we set up our environment. We use an already compiled and packaged installation of HOOMD-blue and the hoomd-dlext plugin.\n",
"We download it from Google Drive and make it visible to the running python process in this Colab instance."
"First, we set up our environment. We will be using a pre-compiled and packaged installation of HOOMD-blue and the hoomd-dlext plugin.\n",
"It will be downloaded from Google Drive and made accessible to the Python process running in this Colab instance."
]
},
{
Expand Down Expand Up @@ -112,7 +112,7 @@
"source": [
"## PySAGES\n",
"\n",
"The next step is to install PySAGES. We retrieve the latest version from GitHub and add its dependecies via `pip`."
"Next, we install PySAGES. The latest version is retrieved from GitHub and installed (along with its dependencies) using `pip`."
]
},
{
Expand Down Expand Up @@ -157,7 +157,7 @@
"source": [
"ANN gradually learns the free energy from a probability density estimate based on the frequency of visits to the grid on collective variable space.\n",
"\n",
"For this Colab, we are using butane as the example molecule."
"In this Colab notebook, we will use butane as an example system."
]
},
{
Expand Down Expand Up @@ -435,7 +435,7 @@
},
"source": [
"\n",
"Next, we load PySAGES and the relevant classes and methods for our problem\n"
"Next, we import PySAGES and the necessary classes and methods for our simulation\n"
]
},
{
Expand Down Expand Up @@ -494,8 +494,8 @@
},
"source": [
"\n",
"We now simulate $5\\times10^5$ time steps.\n",
"Make sure to run with GPU support, otherwise, it can take a very long time.\n"
"We will now run a simulation for $5\\times10^5$ time steps.\n",
"For optimal performance, ensure that the simulation is executed with GPU acceleration. Otherwise, it may take a considerably longer time to complete.\n"
]
},
{
Expand Down Expand Up @@ -688,8 +688,7 @@
"id": "PXBKUfK0p9T2"
},
"source": [
"\n",
"Let's now plot the free energy landscape learned by the ANN sampling method.\n"
"We can now visualize the free energy landscape learned by the ANN sampling method."
]
},
{
Expand Down Expand Up @@ -768,8 +767,7 @@
"id": "Kf_CMdih90Cd"
},
"source": [
"\n",
"You can compare this with the free energy landscape for the different conformations of butane.\n"
"You can compare this with the free energy landscape for the different conformations of butane."
]
}
],
Expand Down
20 changes: 8 additions & 12 deletions examples/hoomd-blue/ann/Butane_ANN.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ jupyter:
<!-- #region id="T-Qkg9C9n7Cc" -->
# Setting up the environment

First, we set up our environment. We use an already compiled and packaged installation of HOOMD-blue and the hoomd-dlext plugin.
We download it from Google Drive and make it visible to the running python process in this Colab instance.
First, we set up our environment. We will be using a pre-compiled and packaged installation of HOOMD-blue and the hoomd-dlext plugin.
It will be downloaded from Google Drive and made accessible to the Python process running in this Colab instance.
<!-- #endregion -->

```bash id="3eTbKklCnyd_"
Expand Down Expand Up @@ -61,7 +61,7 @@ We'll also need some additional python dependencies
<!-- #region id="we_mTkFioS6R" -->
## PySAGES

The next step is to install PySAGES. We retrieve the latest version from GitHub and add its dependecies via `pip`.
Next, we install PySAGES. The latest version is retrieved from GitHub and installed (along with its dependencies) using `pip`.
<!-- #endregion -->

```python id="B-HB9CzioV5j"
Expand All @@ -81,7 +81,7 @@ cd /content/ann
<!-- #region id="0W2ukJuuojAl" -->
ANN gradually learns the free energy from a probability density estimate based on the frequency of visits to the grid on collective variable space.

For this Colab, we are using butane as the example molecule.
In this Colab notebook, we will use butane as an example system.
<!-- #endregion -->

```python id="BBvC7Spoog82"
Expand Down Expand Up @@ -347,7 +347,7 @@ def generate_simulation(kT = kT, dt = dt, device = hoomd.device.auto_select(), s

<!-- #region id="3UrzENm_oo6U" -->

Next, we load PySAGES and the relevant classes and methods for our problem
Next, we import PySAGES and the necessary classes and methods for our simulation

<!-- #endregion -->

Expand Down Expand Up @@ -384,8 +384,8 @@ method = ANN(cvs, grid, topology, kT)

<!-- #region id="Fz8BfU34pA_N" -->

We now simulate $5\times10^5$ time steps.
Make sure to run with GPU support, otherwise, it can take a very long time.
We will now run a simulation for $5\times10^5$ time steps.
For optimal performance, ensure that the simulation is executed with GPU acceleration. Otherwise, it may take a considerably longer time to complete.

<!-- #endregion -->

Expand All @@ -394,9 +394,7 @@ run_result = pysages.run(method, generate_simulation, int(5e5))
```

<!-- #region id="PXBKUfK0p9T2" -->

Let's now plot the free energy landscape learned by the ANN sampling method.

We can now visualize the free energy landscape learned by the ANN sampling method.
<!-- #endregion -->

```python id="X69d1R7OpW4P"
Expand All @@ -421,7 +419,5 @@ fig.show()
```

<!-- #region id="Kf_CMdih90Cd" -->

You can compare this with the free energy landscape for the different conformations of butane.

<!-- #endregion -->
Loading

0 comments on commit 5f5bfc7

Please sign in to comment.