UPDATED
I've coded a multiparticle MD simulation in 3D. It is based on Langevin Dynamics, with random impulse and dissipation. I think the program works correctly now? I have attached the plots of kinetic, potential, and total energy. I believe that in the case of no Langevin Dynamics, total energy should be conserved as dissipation is turned off. But when dissipation is turned on, one shouldn't expect total energy conservation anymore. At this point, I would like to know if my results seem reasonable. I have included some of the more important code snippets (please ask for more if needed)
Physical parameters:
//V0 is the potential depth, r0 is the effective radius for the potential
double const m = 1., V0 = 1., r0 = 1., boxLength = 15., kT = 0.5;
int const n_atoms = 12;
double gamma = 0.5; //damping coeff.
double var = 2.*gamma*m*kT*dt; //variance of the gaussian distributed I
double c = (2.-gamma*dt)/(2.+gamma*dt); //due to damping
double dt = 0.005; //time step
int N = (int)(1000 / dt); //simulation time
Initializing the system
void init(struct Atom system[n_atoms]){
double rc = 0.9;
double xx = 0., yy = boxLength, zz = boxLength;
int atoms_in_row = (int)(boxLength / rc);
int n = 0;
for(int k = 0; k < (int)boxLength; k++) {
for(int i = 0; i <= atoms_in_row; i++) {
for(int j = 0; j <= atoms_in_row; j++) {
if(n >= n_atoms) break;
system[n].x = xx;
system[n].y = yy;
system[n].z = zz;
system[n].vx = system[n].vy = system[n].vz = 0.;
system[n].ax = system[n].ay = system[n].az = 0.;
xx += rc;
n++;
}
yy -= rc;
xx = 0.;
}
yy = 0.;
zz -= rc;
}
}
Here are the energy plots with dissipation/random impulse turned off and on, respectively. The first one shows the plot of energy for two atoms only, in a non LD case. The next two are for 12 atoms. In particular, I think the result for non LD cases is fine as total energy is more or less conserved. And maybe the results are good for LD case as well? I'm not quite sure on this one.