78 {
79 if(argc < 2) {
80 printf("Usage: 1.This 2.Directory\n");
81 exit(EXIT_FAILURE);
82 }
88 double ratio, expval, stddev, fE, dos, MCave, dtemp;
89
90 struct stat statBuf;
92 double HI;
93 double KLdivergence;
94 double JSdivergence;
97 };
99
100 struct EnsembleAverage {
102 double ExpValue[
Nbin];
106 };
109 Average[i].N[j] = 0;
110 Average[i].ExpValue[j] = 0;
111 Average[i].Stddev[j] = 0;
112 Average[i].funcF[j] = 0;
113 Average[i].DOS[j] = 0;
114 }
115
117 char dstr[BUFSIZE], str[BUFSIZE], stemp[BUFSIZE];
118 char *filename = str;
119 char *ext;
120 strcpy(dstr, argv[1]);
121 DIR *dir;
122 FILE *Input, *Output;
123 struct dirent *dp;
124
125
126 strcpy(stemp, dstr);
127 strcat(stemp, "/Output");
128 strcpy(str, stemp);
129 strcat(str, "/");
130 strcat(str, "EnsembleAverage.txt");
131 printf("Input file: %s\n", filename);
132 Input = fopen(filename, "r");
133 if(Input == NULL) {
134 printf("Can't open a file %s\n", filename);
135 exit(EXIT_FAILURE);
136 }
137 skip_header(Input);
138 while( fscanf(Input, "%lld %lf %le %le %le %le %lld", &n, &ratio, &expval, &stddev, &fE, &dos, &itemp) != EOF ) {
140 Average[n].N[bin] = itemp;
141 Average[n].ExpValue[bin] = expval;
142 Average[n].Stddev[bin] = stddev;
143 Average[n].funcF[bin] = fE;
144 Average[n].DOS[bin] = dos;
145 }
146 fclose(Input);
147
148
149
150 strcpy(stemp, dstr);
151 strcat(stemp, "/Output");
152 mkdir(stemp, 0777);
153 strcpy(str, stemp);
154 strcat(str, "/");
155 strcat(str, "ErgodicityFluctuation_Compare.txt");
156 strcpy(stemp, str);
157 printf("Output file: %s\n", filename);
158 Output = fopen(filename, "w");
159 if(Output == NULL) {
160 printf("Can't open a file %s\n", filename);
161 exit(EXIT_FAILURE);
162 }
163 fprintf(Output, "# 1.Nsample 2.N 3.funcF L1norm 4.funcF L2norm\n\n");
164
165
166 dir = opendir(dstr);
167 for(dp = readdir(dir);dp != NULL;dp = readdir(dir)) {
168 if( strstr(dp->d_name, "Operators_") == NULL ) continue;
169 ext = strrchr(dp->d_name, '.');
170 if( strcmp(ext, ".txt") != 0 ) continue;
171
172 strcpy(str, dstr);
173 strcat(str, "/");
174 strcat(str, dp->d_name);
175 if( stat(filename, &statBuf) == -1 ){
176 printf("Can't get file information: %s.", filename);
177 continue;
178 }
179 printf("Input file: %s, size: %lld\n", filename, statBuf.st_size);
180 if( statBuf.st_size==0 ) continue;
181 Input = fopen(filename, "r");
182 if(Input == NULL) {
183 printf("Can't open a file %s\n", filename);
184 continue;
185 }
186
188 Ntotal[n] = 0;
189 NnanfE[n] = 0;
190 }
192 distance[n][j].HI = 0;
193 distance[n][j].KLdivergence = 0;
194 distance[n][j].JSdivergence = 0;
195 distance[n][j].L1norm = 0;
196 distance[n][j].L2norm = 0;
197 }
198
199
200 Nsample += 1;
201 skip_header(Input);
202
203 while( fscanf(Input, "%lld %lld %le %le %le %le %le %le %lld", &itemp, &n, &dtemp, &ratio, &expval, &MCave, &fE, &dtemp, &dimShell) != EOF ) {
204 if( isnan(fE) ) {
205 NnanfE[n] += 1;
206 continue;
207 }
208 Ntotal[n] += 1;
210
211 distance[n][2].L1norm += fabs(fE -Average[n].funcF[bin]);
212 distance[n][2].L2norm += (fE -Average[n].funcF[bin])*(fE -Average[n].funcF[bin]);
213 }
214
215 fclose(Input);
216
217
219 if( Ntotal[n] == 0) continue;
220 fprintf(Output, "%lld %lld ", Nsample, n);
221 fprintf(Output, "%le ", distance[n][2].L1norm/(double)( Ntotal[n] ) );
222 fprintf(Output, "%le ", sqrt( distance[n][2].L2norm/(double)( Ntotal[n] ) ) );
223 fprintf(Output, "\n");
224 printf("Ntotal[%lld]=%lld\n", n, Ntotal[n]);
225 }
226
227
228 }
229
230 printf("Output file: %s\n", stemp);
231 fclose(Output);
232
233 return 0;
234}
Integer_t const Nitem
Definition OpErgodicity_Compare.cpp:15
Integer_t const SistemSizeMAX
Definition OpErgodicity_Compare.cpp:14
Definition OpHistogram.cpp:24
double L1norm
Definition OpHistogram.cpp:29
double L2norm
Definition OpHistogram.cpp:30