96 static bool hasVs =
false;
97 static bool hasFs =
false;
100 static Index mpbct = 0;
101 static Index matoms = 0;
104 static Index nerrt = 0;
115 cout <<
"Read from dlpoly file '" <<
fname_ <<
"' : '" << line
116 <<
"' - header" << endl;
122 cout <<
"Read from dlpoly file '" <<
fname_ <<
"' : '" << line
123 <<
"' - directives line" << endl;
129 if (fields.size() < 3) {
130 throw std::runtime_error(
"Error: too few directive switches (<3) in '" +
131 fname_ +
"' header (check its 2-nd line)");
138 hasVs = (mavecs > 0);
140 hasFs = (mavecs > 1);
145 cout <<
"WARNING: N of atom vectors (keytrj) in '" <<
fname_
146 <<
"' header differs from that read with topology" << endl;
154 cout <<
"Read from dlpoly file '" <<
fname_ <<
"' : keytrj - " << mavecs
160 throw std::runtime_error(
"Number of atoms/beads in '" +
fname_ +
161 "' header differs from that read with topology");
166 }
else if (mpbct == 1 || mpbct == 2) {
168 }
else if (mpbct == 3) {
173 cout <<
"Read from dlpoly file '" <<
fname_ <<
"' : pbc_type (imcon) - '"
174 << pbc_type <<
"'" << endl;
177 cout <<
"WARNING: PBC type in dlpoly file '" <<
fname_
178 <<
"' header differs from that read with topology" << endl;
192 cout <<
"Read from dlpoly file '" <<
fname_ <<
"' : '" << line <<
"'"
213 cout <<
"Read from CONFIG: traj_key - " << navecs <<
", hasV - "
220 vector<string> fields = tok.
ToVector();
222 if (fields.size() < 6) {
223 throw std::runtime_error(
224 "Error: too few directive switches (<6) in 'timestep' record");
227 nstep = boost::lexical_cast<Index>(fields[1]);
228 natoms = boost::lexical_cast<Index>(fields[2]);
229 navecs = boost::lexical_cast<Index>(fields[3]);
230 Index npbct = boost::lexical_cast<Index>(fields[4]);
234 stod(fields[fields.size() - 1]);
238 cout <<
"Read from dlpoly file '" <<
fname_ <<
"' : natoms = " << natoms
239 <<
", levcfg = " << fields[3];
240 cout <<
", dt = " << fields[5] <<
", time = " << stime << endl;
244 throw std::runtime_error(
245 "Error: N of atoms/beads in '" +
fname_ +
246 "' header differs from that found in topology");
248 if (natoms != matoms) {
249 throw std::runtime_error(
250 "Error: N of atoms/beads in '" +
fname_ +
251 "' header differs from that found in the frame");
253 if (navecs != mavecs) {
254 throw std::runtime_error(
255 "Error: N of atom vectors (keytrj) in '" +
fname_ +
256 "' header differs from that found in the frame");
258 if (npbct != mpbct) {
259 throw std::runtime_error(
260 "Error: boundary conditions (imcon) in '" +
fname_ +
261 "' header differs from that found in the frame");
266 conf.
setTime(
double(nstep) * dtime);
269 if (std::abs(stime - conf.
getTime()) > 1.e-8) {
272 cout <<
"Check: nstep = " << nstep <<
", dt = " << dtime
273 <<
", time = " << stime <<
" (correct?)" << endl;
274 }
else if (nerrt == 11) {
275 cout <<
"Check: timestep - more than 10 mismatches in total time "
283 }
else if (npbct == 1 || npbct == 2) {
285 }
else if (npbct == 3) {
290 Eigen::Matrix3d box = Eigen::Matrix3d::Zero();
291 for (
Index i = 0; i < 3; i++) {
296 cout <<
"Read from dlpoly file '" <<
fname_ <<
"' : '" << line
297 <<
"' - box vector # " << i + 1 << endl;
301 throw std::runtime_error(
"Error: unexpected EOF in dlpoly file '" +
302 fname_ +
"', when reading box vector" +
303 boost::lexical_cast<string>(i));
307 vector<double> fields = tok.
ToVector<
double>();
309 box.col(i) = scale * Eigen::Vector3d(fields[0], fields[1], fields[2]);
312 conf.
setBox(box, pbc_type);
314 for (
Index i = 0; i < natoms; i++) {
320 cout <<
"Read from dlpoly file '" <<
fname_ <<
"' : '" << line <<
"'"
325 throw std::runtime_error(
"Error: unexpected EOF in dlpoly file '" +
326 fname_ +
"', when reading atom/bead # " +
327 boost::lexical_cast<string>(i + 1));
331 vector<string> fields = tok.
ToVector();
332 Index id = boost::lexical_cast<Index>(fields[1]);
334 throw std::runtime_error(
335 "Error: unexpected atom/bead index in dlpoly file '" +
fname_ +
336 "' : expected " + boost::lexical_cast<string>(i + 1) +
337 " but got " + boost::lexical_cast<string>(
id));
342 Eigen::Matrix3d atom_vecs = Eigen::Matrix3d::Zero();
343 for (
Index j = 0; j < std::min(navecs,
Index(2)) + 1; j++) {
348 cout <<
"Read from dlpoly file '" <<
fname_ <<
"' : '" << line <<
"'"
353 throw std::runtime_error(
354 "Error: unexpected EOF in dlpoly file '" +
fname_ +
355 "', when reading atom/bead vector # " +
356 boost::lexical_cast<string>(j) +
" of atom " +
357 boost::lexical_cast<string>(i + 1));
361 vector<double> fields = tok.
ToVector<
double>();
364 scale * Eigen::Vector3d(fields[0], fields[1], fields[2]);
367 b->
setPos(atom_vecs.col(0));
369 cout <<
"Crds from dlpoly file '" <<
fname_ <<
"' : " << atom_vecs.col(0)
373 b->
setVel(atom_vecs.col(1));
375 cout <<
"Vels from dlpoly file '" <<
fname_
376 <<
"' : " << atom_vecs.col(1) << endl;
379 b->
setF(atom_vecs.col(2));
381 cout <<
"Frcs from dlpoly file '" <<
fname_
382 <<
"' : " << atom_vecs.col(2) << endl;