Merge branch 'leadoff'
[physik/posic.git] / diffusion_calc.c
1 /*
2  * calculation of diffusion coefficient
3  *
4  * author: frank.zirkelbach@physik.uni-augsburg.de
5  *
6  */
7
8 #define _GNU_SOURCE
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include <unistd.h>
12 #include <string.h>
13 #include <sys/types.h>
14 #include <sys/stat.h>
15 #include <fcntl.h>
16
17 #include "moldyn.h"
18
19 int usage(char *prog) {
20
21         printf("\nusage:\n");
22         printf("  %s <save file>\n\n",prog);
23
24         return -1;
25 }
26
27 int main(int argc,char **argv) {
28
29         t_moldyn moldyn;
30         int ret;
31         double dc[3];
32
33         if(argc!=2) {
34                 usage(argv[0]);
35                 return -1;
36         }
37
38         memset(&moldyn,0,sizeof(t_moldyn));
39
40         printf("[diffusion calc] reading save file ...\n");
41         ret=moldyn_read_save_file(&moldyn,argv[1]);
42         if(ret) {
43                 printf("[diffusion calc] exit!\n");
44                 return ret;
45         }
46
47         calculate_diffusion_coefficient(&moldyn,dc);
48         
49         dc[0]*=(100*100*SECOND/(METER*METER));
50         dc[1]*=(100*100*SECOND/(METER*METER));
51         dc[2]*=(100*100*SECOND/(METER*METER));
52
53         printf("diffusion coefficients: %.10f %.10f %.10f [cm^2/s]\n",
54                dc[0],dc[1],dc[2]);
55
56         return 0;
57 }
58