@@ -154,167 +154,4 @@ void bounds()
154
154
TINKER_FCALL2 (acc1, cu1, bounds);
155
155
copyPosToXyz ();
156
156
}
157
-
158
- inline namespace v1 {
159
- enum
160
- {
161
- DCD_HEADER = 0 ,
162
- DCD_TDELTA = 10 ,
163
- DCD_USEBOX = 11 ,
164
- DCD_CTRL_LEN = 21 ,
165
-
166
- DCD_TITLE_NCHARS = 80 ,
167
-
168
- DCD_AX = 0 ,
169
- DCD_COS_G = 1 ,
170
- DCD_BX = 2 ,
171
- DCD_COS_B = 3 ,
172
- DCD_COS_A = 4 ,
173
- DCD_CX = 5 ,
174
- DCD_XTAL_LEN = 6 ,
175
- };
176
-
177
- enum class Archive
178
- {
179
- NONE = 0 ,
180
- XYZ = 1 ,
181
- DCD = 2 ,
182
- };
183
- }
184
-
185
- static int dcdControl[DCD_CTRL_LEN] = {0 };
186
- static std::vector<float > dcdx, dcdy, dcdz;
187
- static Archive archive = Archive::NONE;
188
-
189
- static void dcdReadIntoBuffer (void * buffer, int nbyte, std::ifstream& ipt)
190
- {
191
- int size1, size2;
192
- ipt.read ((char *)&size1, sizeof (int ));
193
- if (nbyte > 0 ) assert (nbyte == size1);
194
- ipt.read ((char *)buffer, size1);
195
- ipt.read ((char *)&size2, sizeof (int ));
196
- }
197
-
198
- void readFrameOpen (const std::string& filename, std::ifstream& ipt)
199
- {
200
- // get file format type by inspection of first character
201
- char a1;
202
- ipt.open (filename);
203
- ipt >> a1;
204
- auto arc = Archive::NONE;
205
- if (a1 == ' ' )
206
- arc = Archive::XYZ;
207
- else if (' 0' <= a1 and a1 <= ' 9' )
208
- arc = Archive::XYZ;
209
- else
210
- arc = Archive::DCD;
211
-
212
- if (arc == Archive::DCD) {
213
- ipt.close ();
214
- ipt.open (filename, std::ios::in | std::ios::binary);
215
-
216
- // read header info along with title and number of atoms
217
- dcdReadIntoBuffer (dcdControl, sizeof (int ) * DCD_CTRL_LEN, ipt);
218
-
219
- int dcdTitleRecordLen;
220
- ipt.read ((char *)&dcdTitleRecordLen, sizeof (int ));
221
- std::vector<char > titlebuf;
222
- titlebuf.resize (dcdTitleRecordLen + sizeof (int ));
223
- ipt.read (titlebuf.data (), dcdTitleRecordLen + sizeof (int ));
224
-
225
- int dcdNAtom;
226
- dcdReadIntoBuffer (&dcdNAtom, sizeof (int ), ipt);
227
- assert (n == dcdNAtom);
228
- dcdx.resize (n);
229
- dcdy.resize (n);
230
- dcdz.resize (n);
231
- }
232
-
233
- archive = arc;
234
- }
235
-
236
- static void readFrameDCD (std::ifstream& ipt)
237
- {
238
- if (dcdControl[DCD_USEBOX]) {
239
- double dcdXtal[DCD_XTAL_LEN];
240
- dcdReadIntoBuffer (dcdXtal, sizeof (double ) * DCD_XTAL_LEN, ipt);
241
- double ax = dcdXtal[DCD_AX], bx = dcdXtal[DCD_BX], cx = dcdXtal[DCD_CX];
242
- double al = 90 ., be = 90 ., ga = 90 .;
243
- if (dcdXtal[DCD_COS_A] != 0.0 ) al = std::acos (dcdXtal[DCD_COS_A]) * radian;
244
- if (dcdXtal[DCD_COS_B] != 0.0 ) be = std::acos (dcdXtal[DCD_COS_B]) * radian;
245
- if (dcdXtal[DCD_COS_G] != 0.0 ) ga = std::acos (dcdXtal[DCD_COS_G]) * radian;
246
- Box p;
247
- boxLattice (p, box_shape, ax, bx, cx, al, be, ga);
248
- boxSetCurrent (p);
249
- }
250
-
251
- dcdReadIntoBuffer (dcdx.data (), sizeof (float ) * n, ipt);
252
- dcdReadIntoBuffer (dcdy.data (), sizeof (float ) * n, ipt);
253
- dcdReadIntoBuffer (dcdz.data (), sizeof (float ) * n, ipt);
254
- for (int i = 0 ; i < n; ++i) {
255
- atoms::x[i] = dcdx[i];
256
- atoms::y[i] = dcdy[i];
257
- atoms::z[i] = dcdz[i];
258
- }
259
- }
260
-
261
- static void readFrameXYZ (std::ifstream& ipt)
262
- {
263
- std::string line;
264
- std::getline (ipt, line); // n and title
265
- std::getline (ipt, line); // either box size or first atom
266
- // 18.643000 18.643000 18.643000 90.000000 90.000000 90.000000
267
- // 1 O 8.733783 7.084710 -0.688468 1 2 3
268
- double l1, l2, l3, a1, a2, a3;
269
- int matched = std::sscanf (line.data (), " %lf%lf%lf%lf%lf%lf" , &l1, &l2, &l3, &a1, &a2, &a3);
270
- int row = 0 ;
271
- int index;
272
- char name[32 ];
273
- double xr, yr, zr;
274
- if (matched == 6 ) {
275
- Box p;
276
- boxLattice (p, box_shape, l1, l2, l3, a1, a2, a3);
277
- boxSetCurrent (p);
278
- } else {
279
- std::sscanf (line.data (), " %d%s%lf%lf%lf" , &index, name, &xr, &yr, &zr);
280
- index -= 1 ;
281
- atoms::x[index] = xr;
282
- atoms::y[index] = yr;
283
- atoms::z[index] = zr;
284
- row = 1 ;
285
- }
286
-
287
- for (int ir = row; ir < n; ++ir) {
288
- std::getline (ipt, line);
289
- std::sscanf (line.data (), " %d%s%lf%lf%lf" , &index, name, &xr, &yr, &zr);
290
- index -= 1 ;
291
- atoms::x[index] = xr;
292
- atoms::y[index] = yr;
293
- atoms::z[index] = zr;
294
- }
295
- }
296
-
297
- void readFrameCopyinToXyz (std::ifstream& ipt, bool & done)
298
- {
299
- if (!ipt) done = true ;
300
- if (done) return ;
301
-
302
- if (archive == Archive::XYZ)
303
- readFrameXYZ (ipt);
304
- else if (archive == Archive::DCD)
305
- readFrameDCD (ipt);
306
-
307
- xyzData (RcOp::INIT);
308
-
309
- if (!ipt.good () or ipt.peek () == EOF) done = true ;
310
- }
311
-
312
- void readFrameClose (std::ifstream& ipt)
313
- {
314
- ipt.close ();
315
- dcdx.clear ();
316
- dcdy.clear ();
317
- dcdz.clear ();
318
- archive = Archive::NONE;
319
- }
320
157
}
0 commit comments