50 Index readinmultipoles = 0;
51 Index numberofmultipoles = 0;
52 Vector9d multipoles = Vector9d::Zero();
55 if (!intt.is_open()) {
56 throw std::runtime_error(
"File:" + filename +
" could not be opened");
62 std::vector<std::string> split = toker.
ToVector();
64 if (!split.size() || split[0] ==
"!" || split[0].substr(0, 1) ==
"!") {
80 if (split[0] ==
"Units") {
81 std::string units = split[1];
82 if (units !=
"bohr" && units !=
"angstrom") {
83 throw std::runtime_error(
"Unit " + units +
" in file " + filename +
86 if (units ==
"bohr") {
87 unit_conversion = 1.0;
89 }
else if (split.size() == 6) {
91 std::string name = split[0];
94 pos[0] = boost::lexical_cast<double>(split[1]);
95 pos[1] = boost::lexical_cast<double>(split[2]);
96 pos[2] = boost::lexical_cast<double>(split[3]);
97 rank = boost::lexical_cast<Index>(split[5]);
98 numberofmultipoles = (rank + 1) * (rank + 1);
99 multipoles = Vector9d::Zero();
100 pos *= unit_conversion;
101 this->
atomlist_.push_back(T(
id, name, pos));
104 else if (split[0] ==
"P") {
106 if (split.size() == 7) {
107 double pxx = boost::lexical_cast<double>(split[1]);
108 double pxy = boost::lexical_cast<double>(split[2]);
109 double pxz = boost::lexical_cast<double>(split[3]);
110 double pyy = boost::lexical_cast<double>(split[4]);
111 double pyz = boost::lexical_cast<double>(split[5]);
112 double pzz = boost::lexical_cast<double>(split[6]);
113 p1 << pxx, pxy, pxz, pxy, pyy, pyz, pxz, pyz, pzz;
114 }
else if (split.size() == 2) {
115 double pxx = boost::lexical_cast<double>(split[1]);
116 p1 = pxx * Eigen::Matrix3d::Identity();
118 throw std::runtime_error(
"Invalid line in " + filename +
": " + line);
121 p1 = p1 * unit_conversion_3;
122 this->
atomlist_.back().setpolarization(p1);
127 for (
const std::string& entry : split) {
128 double qXYZ = boost::lexical_cast<double>(entry);
129 if (multipoles.size() < readinmultipoles) {
130 throw std::runtime_error(
"ReadMpsFile: File" + filename +
131 "is not properly formatted");
133 multipoles(readinmultipoles) = qXYZ;
136 if (readinmultipoles == numberofmultipoles) {
137 Eigen::Vector3d temp_dipoles = multipoles.segment<3>(1);
140 multipoles(1) = temp_dipoles(1);
141 multipoles(2) = temp_dipoles(2);
142 multipoles(3) = temp_dipoles(0);
143 this->
atomlist_.back().setMultipole(multipoles, rank);
144 readinmultipoles = 0;