Skip to content
jspngler edited this page Aug 8, 2024 · 5 revisions

Overview

The workflow for this code is:

  1. Compile MD.cpp to MD. This only needs to be done once, unless you modify MD.cpp.
  2. Compile a geometry/state generate code. This usually only needs to be done once.
  3. Run the geometry/state generation code to produce a name.mpd file.
  4. Run "MD name" to step the simulation state.
  5. Analyze the results.

Compiling code

This code requires a compiler that supports c++11. These can be added by the following flags:

  • g++, clang, or icc: -std=c++11 or -std=c++0x

This can be guaranteed on University of Memphis clusters with module load gnu13/13.2.0, but isn't strictly necessary. Additionally, there is an fftw dependency in the structure factor code that can be enabled with module load fftw/3.3.10/gcc-8.5.0

Compile everything

Just run make in the top most directory:

make

Compiling one code

For most codes, make sure you are in one of the directories, like generate for generating system parameters, and make sure you include the proper directories in your c++ file:

#include "../include/MD.h"
#include "../include/system.h"

int main()
{
    //Your code here
    return 0;
}

Then, run g++ (assuming your source file is called generate.cpp in the generate subdirectory):

g++ -O3 generate.cpp -o ~/bin/generate

Installing

Just run make install in the top most directory after running make:

make install

Running simulations

MD

Create an MPD file with a generation code or by a new code. For example create a liposome and parameters, named testLipo, from the generate/liposome.cpp file:

liposome testLipo $RANDOM 80000 3.45

This will generate two files: testLipo.mpd (all the system's parameters, positions, velocities, etc...) and testLipo.xyz (the system's positions in a VMD readable file for viewing the configuration). Run MD:

MD testLipo

The simulation will run until initialTime in the MPD file is equal to finalTime. You will see output in two columns. The first column is the time (in simulation units, tau), and the second column is the time since the last measurement (in seconds). You can determine the running time per tau by dividing the measureInterval from the MPD file by the time since the last measurement column.

Check the results files. Should be files like frames_testLipo.xzy, potential_testLipo.dat, kinetic_testLipo.dat, etc...

On a cluster

Utilizing a cluster, like the University of Memphis BigBlue cluster, just requires a script to automate the above steps. Usually you would have a bash script with a time limit, shared memory CPU-cores, and memory per core, like the following SLURM script:

#!/bin/bash
#SBATCH --cpus-per-task=8
#SBATCH --time=7-00:00:00
#SBATCH --mem-per-cpu=100M
# The above options will allocate a job with 
# 8 CPU-cores and 800 megabytes of memory for 7 days.

# The 'liposome.cpp' code should be compiled before submitting this script!
liposome testLipo $RANDOM 80000 3.45

# The 'MD.cpp' code should be compiled before submitting this script!
MD testLipo

Modifying simulation parameters

MPD formatted file

There are a number of fields in the MPD file that can be modified. The most common are the initialTime and finalTime for continuing simulations, storeInterval for frames file frequency, and measureInterval for measure frequency. finalTime and initialTime

If you are starting a new simulation, initialTime should be 0 and finalTime should be however long you want to run a simulation. For lipid systems, with 19 ns per tau, you will probably want to set this to around 100000 tau. This will result in at least a 100 frames of useful data if the correlation time is on the order of 1000 tau. The correlation time depends on the system parameters, but using data below the correlation time may introduce artifacts in your data.

If you are restarting a simulation, you should leave initialTime alone and set finalTime to however high you would like. For example, if the above resulted in:

initialTime 100000 finalTime 100000

Then, if you want to add another 100000 tau, you would have:

initialTime 100000 finalTime 200000

storeInterval

storeInterval should be set for the accuracy you prefer in your data. This can result in a very large frames file if it is set too low. Your accuracy should be proportional to the correlation time of the underlying system. For example, the lipid systems, with 3 particles per lipid, have a correlation time on the order of 1000 tau, so storeInterval 1000 will likely be appropriate. In some systems, like with nanoparticles, the nanoparticle itself may take a long time to stabilize, with a correlation time of around 50000 tau, but you may be interested in the lipid bilayer itself, so you might set storeInterval 1000 which would preserve the dynamics of the nanoparticle.

measureInterval

measureInterval adjusts how often potential and kinetic energy are calculated. Overall, this can be set low, like measureInterval 100, but if it is set too low, it might cause the MD program to take much longer to run the same number of steps. Modifying the simulation