/* Mean-squared displacement calculation, straightforward algorithm. Reads in an arbitrary number of configuration snapshots in XYZ format, and computes msd(t). Cameron F. Abrams Written for the course CHE 800-002, Molecular Simulation Spring 0304 compile using "gcc -o rdf rdf.c -lm" Drexel University, Department of Chemical Engineering Philadelphia (c) 2004 */ #include #include #include /* Prints usage information */ void usage ( void ) { fprintf(stdout,"msd usage:\n"); fprintf(stdout,"msd [options]\n\n"); fprintf(stdout,"Options:\n"); fprintf(stdout,"\t -fnf [string]\t\tFile name format (%i.xyz)\n"); fprintf(stdout,"\t -for start,stop,step\t\tloop control\n"); fprintf(stdout,"\t -mddt [real(0.001)]\t\tMD time step\n"); fprintf(stdout,"\t -h \t\tPrint this info.\n"); } /* Reads in a configuration snapshot in XYZ format (such as that created by mdlj.c) */ int xyz_in (FILE * fp, double * rx, double * ry, double * rz, double * vx, double * vy, double * vz, int * N) { int i; int has_vel, dum; fscanf(fp,"%i %i\n\n",N,&has_vel); for (i=0;i<(*N);i++) { fscanf(fp,"%i %lf %lf %lf ",&dum,&rx[i],&ry[i],&rz[i]); if (has_vel) fscanf(fp, "%lf %lf %lf\n",&vx[i],&vy[i],&vz[i]); } return has_vel; } void com ( double * rx, double * ry, double * rz, int N, double * cx, double * cy, double * cz) { int i; *cx=0.0;*cy=0.0;*cz=0.0; for (i=0;i