I don't know much about molecular dynamics, but I am suspicious of my pressure being equal to kinetic energy. I am using

// sum the velocities squared:

double v2sum = 0.0;

for (int i = 0; i < N; i++) {

v2sum += vx[i]*vx[i] + vy[i]*vy[i];

}

KE = 0.5 * v2sum;

KE /= N; // kinetic energy per particle

Tp = KE; // reduced temperature (boltzmann's (kB) = 1)

for temperature and

//instantaneous pressure calcs

double w = 0.0;

w += 0.5 * (dx*fx + dy*fy);

Pr = N*Tp+w;

for pressure.

Similar questions and discussions