| 1 |
/****************************************************************************** |
| 2 |
This source file is part of the Avogadro project. |
| 3 |
This source code is released under the 3-Clause BSD License, (see "LICENSE"). |
| 4 |
******************************************************************************/ |
| 5 |
|
| 6 |
#include "mopacaux.h" |
| 7 |
|
| 8 |
#include <avogadro/core/elements.h> |
| 9 |
#include <avogadro/core/molecule.h> |
| 10 |
#include <avogadro/core/utilities.h> |
| 11 |
|
| 12 |
#include <iostream> |
| 13 |
|
| 14 |
using std::cout; |
| 15 |
using std::endl; |
| 16 |
using std::string; |
| 17 |
using std::vector; |
| 18 |
|
| 19 |
namespace Avogadro::QuantumIO { |
| 20 |
|
| 21 |
using Core::Atom; |
| 22 |
using Core::SlaterSet; |
| 23 |
|
| 24 |
MopacAux::MopacAux() : m_electrons(0) {} |
| 25 |
|
| 26 |
MopacAux::~MopacAux() {} |
| 27 |
|
| 28 |
std::vector<std::string> MopacAux::fileExtensions() const |
| 29 |
{ |
| 30 |
std::vector<std::string> extensions; |
| 31 |
extensions.emplace_back("aux"); |
| 32 |
return extensions; |
| 33 |
} |
| 34 |
|
| 35 |
std::vector<std::string> MopacAux::mimeTypes() const |
| 36 |
{ |
| 37 |
return std::vector<std::string>(); |
| 38 |
} |
| 39 |
|
| 40 |
bool MopacAux::read(std::istream& in, Core::Molecule& molecule) |
| 41 |
{ |
| 42 |
// Read the log file line by line, most sections are terminated by an empty |
| 43 |
// line, so they should be retained. |
| 44 |
while (!in.eof()) |
| 45 |
processLine(in); |
| 46 |
|
| 47 |
auto* basis = new SlaterSet; |
| 48 |
|
| 49 |
for (unsigned int i = 0; i < m_atomPos.size(); ++i) { |
| 50 |
Atom a = molecule.addAtom(static_cast<unsigned char>(m_atomNums[i])); |
| 51 |
a.setPosition3d(m_atomPos[i]); |
| 52 |
} |
| 53 |
// Do simple bond perception. |
| 54 |
molecule.perceiveBondsSimple(); |
| 55 |
molecule.perceiveBondOrders(); |
| 56 |
molecule.setBasisSet(basis); |
| 57 |
basis->setMolecule(&molecule); |
| 58 |
load(basis); |
| 59 |
|
| 60 |
// check if there is vibrational data |
| 61 |
if (m_frequencies.size() > 0) { |
| 62 |
// convert the std::vector to Array |
| 63 |
Core::Array<double> frequencies(m_frequencies.size()); |
| 64 |
for (unsigned int i = 0; i < m_frequencies.size(); ++i) |
| 65 |
frequencies[i] = m_frequencies[i]; |
| 66 |
molecule.setVibrationFrequencies(frequencies); |
| 67 |
|
| 68 |
// convert the std::vector to Array |
| 69 |
Core::Array<double> intensities(m_frequencies.size(), 0.0); |
| 70 |
if (m_irIntensities.size() == m_frequencies.size()) { |
| 71 |
for (unsigned int i = 0; i < m_irIntensities.size(); ++i) |
| 72 |
intensities[i] = m_irIntensities[i]; |
| 73 |
} |
| 74 |
molecule.setVibrationIRIntensities(intensities); |
| 75 |
|
| 76 |
// wrap the normal modes into a vector of vectors |
| 77 |
Core::Array<Core::Array<Vector3>> normalModes; |
| 78 |
Core::Array<Vector3> normalMode; |
| 79 |
Index atomCount = molecule.atomCount(); |
| 80 |
for (unsigned int i = 0; i < m_normalModes.size(); ++i) { |
| 81 |
normalMode.push_back(m_normalModes[i]); |
| 82 |
if (i % atomCount == 0 && normalMode.size() > 0) { |
| 83 |
normalModes.push_back(normalMode); |
| 84 |
normalMode.clear(); |
| 85 |
} |
| 86 |
} |
| 87 |
molecule.setVibrationLx(normalModes); |
| 88 |
} |
| 89 |
|
| 90 |
// add charges and properties |
| 91 |
molecule.setData("totalCharge", m_charge); |
| 92 |
molecule.setData("totalSpinMultiplicity", m_spin); |
| 93 |
molecule.setData("dipoleMoment", m_dipoleMoment); |
| 94 |
molecule.setData("DeltaH", m_heatOfFormation); |
| 95 |
molecule.setData("Area", m_area); |
| 96 |
molecule.setData("Volume", m_volume); |
| 97 |
if (m_energies.size() > 0) |
| 98 |
molecule.setData("energies", m_energies); |
| 99 |
if (m_forces.size() > 0) |
| 100 |
molecule.setData("forces", m_forces); |
| 101 |
|
| 102 |
if (m_partialCharges.size() > 0) { |
| 103 |
MatrixX charges(m_partialCharges.size(), 1); |
| 104 |
for (size_t i = 0; i < m_partialCharges.size(); ++i) |
| 105 |
charges(i, 0) = m_partialCharges[i]; |
| 106 |
molecule.setPartialCharges("MOPAC", charges); |
| 107 |
} |
| 108 |
|
| 109 |
// if we have more than one coordinate set |
| 110 |
if (m_coordSets.size() > 1) { |
| 111 |
for (unsigned int i = 0; i < m_coordSets.size(); ++i) { |
| 112 |
Core::Array<Vector3> positions; |
| 113 |
positions.reserve(molecule.atomCount()); |
| 114 |
for (size_t j = 0; j < molecule.atomCount(); ++j) { |
| 115 |
positions.push_back(m_coordSets[i][j]); |
| 116 |
} |
| 117 |
molecule.setCoordinate3d(positions, i); |
| 118 |
} |
| 119 |
} |
| 120 |
|
| 121 |
return true; |
| 122 |
} |
| 123 |
|
| 124 |
void MopacAux::processLine(std::istream& in) |
| 125 |
{ |
| 126 |
// First truncate the line, remove trailing white space and check |
| 127 |
string line; |
| 128 |
if (!getline(in, line) || Core::trimmed(line).empty()) |
| 129 |
return; |
| 130 |
|
| 131 |
string key = Core::trimmed(line); |
| 132 |
|
| 133 |
// Big switch statement checking for various things we are interested in |
| 134 |
if (Core::contains(key, "ATOM_EL")) { |
| 135 |
int tmp = |
| 136 |
Core::lexicalCast<int>(key.substr(key.find('[') + 1, 4)).value_or(0); |
| 137 |
cout << "Number of atoms = " << tmp << endl; |
| 138 |
m_atomNums = readArrayElements(in, tmp); |
| 139 |
} else if (Core::contains(key, "HEAT_OF_FORMATION:KCAL/MOL")) { |
| 140 |
vector<string> list = Core::split(line, '='); |
| 141 |
if (list.size() > 1) { |
| 142 |
std::replace(list[1].begin(), list[1].end(), 'D', 'E'); |
| 143 |
m_heatOfFormation = Core::lexicalCast<double>(list[1]).value_or(0.0); |
| 144 |
cout << "Heat of formation = " << m_heatOfFormation << " kcal/mol" |
| 145 |
<< endl; |
| 146 |
} |
| 147 |
} else if (Core::contains(key, "HEAT_OF_FORM_UPDATED:KCAL/MOL")) { |
| 148 |
vector<string> list = Core::split(line, '='); |
| 149 |
if (list.size() > 1) { |
| 150 |
std::replace(list[1].begin(), list[1].end(), 'D', 'E'); |
| 151 |
m_energies.push_back(Core::lexicalCast<double>(list[1]).value_or(0.0)); |
| 152 |
} |
| 153 |
} else if (Core::contains(key, "GRADIENT_NORM_UPDATED:KCAL/MOL")) { |
| 154 |
vector<string> list = Core::split(line, '='); |
| 155 |
if (list.size() > 1) { |
| 156 |
std::replace(list[1].begin(), list[1].end(), 'D', 'E'); |
| 157 |
m_forces.push_back(Core::lexicalCast<double>(list[1]).value_or(0.0)); |
| 158 |
} |
| 159 |
} else if (Core::contains(key, "AREA:SQUARE ANGSTROMS")) { |
| 160 |
vector<string> list = Core::split(line, '='); |
| 161 |
if (list.size() > 1) { |
| 162 |
std::replace(list[1].begin(), list[1].end(), 'D', 'E'); |
| 163 |
m_area = Core::lexicalCast<double>(list[1]).value_or(0.0); |
| 164 |
cout << "Area = " << m_area << " square Angstroms" << endl; |
| 165 |
} |
| 166 |
} else if (Core::contains(key, "VOLUME:CUBIC ANGSTROMS")) { |
| 167 |
vector<string> list = Core::split(line, '='); |
| 168 |
if (list.size() > 1) { |
| 169 |
std::replace(list[1].begin(), list[1].end(), 'D', 'E'); |
| 170 |
m_volume = Core::lexicalCast<double>(list[1]).value_or(0.0); |
| 171 |
cout << "Volume = " << m_volume << " cubic Angstroms" << endl; |
| 172 |
} |
| 173 |
} else if (Core::contains(key, "KEYWORDS=")) { |
| 174 |
// parse for charge and spin |
| 175 |
std::vector<std::string> list = Core::split(key, ' '); |
| 176 |
for (size_t i = 0; i < list.size(); ++i) { |
| 177 |
if (Core::contains(list[i], "CHARGE=")) { |
| 178 |
m_charge = Core::lexicalCast<int>(list[i].substr(7)).value_or(0); |
| 179 |
} else if (Core::contains(list[i], "DOUBLET")) { |
| 180 |
m_spin = 2; |
| 181 |
} else if (Core::contains(list[i], "TRIPLET")) { |
| 182 |
m_spin = 3; |
| 183 |
} else if (Core::contains(list[i], "QUARTET")) { |
| 184 |
m_spin = 4; |
| 185 |
} else if (Core::contains(list[i], "QUINTET")) { |
| 186 |
m_spin = 5; |
| 187 |
} else if (Core::contains(list[i], "SEXTET")) { |
| 188 |
m_spin = 6; |
| 189 |
} else if (Core::contains(list[i], "SEPTET")) { |
| 190 |
m_spin = 7; |
| 191 |
} else if (Core::contains(list[i], "OCTET")) { |
| 192 |
m_spin = 8; |
| 193 |
} else if (Core::contains(list[i], "NONET")) { |
| 194 |
m_spin = 9; |
| 195 |
} |
| 196 |
} |
| 197 |
} else if (Core::contains(key, "DIP_VEC:DEBYE")) { |
| 198 |
vector<string> list = Core::split(line, '='); |
| 199 |
if (list.size() > 1) { |
| 200 |
// split based on spaces |
| 201 |
std::replace(list[1].begin(), list[1].end(), 'D', 'E'); |
| 202 |
vector<string> dipole = Core::split(list[1], ' '); |
| 203 |
if (dipole.size() == 3) { |
| 204 |
m_dipoleMoment = |
| 205 |
Vector3(Core::lexicalCast<double>(dipole[0]).value_or(0.0), |
| 206 |
Core::lexicalCast<double>(dipole[1]).value_or(0.0), |
| 207 |
Core::lexicalCast<double>(dipole[2]).value_or(0.0)); |
| 208 |
} |
| 209 |
} |
| 210 |
cout << "Dipole moment " << m_dipoleMoment.norm() << " Debye" << endl; |
| 211 |
} else if (Core::contains(key, "AO_ATOMINDEX")) { |
| 212 |
int tmp = |
| 213 |
Core::lexicalCast<int>(key.substr(key.find('[') + 1, 4)).value_or(0); |
| 214 |
cout << "Number of atomic orbitals = " << tmp << endl; |
| 215 |
m_atomIndex = readArrayI(in, tmp); |
| 216 |
for (int& i : m_atomIndex) |
| 217 |
--i; |
| 218 |
} else if (Core::contains(key, "ATOM_SYMTYPE")) { |
| 219 |
int tmp = |
| 220 |
Core::lexicalCast<int>(key.substr(key.find('[') + 1, 4)).value_or(0); |
| 221 |
cout << "Number of atomic orbital types = " << tmp << endl; |
| 222 |
m_atomSym = readArraySym(in, tmp); |
| 223 |
} else if (Core::contains(key, "AO_ZETA")) { |
| 224 |
int tmp = |
| 225 |
Core::lexicalCast<int>(key.substr(key.find('[') + 1, 4)).value_or(0); |
| 226 |
cout << "Number of zeta values = " << tmp << endl; |
| 227 |
m_zeta = readArrayD(in, tmp); |
| 228 |
} else if (Core::contains(key, "ATOM_CHARGES")) { |
| 229 |
int tmp = |
| 230 |
Core::lexicalCast<int>(key.substr(key.find('[') + 1, 4)).value_or(0); |
| 231 |
cout << "Number of atomic charges = " << tmp << endl; |
| 232 |
m_partialCharges = readArrayD(in, tmp); |
| 233 |
} else if (Core::contains(key, "ATOM_PQN")) { |
| 234 |
int tmp = |
| 235 |
Core::lexicalCast<int>(key.substr(key.find('[') + 1, 4)).value_or(0); |
| 236 |
cout << "Number of PQN values =" << tmp << endl; |
| 237 |
m_pqn = readArrayI(in, tmp); |
| 238 |
} else if (Core::contains(key, "NUM_ELECTRONS")) { |
| 239 |
vector<string> list = Core::split(line, '='); |
| 240 |
if (list.size() > 1) { |
| 241 |
m_electrons = Core::lexicalCast<int>(list[1]).value_or(0); |
| 242 |
cout << "Number of electrons = " << m_electrons << endl; |
| 243 |
} |
| 244 |
} else if (Core::contains(key, "ATOM_X")) { |
| 245 |
auto lBracket = key.find('['); |
| 246 |
auto rBracket = key.find(']'); |
| 247 |
int tmp = |
| 248 |
Core::lexicalCast<int>(key.substr(lBracket + 1, rBracket - lBracket - 1)) |
| 249 |
.value_or(0); |
| 250 |
cout << "Number of atomic coordinates = " << tmp << endl; |
| 251 |
m_atomPos = readArrayVec(in, tmp); |
| 252 |
m_coordSets.push_back(m_atomPos); |
| 253 |
} else if (Core::contains(key, "OVERLAP_MATRIX")) { |
| 254 |
int tmp = |
| 255 |
Core::lexicalCast<int>(key.substr(key.find('[') + 1, 6)).value_or(0); |
| 256 |
cout << "Size of lower half triangle of overlap matrix = " << tmp << endl; |
| 257 |
readOverlapMatrix(in, tmp); |
| 258 |
} else if (Core::contains(key, "EIGENVECTORS")) { |
| 259 |
// For large molecules the Eigenvectors counter overflows to [*****] |
| 260 |
// So just use the square of the m_atomIndex array |
| 261 |
// QString tmp = key.mid(key.indexOf('[')+1, 6); |
| 262 |
cout << "Size of eigen vectors matrix = " |
| 263 |
<< m_atomIndex.size() * m_atomIndex.size() << endl; |
| 264 |
readEigenVectors(in, |
| 265 |
static_cast<int>(m_atomIndex.size() * m_atomIndex.size())); |
| 266 |
} else if (Core::contains(key, "TOTAL_DENSITY_MATRIX")) { |
| 267 |
int tmp = |
| 268 |
Core::lexicalCast<int>(key.substr(key.find('[') + 1, 6)).value_or(0); |
| 269 |
cout << "Size of lower half triangle of density matrix = " << tmp << endl; |
| 270 |
readDensityMatrix(in, tmp); |
| 271 |
} else if (Core::contains(key, "VIB._FREQ")) { |
| 272 |
int tmp = |
| 273 |
Core::lexicalCast<int>(key.substr(key.find('[') + 1, 6)).value_or(0); |
| 274 |
readVibrationFrequencies(in, tmp); |
| 275 |
} else if (Core::contains(key, "VIB._T_DIP")) { |
| 276 |
int tmp = |
| 277 |
Core::lexicalCast<int>(key.substr(key.find('[') + 1, 6)).value_or(0); |
| 278 |
readVibrationIntensities(in, tmp); |
| 279 |
} else if (Core::contains(key, "NORMAL_MODES")) { |
| 280 |
int tmp = |
| 281 |
Core::lexicalCast<int>(key.substr(key.find('[') + 1, 6)).value_or(0); |
| 282 |
readNormalModes(in, tmp); |
| 283 |
} |
| 284 |
} |
| 285 |
|
| 286 |
void MopacAux::load(SlaterSet* basis) |
| 287 |
{ |
| 288 |
if (m_atomPos.size() == 0) { |
| 289 |
cout << "No atoms found in .aux file. Bailing out." << endl; |
| 290 |
// basis->setIsValid(false); |
| 291 |
return; |
| 292 |
} |
| 293 |
// Now load up our basis set |
| 294 |
basis->addSlaterIndices(m_atomIndex); |
| 295 |
basis->addSlaterTypes(m_atomSym); |
| 296 |
basis->addZetas(m_zeta); |
| 297 |
basis->addPQNs(m_pqn); |
| 298 |
basis->setElectronCount(m_electrons); |
| 299 |
basis->addOverlapMatrix(m_overlap); |
| 300 |
basis->addEigenVectors(m_eigenVectors); |
| 301 |
basis->addDensityMatrix(m_density); |
| 302 |
} |
| 303 |
|
| 304 |
vector<int> MopacAux::readArrayElements(std::istream& in, unsigned int n) |
| 305 |
{ |
| 306 |
vector<int> tmp; |
| 307 |
while (tmp.size() < n) { |
| 308 |
string line; |
| 309 |
getline(in, line); |
| 310 |
vector<string> list = Core::split(line, ' '); |
| 311 |
for (auto& i : list) { |
| 312 |
tmp.push_back( |
| 313 |
static_cast<int>(Core::Elements::atomicNumberFromSymbol(i))); |
| 314 |
} |
| 315 |
} |
| 316 |
return tmp; |
| 317 |
} |
| 318 |
|
| 319 |
vector<int> MopacAux::readArrayI(std::istream& in, unsigned int n) |
| 320 |
{ |
| 321 |
vector<int> tmp; |
| 322 |
while (tmp.size() < n) { |
| 323 |
string line; |
| 324 |
getline(in, line); |
| 325 |
vector<string> list = Core::split(line, ' '); |
| 326 |
for (auto& i : list) |
| 327 |
tmp.push_back(Core::lexicalCast<int>(i).value_or(0)); |
| 328 |
} |
| 329 |
return tmp; |
| 330 |
} |
| 331 |
|
| 332 |
vector<double> MopacAux::readArrayD(std::istream& in, unsigned int n) |
| 333 |
{ |
| 334 |
vector<double> tmp; |
| 335 |
while (tmp.size() < n) { |
| 336 |
string line; |
| 337 |
getline(in, line); |
| 338 |
vector<string> list = Core::split(line, ' '); |
| 339 |
for (auto& i : list) |
| 340 |
tmp.push_back(Core::lexicalCast<double>(i).value_or(0.0)); |
| 341 |
} |
| 342 |
return tmp; |
| 343 |
} |
| 344 |
|
| 345 |
vector<int> MopacAux::readArraySym(std::istream& in, unsigned int n) |
| 346 |
{ |
| 347 |
int type; |
| 348 |
vector<int> tmp; |
| 349 |
while (tmp.size() < n) { |
| 350 |
string line; |
| 351 |
getline(in, line); |
| 352 |
vector<string> list = Core::split(line, ' '); |
| 353 |
for (auto& i : list) { |
| 354 |
if (i == "S") |
| 355 |
type = SlaterSet::S; |
| 356 |
else if (i == "PX") |
| 357 |
type = SlaterSet::PX; |
| 358 |
else if (i == "PY") |
| 359 |
type = SlaterSet::PY; |
| 360 |
else if (i == "PZ") |
| 361 |
type = SlaterSet::PZ; |
| 362 |
else if (i == "X2") |
| 363 |
type = SlaterSet::X2; |
| 364 |
else if (i == "XZ") |
| 365 |
type = SlaterSet::XZ; |
| 366 |
else if (i == "Z2") |
| 367 |
type = SlaterSet::Z2; |
| 368 |
else if (i == "YZ") |
| 369 |
type = SlaterSet::YZ; |
| 370 |
else if (i == "XY") |
| 371 |
type = SlaterSet::XY; |
| 372 |
else |
| 373 |
type = SlaterSet::UU; |
| 374 |
tmp.push_back(type); |
| 375 |
} |
| 376 |
} |
| 377 |
return tmp; |
| 378 |
} |
| 379 |
|
| 380 |
vector<Vector3> MopacAux::readArrayVec(std::istream& in, unsigned int n) |
| 381 |
{ |
| 382 |
vector<Vector3> tmp(n / 3); |
| 383 |
double* ptr = tmp[0].data(); |
| 384 |
unsigned int cnt = 0; |
| 385 |
while (cnt < n) { |
| 386 |
string line; |
| 387 |
getline(in, line); |
| 388 |
vector<string> list = Core::split(line, ' '); |
| 389 |
for (auto& i : list) |
| 390 |
ptr[cnt++] = Core::lexicalCast<double>(i).value_or(0.0); |
| 391 |
} |
| 392 |
return tmp; |
| 393 |
} |
| 394 |
|
| 395 |
bool MopacAux::readVibrationFrequencies(std::istream& in, unsigned int n) |
| 396 |
{ |
| 397 |
vector<double> tmp = readArrayD(in, n); |
| 398 |
m_frequencies.insert(m_frequencies.end(), tmp.begin(), tmp.end()); |
| 399 |
return true; |
| 400 |
} |
| 401 |
|
| 402 |
bool MopacAux::readVibrationIntensities(std::istream& in, unsigned int n) |
| 403 |
{ |
| 404 |
vector<double> tmp = readArrayD(in, n); |
| 405 |
m_irIntensities.insert(m_irIntensities.end(), tmp.begin(), tmp.end()); |
| 406 |
return true; |
| 407 |
} |
| 408 |
|
| 409 |
bool MopacAux::readNormalModes(std::istream& in, unsigned int n) |
| 410 |
{ |
| 411 |
vector<Vector3> tmp = readArrayVec(in, n); |
| 412 |
m_normalModes.insert(m_normalModes.end(), tmp.begin(), tmp.end()); |
| 413 |
return true; |
| 414 |
} |
| 415 |
|
| 416 |
bool MopacAux::readOverlapMatrix(std::istream& in, unsigned int n) |
| 417 |
{ |
| 418 |
m_overlap.resize(m_zeta.size(), m_zeta.size()); |
| 419 |
unsigned int cnt = 0; |
| 420 |
unsigned int i = 0, j = 0; |
| 421 |
unsigned int f = 1; |
| 422 |
// Skip the first comment line... |
| 423 |
string line; |
| 424 |
getline(in, line); |
| 425 |
while (cnt < n) { |
| 426 |
getline(in, line); |
| 427 |
vector<string> list = Core::split(line, ' '); |
| 428 |
for (auto& k : list) { |
| 429 |
// m_overlap.part<Eigen::SelfAdjoint>()(i, j) = list.at(k).toDouble(); |
| 430 |
m_overlap(i, j) = m_overlap(j, i) = |
| 431 |
Core::lexicalCast<double>(k).value_or(0.0); |
| 432 |
++i; |
| 433 |
++cnt; |
| 434 |
if (i == f) { |
| 435 |
// We need to move down to the next row and increment f - lower tri |
| 436 |
i = 0; |
| 437 |
++f; |
| 438 |
++j; |
| 439 |
} |
| 440 |
} |
| 441 |
} |
| 442 |
return true; |
| 443 |
} |
| 444 |
|
| 445 |
bool MopacAux::readEigenVectors(std::istream& in, unsigned int n) |
| 446 |
{ |
| 447 |
m_eigenVectors.resize(m_zeta.size(), m_zeta.size()); |
| 448 |
unsigned int cnt = 0; |
| 449 |
unsigned int i = 0, j = 0; |
| 450 |
while (cnt < n) { |
| 451 |
string line; |
| 452 |
getline(in, line); |
| 453 |
vector<string> list = Core::split(line, ' '); |
| 454 |
for (auto& k : list) { |
| 455 |
m_eigenVectors(i, j) = Core::lexicalCast<double>(k).value_or(0.0); |
| 456 |
++i; |
| 457 |
++cnt; |
| 458 |
if (i == m_zeta.size()) { |
| 459 |
// We need to move down to the next row and increment f - lower tri |
| 460 |
i = 0; |
| 461 |
++j; |
| 462 |
} |
| 463 |
} |
| 464 |
} |
| 465 |
return true; |
| 466 |
} |
| 467 |
|
| 468 |
bool MopacAux::readDensityMatrix(std::istream& in, unsigned int n) |
| 469 |
{ |
| 470 |
m_density.resize(m_zeta.size(), m_zeta.size()); |
| 471 |
unsigned int cnt = 0; |
| 472 |
unsigned int i = 0, j = 0; |
| 473 |
unsigned int f = 1; |
| 474 |
// Skip the first comment line... |
| 475 |
string line; |
| 476 |
getline(in, line); |
| 477 |
while (cnt < n) { |
| 478 |
getline(in, line); |
| 479 |
vector<string> list = Core::split(line, ' '); |
| 480 |
for (auto& k : list) { |
| 481 |
// m_overlap.part<Eigen::SelfAdjoint>()(i, j) = list.at(k).toDouble(); |
| 482 |
m_density(i, j) = m_density(j, i) = |
| 483 |
Core::lexicalCast<double>(k).value_or(0.0); |
| 484 |
++i; |
| 485 |
++cnt; |
| 486 |
if (i == f) { |
| 487 |
// We need to move down to the next row and increment f - lower tri |
| 488 |
i = 0; |
| 489 |
++f; |
| 490 |
++j; |
| 491 |
} |
| 492 |
} |
| 493 |
} |
| 494 |
return true; |
| 495 |
} |
| 496 |
|
| 497 |
void MopacAux::outputAll() |
| 498 |
{ |
| 499 |
cout << "Shell mappings:\n"; |
| 500 |
for (unsigned int i = 0; i < m_shellTypes.size(); ++i) |
| 501 |
cout << i << ": type = " << m_shellTypes.at(i) |
| 502 |
<< ", number = " << m_shellNums.at(i) |
| 503 |
<< ", atom = " << m_shelltoAtom.at(i) << endl; |
| 504 |
cout << "MO coefficients:\n"; |
| 505 |
for (double m_MOcoeff : m_MOcoeffs) |
| 506 |
cout << m_MOcoeff << "\t"; |
| 507 |
cout << endl; |
| 508 |
} |
| 509 |
} // namespace Avogadro::QuantumIO |