It's been a while. I haven't been writing like I am supposed to. So I figure I might write something of substance today.
Molecular dynamics is a finicky business. The problem of MD is, at its core, a many body problem. You sum up pairwise electrostatic interactions, toss it into Newton's equations, then watch a bunch of pixels lurch forward in time. This process is repeated ad nauseum.
Pairwise sums of anything scale as O(n^2). Ain't nobody got time for that. So some very smart people get together and figure out all sorts of approximations and tricks to reduce that 2 into something much more manageable. The particular approximation I use is called the General AMBER Force Field (GAFF).
The use of any approximation introduces error. In this case, we can get around them by modifying the two constants associated with the Lennard-Jones potential for each particular atom type. One simply plays around with them, and checks to see if density and some other measurements of your substance match with accepted values.
Now there are no hard and fast rules for doing this sort of thing. It's possible that more than one combination of constants will lead to the correct density. Also, there's often no good indication of how to even go about adjusting these parameters in the first place.
I hate work. My motto is "Automate what can be automated. Make automatable what cannot." So I wasn't about to go and try to figure this out on my own. Instead, I programmed a minimizer to do that biz for me.
I popped open "Numerical Recipes" and implemented the Nelder-Mead simplex algorithm. A simplex is a general name for an n-dimensional polyhedron. The vertices of this shape corresponds to a particular set of parameters. The simplex then navigates through the solution space much the same way an amoeba might crawl through some primordial goop. Eventually, it will happen upon a minimum and the corners of the simplex will cage around the solution.
The gif shown here is the algorithm at work. The contour plot is of Rosenbrock's Banana. With the coefficients that I used, the global minimum exists at (1,1). The red triangle is the simplex reaching and feeling out for the minimum of this function.