76 Index natoms = std::stoi(tmp);
78 throw std::runtime_error(
79 "number of beads in topology and trajectory differ");
82 for (
Index i = 0; i < natoms; i++) {
85 string resNum, resName, atName, x, y, z;
87 resNum = string(line, 0, 5);
88 resName = string(line, 5, 5);
89 atName = string(line, 10, 5);
91 x = string(line, 20, 8);
92 y = string(line, 28, 8);
93 z = string(line, 36, 8);
94 }
catch (std::out_of_range &) {
95 throw std::runtime_error(
"Misformated gro file");
97 boost::algorithm::trim(atName);
98 boost::algorithm::trim(resName);
99 boost::algorithm::trim(resNum);
100 boost::algorithm::trim(x);
101 boost::algorithm::trim(y);
102 boost::algorithm::trim(z);
106 vx = string(line, 44, 8);
107 vy = string(line, 52, 8);
108 vz = string(line, 60, 8);
109 }
catch (std::out_of_range &) {
115 Index resnr = boost::lexical_cast<Index>(resNum);
117 throw std::runtime_error(
"Misformated gro file, resnr has to be > 0");
126 cout <<
"Warning: residue numbers not continous, create DUMMY "
143 b->
setPos(Eigen::Vector3d(stod(x), stod(y), stod(z)));
145 boost::algorithm::trim(vx);
146 boost::algorithm::trim(vy);
147 boost::algorithm::trim(vz);
148 b->
setVel(Eigen::Vector3d(stod(vx), stod(vy), stod(vz)));
154 throw std::runtime_error(
155 "unexpected end of file in poly file, when boxline");
159 if (fields.size() == 3) {
160 box = Eigen::Matrix3d::Zero();
161 for (
Index i = 0; i < 3; i++) {
162 box(i, i) = fields[i];
164 }
else if (fields.size() == 9) {
165 box(0, 0) = fields[0];
166 box(1, 1) = fields[1];
167 box(2, 2) = fields[2];
168 box(1, 0) = fields[3];
169 box(2, 0) = fields[4];
170 box(0, 1) = fields[5];
171 box(2, 1) = fields[6];
172 box(0, 2) = fields[7];
173 box(1, 2) = fields[8];
175 throw std::runtime_error(
"Error while reading box (last) line");
180 cout <<
"WARNING: topology created from .gro file, masses and charges are "