2 * calculation of diffusion coefficient (version 2)
4 * author: frank.zirkelbach@physik.uni-augsburg.de
13 #include <sys/types.h>
21 int usage(char *prog) {
24 printf(" %s <save file 1> <save file 2>\n\n",prog);
29 int main(int argc,char **argv) {
31 t_moldyn moldyn_0,moldyn_1;
32 int ret,i,a_cnt,b_cnt;
33 double dx,dy,dz,dc[3];
40 memset(&moldyn_0,0,sizeof(t_moldyn));
41 memset(&moldyn_1,0,sizeof(t_moldyn));
50 printf("[diffusion calc] reading save files ...\n");
51 ret=moldyn_read_save_file(&moldyn_0,argv[1]);
53 printf("[diffusion calc] exit!\n");
56 ret=moldyn_read_save_file(&moldyn_1,argv[2]);
58 printf("[diffusion calc] exit!\n");
62 if(moldyn_0.count!=moldyn_1.count) {
63 printf("[diffusion calc] atom count mismatch\n");
67 for(i=0;i<moldyn_0.count;i++) {
68 dx=moldyn_0.atom[i].r.x/moldyn_0.dim.x;
69 dy=moldyn_0.atom[i].r.y/moldyn_0.dim.y;
70 dz=moldyn_0.atom[i].r.z/moldyn_0.dim.z;
71 dx-=(moldyn_1.atom[i].r.x/moldyn_1.dim.x);
72 dy-=(moldyn_1.atom[i].r.y/moldyn_1.dim.y);
73 dz-=(moldyn_1.atom[i].r.z/moldyn_1.dim.z);
89 if(moldyn_0.atom[i].brand) {
91 dc[1]+=dx*dx+dy*dy+dz*dz;
95 dc[0]+=dx*dx+dy*dy+dz*dz;
97 dc[2]+=dx*dx+dy*dy+dz*dz;
100 dc[0]*=(1.0/(6.0*(moldyn_1.time-moldyn_0.time)*a_cnt));
101 dc[1]*=(1.0/(6.0*(moldyn_1.time-moldyn_0.time)*b_cnt));
102 dc[2]*=(1.0/(6.0*(moldyn_1.time-moldyn_0.time)*moldyn_0.count));
104 dc[0]*=(SECOND/(CM*CM));
105 dc[1]*=(SECOND/(CM*CM));
106 dc[2]*=(SECOND/(CM*CM));
108 printf("diffusion coefficients: %.10f %.10f %.10f [cm^2/s]\n",