Monday, March 3, 2014

Replaying a Lammps Trajectory

EDIT: Turns out I just didn't google the correct words, LAMMPS does have one. It's the command rerun. Oops.

LAMMPS, the molecular dynamics engine, doesn't have a replay function allowing one to go back and calculate properties on a trajectory, especially forces and energies. This came up in my work and I got started on writing some new LAMMPS code to accomplish this. I wanted to be able to calculate forces with a different potential on a trajectory. Anyway, I realized you can accomplish this just by using the LAMMPS looping variables. No new code necessary. It can be done by using the read_dump command to load particular trajectory frame. A sample input script is below


Thursday, February 6, 2014

Predicting the Future of Simulations

In my day job, molecular modeling, I simulate the position and velocity of every atom in biological molecules. As you can imagine, doing this yields nearly complete information about whatever biological system I'm studying and allows me to predict the behavior of proteins. Well, that's the theory. It's more complex than that and often fails spectacularly in practice. Ignore that for now. Let's focus on the systems that can be simulated. In 1982 CHARMM, one the first molecular dynamics tool capable of simulating tiny proteins, was released. It was possible to simulate a small protein for one tenth of one billionth of one second. Now we can simulate a protein for one thousandth of a second. That's an increase of 10^7 in the speed of molecular simulations in about 30 years. In 1990, we were able to simulate lysozyme, a small protein, for few billionths of a seconds. Now we can simulate a virus for a few billionths of a second. That's an increase in about 10^4 mass of molecular simulations in 30 years. Assuming continued exponential growth (see plots below), here are my upcoming interesting milestones in computer simulation



Year Event
2023 The first simulation of every atom in a ribosome for 10 milliseconds
2038 The first simulation of every atom in a virus for 1 second
2131 The first simulation of every atom of a cell for 1 hour
2191 We can simulate every atom of every cell in a heart for 1 heartbeat
2227 Every atom of every cell in a human brain can be simulated as fast they move in a human brain

Thursday, December 12, 2013

Radial Distribution Functions of Water from Experiment

Site-site radial distribution functions, sometimes called g(r) for short, are one of the most important measured quantities in molecular simulations. As usual, wikipedia has a nice overview of them. Probably the most famous non-trivial g(r) is the water oxygen-oxygen radial distribution function. It's often taught in statistical mechanics courses that it's possible to compare a simulation g(r) with X-ray or neutron-diffraction experiments with a simple Fourier transform. In fact, this is almost never the case due to sources of error in experiments. Check out the Introduction to this article by AK Soper for more info on the kinds of error which prevent the simple Fourier transform from converting experimental structure factors to a g(r).

In any case, the point of this post is to put the raw data for an experimental g(r) for water. The AK Soper article uses the empirical potential structure refinement method for converting experimental neutron diffraction data at 298 K 1 bar into the three radial distribution functions for water (O-O, O-H, H-H). This is the best method I know of for obtaining these radial distribution functions and this is the data used to test the TIP4P/2005 water model. I've extracted the data from their paper and made it available here. Make sure to cite their paper if you use the data in a publication. Hopefully these g(r)s will help you in creating your own new special water models! See the figure below the break:

Tuesday, October 1, 2013

Indexing an Emacs Macro

This post is about how to increment and paste a counter while executing an emacs macro. For some reason, this is not easy to find on the Internet. So I'll write it down on my blog since I keep forgetting.


  1. Set the start point of the counter
    M-: (setq i 1)
  2. Start recording macro with
    C-x (
  3. Insert index as needed with
    C-u M-: i
  4. Increment index when finished with macro
    M-: (setq i (+ i 1))
  5. Complete macro with
    C-x )
  6. Execute Macro with
    C-x e
To execute the macro multiple times, use ALT-(# of times) C-x e.

Thursday, May 16, 2013

Extending Radial Distributions

Radial distribution functions are one of the most important quantities to calculate when running a molecular dynamics simulation. They give good insight into the phase and pair potentials between molecules. Practically, they are calculated according to the following equation:

Tuesday, April 30, 2013

Cube-Sphere Intersection Volume

This week's math problem was particularly difficult. I wanted to know the intersection volume between a cube and a sphere. Imagine a sphere contained in a cube. The sphere will first touch the cube when its radius is equal to half the width of the cube. Until that point, its volume is just the formula for the volume of a sphere. Once the sphere's radius is 2 sqrt(3) times the width of the cube, then it completely engulfs the cube and the intersection of the 2 objects is just the volume of a cube. In between, I've found it looks like this: