1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
|
/**********************************************************************
iterout.c:
iterout.c is a subroutine to output calculated quantities
at each MD step to filename.ene.
Log of iterout.c:
22/Nov/2001 Released by T.Ozaki
14/May/2004 Modified by M.Ohfuti
***********************************************************************/
#include <stdio.h>
#include "openmx_common.h"
void iterout(int iter,double drctime,char fileSE[YOUSO10],char fileSDRC[YOUSO10])
{
int i,j,k;
double dt,itermax,aa,dx,dy,dz,xido,yido,zido;
char fileXYZ[YOUSO10];
FILE *fp;
char buf[fp_bsize]; /* setvbuf */
if ((fp = fopen(fileSE,"a")) != NULL){
#ifdef xt3
setvbuf(fp,buf,_IOFBF,fp_bsize); /* setvbuf */
#endif
/* 1 */ fprintf(fp,"%5d ",iter);
/* 2 */ fprintf(fp,"%10.7f ",drctime);
/* 3 */ fprintf(fp,"%10.7f ",Uele_OS0);
/* 4 */ fprintf(fp,"%10.7f ",Uele_IS0);
/* 5 */ fprintf(fp,"%10.7f ",Uele_OS1);
/* 6 */ fprintf(fp,"%10.7f ",Uele);
/* 7 */ fprintf(fp,"%10.7f ",Uxc0);
/* 8 */ fprintf(fp,"%10.7f ",Uxc1);
/* 9 */ fprintf(fp,"%10.7f ",UH0);
/* 10 */ fprintf(fp,"%10.7f ",UH1);
/* 11 */ fprintf(fp,"%10.7f ",Ucore);
/* 12 */ fprintf(fp,"%10.7f ",Udc);
/* 13 */ fprintf(fp,"%10.7f ",Ucoh);
/* 14 */ fprintf(fp,"%10.7f ",Ukc);
/* 15 */ fprintf(fp,"%10.7f ",Utot);
/* 16 */ fprintf(fp,"%10.7f ",Utot+Ukc);
/* 17 */ fprintf(fp,"%10.7f ",ChemP);
/* 18 */ fprintf(fp,"%10.7f ",GivenTemp);
/* 19 */ fprintf(fp,"%10.7f ",Temp);
/* 20 */ fprintf(fp,"%10.7f ",NH_czeta);
/* 21 */ fprintf(fp,"%10.7f ",NH_nzeta);
/* 22 */ fprintf(fp,"%10.7f ",NH_Ham);
/* 23 */ fprintf(fp,"%10.7f ",tv[3][2]);
/* 24 */ fprintf(fp,"%10.7f ",tv[1][3]);
/* 25 */ fprintf(fp,"%10.7f ",tv[2][3]);
/* 26 */ fprintf(fp,"%10.7f ",tv[3][3]);
/* 27 */ fprintf(fp,"%10.7f ",Weight/Cell_Volume*10.0/6.022);
/* 28 */ fprintf(fp,"%10.7f ",GP*1.60219*100);
/* 29 */ fprintf(fp,"%10.7f ",GT);
/* 30 */ fprintf(fp,"%17.15f ",Max_Force);
/* 31 */ fprintf(fp,"%10.7f ",Total_SpinS*2.0);
/* 32 */ fprintf(fp,"%10.7f ",ChemP);
/* 33 */ fprintf(fp,"%10.7f ",(Gxyz[1][1]-Gxyz[1][1]));
/* 34 */ fprintf(fp,"%10.7f\n",Gxyz[1][17]);
fclose(fp);
}
else
printf("error in saving *.ene\n");
/****************************************************
cartesian coordinates for MD or geometry opt.
****************************************************/
if ( ((iter-1) % 1)==0 ){
if ((fp = fopen(fileSDRC,"a")) != NULL){
#ifdef xt3
setvbuf(fp,buf,_IOFBF,fp_bsize); /* setvbuf */
#endif
fprintf(fp,"%i \n",atomnum);
if(MD_switch==1 || MD_switch==2 || MD_switch==9) {
fprintf(fp,"time= %8.3f (fs) Energy= %8.5f (Hatree) Temperature= %8.3f\n",drctime,Utot,Temp);
}
else {
fprintf(fp," time= %8.3f (fs) Energy= %8.5f (Hatree)\n",drctime,Utot);
}
for (k=1; k<=atomnum; k++){
i = WhatSpecies[k];
j = Spe_WhatAtom[i];
if ( MD_switch==1 ||
MD_switch==2 ||
MD_switch==9
) {
fprintf(fp,"%4s %8.5f %8.5f %8.5f %14.6f %14.6f %14.6f\n",
Atom_Symbol[j],
Gxyz[k][1]*BohrR,Gxyz[k][2]*BohrR,Gxyz[k][3]*BohrR,
Gxyz[k][24]*2.36852*1000000,
Gxyz[k][25]*2.36852*1000000,
Gxyz[k][26]*2.36852*1000000);
}
else {
fprintf(fp,"%4s %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f\n",
Atom_Symbol[j],
Gxyz[k][1]*BohrR,Gxyz[k][2]*BohrR,Gxyz[k][3]*BohrR,
Gxyz[k][17],Gxyz[k][18],Gxyz[k][19]);
}
}
fclose(fp);
}
else{
printf("failure of saving md file\n");
fclose(fp);
}
}
/****************************************************
cartesian coordinates of the final structure
****************************************************/
sprintf(fileXYZ,"%s2",fileSDRC);
if ((fp = fopen(fileXYZ,"w")) != NULL){
#ifdef xt3
setvbuf(fp,buf,_IOFBF,fp_bsize); /* setvbuf */
#endif
fprintf(fp,"%i \n",atomnum);
if(MD_switch==2) {
fprintf(fp,"time= %8.3f (fs) Energy= %8.5f (Hatree) Temperature= %8.3f\n",drctime,Utot,Temp);
}
else {
fprintf(fp," time= %8.3f (fs) Energy= %8.5f (Hatree)\n",drctime,Utot);
}
for (k=1; k<=atomnum; k++){
i = WhatSpecies[k];
fprintf(fp,"%6d %4s %12.7f %12.7f %12.7f %8.5f %8.5f\n",
k,
SpeName[i],
Gxyz[k][1]*BohrR,Gxyz[k][2]*BohrR,Gxyz[k][3]*BohrR,
0.5*Spe_Core_Charge[i],0.5*Spe_Core_Charge[i]);
}
fclose(fp);
}
else{
printf("failure of saving md file\n");
fclose(fp);
}
}
|