5 #include <boost/regex.hpp>
17 setlocale(LC_ALL,
"C");
18 m_contractedBasisFunctions.clear();
19 ifstream dataFile(fileName);
20 if(!dataFile.is_open()) {
25 vector<int> nValenceOrbitals;
26 string atomTypeAbbreviation;
27 while (getline(dataFile, line))
29 bool ignoredLine =
false;
30 ignoredLine |= regex_match(line, regex(
"#.*"));
31 ignoredLine |= regex_match(line, regex(
"$basis.*"));
32 ignoredLine |= regex_match(line, regex(
"$end.*"));
33 ignoredLine |= regex_match(line, regex(
"\\*.*"));
38 regex basisRegex(
"^\\s*([a-zA-Z]+)");
39 while(regex_search(line, what, basisRegex)) {
40 atomTypeAbbreviation = string(what[1]);
44 regex orbitalRegex(
"\\s*([0-9])\\s*([spdf])\\s*");
45 if(regex_search(line, what, orbitalRegex)) {
46 mergePrimitivesIntoContracted();
49 }
else if(what[2] ==
"p") {
51 }
else if(what[2] ==
"d") {
53 }
else if(what[2] ==
"f") {
56 cerr <<
"Unknown orbital type " << string(what[1]) << endl;
60 regex exponentWeightRegex(
"\\s*(-?[0-9]+\\.?[0-9]+)\\s*(-?[0-9]+\\.?[0-9]+)\\s*");
61 if(regex_search(line, what, exponentWeightRegex)) {
62 double exponent = stod(
string(what[1]));
63 double weight = stod(
string(what[2]));
68 m_collectedPrimitiveBasisFunctions.push_back(primitive);
71 mergePrimitivesIntoContracted();
84 return m_contractedBasisFunctions;
87 void TurboMoleParser::mergePrimitivesIntoContracted()
89 if(m_collectedPrimitiveBasisFunctions.size() > 0) {
90 switch(m_currentOrbitalType) {
94 double weightAdjusted = primitive.weight() * pow(2 * primitive.exponent() / M_PI, 3.0/4.0);
95 primitive.setWeight(weightAdjusted);
98 m_contractedBasisFunctions.push_back(contractedOrbital);
103 for(
int i = 0; i < dim; i++) {
106 double weightAdjusted = primitive.weight() * pow(2 * primitive.exponent() / M_PI, 3.0/4.0) * 2 * sqrt(primitive.exponent());
107 primitive.setWeight(weightAdjusted);
108 primitive.setXExponent(i == 0);
109 primitive.setYExponent(i == 1);
110 primitive.setZExponent(i == 2);
113 m_contractedBasisFunctions.push_back(contractedOrbital);
119 exponents << 2 << 0 << 0 << endr
120 << 0 << 2 << 0 << endr
121 << 0 << 0 << 2 << endr
122 << 1 << 1 << 0 << endr
123 << 1 << 0 << 1 << endr
124 << 0 << 1 << 1 << endr;
125 for(
int i = 0; i < int(exponents.n_rows); i++) {
128 double weightAdjusted = primitive.weight() * normalizationFactor(primitive.exponent(), exponents.row(i));
129 primitive.setWeight(weightAdjusted);
130 primitive.setXExponent(exponents(i, 0));
131 primitive.setYExponent(exponents(i, 1));
132 primitive.setZExponent(exponents(i, 2));
135 m_contractedBasisFunctions.push_back(contractedOrbital);
140 cout <<
"ERROR: f orbitals not yet supported" << endl;
144 cout <<
"ERROR: Unknown orbital type." << endl;
148 m_collectedPrimitiveBasisFunctions.clear();
162 return pow((2*exp/M_PI),0.75)*sqrt(pow(8*exp,i+j+k)*factorial(i)*factorial(j)*factorial(k)/(factorial(2*i)*factorial(2*j)*factorial(2*k)));