5#include <boost/algorithm/string.hpp>
11 std::ofstream& outFile)
const {
12 for (
const auto& atom : orbitals.
QMAtoms()) {
13 const Eigen::Vector3d& pos = atom.getPos();
14 outFile << boost::format(
"%-4s %5d %5d %22.12e %22.10e %22.10e\n") %
15 atom.getElement() % (atom.getId() + 1) %
16 atom.getElementNumber() % pos[0] % pos[1] % pos[2];
22 bool fromVotcaToExternal =
true;
29 outFile << boost::format(
"Ene= %-20.12e\n") % energies[i];
30 outFile <<
"Spin= Alpha\n";
31 outFile << boost::format(
"Occup= %-5.2f\n") %
34 outFile << boost::format(
"%5d %22.12e\n") % (j + 1) %
41 std::ofstream& outFile)
const {
43 for (
const auto& atom : orbitals.
QMAtoms()) {
46 outFile << boost::format(
"%4d 0 \n") % (atom.getId() + 1);
47 const std::vector<const AOShell*> shells =
49 for (
const AOShell* shell : shells) {
52 outFile << boost::format(
"%-3s %4d %3.1f \n") %
54 shell->getSize() % 1.0;
56 outFile << boost::format(
"%22.10e %22.10e\n") % gaussian.getDecay() %
57 gaussian.getContraction();
67 throw std::runtime_error(
".orb file does not contain a basisset name");
70 std::ofstream outFile(filename);
71 if (outFile.is_open()) {
76 outFile <<
"[Molden Format]\n";
77 outFile <<
"[Title]\n";
78 outFile <<
"Molden file created by VOTCA-XTP\n";
81 outFile <<
"[Atoms] AU\n";
84 outFile <<
"[GTO] \n";
88 outFile <<
"[5D] \n[7F] \n[9G] \n";
93 <<
"Finished writing to molden file." << std::flush;
98 std::ifstream& input_file)
const {
100 std::istringstream iss(
" ");
101 while (std::getline(input_file, line)) {
103 if (line ==
"" || line[0] ==
'[') {
113 std::string atom_type;
114 iss >> atom_type >> atom_id >> junk >> x >> y >> z;
119 Eigen::Vector3d pos(x, y, z);
120 if (units ==
"Angs") {
131 std::ifstream& input_file)
const {
135 if (basis_size == 0) {
136 throw std::runtime_error(
137 "Basis size not set, atoms were not parsed first.");
141 orbitals.
Occupations() = Eigen::MatrixXd::Zero(basis_size, 2);
154 std::istringstream iss(
" ");
155 for (
Index i = 0; i < basis_size; i++) {
156 std::getline(input_file, line);
158 std::getline(input_file, line);
161 iss >> tempStr >> tempDouble;
164 std::getline(input_file, line);
167 iss >> tempStr >> tempStr;
169 std::getline(input_file, line);
172 iss >> tempStr >> tempDouble;
173 if ((
int)tempDouble == 1 && !orbitals.
isOpenShell()) {
174 throw std::runtime_error(
175 "Encountered occupation 1 for a closed-shell calculation.");
180 for (
int j = 0; j < basis_size; j++) {
181 std::getline(input_file, line);
184 iss >> tempIndex >> tempDouble;
191 for (
Index i = 0; i < basis_size; i++) {
192 std::getline(input_file, line);
194 std::getline(input_file, line);
197 iss >> tempStr >> tempDouble;
200 std::getline(input_file, line);
203 iss >> tempStr >> tempStr;
205 std::getline(input_file, line);
208 iss >> tempStr >> tempDouble;
209 if ((
int)tempDouble == 2) {
210 throw std::runtime_error(
211 "Encountered occupation 2 in an open-shell calculation.");
215 for (
int j = 0; j < basis_size; j++) {
216 std::getline(input_file, line);
219 iss >> tempIndex >> tempDouble;
249 throw std::runtime_error(
250 "Basisset names should be set before reading the molden file.");
253 std::ifstream input_file(filename);
255 if (input_file.fail()) {
256 throw std::runtime_error(
"Could not open molden file with name: " +
261 std::getline(input_file, line);
264 if (line[0] !=
'[') {
265 std::getline(input_file, line);
270 long unsigned close = line.find(
"]");
271 std::string sectionType = line.substr(1, close - 1);
274 if (sectionType ==
"Atoms") {
275 std::string units = line.substr(close + 1);
278 <<
"Reading atoms using " << units <<
" units." << std::flush;
283 throw std::runtime_error(
284 "Could not clear QMAtoms while reading Molden file.");
287 }
else if (sectionType ==
"GTO") {
289 <<
"Basisset specification is ignored." << std::flush;
291 <<
"Basissets are specified via the mol2orb.xml options file."
293 std::getline(input_file, line);
294 }
else if (sectionType ==
"MO") {
296 throw std::runtime_error(
297 "Atoms should be specified before MO coefficients.");
300 <<
"Reading molecular orbital coefficients" << std::flush;
301 line =
readMOs(orbitals, input_file);
303 }
else if (sectionType ==
"STO") {
304 throw std::runtime_error(
305 "Slater Type Orbitals (STOs) are not supported in VOTCA-XTP.");
307 std::getline(input_file, line);
Container to hold Basisfunctions for all atoms.
const std::vector< const AOShell * > getShellsofAtom(Index AtomId) const
void push_back(const T &atom)
std::string readMOs(Orbitals &orbitals, std::ifstream &input_file) const
std::string basisset_name_
void WriteFile(const std::string &filename, const Orbitals &orbitals) const
std::string aux_basisset_name_
std::string readAtoms(QMMolecule &mol, const std::string &units, std::ifstream &input_file) const
void writeAtoms(const Orbitals &orbitals, std::ofstream &outFile) const
void writeMOs(const Orbitals &orbitals, std::ofstream &outFile) const
void addBasissetInfo(Orbitals &orbitals) const
void parseMoldenFile(const std::string &filename, Orbitals &orbitals) const
void writeBasisSet(const Orbitals &orbitals, std::ofstream &outFile) const
std::array< Index, 49 > reorderList_
std::array< Index, 49 > multipliers_
void reorderOrbitals(Eigen::MatrixXd &moCoefficients, const AOBasis &basis)
container for molecular orbitals
const tools::EigenSystem & MOs_beta() const
const Eigen::MatrixXd & Occupations() const
void SetupAuxBasis(std::string aux_basis_name)
Index getBasisSetSize() const
const tools::EigenSystem & MOs() const
const QMMolecule & QMAtoms() const
bool hasDFTbasisName() const
void SetupDftBasis(std::string basis_name)
const AOBasis & getDftBasis() const
#define XTP_LOG(level, log)
std::string EnumToString(L l)
base class for all analysis tools