1 /**********************************************************************
2   iterout_md.c:
3 
4      iterout_md.c is a subroutine to output calculated quantities
5      at each MD step to filename.ene.
6 
7   Log of iterout_md.c:
8 
9      20/Sep./2007  Released by T.Ozaki
10 
11 ***********************************************************************/
12 
13 #include <stdio.h>
14 #include "openmx_common.h"
15 
iterout_md(int iter,double drctime,char fileSE[YOUSO10])16 void iterout_md(int iter, double drctime, char fileSE[YOUSO10])
17 {
18   int i,j,k;
19   double dt,itermax,aa,dx,dy,dz,xido,yido,zido;
20   FILE *fp;
21   char buf[fp_bsize];          /* setvbuf */
22   char fileEvsLC[YOUSO10];
23 
24   if ((fp = fopen(fileSE,"a")) != NULL){
25 
26 #ifdef xt3
27     setvbuf(fp,buf,_IOFBF,fp_bsize);  /* setvbuf */
28 #endif
29 
30     /*  1 */      fprintf(fp,"%5d ",iter);
31     /*  2 */      fprintf(fp,"%10.7f ",drctime);
32     /*  3 */      fprintf(fp,"%10.7f ",Uele_OS0);
33     /*  4 */      fprintf(fp,"%10.7f ",Uele_IS0);
34     /*  5 */      fprintf(fp,"%10.7f ",Uele_OS1);
35     /*  6 */      fprintf(fp,"%10.7f ",Uele);
36     /*  7 */      fprintf(fp,"%10.7f ",Uxc0);
37     /*  8 */      fprintf(fp,"%10.7f ",Uxc1);
38     /*  9 */      fprintf(fp,"%10.7f ",UH0);
39     /* 10 */      fprintf(fp,"%10.7f ",UH1);
40     /* 11 */      fprintf(fp,"%10.7f ",Ucore);
41     /* 12 */      fprintf(fp,"%10.7f ",Udc);
42     /* 13 */      fprintf(fp,"%10.7f ",Ucoh);
43     /* 14 */      fprintf(fp,"%10.7f ",Ukc);
44     /* 15 */      fprintf(fp,"%10.7f ",Utot);
45     /* 16 */      fprintf(fp,"%10.7f ",Utot+Ukc);
46     /* 17 */      fprintf(fp,"%10.7f ",ChemP);
47     /* 18 */      fprintf(fp,"%10.7f ",GivenTemp);
48     /* 19 */      fprintf(fp,"%10.7f ",Temp);
49     /* 20 */      fprintf(fp,"%10.7f ",NH_czeta);
50     /* 21 */      fprintf(fp,"%10.7f ",NH_nzeta);
51     /* 22 */      fprintf(fp,"%10.7f ",NH_Ham);
52     /* 23 */      fprintf(fp,"%10.7f ",tv[1][1]*BohrR);
53     /* 24 */      fprintf(fp,"%10.7f ",tv[1][2]*BohrR);
54     /* 25 */      fprintf(fp,"%10.7f ",tv[1][3]*BohrR);
55     /* 26 */      fprintf(fp,"%10.7f ",tv[3][3]*BohrR);
56     /* 27 */      fprintf(fp,"%10.7f ",Weight/Cell_Volume*10.0/6.022);
57     /* 28 */      fprintf(fp,"%10.7f ",GP*1.60219*100);
58     /* 29 */      fprintf(fp,"%10.7f ",GT);
59     /* 30 */      fprintf(fp,"%17.15f ",Max_Force);
60     /* 31 */      fprintf(fp,"%10.7f ",Total_SpinS*2.0);
61     /* 32 */      fprintf(fp,"%10.7f ",ChemP);
62     /* 33 */      fprintf(fp,"%10.7f ", Gxyz[1][17]);
63     /* 34 */      fprintf(fp,"%10.7f\n",Gxyz[1][17]);
64     fclose(fp);
65   }
66   else
67     printf("error in saving *.ene\n");
68 
69   /* E vs. LC */
70 
71   if (MD_switch==12){
72 
73     sprintf(fileEvsLC,"%s%s.EvsLC",filepath,filename);
74 
75     if ((fp = fopen(fileEvsLC,"a")) != NULL){
76 
77       fprintf(fp,"%15.10f ",tv[1][1]*BohrR);
78       fprintf(fp,"%15.10f ",tv[1][2]*BohrR);
79       fprintf(fp,"%15.10f ",tv[1][3]*BohrR);
80       fprintf(fp,"%15.10f ",tv[2][1]*BohrR);
81       fprintf(fp,"%15.10f ",tv[2][2]*BohrR);
82       fprintf(fp,"%15.10f ",tv[2][3]*BohrR);
83       fprintf(fp,"%15.10f ",tv[3][1]*BohrR);
84       fprintf(fp,"%15.10f ",tv[3][2]*BohrR);
85       fprintf(fp,"%15.10f ",tv[3][3]*BohrR);
86       fprintf(fp,"%15.10f\n",Utot);
87 
88       fclose(fp);
89     }
90     else
91       printf("error in saving *.EvsLC\n");
92 
93   }
94 
95   /* for calculation of the delta factor */
96 
97   if (MD_switch==16){
98 
99     sprintf(fileEvsLC,"%s%s.DF",filepath,filename);
100 
101     if ((fp = fopen(fileEvsLC,"a")) != NULL){
102 
103       fprintf(fp,"%18.12f ",Cell_Volume*BohrR*BohrR*BohrR/(double)atomnum);
104       fprintf(fp,"%18.12f\n",Utot*eV2Hartree/(double)atomnum);
105 
106       fclose(fp);
107     }
108     else
109       printf("error in saving *.EvsLC\n");
110 
111   }
112 
113 }
114 
115 
116