Skip to content
Snippets Groups Projects
Commit 5d719373 authored by cmaffeo2's avatar cmaffeo2
Browse files

Initial draft of tutorial

parents
No related branches found
No related tags found
No related merge requests found
%% Cell type:markdown id: tags:
# Basic usage of the `arbdmodel` package
%% Cell type:markdown id: tags:
### Step 1: Create particle types
%% Cell type:code id: tags:
``` python
import numpy as np
from arbdmodel import ParticleType, PointParticle, ArbdModel
system_size = 620
num_particles = 6400
## diffusion of liquid argon: https://www.sciencedirect.com/science/article/pii/0375960171901290
## units "60 * 3.41 AA * sqrt(119.5 k K / 40 dalton)" "AA**2/ns"
argon = ParticleType(name="Ar",
mass=39.95, # dalton
damping_coefficient=5000, # per ns
custom_property="my_value",
epsilon=0.177, # kcal_mol
radius=3.345/2) # Angstroms
print(argon)
```
%% Cell type:markdown id: tags:
### Step 2: Build system
%% Cell type:code id: tags:
``` python
## Generate Nx3 array of random cartesian coordinates
positions = system_size*(np.random.random([num_particles,3])-0.5)
## Create a list of point particles located at those positions
points = [PointParticle(type_=argon, name="Ar", position=positions[i])
for i in range(num_particles)]
model = ArbdModel(points,
dimensions=[system_size for i in range(3)], # Ångstroms
timestep = 20e-6, # ns; can be specified below with engine instead
)
print(model)
print(model.children[:2])
```
%% Cell type:markdown id: tags:
### Step 3: Describe the interactions between the particles
%% Cell type:code id: tags:
``` python
from arbdmodel.interactions import LennardJones
lj = LennardJones()
model.add_nonbonded_interaction(lj)
```
%% Cell type:markdown id: tags:
### Step 4: Run the simulation
%% Cell type:code id: tags:
``` python
from arbdmodel import ArbdEngine
engine = ArbdEngine(output_period = 1e2, num_steps = 1e5)
engine.simulate(model, output_name="1-lj", directory='sims/1-argon',
num_steps=1e3, gpu=1
) # simulation parameters here override those in constructor
```
%% Cell type:markdown id: tags:
### Step 5: Visualize the results
We recommend using VMD for visualizing the simulations trajectories with:
```bash
vmd sims/1-argon/1-lj.psf sims/1-argon/output/1-lj.dcd
```
However, for convenience we have provided commands to use the nglview module, which provides browser-based visualization.
note: you must enable certain jupyter extensions to use nglview as follows
```bash
jupyter-nbextension enable --py --sys-prefix widgetsnbextension
jupyter-nbextension enable nglview --py --sys-prefix
```
%% Cell type:code id: tags:
``` python
import MDAnalysis as mda
import nglview as nv
u = mda.Universe("sims/1-argon/1-lj.pdb", "sims/1-argon/output/1-lj.dcd")
w = nv.show_mdanalysis(u)
w.clear_representations()
w.add_ball_and_stick("all",radius=10)
w
```
%% Cell type:markdown id: tags:
### Step 6: Customize the interactions
%% Cell type:code id: tags:
``` python
from arbdmodel.interactions import NonbondedPotential
## Clear nonbonded interactions
model.nonbonded_interactions = []
class BuckinghamPotential(NonbondedPotential):
def potential(self, r, types):
## https://royalsocietypublishing.org/doi/10.1098/rspa.1938.0173
## optionally could pull information from typeA, typeB
typeA, typeB = types
return 143932.65 * ( 1.69 * np.exp( -r/0.273 ) - 102e-4 / r**6 )
pot = BuckinghamPotential()
model.add_nonbonded_interaction( pot )
engine.simulate(model, output_name="2-buck", directory='sims/1-argon',
num_steps = 1e3, gpu=1
)
```
%% Cell type:code id: tags:
``` python
import MDAnalysis as mda
import nglview as nv
## note: you must enable
u = mda.Universe("sims/1-argon/2-buck.pdb", "sims/1-argon/output/2-buck.dcd")
w = nv.show_mdanalysis(u)
w.clear_representations()
w.add_ball_and_stick("all",radius=10)
w
```
%% Cell type:markdown id: tags:
### Step 6: Add bonds
%% Cell type:code id: tags:
``` python
from arbdmodel.interactions import HarmonicBond
bond = HarmonicBond(k=1, # kcal/mol AA**2
r0 = 3 # AA
)
## Go through every other index
for i in range(0,len(model.children),2):
j = i+1
model.add_bond( model.children[i],
model.children[j],
bond )
print("numbonds:", len(model.bonds))
engine.simulate(model, output_name="3-bonds", directory='sims/1-argon',
num_steps = 1e3, gpu=1
)
```
%% Cell type:code id: tags:
``` python
import MDAnalysis as mda
import nglview as nv
## note: you must enable
u = mda.Universe("sims/1-argon/3-bonds.psf","sims/1-argon/3-bonds.pdb", "sims/1-argon/output/3-bonds.dcd")
w = nv.show_mdanalysis(u)
w.clear_representations()
w.add_ball_and_stick("index < 10",radius=10)
w
```
%% Cell type:markdown id: tags:
### More to come shortly...
First, we'll introduce some classes helpful for working with polymers, and we'll show the polymer models that ship with the class.
We'll show how beads can experience grid-based potentials.
Then we'll show how to construct simple rigid body models.
%% Cell type:code id: tags:
``` python
```
# ARBDmodel
This tutorial introduces a Python3 package called `arbdmodel` that provides a convenient interface for building coarse-grained models of biological and nanotechnological systems that run on the ARBD simulation engine.
The tutorial shows you how to use existing models of ssDNA and disordered peptides, how to include confinement potentials, and how to run simulations that include rigid body systems.
## Getting started
### Required hardware and operating system
Please note that this tutorial is written for the Linux platform and x86 architecture.
Proceed at your own risk using other operating systems and architectures.
Currently, a CUDA-enabled GPU is required for running simulations using the ARBD engine.
### Required software
Make sure you have the `arbdmodel` package properly installed.
You will also need the `jupyter` package installed to your Python environment.
Finally, you will need to install
[VMD](https://www.ks.uiuc.edu/Development/Download/download.cgi?PackageName=VMD),
[NAMD](https://www.ks.uiuc.edu/Development/Download/download.cgi?PackageName=NAMD)
and [ARBD](http://bionano.physics.illinois.edu/arbd).
<!-- ## Instructions -->
<!-- Follow the pdf for steps 1-2, which cover the usage of a command line utility that makes fast multi-resolution simulations of DNA objects very easy to perform. -->
<!-- Then launch the Jupyter notebook "step3.ipynb" for an introduction to scripting with the `mrdna` framework. -->
<!-- If you have any questions or concerns, please contact Chris Maffeo at [cmaffeo2@illinois.edu](mailto:cmaffeo2@illinois.edu). -->
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment