// Print out details of Molecule, taking the form: // ======== // MOLECULE // ======== // No. of e- = nel, charge = q, singlet/doublet/triplet etc. // Enuc = nuclear energy // (if inertia = true then also prints the section: // ............................ // Principal Moments of Inertia // ............................ // Ia = ..., Ib = ..., Ic = ... // Rotational type: ... // .................... // Rotational Constants // .................... // (the coordinate system is also transformed to inertial coords) // ===== // ATOMS // ===== // Atom z Mass (a.m.u) Coordinates // ............................................................... // C 6 12.014 (0.0, 3.53, -1.24) // etc... void Logger::print(Molecule& mol, bool inertia) const { title("Molecule"); // Print out basic details outfile << "# electrons = " << mol.getNel() << ", "; outfile << "charge = " << mol.getCharge() << ", "; std::string temp; // Get the state type switch (mol.getMultiplicity()) { case 1: { temp = "Singlet"; break; } case 2: { temp = "Doublet"; break; } case 3: { temp = "Triplet"; break; } case 4: { temp = "Quartet"; break; } case 5: { temp = "Quintet"; break; } default: { temp = "Spintacular"; break; } // Are hextets even a thing?! } outfile << temp << "\n"; outfile << "ENUC = " << mol.getEnuc() << " Hartree\n"; // Print inertial details if needed, and rotate // into the inertial coordinate system if (inertia) { // Get it temp = mol.rType(); Vector rconsts(3); rconsts = mol.rConsts(1); // MHz Vector inert(3); inert = mol.getInertia(true); // Print it out outfile << std::string(30, '.') << "\n"; outfile << "Principal Moments of Inertia\n"; outfile << std::string(30, '.') << "\n"; outfile << "Ia = " << std::setw(12) << inert(0); outfile << ", Ib = " << std::setw(12) << inert(1); outfile << ", Ic = " << std::setw(12) << inert(2) << "\n"; outfile << "Rotational type: " << temp << "\n"; outfile << std::string(29, '.') << "\n"; outfile << "Rotational Constants / GHz\n"; outfile << std::string(29, '.') << "\n"; outfile << "A = " << std::setw(12) << rconsts(0); outfile << ", B = " << std::setw(12) << rconsts(1); outfile << ", C = " << std::setw(12) << rconsts(2) << "\n"; } // Finally, print out all the atoms title("Atoms"); outfile << std::setw(10) << "Atom" << std::setw(10) << "z"; outfile << std::setw(10) << "Mass" << std::setw(10) << "#CGBFs"; outfile << std::setw(30) << "Coordinates" << "\n"; outfile << std::string(70, '.') << "\n"; for (int i = 0; i < mol.getNAtoms(); i++){ print(mol.getAtom(i)); } }
RESULT CHECK(const System* getSystem() const throw()) System s1("aya"); Molecule m("a"); s1.append(m); const System s(s1); TEST_EQUAL(m.getSystem()->getName(), "aya") RESULT CHECK(void prepend(Atom& atom) throw()) Molecule m; Atom a1; Atom a2; m.insert(a1); TEST_EQUAL(m.getAtom(0), &a1) m.prepend(a2); TEST_EQUAL(m.getAtom(0), &a2) TEST_EQUAL(m.getAtom(1), &a1) RESULT CHECK(void append(Atom& atom) throw()) Molecule m; Atom a1; Atom a2; m.insert(a1); m.append(a2); TEST_EQUAL(m.getAtom(0), &a1) TEST_EQUAL(m.getAtom(1), &a2) RESULT
const Molecule* LevelSet::readLevelMolecule(int levelNum) const { Molecule* mol = new Molecule(); KConfigGroup config = m_levelsFile->group("Level"+QString::number(levelNum)); QString key; atom current; int atom_index = 1; QString value; while (true) { key.sprintf("atom_%c", int2atom(atom_index)); value = config.readEntry(key,QString()); if (value.isEmpty()) break; current.obj = value.at(0).toLatin1(); value = value.mid(2); strncpy(current.conn, value.toLatin1(), sizeof(current.conn)); if (mol->m_atoms.indexOf(current) != -1) qWarning() << "OOOPS, duplicate atom definition in" << key; mol->m_atoms.append(current); atom_index++; } QString line; mol->m_width = 0; mol->m_height = 0; mol->m_weight = 0.0; int max_i = -1; for (int j = 0; j < MOLECULE_SIZE; j++) { key.sprintf("mole_%d", j); line = config.readEntry(key,QString()); int max_non_null_i = -1; for (int i = 0; i < MOLECULE_SIZE; i++) { if (i >= line.size()) mol->m_molek[i][j] = 0; else { mol->m_molek[i][j] = atom2int(line.at(i).toLatin1()); mol->m_weight += mol->getAtom(mol->m_molek[i][j]).weight(); max_non_null_i = i; } } if( max_non_null_i != -1 ) mol->m_height++; max_i = qMax( max_i, max_non_null_i ); } mol->m_width = max_i+1; mol->m_name = i18n(config.readEntry("Name", I18N_NOOP("Noname")).toUtf8()); return mol; }