From cfa59271c80a73bda17c3782592eb8cae541ae32 Mon Sep 17 00:00:00 2001
From: pinyili2 <pinyili2@illinois.edu>
Date: Wed, 26 Jun 2024 16:57:49 -0500
Subject: [PATCH] same as above

---
 .../3-run-and-customized-checkpoint.ipynb     | 128 +++++++++++-------
 3-run-and-customized.ipynb                    | 128 +++++++++++-------
 2 files changed, 152 insertions(+), 104 deletions(-)

diff --git a/.ipynb_checkpoints/3-run-and-customized-checkpoint.ipynb b/.ipynb_checkpoints/3-run-and-customized-checkpoint.ipynb
index e8ee5f1..670aa50 100644
--- a/.ipynb_checkpoints/3-run-and-customized-checkpoint.ipynb
+++ b/.ipynb_checkpoints/3-run-and-customized-checkpoint.ipynb
@@ -2,7 +2,7 @@
  "cells": [
   {
    "cell_type": "markdown",
-   "id": "fba6117b",
+   "id": "024005b4",
    "metadata": {},
    "source": [
     "# Learn to run simulation and implement customized coarsed-grained polymer models\n",
@@ -10,23 +10,94 @@
     "As we've dived into the polymer objects in arbd and learned the basic usage of arbd, now it's time to put everything together and run coarsed-grained protein model using arbd! \n",
     "We will constructing a polymer model by coarse-graining the HpsModel.\n",
     "\n",
-    "## Step 1: Model Construction testing\n",
+    "## Step 1: Model Construction\n",
     "\n",
-    "We will begin with "
+    "We will start with the Hps Model we just saw in section 2 following and run the initial conformation with the same procedures. "
    ]
   },
   {
    "cell_type": "code",
    "execution_count": null,
-   "id": "60d287ac",
+   "id": "04d59bef",
    "metadata": {},
    "outputs": [],
    "source": [
     "import numpy as np\n",
+    "from pathlib import Path\n",
+    "from arbdmodel import ArbdEngine\n",
+    "from arbdmodel.coords import readArbdCoords\n",
     "from arbdmodel.polymer import PolymerSection\n",
     "from arbdmodel.hps_polymer_model import _types\n",
     "from arbdmodel.hps_polymer_model import HpsModel as NupModel\n",
     "\n",
+    "#from info import NupModel, create_arbd_polymer_objects, dimensions\n",
+    "\n",
+    "temperature = 298.15\n",
+    "ion_concentration = 250         # in mM\n",
+    "gpu = 0\n",
+    "\n",
+    "decomp_period = 50\n",
+    "skin_depth = 8\n",
+    "## 3.2\n",
+    "\n",
+    "model_name = 'HPS'\n",
+    "step = 1\n",
+    "\n",
+    "## units \"sqrt(80 epsilon0 k K /(2 * (mM/particle) * e**2))\" AA\n",
+    "debye_length = 10\n",
+    "\n",
+    "polymers, sequences = create_arbd_polymer_objects()\n",
+    "\n",
+    "model = NupModel( polymers, sequences,\n",
+    "                  debye_length = debye_length,\n",
+    "                  temperature=temperature,\n",
+    "                  damping_coefficient = 50000, # units of 1/ns\n",
+    "                  decomp_period = decomp_period,\n",
+    "                  pairlist_distance = 50+skin_depth,\n",
+    "                  dimensions = dimensions\n",
+    "                  )\n",
+    "engine = ArbdEngine( integrator = 'Langevin',\n",
+    "                     num_steps=1e7,\n",
+    "                     output_period=1e4,\n",
+    "                     gpu = 0\n",
+    "                    )\n",
+    "directory = f'1-one_bead_per_res-{model_name}'\n",
+    "outname = 'run'\n",
+    "\n",
+    "if not Path(f'{directory}/output/{outname}.dcd').exists():\n",
+    "    # \"\"\" \"Minimization\" \"\"\"\n",
+    "    # add_restraints(model,restraints)\n",
+    "    # model.simulate(output_name='{}-min-{}'.format(model_name,step),\n",
+    "    #                num_steps=1e3, output_period=500,\n",
+    "    #                gpu=gpu,\n",
+    "    # )\n",
+    "    # coords = readArbdCoords('output/{}-min-{}.restart'.format(model_name,step))\n",
+    "    # model.update_splines(coords)\n",
+    "\n",
+    "    \"\"\" Production \"\"\"\n",
+    "    model.set_damping_coefficient( 100 )\n",
+    "    engine.simulate(model, output_name=outname,\n",
+    "                    directory = directory\n",
+    "                    )\n"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "id": "5fb80332",
+   "metadata": {},
+   "source": [
+    "Then we can run the simulation with "
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "id": "28a28e18",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "\n",
+    "\n",
     "_seq = 'GLFG' * 8              # 10 repeats per polymer\n",
     "## We're going to tile polymers along x and y in a square lattice\n",
     "Nx = 5\n",
@@ -64,57 +135,10 @@
     "\n"
    ]
   },
-  {
-   "cell_type": "markdown",
-   "id": "e0987f4a",
-   "metadata": {},
-   "source": [
-    "Then we can run the simulation with "
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "id": "1ad8de8d",
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "from pathlib import Path\n",
-    "from arbdmodel import ArbdEngine\n",
-    "from arbdmodel.coords import readArbdCoords\n",
-    "\n",
-    "#from info import NupModel, create_arbd_polymer_objects, dimensions\n",
-    "\n",
-    "temperature = 298.15\n",
-    "ion_concentration = 250         # in mM\n",
-    "gpu = 0\n",
-    "\n",
-    "decomp_period = 50\n",
-    "skin_depth = 8\n",
-    "## 3.2\n",
-    "\n",
-    "model_name = 'HPS'\n",
-    "step = 1\n",
-    "\n",
-    "## units \"sqrt(80 epsilon0 k K /(2 * (mM/particle) * e**2))\" AA\n",
-    "debye_length = 10\n",
-    "\n",
-    "polymers, sequences = create_arbd_polymer_objects()\n",
-    "\n",
-    "model = NupModel( polymers, sequences,\n",
-    "                  debye_length = debye_length,\n",
-    "                  temperature=temperature,\n",
-    "                  damping_coefficient = 50000, # units of 1/ns\n",
-    "                  decomp_period = decomp_period,\n",
-    "                  pairlist_distance = 50+skin_depth,\n",
-    "                  dimensions = dimensions\n",
-    "                  )\n"
-   ]
-  },
   {
    "cell_type": "code",
    "execution_count": null,
-   "id": "6942a0b7",
+   "id": "b5aef887",
    "metadata": {},
    "outputs": [],
    "source": []
diff --git a/3-run-and-customized.ipynb b/3-run-and-customized.ipynb
index e8ee5f1..670aa50 100644
--- a/3-run-and-customized.ipynb
+++ b/3-run-and-customized.ipynb
@@ -2,7 +2,7 @@
  "cells": [
   {
    "cell_type": "markdown",
-   "id": "fba6117b",
+   "id": "024005b4",
    "metadata": {},
    "source": [
     "# Learn to run simulation and implement customized coarsed-grained polymer models\n",
@@ -10,23 +10,94 @@
     "As we've dived into the polymer objects in arbd and learned the basic usage of arbd, now it's time to put everything together and run coarsed-grained protein model using arbd! \n",
     "We will constructing a polymer model by coarse-graining the HpsModel.\n",
     "\n",
-    "## Step 1: Model Construction testing\n",
+    "## Step 1: Model Construction\n",
     "\n",
-    "We will begin with "
+    "We will start with the Hps Model we just saw in section 2 following and run the initial conformation with the same procedures. "
    ]
   },
   {
    "cell_type": "code",
    "execution_count": null,
-   "id": "60d287ac",
+   "id": "04d59bef",
    "metadata": {},
    "outputs": [],
    "source": [
     "import numpy as np\n",
+    "from pathlib import Path\n",
+    "from arbdmodel import ArbdEngine\n",
+    "from arbdmodel.coords import readArbdCoords\n",
     "from arbdmodel.polymer import PolymerSection\n",
     "from arbdmodel.hps_polymer_model import _types\n",
     "from arbdmodel.hps_polymer_model import HpsModel as NupModel\n",
     "\n",
+    "#from info import NupModel, create_arbd_polymer_objects, dimensions\n",
+    "\n",
+    "temperature = 298.15\n",
+    "ion_concentration = 250         # in mM\n",
+    "gpu = 0\n",
+    "\n",
+    "decomp_period = 50\n",
+    "skin_depth = 8\n",
+    "## 3.2\n",
+    "\n",
+    "model_name = 'HPS'\n",
+    "step = 1\n",
+    "\n",
+    "## units \"sqrt(80 epsilon0 k K /(2 * (mM/particle) * e**2))\" AA\n",
+    "debye_length = 10\n",
+    "\n",
+    "polymers, sequences = create_arbd_polymer_objects()\n",
+    "\n",
+    "model = NupModel( polymers, sequences,\n",
+    "                  debye_length = debye_length,\n",
+    "                  temperature=temperature,\n",
+    "                  damping_coefficient = 50000, # units of 1/ns\n",
+    "                  decomp_period = decomp_period,\n",
+    "                  pairlist_distance = 50+skin_depth,\n",
+    "                  dimensions = dimensions\n",
+    "                  )\n",
+    "engine = ArbdEngine( integrator = 'Langevin',\n",
+    "                     num_steps=1e7,\n",
+    "                     output_period=1e4,\n",
+    "                     gpu = 0\n",
+    "                    )\n",
+    "directory = f'1-one_bead_per_res-{model_name}'\n",
+    "outname = 'run'\n",
+    "\n",
+    "if not Path(f'{directory}/output/{outname}.dcd').exists():\n",
+    "    # \"\"\" \"Minimization\" \"\"\"\n",
+    "    # add_restraints(model,restraints)\n",
+    "    # model.simulate(output_name='{}-min-{}'.format(model_name,step),\n",
+    "    #                num_steps=1e3, output_period=500,\n",
+    "    #                gpu=gpu,\n",
+    "    # )\n",
+    "    # coords = readArbdCoords('output/{}-min-{}.restart'.format(model_name,step))\n",
+    "    # model.update_splines(coords)\n",
+    "\n",
+    "    \"\"\" Production \"\"\"\n",
+    "    model.set_damping_coefficient( 100 )\n",
+    "    engine.simulate(model, output_name=outname,\n",
+    "                    directory = directory\n",
+    "                    )\n"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "id": "5fb80332",
+   "metadata": {},
+   "source": [
+    "Then we can run the simulation with "
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "id": "28a28e18",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "\n",
+    "\n",
     "_seq = 'GLFG' * 8              # 10 repeats per polymer\n",
     "## We're going to tile polymers along x and y in a square lattice\n",
     "Nx = 5\n",
@@ -64,57 +135,10 @@
     "\n"
    ]
   },
-  {
-   "cell_type": "markdown",
-   "id": "e0987f4a",
-   "metadata": {},
-   "source": [
-    "Then we can run the simulation with "
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "id": "1ad8de8d",
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "from pathlib import Path\n",
-    "from arbdmodel import ArbdEngine\n",
-    "from arbdmodel.coords import readArbdCoords\n",
-    "\n",
-    "#from info import NupModel, create_arbd_polymer_objects, dimensions\n",
-    "\n",
-    "temperature = 298.15\n",
-    "ion_concentration = 250         # in mM\n",
-    "gpu = 0\n",
-    "\n",
-    "decomp_period = 50\n",
-    "skin_depth = 8\n",
-    "## 3.2\n",
-    "\n",
-    "model_name = 'HPS'\n",
-    "step = 1\n",
-    "\n",
-    "## units \"sqrt(80 epsilon0 k K /(2 * (mM/particle) * e**2))\" AA\n",
-    "debye_length = 10\n",
-    "\n",
-    "polymers, sequences = create_arbd_polymer_objects()\n",
-    "\n",
-    "model = NupModel( polymers, sequences,\n",
-    "                  debye_length = debye_length,\n",
-    "                  temperature=temperature,\n",
-    "                  damping_coefficient = 50000, # units of 1/ns\n",
-    "                  decomp_period = decomp_period,\n",
-    "                  pairlist_distance = 50+skin_depth,\n",
-    "                  dimensions = dimensions\n",
-    "                  )\n"
-   ]
-  },
   {
    "cell_type": "code",
    "execution_count": null,
-   "id": "6942a0b7",
+   "id": "b5aef887",
    "metadata": {},
    "outputs": [],
    "source": []
-- 
GitLab