Skip to content

Commit

Permalink
Update HOOMD-blue Colab notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
pabloferz committed Oct 30, 2024
1 parent b746558 commit 87859e1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@
"\n",
" return snapshot\n",
"\n",
"\n",
"system = System()\n",
"snap = get_snap(system)\n",
"snap = post_process_pos(snap)\n",
Expand Down Expand Up @@ -319,7 +320,7 @@
")\n",
"periodic_params = dict(\n",
" A = dict(A = 0.5, i = 0, w = 0.2, p = 2),\n",
" B = dict(A = 0.0, i = 0, w = 0.2, p = 1),\n",
" B = dict(A = 0.0, i = 0, w = 0.02, p = 1),\n",
")\n",
"\n",
"def generate_simulation(\n",
Expand Down Expand Up @@ -403,7 +404,7 @@
},
"source": [
"The next parameters we need to define and run the method are the harmonic biasing spring constant,\n",
"(which we set to to $50$), the log frequency for the histogram ($50$), the number of steps we discard\n",
"(which we set to to $100$), the log frequency for the histogram ($50$), the number of steps we discard\n",
"as equilibration before logging ($10^3$), and the number of time steps per replica ($10^4$).\n",
"\n",
"Since this runs multiple simulations, we expect the next cell to execute for a while."
Expand Down Expand Up @@ -1028,7 +1029,7 @@
}
],
"source": [
"method = UmbrellaIntegration(cvs, 50.0, centers, 50, int(1e3))\n",
"method = UmbrellaIntegration(cvs, 100.0, centers, 50, int(1e3))\n",
"raw_result = pysages.run(method, generate_simulation, int(1e4))\n",
"result = pysages.analyze(raw_result)"
]
Expand Down Expand Up @@ -1070,7 +1071,7 @@
"source": [
"import matplotlib.pyplot as plt\n",
"\n",
"bins =50\n",
"bins = 50\n",
"\n",
"fig, ax = plt.subplots(2, 2)\n",
"\n",
Expand Down Expand Up @@ -1147,7 +1148,7 @@
"def external_field(r, A, p, w, **kwargs):\n",
" return A * np.tanh(1 / (2 * np.pi * p * w) * np.cos(p * r))\n",
"\n",
"x = np.linspace(-2, 2, 50)\n",
"x = np.linspace(-2, 2, 100)\n",
"data = external_field(x, **periodic_params[\"A\"])\n",
"\n",
"centers = np.asarray(result[\"centers\"])\n",
Expand Down
11 changes: 6 additions & 5 deletions examples/hoomd-blue/umbrella_integration/Umbrella_Integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ def get_snap(system):

return snapshot


system = System()
snap = get_snap(system)
snap = post_process_pos(snap)
Expand Down Expand Up @@ -156,7 +157,7 @@ dpd_params = dict(
)
periodic_params = dict(
A = dict(A = 0.5, i = 0, w = 0.2, p = 2),
B = dict(A = 0.0, i = 0, w = 0.2, p = 1),
B = dict(A = 0.0, i = 0, w = 0.02, p = 1),
)

def generate_simulation(
Expand Down Expand Up @@ -211,14 +212,14 @@ centers = list(np.linspace(-1.5, 1.5, 25))

<!-- #region id="q37sUT-tbOMS" -->
The next parameters we need to define and run the method are the harmonic biasing spring constant,
(which we set to to $50$), the log frequency for the histogram ($50$), the number of steps we discard
(which we set to to $100$), the log frequency for the histogram ($50$), the number of steps we discard
as equilibration before logging ($10^3$), and the number of time steps per replica ($10^4$).

Since this runs multiple simulations, we expect the next cell to execute for a while.
<!-- #endregion -->

```python colab={"base_uri": "https://localhost:8080/"} id="wIrPB2N0bFIl" outputId="2f018685-a115-4c66-a21a-eef1d515bd02"
method = UmbrellaIntegration(cvs, 50.0, centers, 50, int(1e3))
method = UmbrellaIntegration(cvs, 100.0, centers, 50, int(1e3))
raw_result = pysages.run(method, generate_simulation, int(1e4))
result = pysages.analyze(raw_result)
```
Expand All @@ -230,7 +231,7 @@ What is left after the run is evaluating the resulting histograms for each of th
```python colab={"base_uri": "https://localhost:8080/", "height": 265} id="OOpagwvlb3_d" outputId="62b507a1-d404-4924-ec1b-00b9d3f39085"
import matplotlib.pyplot as plt

bins =50
bins = 50

fig, ax = plt.subplots(2, 2)

Expand Down Expand Up @@ -267,7 +268,7 @@ And finally, as the last step, we can visualize the estimated free-energy path f
def external_field(r, A, p, w, **kwargs):
return A * np.tanh(1 / (2 * np.pi * p * w) * np.cos(p * r))

x = np.linspace(-2, 2, 50)
x = np.linspace(-2, 2, 100)
data = external_field(x, **periodic_params["A"])

centers = np.asarray(result["centers"])
Expand Down

0 comments on commit 87859e1

Please sign in to comment.