Kindfield
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Friends Pages
Public Member Functions | List of all members
TurboMoleParser Class Reference

#include <turbomoleparser.h>

Public Member Functions

 TurboMoleParser ()
 
bool load (string fileName)
 
const vector
< GaussianContractedOrbital > & 
contractedBasisFunctions () const
 
HF::AtomType atomType () const
 
double normalizationFactor (double exp, urowvec pows)
 
int factorial (int n)
 

Detailed Description

Definition at line 14 of file turbomoleparser.h.

Constructor & Destructor Documentation

TurboMoleParser::TurboMoleParser ( )

Definition at line 11 of file turbomoleparser.cpp.

12 {
13 }

Member Function Documentation

HF::AtomType TurboMoleParser::atomType ( ) const

Definition at line 151 of file turbomoleparser.cpp.

152 {
153  return m_atomType;
154 }
const vector< GaussianContractedOrbital > & TurboMoleParser::contractedBasisFunctions ( ) const

Definition at line 82 of file turbomoleparser.cpp.

83 {
84  return m_contractedBasisFunctions;
85 }
int TurboMoleParser::factorial ( int  n)

Definition at line 165 of file turbomoleparser.cpp.

166 {
167  double value = 1;
168  double i = 1;
169 
170  while(i < n){
171  i += 1;
172  value *= i;
173  }
174  return value;
175 }
bool TurboMoleParser::load ( string  fileName)

Definition at line 15 of file turbomoleparser.cpp.

16 {
17  setlocale(LC_ALL, "C");
18  m_contractedBasisFunctions.clear();
19  ifstream dataFile(fileName);
20  if(!dataFile.is_open()) {
21  return false;
22  }
23  string line;
24 
25  vector<int> nValenceOrbitals;
26  string atomTypeAbbreviation;
27  while (getline(dataFile, line))
28  {
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("\\*.*"));
34  if(ignoredLine) {
35  continue;
36  }
37  smatch what;
38  regex basisRegex("^\\s*([a-zA-Z]+)");
39  while(regex_search(line, what, basisRegex)) { // n 4-31G
40  atomTypeAbbreviation = string(what[1]);
41  m_atomType = HF::abbreviationToAtomType(atomTypeAbbreviation);
42  break;
43  }
44  regex orbitalRegex("\\s*([0-9])\\s*([spdf])\\s*");
45  if(regex_search(line, what, orbitalRegex)) { // 4 s
46  mergePrimitivesIntoContracted();
47  if(what[2] == "s") {
48  m_currentOrbitalType = HF::sOrbitalType;
49  } else if(what[2] == "p") {
50  m_currentOrbitalType = HF::pOrbitalType;
51  } else if(what[2] == "d") {
52  m_currentOrbitalType = HF::dOrbitalType;
53  } else if(what[2] == "f") {
54  m_currentOrbitalType = HF::fOrbitalType;
55  } else {
56  cerr << "Unknown orbital type " << string(what[1]) << endl;
57  return false;
58  }
59  }
60  regex exponentWeightRegex("\\s*(-?[0-9]+\\.?[0-9]+)\\s*(-?[0-9]+\\.?[0-9]+)\\s*"); // 2.1 4.9
61  if(regex_search(line, what, exponentWeightRegex)) {
62  double exponent = stod(string(what[1]));
63  double weight = stod(string(what[2]));
64 
65  GaussianPrimitiveOrbital primitive;
66  primitive.setWeight(weight);
67  primitive.setExponent(exponent);
68  m_collectedPrimitiveBasisFunctions.push_back(primitive);
69  }
70  }
71  mergePrimitivesIntoContracted();
72  // for(GaussianContractedOrbital orbital : m_contractedBasisFunctions) {
73  // cout << "Contracted:" << endl;
74  // for(GaussianPrimitiveOrbital primitive : orbital.primitiveBasisFunctions()) {
75  // cout << primitive.weight() << " * " << primitive.exponent() << endl;
76  // }
77  // }
78  // cout << "Done!" << endl;
79  return true;
80 }
double TurboMoleParser::normalizationFactor ( double  exp,
urowvec  pows 
)

Definition at line 157 of file turbomoleparser.cpp.

158 {
159  int i = pows.at(0);
160  int j = pows.at(1);
161  int k = pows.at(2);
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)));
163 }

The documentation for this class was generated from the following files: