Skip to content

Commit

Permalink
Clean up rogue cell and reduce simulation times on Colab
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoshanuikabundi committed Feb 27, 2024
1 parent cefd7f2 commit 4cf9d1e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 49 deletions.
Binary file not shown.
54 changes: 5 additions & 49 deletions source/workshops/2024/protein_prep/colab-protein_prep.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1083,7 +1083,7 @@
"metadata": {},
"outputs": [],
"source": [
"simulation.step(100 * openmm.unit.picosecond / simulation.integrator.getStepSize())"
"simulation.step(1 * openmm.unit.picosecond / simulation.integrator.getStepSize())"
]
},
{
Expand Down Expand Up @@ -1119,7 +1119,7 @@
"metadata": {},
"outputs": [],
"source": [
"simulation.step(100 * openmm.unit.picosecond / simulation.integrator.getStepSize())"
"simulation.step(1 * openmm.unit.picosecond / simulation.integrator.getStepSize())"
]
},
{
Expand Down Expand Up @@ -1171,19 +1171,19 @@
" openmm.app.XTCReporter( # Compressed trajectory format\n",
" file=\"trajectory.xtc\",\n",
" reportInterval=int(\n",
" 1 * openmm.unit.picosecond / simulation.integrator.getStepSize()\n",
" 0.01 * openmm.unit.picosecond / simulation.integrator.getStepSize()\n",
" ),\n",
" ),\n",
" openmm.app.CheckpointReporter( # Checkpoint for exact continuation in case of crash\n",
" file=\"checkpoint.chk\",\n",
" reportInterval=int(\n",
" 100 * openmm.unit.picosecond / simulation.integrator.getStepSize()\n",
" 1 * openmm.unit.picosecond / simulation.integrator.getStepSize()\n",
" ),\n",
" ),\n",
" openmm.app.StateDataReporter( # Human readable state information over time\n",
" file=\"states.csv\",\n",
" reportInterval=int(\n",
" 1 * openmm.unit.picosecond / simulation.integrator.getStepSize()\n",
" 0.01 * openmm.unit.picosecond / simulation.integrator.getStepSize()\n",
" ),\n",
" step=True,\n",
" time=True,\n",
Expand Down Expand Up @@ -1216,50 +1216,6 @@
"simulation.runForClockTime(1 * openmm.unit.minute)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e8e54de6-f0af-413d-a119-2987daa36097",
"metadata": {},
"outputs": [],
"source": [
"def nglview_show_openmm(topology: openmm.app.Topology, positions, image_molecules=False):\n",
" import mdtraj\n",
" import openmm.unit\n",
" import nglview\n",
" \n",
" top = mdtraj.Topology.from_openmm(topology)\n",
"\n",
" if isinstance(positions, str) or isinstance(positions, Path):\n",
" traj = mdtraj.load(positions, top=top)\n",
" if image_molecules:\n",
" traj.image_molecules(inplace=True)\n",
" else:\n",
" positions = ensure_quantity(positions, \"openmm\").value_in_unit(\n",
" openmm.unit.nanometer\n",
" )\n",
" xyz = numpy.asarray([positions])\n",
" box_vectors = topology.getPeriodicBoxVectors()\n",
" if box_vectors is not None:\n",
" (\n",
" l1,\n",
" l2,\n",
" l3,\n",
" alpha,\n",
" beta,\n",
" gamma,\n",
" ) = mdtraj.utils.box_vectors_to_lengths_and_angles(\n",
" *numpy.asarray(box_vectors.value_in_unit(openmm.unit.nanometer))\n",
" )\n",
" unitcell_angles, unitcell_lengths = [alpha, beta, gamma], [l1, l2, l3]\n",
" else:\n",
" unitcell_angles, unitcell_lengths = None, None\n",
" traj = mdtraj.Trajectory(\n",
" xyz, top, unitcell_lengths=unitcell_lengths, unitcell_angles=unitcell_angles\n",
" )\n",
" return nglview.show_mdtraj(traj)"
]
},
{
"cell_type": "markdown",
"id": "77f0ff3b-3ce3-4aa1-a77e-29b8582dc78a",
Expand Down

0 comments on commit 4cf9d1e

Please sign in to comment.