QMCPACK
GamesAsciiParser Class Reference
+ Inheritance diagram for GamesAsciiParser:
+ Collaboration diagram for GamesAsciiParser:

Public Member Functions

 GamesAsciiParser ()
 
 GamesAsciiParser (int argc, char **argv)
 
void parse (const std::string &fname) override
 
void getGeometry (std::istream &is)
 
void getGaussianCenters (std::istream &is)
 
void getMO (std::istream &is)
 
void getMO_single_set (std::istream &is, Matrix< double > &CartMat, std::vector< value_type > &EigVal_alpha)
 
void getCI (std::istream &is)
 
void getORMAS (std::istream &is)
 
void getCSF (std::istream &is)
 
double getCSFSign (std::vector< int > &)
 
- Public Member Functions inherited from QMCGaussianParserBase
 QMCGaussianParserBase ()
 
 QMCGaussianParserBase (int argc, char **argv)
 
virtual ~QMCGaussianParserBase ()=default
 
void setOccupationNumbers ()
 
void createGridNode (int argc, char **argv)
 
void createSPOSets (xmlNodePtr, xmlNodePtr)
 
void createSPOSetsH5 (xmlNodePtr, xmlNodePtr)
 
void PrepareSPOSetsFromH5 (xmlNodePtr, xmlNodePtr)
 
xmlNodePtr createElectronSet (const std::string &ion_tag)
 
xmlNodePtr createIonSet ()
 
xmlNodePtr createCell ()
 
xmlNodePtr createHamiltonian (const std::string &ion_tag, const std::string &psi_tag)
 
xmlNodePtr createBasisSet ()
 
xmlNodePtr createBasisSetWithHDF5 ()
 
xmlNodePtr createCenter (int iat, int _off)
 
void createCenterH5 (int iat, int _off, int numelem)
 
void createShell (int n, int ig, int off_, xmlNodePtr abasis)
 
void createShellH5 (int n, int ig, int off_, int numelem)
 
xmlNodePtr createDeterminantSet ()
 
xmlNodePtr createMultiDeterminantSet ()
 
xmlNodePtr createDeterminantSetWithHDF5 ()
 
xmlNodePtr createMultiDeterminantSetFromH5 ()
 
xmlNodePtr createMultiDeterminantSetCIHDF5 ()
 
xmlNodePtr PrepareDeterminantSetFromHDF5 ()
 
xmlNodePtr createJ3 ()
 
xmlNodePtr createJ2 ()
 
xmlNodePtr createJ1 ()
 
xmlNodePtr parameter (xmlNodePtr Parent, std::string Mypara, std::string a)
 
int numberOfExcitationsCSF (std::string &)
 
virtual void dumpPBC (const std::string &psi_tag, const std::string &ion_tag)
 
virtual void dump (const std::string &psi_tag, const std::string &ion_tag)
 
void dumpStdInput (const std::string &psi_tag, const std::string &ion_tag)
 
void dumpStdInputProd (const std::string &psi_tag, const std::string &ion_tag)
 
- Public Member Functions inherited from OhmmsAsciiParser
void skiplines (std::istream &is, int n)
 
template<class T >
void getValue (std::istream &is, T &aval)
 
template<class T1 , class T2 >
void getValue (std::istream &is, T1 &aval, T2 &bval)
 
template<class IT >
void getValues (std::istream &is, IT first, IT last)
 
int search (std::istream &is, const std::string &keyword)
 
int search (std::istream &is, const std::string &keyword, std::string &the_line)
 
bool lookFor (std::istream &is, const std::string &keyword)
 
bool lookFor (std::istream &is, const std::string &keyword, std::string &the_line)
 

Public Attributes

std::streampos pivot_begin
 
std::vector< std::string > tags
 
bool usingECP
 
std::string MOtype
 
int readtype
 
int NFZC
 
int NEXT
 
int NTOT
 
int NAC
 
- Public Attributes inherited from QMCGaussianParserBase
bool multideterminant
 
bool multidetH5
 
bool BohrUnit
 
bool SpinRestricted
 
bool Periodicity
 
bool UseHDF5
 
bool PBC
 
bool production
 
bool zeroCI
 
bool orderByExcitation
 
bool addJastrow
 
bool addJastrow3Body
 
bool ECP
 
bool debug
 
bool Structure
 
bool DoCusp
 
bool FixValence
 
bool singledetH5
 
bool optDetCoeffs
 
bool usingCSF
 
bool isSpinor
 
int IonChargeIndex
 
int ValenceChargeIndex
 
int AtomicNumberIndex
 
int NumberOfAtoms
 
int NumberOfEls
 
int target_state
 
int SpinMultiplicity
 
int NumberOfAlpha
 
int NumberOfBeta
 
int SizeOfBasisSet
 
int numMO
 
int readNO
 
int readGuess
 
int numMO2print
 
int ci_size
 
int ci_nca
 
int ci_ncb
 
int ci_nea
 
int ci_neb
 
int ci_nstates
 
int NbKpts
 
int nbexcitedstates
 
double ci_threshold
 
std::vector< double > STwist_Coord
 
std::string Title
 
std::string basisType
 
std::string basisName
 
std::string Normalized
 
std::string CurrentCenter
 
std::string outputFile
 
std::string angular_type
 
std::string expandYlm
 
std::string h5file
 
std::string multih5file
 
std::string WFS_name
 
std::string CodeName
 
const SimulationCell simulation_cell
 
ParticleSet IonSystem
 
std::vector< std::string > GroupName
 
std::vector< int > gShell
 
std::vector< int > gNumber
 
std::vector< int > gBound
 
std::vector< int > Occ_alpha
 
std::vector< int > Occ_beta
 
std::vector< value_typeQv
 
std::vector< value_typegExp
 
std::vector< value_typegC0
 
std::vector< value_typegC1
 
std::vector< value_typeEigVal_alpha
 
std::vector< value_typeEigVal_beta
 
std::vector< value_typeEigVec
 
std::unique_ptr< xmlNode, void(*)(xmlNodePtr)> gridPtr
 
std::vector< std::string > CIalpha
 
std::vector< std::string > CIbeta
 
std::vector< std::string > CSFocc
 
std::vector< std::vector< std::string > > CSFalpha
 
std::vector< std::vector< std::string > > CSFbeta
 
std::vector< std::vector< double > > CSFexpansion
 
std::vector< double > CIcoeff
 
std::vector< double > X
 
std::vector< double > Y
 
std::vector< double > Z
 
std::vector< int > Image
 
std::vector< int > CIexcitLVL
 
std::vector< std::pair< int, double > > coeff2csf
 
- Public Attributes inherited from OhmmsAsciiParser
char dbuffer [bufferSize]
 
std::vector< std::string > currentWords
 

Additional Inherited Members

- Public Types inherited from QMCGaussianParserBase
using value_type = double
 
using SingleParticlePos = ParticleSet::SingleParticlePos
 
- Static Public Member Functions inherited from QMCGaussianParserBase
static void init ()
 
- Static Public Attributes inherited from QMCGaussianParserBase
static std::map< int, std::string > IonName
 
static std::vector< std::string > gShellType
 
static std::vector< int > gShellID
 
static const std::vector< double > gCoreTable
 
- Static Public Attributes inherited from OhmmsAsciiParser
static const int bufferSize = 200
 

Detailed Description

Definition at line 27 of file GamesAsciiParser.h.

Constructor & Destructor Documentation

◆ GamesAsciiParser() [1/2]

◆ GamesAsciiParser() [2/2]

GamesAsciiParser ( int  argc,
char **  argv 
)

Definition at line 41 of file GamesAsciiParser.cpp.

References QMCGaussianParserBase::angular_type, QMCGaussianParserBase::basisName, QMCGaussianParserBase::BohrUnit, QMCGaussianParserBase::ECP, QMCGaussianParserBase::FixValence, MOtype, NFZC, QMCGaussianParserBase::Normalized, readtype, QMCGaussianParserBase::SpinRestricted, and usingECP.

41  : QMCGaussianParserBase(argc, argv)
42 {
43  basisName = "Gaussian";
44  Normalized = "no";
45  usingECP = false;
46  ECP = false;
47  BohrUnit = true;
48  MOtype = "Canonical";
49  angular_type = "cartesian";
50  SpinRestricted = true;
51  readtype = 0;
52  NFZC = 0;
53  FixValence = true;
54 }
std::string MOtype

Member Function Documentation

◆ getCI()

void getCI ( std::istream &  is)

Definition at line 1377 of file GamesAsciiParser.cpp.

References QMCGaussianParserBase::ci_nea, QMCGaussianParserBase::ci_neb, QMCGaussianParserBase::ci_nstates, QMCGaussianParserBase::ci_size, QMCGaussianParserBase::CIalpha, QMCGaussianParserBase::CIbeta, QMCGaussianParserBase::CIcoeff, OhmmsAsciiParser::currentWords, getwords(), QMCGaussianParserBase::NumberOfBeta, QMCGaussianParserBase::NumberOfEls, pivot_begin, QMCGaussianParserBase::SpinMultiplicity, and QMCGaussianParserBase::target_state.

Referenced by parse().

1378 {
1379  is.seekg(pivot_begin);
1380  //look for CI coefficients
1381  bool notfound = true;
1382  ci_size = 0;
1383  CIcoeff.clear();
1384  CIalpha.clear();
1385  CIbeta.clear();
1386 
1387  // set a count to check if we arrive our target state or not
1388  int state_num = -1;
1389 
1390  std::cout << "Target State Number is " << target_state << std::endl;
1391 
1392 
1393  do
1394  {
1395  if (is.eof())
1396  {
1397  std::cerr << "Could not find CI expansion. \n";
1398  abort();
1399  }
1400  getwords(currentWords, is, 0, std::string("|"));
1401  if (currentWords.size() < 3)
1402  continue;
1403  if (currentWords[0].find("ALP") == 0 && currentWords[1].find("BET") == 0 &&
1404  (currentWords[2] == "COEFFICIENT" || currentWords[3] == "COEFFICIENT"))
1405  {
1406  // add the state number by one
1407  state_num++;
1408 
1409  // if we have not reached target state, continue
1410  if (state_num != target_state)
1411  continue;
1412 
1413  getwords(currentWords, is); // --------
1414  notfound = false;
1415  getwords(currentWords, is);
1416  while (currentWords.size() != 0)
1417  {
1418  if (currentWords[0] == "....." || currentWords[1] == "DONE")
1419  break;
1420  ci_size++;
1421  CIcoeff.push_back(atof(currentWords[4].c_str()));
1422  CIalpha.push_back(currentWords[0]);
1423  CIbeta.push_back(currentWords[2]);
1424  getwords(currentWords, is);
1425  }
1426  }
1427  } while (notfound);
1428  ci_nea = ci_neb = 0;
1429  for (int i = 0; i < CIalpha[0].size(); i++)
1430  if (CIalpha[0].at(i) == '1')
1431  ci_nea++;
1432  for (int i = 0; i < CIbeta[0].size(); i++)
1433  if (CIbeta[0].at(i) == '1')
1434  ci_neb++;
1435  if (CIalpha[0].size() != CIbeta[0].size())
1436  {
1437  std::cerr << "QMCPACK can't handle different number of active orbitals in alpha and beta channels right now. "
1438  "Contact developers for help (Miguel).\n";
1439  abort();
1440  }
1441  int ds = SpinMultiplicity - 1;
1442  int neb = (NumberOfEls - ds) / 2;
1443  int nea = NumberOfEls - NumberOfBeta;
1444 
1445  for (int i = 0; i < CIalpha.size(); i++)
1446  CIalpha[i].insert(0, std::string(nea - ci_nea, '1'));
1447  for (int i = 0; i < CIbeta.size(); i++)
1448  CIbeta[i].insert(0, std::string(neb - ci_neb, '1'));
1449 
1450  ci_nea = nea;
1451  ci_neb = neb;
1452 
1453  ci_nstates = CIalpha[0].size();
1454 }
std::vector< std::string > currentWords
Definition: SimpleParser.h:49
std::streampos pivot_begin
std::vector< double > CIcoeff
std::vector< std::string > CIalpha
int getwords(std::vector< std::string > &slist, std::istream &fp, std::string &aline)
std::vector< std::string > CIbeta

◆ getCSF()

void getCSF ( std::istream &  is)

Definition at line 1002 of file GamesAsciiParser.cpp.

References qmcplusplus::abs(), QMCGaussianParserBase::ci_nca, QMCGaussianParserBase::ci_ncb, QMCGaussianParserBase::ci_nea, QMCGaussianParserBase::ci_neb, QMCGaussianParserBase::ci_nstates, QMCGaussianParserBase::ci_size, QMCGaussianParserBase::ci_threshold, QMCGaussianParserBase::coeff2csf, QMCGaussianParserBase::CSFalpha, QMCGaussianParserBase::CSFbeta, QMCGaussianParserBase::CSFexpansion, QMCGaussianParserBase::CSFocc, OhmmsAsciiParser::currentWords, getCSFSign(), getwords(), OhmmsAsciiParser::lookFor(), NFZC, NTOT, pivot_begin, QMCGaussianParserBase::target_state, and QMCGaussianParserBase::usingCSF.

Referenced by parse().

1003 {
1004  //look for CI coefficients, only working for slater dets right now
1005  bool notfound = true;
1006  ci_size = 0;
1007  CSFocc.clear();
1008  CSFalpha.clear();
1009  CSFbeta.clear();
1010  coeff2csf.clear();
1011  usingCSF = true;
1012 
1013  // set a count to check if we arrive our target state or not
1014  int state_num = -1;
1015 
1016  std::cout << "Target State Number is " << target_state << std::endl;
1017 
1018  do
1019  {
1020  if (is.eof())
1021  {
1022  std::cerr << "Could not find CSF expansion. \n";
1023  abort();
1024  }
1025  getwords(currentWords, is);
1026  if (currentWords.size() < 3)
1027  continue;
1028  if (currentWords[0] == "CSF" && currentWords[1] == "COEF" && currentWords[2] == "OCCUPANCY")
1029  {
1030  // add the state number by one
1031  state_num++;
1032 
1033  // if we have not reached target state, continue
1034  if (state_num != target_state)
1035  continue;
1036 
1037  getwords(currentWords, is); // --------
1038  notfound = false;
1039  getwords(currentWords, is);
1040  while (currentWords.size() != 0)
1041  {
1042  if (currentWords[0] == "......" || currentWords[1] == "END")
1043  break;
1044  double cof = atof(currentWords[1].c_str());
1045  if (std::abs(cof) > ci_threshold)
1046  {
1047  ci_size++;
1048  int nq = atoi(currentWords[0].c_str());
1049  std::pair<int, double> cic(nq, cof);
1050  coeff2csf.push_back(cic);
1051  if (NTOT < 50)
1052  {
1053  CSFocc.push_back(currentWords[2]);
1054  }
1055  else if (NTOT == 50)
1056  {
1057  CSFocc.push_back(currentWords[2]);
1058  getwords(currentWords, is);
1059  }
1060  else
1061  {
1062  std::string tmp = currentWords[2];
1063  getwords(currentWords, is);
1064  tmp += currentWords[0];
1065  CSFocc.push_back(tmp);
1066  }
1067  getwords(currentWords, is);
1068  }
1069  else
1070  {
1071  if (NTOT < 50)
1072  getwords(currentWords, is);
1073  else
1074  {
1075  getwords(currentWords, is);
1076  getwords(currentWords, is);
1077  }
1078  }
1079  }
1080  }
1081  } while (notfound);
1082  std::cout << "Done reading csf coefficients." << std::endl;
1083  std::cout << "Found: " << coeff2csf.size() << " CSFs.\n";
1084  std::cout.flush();
1085  // look for highest occupied MO to avoid using unnecessary ones
1086  ci_nstates = 0;
1087  for (int i = 0; i < CSFocc.size(); i++)
1088  {
1089  int max = CSFocc[i].size();
1090  for (int k = CSFocc[i].size() - 1; k >= 0; k--)
1091  {
1092  if (CSFocc[i][k] == '1' || CSFocc[i][k] == '2')
1093  {
1094  max = k + 1;
1095  break;
1096  }
1097  }
1098  if (ci_nstates < max)
1099  ci_nstates = max;
1100  }
1101  CSFalpha.resize(ci_size);
1102  CSFbeta.resize(ci_size);
1103  CSFexpansion.resize(ci_size);
1104  // now rewind and look for CSF definitions
1105  is.seekg(pivot_begin);
1106  if (!lookFor(is, "DETERMINANT CONTRIBUTION TO CSF'S"))
1107  {
1108  std::cerr
1109  << "Could not find CSF determinant contributions. Please use NPRT=2 in $CIDRT/DRT input section of gamess. \n";
1110  abort();
1111  }
1112  getwords(currentWords, is); // ----------------
1113  getwords(currentWords, is); // ----------------
1114  if (currentWords[0] != "CASE" || currentWords[1] != "VECTOR")
1115  {
1116  std::cerr << "Problems reading DETERMINANT CONTRIBUTION TO CSF'S (1). \n";
1117  abort();
1118  }
1119  // int ds=SpinMultiplicity-1;
1120  // int neb= (NumberOfEls-ds)/2;
1121  // int nea= NumberOfEls-NumberOfBeta;
1122  ci_nca = ci_ncb = NFZC;
1123  std::vector<int> csfOccup;
1124  bool first = true;
1125  int cnt = 1, current = 0;
1126  int naea = 0, naeb = 0;
1127  std::string aline;
1128  while (current < ci_size)
1129  {
1130  if (is.eof())
1131  {
1132  std::cerr << "Problems reading DETERMINANT CONTRIBUTION TO CSF'S (2). \n";
1133  abort();
1134  }
1135  getwords(currentWords, is);
1136  getwords(currentWords, is);
1137  getwords(currentWords, is);
1138  // checking
1139  //if(currentWords[0] != "FOR" || currentWords[1] != "MS") {
1140  // std::cerr <<"Problems reading DETERMINANT CONTRIBUTION TO CSF'S (3). \n";
1141  // abort();
1142  //}
1143  getwords(currentWords, is, aline);
1144  if (aline.substr(1, 3) != "CSF")
1145  {
1146  std::cerr << "aline:" << aline << std::endl;
1147  std::cerr << "Problems reading DETERMINANT CONTRIBUTION TO CSF'S (4). \n";
1148  abort();
1149  }
1150  if (coeff2csf[current].first == cnt)
1151  // read dets
1152  {
1153  // first time the std::string is longer
1154  csfOccup.clear();
1155  {
1156  std::string alp(ci_nstates, '0'), beta(ci_nstates, '0');
1157  if (first)
1158  {
1159  first = false;
1160  int num = (aline.size() - 33) / 3;
1161  for (int i = 0; i < num; i++)
1162  {
1163  //int nq = atoi(currentWords[i].c_str());
1164  int nq = atoi(aline.substr(33 + i * 3, 3).c_str());
1165  csfOccup.push_back(nq);
1166  if (nq > 0)
1167  {
1168  if (nq - 1 >= ci_nstates + ci_nca)
1169  {
1170  std::cerr << "Problems with det std::string #,nq,i: " << cnt << " " << nq << " " << i << std::endl;
1171  std::cout << "line: " << aline << std::endl;
1172  std::cout << "alpha: " << alp << std::endl;
1173  std::cout << "beta: " << beta << std::endl;
1174  for (int i = 6; i < currentWords.size(); i++)
1175  std::cerr << currentWords[i] << " ";
1176  std::cerr << std::endl;
1177  abort();
1178  }
1179  alp.at(nq - 1 - ci_nca) = '1';
1180  naea++;
1181  }
1182  else
1183  {
1184  if (-nq - 1 >= ci_nstates + ci_ncb)
1185  {
1186  std::cerr << "Problems with det std::string #,nq,i: " << cnt << " " << nq << " " << i << std::endl;
1187  std::cout << "line: " << aline << std::endl;
1188  std::cout << "alpha: " << alp << std::endl;
1189  std::cout << "beta: " << beta << std::endl;
1190  for (int i = 6; i < currentWords.size(); i++)
1191  std::cerr << currentWords[i] << " ";
1192  std::cerr << std::endl;
1193  abort();
1194  }
1195  beta.at(-nq - 1 - ci_ncb) = '1';
1196  naeb++;
1197  }
1198  }
1199  }
1200  else
1201  {
1202  int na = 0, nb = 0;
1203  int num = (aline.size() - 33) / 3;
1204  for (int i = 0; i < num; i++)
1205  {
1206  //int nq = atoi(currentWords[i].c_str());
1207  int nq = atoi(aline.substr(33 + i * 3, 3).c_str());
1208  csfOccup.push_back(nq);
1209  if (nq > 0)
1210  {
1211  if (nq - 1 >= ci_nstates + ci_nca)
1212  {
1213  std::cerr << "Problems with det std::string #,nq,i: " << cnt << " " << nq << " " << i << std::endl;
1214  std::cout << "line: " << aline << std::endl;
1215  std::cout << "alpha: " << alp << std::endl;
1216  std::cout << "beta: " << beta << std::endl;
1217  for (int i = 6; i < currentWords.size(); i++)
1218  std::cerr << currentWords[i] << " ";
1219  std::cerr << std::endl;
1220  abort();
1221  }
1222  alp.at(nq - 1 - ci_nca) = '1';
1223  na++;
1224  }
1225  else
1226  {
1227  if (-nq - 1 >= ci_nstates + ci_ncb)
1228  {
1229  std::cerr << "Problems with det std::string #,nq,i: " << cnt << " " << nq << " " << i << std::endl;
1230  std::cout << "line: " << aline << std::endl;
1231  std::cout << "alpha: " << alp << std::endl;
1232  std::cout << "beta: " << beta << std::endl;
1233  for (int i = 6; i < currentWords.size(); i++)
1234  std::cerr << currentWords[i] << " ";
1235  std::cerr << std::endl;
1236  abort();
1237  }
1238  beta.at(-nq - 1 - ci_ncb) = '1';
1239  nb++;
1240  }
1241  }
1242  if (na != naea || nb != naeb)
1243  {
1244  std::cerr << "Problems with det std::string #: " << cnt << std::endl;
1245  std::cout << "line: " << aline << std::endl;
1246  std::cout << "alpha: " << alp << std::endl;
1247  std::cout << "beta: " << beta << std::endl;
1248  for (int i = 6; i < currentWords.size(); i++)
1249  std::cerr << currentWords[i] << " ";
1250  std::cerr << std::endl;
1251  abort();
1252  }
1253  }
1254  double sg = getCSFSign(csfOccup);
1255  CSFalpha[current].push_back(alp);
1256  CSFbeta[current].push_back(beta);
1257  //CSFexpansion[current].push_back(atof(currentWords[4].c_str())*sg);
1258  CSFexpansion[current].push_back(atof(aline.substr(20, 9).c_str()) * sg);
1259  getwords(currentWords, is, aline);
1260  }
1261  while (currentWords.size() != 0)
1262  {
1263  if (is.eof())
1264  {
1265  std::cerr << "Problems reading DETERMINANT CONTRIBUTION TO CSF'S (5). \n";
1266  abort();
1267  }
1268  if (currentWords[0] == "CASE" && currentWords[1] == "VECTOR")
1269  {
1270  cnt++;
1271  if (cnt < 10000000 && atoi(currentWords[2].c_str()) != cnt)
1272  {
1273  std::cerr << "Problems reading DETERMINANT CONTRIBUTION TO CSF'S (6). \n";
1274  abort();
1275  }
1276  break;
1277  }
1278  csfOccup.clear();
1279  std::string alp(ci_nstates, '0'), beta(ci_nstates, '0');
1280  int num = (aline.size() - 33) / 3;
1281  for (int i = 0; i < num; i++)
1282  {
1283  //int nq = atoi(currentWords[i].c_str());
1284  int nq = atoi(aline.substr(33 + i * 3, 3).c_str());
1285  csfOccup.push_back(nq);
1286  if (nq > 0)
1287  {
1288  if (nq - 1 >= ci_nstates + ci_nca)
1289  {
1290  std::cerr << "Problems with det std::string #,nq,i: " << cnt << " " << nq << " " << i << std::endl;
1291  std::cout << "line: " << aline << std::endl;
1292  std::cout << "alpha: " << alp << std::endl;
1293  std::cout << "beta: " << beta << std::endl;
1294  for (int i = 6; i < currentWords.size(); i++)
1295  std::cerr << currentWords[i] << " ";
1296  std::cerr << std::endl;
1297  abort();
1298  }
1299  alp.at(nq - 1 - ci_nca) = '1';
1300  }
1301  else
1302  {
1303  if (-nq - 1 >= ci_nstates + ci_ncb)
1304  {
1305  std::cerr << "Problems with det std::string #,nq,i: " << cnt << " " << nq << " " << i << std::endl;
1306  std::cout << "line: " << aline << std::endl;
1307  std::cout << "alpha: " << alp << std::endl;
1308  std::cout << "beta: " << beta << std::endl;
1309  for (int i = 6; i < currentWords.size(); i++)
1310  std::cerr << currentWords[i] << " ";
1311  std::cerr << std::endl;
1312  abort();
1313  }
1314  beta.at(-nq - 1 - ci_ncb) = '1';
1315  }
1316  }
1317  double sg = getCSFSign(csfOccup);
1318  CSFalpha[current].push_back(alp);
1319  CSFbeta[current].push_back(beta);
1320  //CSFexpansion[current].push_back(atof(currentWords[2].c_str())*sg);
1321  CSFexpansion[current].push_back(atof(aline.substr(20, 9).c_str()) * sg);
1322  getwords(currentWords, is, aline);
1323  }
1324  current++;
1325  }
1326  else
1327  // not interested in this CSF, so read until next
1328  {
1329  while (currentWords.size() != 0)
1330  {
1331  if (is.eof())
1332  {
1333  std::cerr << "Problems reading DETERMINANT CONTRIBUTION TO CSF'S (5). \n";
1334  abort();
1335  }
1336  if (currentWords[0] == "CASE" && currentWords[1] == "VECTOR")
1337  {
1338  cnt++;
1339  if (cnt < 10000000 && atoi(currentWords[2].c_str()) != cnt)
1340  {
1341  std::cerr << "Problems reading DETERMINANT CONTRIBUTION TO CSF'S (6). \n";
1342  abort();
1343  }
1344  break;
1345  }
1346  getwords(currentWords, is, aline);
1347  }
1348  }
1349  }
1350  std::cout << "Done reading csf expansion." << std::endl;
1351  std::cout.flush();
1352  ci_nea = 0;
1353  for (int i = 0; i < CSFalpha[0][0].size(); i++)
1354  if (CSFalpha[0][0].at(i) == '1')
1355  ci_nea++;
1356  ci_neb = 0;
1357  for (int i = 0; i < CSFbeta[0][0].size(); i++)
1358  if (CSFbeta[0][0].at(i) == '1')
1359  ci_neb++;
1360  // int ds=SpinMultiplicity-1;
1361  // int neb= (NumberOfEls-ds)/2;
1362  // int nea= NumberOfEls-NumberOfBeta;
1363  // ci_nca = nea-ci_nea;
1364  // ci_ncb = neb-ci_neb;
1365  /*
1366  std::cout <<"Summary. #ci: " <<ci_size << std::endl;
1367  for(int i=0; i<ci_size; i++) {
1368  std::cout <<"c: " <<coeff2csf[i].second << std::endl;
1369  for(int k=0; k<CSFexpansion[i].size(); k++)
1370  std::cout <<" " <<k <<" " <<CSFexpansion[i][k]
1371  <<" " <<CSFalpha[i][k]
1372  <<" " <<CSFbeta[i][k] << std::endl;
1373  }
1374  */
1375 }
std::vector< std::vector< double > > CSFexpansion
std::vector< std::string > currentWords
Definition: SimpleParser.h:49
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
std::streampos pivot_begin
std::vector< std::vector< std::string > > CSFbeta
std::vector< std::string > CSFocc
double getCSFSign(std::vector< int > &)
std::vector< std::pair< int, double > > coeff2csf
bool lookFor(std::istream &is, const std::string &keyword)
Definition: SimpleParser.h:130
int getwords(std::vector< std::string > &slist, std::istream &fp, std::string &aline)
std::vector< std::vector< std::string > > CSFalpha

◆ getCSFSign()

double getCSFSign ( std::vector< int > &  occ)

Definition at line 1567 of file GamesAsciiParser.cpp.

References qmcplusplus::n.

Referenced by getCSF().

1568 {
1569  // reference ordering is irrelevant as long as it is consistent
1570  // within all determinants.
1571  double res = 1.0;
1572  int n = occ.size();
1573  for (int i = 0; i < n; i++)
1574  for (int j = i + 1; j < n; j++)
1575  {
1576  if (occ[j] > occ[i])
1577  {
1578  res *= -1.0;
1579  double tmp = occ[i];
1580  occ[i] = occ[j];
1581  occ[j] = tmp;
1582  }
1583  }
1584  return res;
1585 }

◆ getGaussianCenters()

void getGaussianCenters ( std::istream &  is)

Definition at line 468 of file GamesAsciiParser.cpp.

References OhmmsAsciiParser::currentWords, QMCGaussianParserBase::debug, QMCGaussianParserBase::gBound, QMCGaussianParserBase::gC0, QMCGaussianParserBase::gC1, getwords(), QMCGaussianParserBase::gExp, QMCGaussianParserBase::gNumber, QMCGaussianParserBase::gShell, QMCGaussianParserBase::NumberOfAtoms, pivot_begin, and tags.

Referenced by parse().

469 {
470  gBound.resize(NumberOfAtoms + 1);
471  std::string aline;
472  std::map<std::string, int> basisDataMap;
473  int nUniqAt = 0;
474  for (int i = 0; i < NumberOfAtoms; i++)
475  {
476  std::map<std::string, int>::iterator it(basisDataMap.find(tags[i]));
477  if (it == basisDataMap.end())
478  {
479  basisDataMap[tags[i]] = nUniqAt++;
480  }
481  }
482 
483  std::vector<std::vector<double>> expo(nUniqAt), coef(nUniqAt), coef2(nUniqAt);
484  std::vector<int> nshll(nUniqAt, 0); //use this to
485  std::vector<std::vector<int>> ncoeffpershell(nUniqAt);
486  std::vector<std::vector<std::string>> shID(nUniqAt);
487  std::map<std::string, int> gsMap;
488  gsMap[std::string("S")] = 1;
489  gsMap[std::string("SP")] = 2;
490  gsMap[std::string("L")] = 2;
491  gsMap[std::string("P")] = 3;
492  gsMap[std::string("D")] = 4;
493  gsMap[std::string("F")] = 5;
494  gsMap[std::string("G")] = 6;
495  gsMap[std::string("H")] = 7;
496  gsMap[std::string("I")] = 8;
497  is.seekg(pivot_begin);
498  bool found = false;
499  while (!found)
500  {
501  if (is.eof())
502  {
503  std::cerr << "Problem with basis set data.\n";
504  abort();
505  }
506  getwords(currentWords, is);
507  if (currentWords.size() < 6)
508  continue;
509  if (currentWords[0] == "SHELL" && currentWords[1] == "TYPE" && currentWords[2] == "PRIMITIVE" &&
510  currentWords[3] == "EXPONENT" && currentWords[4] == "CONTRACTION" && currentWords[5] == "COEFFICIENT(S)")
511  found = true;
512  }
513 
514  getwords(currentWords, is); // empty line
515 
516  int currPos = -1;
517  while (true)
518  {
519  getwords(currentWords, is);
520  if (currentWords.empty())
521  continue;
522 
523  if (currentWords[0] == "TOTAL" && currentWords[1] == "NUMBER" && currentWords[2] == "OF" &&
524  currentWords[3] == "BASIS")
525  {
526  break;
527  }
528  if (currentWords.size() == 1) //found Species
529  {
530  std::map<std::string, int>::iterator it(basisDataMap.find(currentWords[0]));
531  if (it == basisDataMap.end())
532  {
533  std::cerr << "Error in parser.\n";
534  abort();
535  }
536  currPos = it->second;
537  bool newgroup = (nshll[currPos] == 0);
538  if (newgroup)
539  {
540  ncoeffpershell[currPos].clear();
541  ncoeffpershell[currPos].push_back(0);
542  shID[currPos].clear();
543  shID[currPos].push_back("NONE");
544  }
545 
546  getwords(currentWords, is); //empty line after species
547 
548  while (true)
549  {
550  std::streampos pivot = is.tellg();
551  getwords(currentWords, is);
552  if (currentWords.empty()) //empty line after the shell
553  {
554  if (newgroup)
555  {
556  nshll[currPos]++;
557  ncoeffpershell[currPos].push_back(0);
558  shID[currPos].push_back("NONE");
559  }
560  continue;
561  }
562  if (currentWords.size() == 1 || currentWords[0] == "TOTAL")
563  { //use the size and TOTAL to skip to the new group
564  is.seekg(pivot);
565  break;
566  }
567  else
568  {
569  if (newgroup)
570  {
571  expo[currPos].push_back(atof(currentWords[3].c_str()));
572  coef[currPos].push_back(atof(currentWords[4].c_str()));
573  ncoeffpershell[currPos][nshll[currPos]]++;
574  shID[currPos][nshll[currPos]] = currentWords[1];
575 
576  if (gsMap.find(currentWords[1]) == gsMap.end())
577  {
578  std::cerr << "Unhandled primitive type " << currentWords[1] << std::endl;
579  abort();
580  }
581  if (gsMap[currentWords[1]] == 2)
582  {
583  std::cerr << "Can't handle SP basis states yet. Fix later.\n";
584  abort();
585  }
586  if (gsMap[currentWords[1]] >= 9)
587  {
588  std::cerr << "Can't handle J basis states or higher yet. Fix later.\n";
589  abort();
590  }
591  if (debug)
592  {
593  std::cout << currPos << ":" << expo[currPos].back() << " " << coef[currPos].back() << " "
594  << ncoeffpershell[currPos][nshll[currPos]] << " " << shID[currPos][nshll[currPos]] << std::endl;
595  }
596  }
597  }
598  }
599  }
600  }
601 
602 
603  /*
604  getwords(currentWords,is); // tag of first atom
605  for(int i=0; i<nUniqAt-1; i++)
606  {
607  int currPos;
608  if(currentWords.size() == 0)
609  {
610  std::cerr <<"Error in parser.\n";
611  abort();
612  }
613  std::map<std::string,int>::iterator it(basisDataMap.find(currentWords[0]));
614  if(it == basisDataMap.end())
615  {
616  std::cerr <<"Error in parser.\n";
617  abort();
618  }
619  currPos=it->second;
620  getwords(currentWords,is); // empty line
621  nshll[currPos]=0;
622  ncoeffpershell[currPos].clear();
623  ncoeffpershell[currPos].push_back(0);
624  shID[currPos].clear();
625  shID[currPos].push_back("NONE");
626  while(true)
627  {
628  getwords(currentWords,is);
629  if(currentWords.size() == 0)
630  {
631  nshll[currPos]++;
632  ncoeffpershell[currPos].push_back(0);
633  shID[currPos].push_back("NONE");
634  continue;
635  }
636  if(basisDataMap.find(currentWords[0]) != basisDataMap.end())
637  break;
638  expo[currPos].push_back(atof(currentWords[3].c_str()));
639  coef[currPos].push_back(atof(currentWords[4].c_str()));
640  ncoeffpershell[currPos][nshll[currPos]]++;
641  shID[currPos][nshll[currPos]] = currentWords[1];
642  if(gsMap[currentWords[1]] == 2)
643  {
644  std::cerr <<"Can't handle SP basis states yet. Fix later.\n";
645  abort();
646  }
647  if(gsMap[currentWords[1]] >= 7)
648  {
649  std::cerr <<"Can't handle H basis states or higher yet. Fix later.\n";
650  abort();
651  }
652  }
653  }
654  {
655  // one last time
656  int currPos;
657  if(currentWords.size() == 0)
658  {
659  std::cerr <<"Error in parser.\n";
660  abort();
661  }
662  std::map<std::string,int>::iterator it(basisDataMap.find(currentWords[0]));
663  if(it == basisDataMap.end())
664  {
665  std::cerr <<"Error in parser.\n";
666  abort();
667  }
668  currPos=it->second;
669  getwords(currentWords,is); // empty line
670  nshll[currPos]=0;
671  ncoeffpershell[currPos].clear();
672  ncoeffpershell[currPos].push_back(0);
673  shID[currPos].clear();
674  shID[currPos].push_back("NONE");
675  while(true)
676  {
677  getwords(currentWords,is);
678  if(currentWords.size() == 0)
679  {
680  nshll[currPos]++;
681  ncoeffpershell[currPos].push_back(0.0);
682  shID[currPos].push_back("NONE");
683  continue;
684  }
685  if(currentWords[0] == "TOTAL" && currentWords[1] == "NUMBER" &&
686  currentWords[2] == "OF" && currentWords[3] == "BASIS")
687  {
688  ng=atoi(currentWords[7].c_str());
689  break;
690  }
691  expo[currPos].push_back(atof(currentWords[3].c_str()));
692  coef[currPos].push_back(atof(currentWords[4].c_str()));
693  ncoeffpershell[currPos][nshll[currPos]]++;
694  shID[currPos][nshll[currPos]] = currentWords[1];
695  if(gsMap[currentWords[1]] == 2)
696  {
697  std::cerr <<"Can't handle SP basis states yet. Fix later.\n";
698  abort();
699  }
700  }
701  }
702 */
703  gShell.clear();
704  gNumber.clear();
705  gExp.clear();
706  gC0.clear();
707  gC1.clear();
708  int gtot = 0;
709  for (int i = 0; i < NumberOfAtoms; i++)
710  {
711  std::map<std::string, int>::iterator it(basisDataMap.find(tags[i]));
712  if (it == basisDataMap.end())
713  {
714  std::cerr << "Error in parser.\n";
715  abort();
716  }
717  gBound[i] = gtot;
718  int indx = it->second;
719  gtot += nshll[indx];
720  for (int k = 0; k < nshll[indx]; k++)
721  gShell.push_back(gsMap[shID[indx][k]]);
722  for (int k = 0; k < nshll[indx]; k++)
723  gNumber.push_back(ncoeffpershell[indx][k]);
724  for (int k = 0; k < expo[indx].size(); k++)
725  gExp.push_back(expo[indx][k]);
726  for (int k = 0; k < coef[indx].size(); k++)
727  gC0.push_back(coef[indx][k]);
728  }
729  gBound[NumberOfAtoms] = gtot;
730 }
std::vector< std::string > currentWords
Definition: SimpleParser.h:49
std::streampos pivot_begin
std::vector< value_type > gC0
std::vector< value_type > gExp
std::vector< std::string > tags
std::vector< int > gNumber
int getwords(std::vector< std::string > &slist, std::istream &fp, std::string &aline)
std::vector< value_type > gC1

◆ getGeometry()

void getGeometry ( std::istream &  is)

Definition at line 296 of file GamesAsciiParser.cpp.

References QMCGaussianParserBase::AtomicNumberIndex, OhmmsAsciiParser::currentWords, BLAS::done, QMCGaussianParserBase::ECP, ParticleSet::getSpeciesSet(), getwords(), ParticleSet::GroupID, QMCGaussianParserBase::GroupName, QMCGaussianParserBase::IonChargeIndex, QMCGaussianParserBase::IonName, QMCGaussianParserBase::IonSystem, QMCGaussianParserBase::NumberOfAtoms, pivot_begin, ParticleSet::R, tags, and usingECP.

Referenced by parse().

297 {
298  //atomic numbers
299  std::vector<int> atomic_number, core;
300  std::vector<double> q, pos;
301  int natms = 0;
302  tags.clear();
303  is.seekg(pivot_begin);
304  //read atomic info
305  bool notfound = true;
306  do
307  {
308  if (is.eof())
309  {
310  std::cerr << "Could not find atomic coordinates. \n";
311  abort();
312  }
313  getwords(currentWords, is);
314  if (currentWords.size() < 4)
315  continue;
316  if (currentWords[0] == "ATOM" && currentWords[1] == "ATOMIC" && currentWords[2] == "COORDINATES" &&
317  currentWords[3] == "(BOHR)")
318  {
319  getwords(currentWords, is); // second header line
320  notfound = false;
321  getwords(currentWords, is);
322  while (currentWords.size() != 0)
323  {
324  if (currentWords[0] == "INTERNUCLEAR")
325  break;
326  natms++;
327  double z = atof(currentWords[1].c_str());
328  int zint = (int)z; // is this dangerous???
329  atomic_number.push_back(zint);
330  q.push_back(z); // if using ECPs, change below
331  tags.push_back(currentWords[0]);
332  pos.push_back(atof(currentWords[2].c_str()));
333  pos.push_back(atof(currentWords[3].c_str()));
334  pos.push_back(atof(currentWords[4].c_str()));
335  getwords(currentWords, is);
336  }
337  }
338  } while (notfound);
339  // effective charges are read from ECP section
340  if (natms != NumberOfAtoms)
341  {
342  std::cerr << "Could not find atomic coordinates for all atoms. \n";
343  abort();
344  }
345  // this is risky but works for now
346  is.seekg(pivot_begin);
347  notfound = true;
348  while (notfound)
349  {
350  if (is.eof())
351  {
352  std::cerr << "Problem looking for ECPs, this should not happen. Contact developers for help. \n";
353  abort();
354  }
355  getwords(currentWords, is);
356  // this should appear below the ECP section in the output file
357  // so use this to avoid going all the way to the bottom
358  if (currentWords.size() < 2)
359  continue;
360  if (currentWords[0] == "ECP" && currentWords[1] == "POTENTIALS")
361  // eureka!!!
362  {
363  usingECP = true;
364  ECP = true;
365  core.resize(NumberOfAtoms);
366  getwords(currentWords, is); // -------------
367  // this only works if all atoms have an ECP, fix later
368  // for(int i=0; i<NumberOfAtoms; i++) {
369  // fixing this problem
370  bool done = false;
371  while (!done)
372  {
373  if (is.eof())
374  {
375  std::cerr << "Found ECPs, but problem looking ZCORE data.\n";
376  abort();
377  }
378  getwords(currentWords, is);
379  if (currentWords.size() == 0)
380  continue;
381  if (currentWords.size() >= 4)
382  {
383  if (currentWords[0] == "THE" && currentWords[1] == "ECP" && currentWords[2] == "RUN" &&
384  currentWords[3] == "REMOVES")
385  {
386  done = true;
387  }
388  }
389  if (currentWords[0] == "PARAMETERS" && currentWords[1] == "FOR")
390  {
391  //done=true;
392  std::vector<std::string>::iterator it, it0;
393  it = find(currentWords.begin(), currentWords.end(), "ZCORE");
394  it0 = find(currentWords.begin(), currentWords.end(), "ATOM");
395  if (it0 == currentWords.end())
396  {
397  std::cerr << "Problem with ECP data. Didn't found ATOM tag\n";
398  std::cerr << is.rdbuf() << std::endl;
399  abort();
400  }
401  it0++;
402  int nq0 = atoi(it0->c_str()) - 1;
403  if (it != currentWords.end())
404  {
405  it++;
406  core[nq0] = atoi(it->c_str());
407  q[nq0] -= core[nq0];
408  std::cout << "Found ECP for atom " << nq0 << " with zcore " << core[nq0] << std::endl;
409  }
410  else
411  {
412  it = find(currentWords.begin(), currentWords.end(), "ATOM");
413  if (it == currentWords.end())
414  {
415  std::cerr << "Problem with ECP data. Didn't found ATOM tag\n";
416  std::cerr << "Atom: " << nq0 << std::endl;
417  abort();
418  }
419  std::vector<std::string>::iterator it2 = it;
420  it2++;
421  int nq = atoi(it2->c_str());
422  if (nq != nq0 + 1)
423  {
424  std::cerr << "Problem with ECP data. ID's don't agree\n";
425  std::cerr << "Atom: " << nq0 << std::endl;
426  abort();
427  }
428  it = find(it2, currentWords.end(), "ATOM");
429  if (it == currentWords.end())
430  {
431  std::cerr << "Problem with ECP data (2).\n";
432  std::cerr << "Atom: " << nq0 << std::endl;
433  abort();
434  }
435  nq = atoi((it + 1)->c_str());
436  core[nq0] = core[nq - 1];
437  q[nq0] -= core[nq0];
438  std::cout << "Found ECP for atom " << nq0 << " with zcore " << core[nq0] << std::endl;
439  }
440  }
441  }
442  notfound = false;
443  }
444  else
445  {
446  if (currentWords.size() < 3)
447  continue;
448  if (currentWords[0] == "1" && currentWords[1] == "ELECTRON" && currentWords[2] == "INTEGRALS")
449  break;
450  }
451  }
452  std::cout << "usingECP: " << (usingECP ? ("yes") : ("no")) << std::endl;
453  std::cout.flush();
454  SpeciesSet& species(IonSystem.getSpeciesSet());
455  for (int i = 0, ii = 0; i < NumberOfAtoms; i++)
456  {
457  IonSystem.R[i][0] = pos[ii++];
458  IonSystem.R[i][1] = pos[ii++];
459  IonSystem.R[i][2] = pos[ii++];
460  GroupName[i] = IonName[atomic_number[i]];
461  int speciesID = species.addSpecies(GroupName[i]);
462  IonSystem.GroupID[i] = speciesID;
463  species(AtomicNumberIndex, speciesID) = atomic_number[i];
464  species(IonChargeIndex, speciesID) = q[i];
465  }
466 }
std::vector< std::string > currentWords
Definition: SimpleParser.h:49
std::streampos pivot_begin
std::vector< std::string > GroupName
ParticleIndex GroupID
Species ID.
Definition: ParticleSet.h:77
ParticlePos R
Position.
Definition: ParticleSet.h:79
static std::map< int, std::string > IonName
std::vector< std::string > tags
SpeciesSet & getSpeciesSet()
retrun the SpeciesSet of this particle set
Definition: ParticleSet.h:231
constexpr double done
Definition: BLAS.hpp:48
Custom container for set of attributes for a set of species.
Definition: SpeciesSet.h:33
int getwords(std::vector< std::string > &slist, std::istream &fp, std::string &aline)

◆ getMO()

void getMO ( std::istream &  is)

Definition at line 732 of file GamesAsciiParser.cpp.

References OhmmsAsciiParser::currentWords, QMCGaussianParserBase::EigVal_alpha, QMCGaussianParserBase::EigVal_beta, QMCGaussianParserBase::EigVec, getMO_single_set(), getwords(), QMCGaussianParserBase::numMO, readtype, OhmmsAsciiParser::search(), QMCGaussianParserBase::SizeOfBasisSet, and QMCGaussianParserBase::SpinRestricted.

Referenced by parse().

733 {
734  EigVal_alpha.resize(numMO);
735  EigVal_beta.resize(numMO);
736  EigVec.resize(2 * SizeOfBasisSet * numMO);
737  std::string aline;
738  //if(MOtype == "Canonical")
739  // search(is," EIGENVECTORS");
740  //else if(MOtype == "NaturalOrbitals") {
741  // if(readtype==1)
742  // search(is,"NATURAL ORBITALS IN ATOMIC ORBITAL BASIS"); // ci
743  // else if(readtype == 2)
744  // search(is,"MCSCF NATURAL ORBITALS"); // mcscf
745  //}
746  getwords(currentWords, is); // ----------------------
747  getwords(currentWords, is); // empty line
748  std::vector<double> dummy(50);
750  std::streampos pivot;
751  pivot = is.tellg();
752  std::vector<std::string> CartLabels(SizeOfBasisSet);
753  // this is not the best way, you should use the basis type (e.g. S,P,D,etc) to do this
754  getwords(currentWords, is);
755  getwords(currentWords, is);
756  getwords(currentWords, is);
757  if (readtype == 2)
758  getwords(currentWords, is);
759  for (int k = 0; k < SizeOfBasisSet; k++)
760  {
761  getwords(currentWords, is);
762  if (currentWords.size() == 8)
763  {
764  CartLabels[k] = currentWords[2];
765  CartLabels[k].erase(0, 1); // remove
766  }
767  else
768  {
769  CartLabels[k] = currentWords[3];
770  }
771  //cout<<"label: " <<k <<" " <<CartLabels[k] << std::endl; std::cout.flush();
772  }
773 
774  is.seekg(pivot);
775  getMO_single_set(is, CartMat, EigVal_alpha);
776  int cnt = 0;
777  for (int i = 0; i < numMO; i++)
778  for (int k = 0; k < SizeOfBasisSet; k++)
779  EigVec[cnt++] = CartMat[i][k];
780 
781  // beta states for now
782  if (!SpinRestricted)
783  {
784  search(is, " EIGENVECTORS");
785  getwords(currentWords, is); // ----------------------
786  getwords(currentWords, is); // empty line
787  getMO_single_set(is, CartMat, EigVal_beta);
788  }
789 
790  for (int i = 0; i < numMO; i++)
791  for (int k = 0; k < SizeOfBasisSet; k++)
792  EigVec[cnt++] = CartMat[i][k];
793  std::cout << "Finished reading MO." << std::endl;
794 }
std::vector< value_type > EigVal_beta
std::vector< std::string > currentWords
Definition: SimpleParser.h:49
void getMO_single_set(std::istream &is, Matrix< double > &CartMat, std::vector< value_type > &EigVal_alpha)
std::vector< value_type > EigVal_alpha
std::vector< value_type > EigVec
int search(std::istream &is, const std::string &keyword)
Definition: SimpleParser.h:89
int getwords(std::vector< std::string > &slist, std::istream &fp, std::string &aline)

◆ getMO_single_set()

void getMO_single_set ( std::istream &  is,
Matrix< double > &  CartMat,
std::vector< value_type > &  EigVal_alpha 
)

Definition at line 796 of file GamesAsciiParser.cpp.

References OhmmsAsciiParser::currentWords, getwords(), getwordsWithMergedNumbers(), QMCGaussianParserBase::numMO, readtype, and QMCGaussianParserBase::SizeOfBasisSet.

Referenced by getMO().

797 {
798  int nq = numMO / 5;
799  int rem = numMO % 5;
800  int cnt = 0;
801  for (int i = 0; i < nq; i++)
802  {
803  getwords(currentWords, is);
804  if (readtype == 2)
805  getwords(currentWords, is);
806  getwords(currentWords, is);
807  EigVal[cnt] = atof(currentWords[0].c_str());
808  EigVal[cnt + 1] = atof(currentWords[1].c_str());
809  EigVal[cnt + 2] = atof(currentWords[2].c_str());
810  EigVal[cnt + 3] = atof(currentWords[3].c_str());
811  EigVal[cnt + 4] = atof(currentWords[4].c_str());
812  getwords(currentWords, is);
813  for (int k = 0; k < SizeOfBasisSet; k++)
814  {
816  //cout<<"i,k,size: " <<i <<" " <<k <<" " <<currentWords.size() <<" " <<currentWords[4] << std::endl;
817  if (currentWords.size() == 8)
818  // G basis or higher TAG gets mixed with atom id
819  {
820  CartMat[cnt][k] = atof(currentWords[3].c_str());
821  CartMat[cnt + 1][k] = atof(currentWords[4].c_str());
822  CartMat[cnt + 2][k] = atof(currentWords[5].c_str());
823  CartMat[cnt + 3][k] = atof(currentWords[6].c_str());
824  CartMat[cnt + 4][k] = atof(currentWords[7].c_str());
825  }
826  else if (currentWords.size() == 7)
827  // I basis TAG gets mixed with atom name
828  {
829  CartMat[cnt][k] = atof(currentWords[2].c_str());
830  CartMat[cnt + 1][k] = atof(currentWords[3].c_str());
831  CartMat[cnt + 2][k] = atof(currentWords[4].c_str());
832  CartMat[cnt + 3][k] = atof(currentWords[5].c_str());
833  CartMat[cnt + 4][k] = atof(currentWords[6].c_str());
834  }
835  else
836  {
837  CartMat[cnt][k] = atof(currentWords[4].c_str());
838  CartMat[cnt + 1][k] = atof(currentWords[5].c_str());
839  CartMat[cnt + 2][k] = atof(currentWords[6].c_str());
840  CartMat[cnt + 3][k] = atof(currentWords[7].c_str());
841  CartMat[cnt + 4][k] = atof(currentWords[8].c_str());
842  }
843  }
844  getwords(currentWords, is);
845  cnt += 5;
846  //cout<<"cnt: " <<cnt << std::endl; std::cout.flush();
847  }
848  //cout<<"done with main block, reading rem: " <<rem << std::endl; std::cout.flush();
849  if (rem > 0)
850  {
851  getwords(currentWords, is);
852  if (readtype == 2)
853  getwords(currentWords, is);
854  getwords(currentWords, is);
855  for (int i = 0; i < rem; i++)
856  {
857  EigVal[cnt + i] = atof(currentWords[i].c_str());
858  }
859  getwords(currentWords, is);
860  for (int k = 0; k < SizeOfBasisSet; k++)
861  {
863  if (currentWords.size() == 3 + rem)
864  // G basis or higher TAG gets mixed with atom id
865  {
866  for (int i = 0; i < rem; i++)
867  {
868  CartMat[cnt + i][k] = atof(currentWords[3 + i].c_str());
869  }
870  }
871  else if (currentWords.size() == 2 + rem)
872  // I basis TAG gets mixed with atom name
873  {
874  for (int i = 0; i < rem; i++)
875  {
876  CartMat[cnt + i][k] = atof(currentWords[2 + i].c_str());
877  }
878  }
879  else
880  {
881  for (int i = 0; i < rem; i++)
882  {
883  CartMat[cnt + i][k] = atof(currentWords[4 + i].c_str());
884  }
885  }
886  }
887  getwords(currentWords, is);
888  }
889  //cout<<"done with rem block, writing eigV: " << std::endl; std::cout.flush();
890 }
std::vector< std::string > currentWords
Definition: SimpleParser.h:49
int getwordsWithMergedNumbers(std::vector< std::string > &slist, std::istream &fp, int dummy, const std::string &extra_tokens)
int getwords(std::vector< std::string > &slist, std::istream &fp, std::string &aline)

◆ getORMAS()

void getORMAS ( std::istream &  is)

Definition at line 1456 of file GamesAsciiParser.cpp.

References qmcplusplus::abs(), QMCGaussianParserBase::ci_nca, QMCGaussianParserBase::ci_ncb, QMCGaussianParserBase::ci_nea, QMCGaussianParserBase::ci_neb, QMCGaussianParserBase::ci_nstates, QMCGaussianParserBase::ci_size, QMCGaussianParserBase::ci_threshold, QMCGaussianParserBase::CIalpha, QMCGaussianParserBase::CIbeta, QMCGaussianParserBase::CIcoeff, OhmmsAsciiParser::currentWords, getwords(), OhmmsAsciiParser::lookFor(), QMCGaussianParserBase::NumberOfBeta, QMCGaussianParserBase::NumberOfEls, parsewords(), pivot_begin, and QMCGaussianParserBase::SpinMultiplicity.

Referenced by parse().

1457 {
1458  is.seekg(pivot_begin);
1459  //look for CI coefficients
1460  bool notfound = true;
1461  ci_size = 0;
1462  CIcoeff.clear();
1463  CIalpha.clear();
1464  CIbeta.clear();
1465  std::string aline;
1466  if (!lookFor(is, "NUMBER OF CORE ORBITALS", aline))
1467  {
1468  std::cerr << "Couldn't find # of CORE ORBITALS in ORMAS.\n";
1469  abort();
1470  }
1471  parsewords(aline.c_str(), currentWords);
1472  ci_nca = ci_ncb = atoi(currentWords[4].c_str());
1473  if (!lookFor(is, "NUMBER OF ACTIVE ORBITALS", aline))
1474  {
1475  std::cerr << "Couldn't find # of ACTIVE ORBITALS in ORMAS.\n";
1476  abort();
1477  }
1478  parsewords(aline.c_str(), currentWords);
1479  int nactive(atoi(currentWords[4].c_str()));
1480  if (!lookFor(is, "NUMBER OF ALPHA ELECTRONS", aline))
1481  {
1482  std::cerr << "Couldn't find # of ALPHA ELECTRONS in ORMAS.\n";
1483  abort();
1484  }
1485  parsewords(aline.c_str(), currentWords);
1486  //ci_nea = atoi(currentWords[4].c_str());
1487  ci_nea = atoi(currentWords[6].c_str());
1488  if (!lookFor(is, "NUMBER OF BETA ELECTRONS", aline))
1489  {
1490  std::cerr << "Couldn't find # of BETA ELECTRONS in ORMAS.\n";
1491  abort();
1492  }
1493  parsewords(aline.c_str(), currentWords);
1494  //ci_neb = atoi(currentWords[4].c_str());
1495  ci_neb = atoi(currentWords[6].c_str());
1496  std::cout << "ORMAS: nea,neb,ncore,nact: " << ci_nea << " " << ci_neb << " " << ci_nca << " " << nactive << "\n";
1497  int ds = SpinMultiplicity - 1;
1498  int neb = (NumberOfEls - ds) / 2;
1499  int nea = NumberOfEls - NumberOfBeta;
1500  if (ci_nca != nea - ci_nea)
1501  {
1502  std::cerr << "Inconsistent number of core electrons: " << ci_nca << " " << nea - ci_nea << std::endl;
1503  abort();
1504  }
1505  if (ci_ncb != neb - ci_neb)
1506  {
1507  std::cerr << "Inconsistent number of core electrons: " << ci_ncb << " " << neb - ci_neb << std::endl;
1508  abort();
1509  }
1510  std::string dummy_alpha(nactive, '0');
1511  std::string dummy_beta(nactive, '0');
1512  int nskip = ci_nea + ci_neb + 2;
1513  do
1514  {
1515  if (is.eof())
1516  {
1517  std::cerr << "Could not find ORMAS CI expansion. \n";
1518  abort();
1519  }
1520  getwords(currentWords, is);
1521  if (currentWords.size() < 5)
1522  continue;
1523  if (currentWords[0] == "ALPHA" && currentWords[2] == "BETA" && currentWords[4] == "COEFFICIENT")
1524  {
1525  getwords(currentWords, is); // 1 2
1526  getwords(currentWords, is); // --------
1527  notfound = false;
1528  getwords(currentWords, is);
1529  while (currentWords.size() != 0)
1530  {
1531  if (currentWords[0] == "....." || currentWords[1] == "DONE")
1532  break;
1533  double cof = atof(currentWords[nskip].c_str());
1534  if (std::abs(cof) > ci_threshold)
1535  {
1536  ci_size++;
1537  CIcoeff.push_back(cof);
1538  CIalpha.push_back(dummy_alpha);
1539  CIbeta.push_back(dummy_beta);
1540  for (int i = 0; i < ci_nea; i++)
1541  (CIalpha.back())[atoi(currentWords[i].c_str()) - 1] = '1';
1542  for (int i = 0; i < ci_neb; i++)
1543  (CIbeta.back())[atoi(currentWords[ci_nea + 1 + i].c_str()) - 1] = '1';
1544  }
1545  getwords(currentWords, is);
1546  }
1547  }
1548  } while (notfound);
1549  ci_nstates = 0;
1550  for (int i = 0; i < ci_size; i++)
1551  {
1552  int max = 0; //=nactive;
1553  for (int k = nactive - 1; k >= 0; k--)
1554  {
1555  if (CIalpha[i][k] == '1' || CIbeta[i][k] == '1')
1556  {
1557  max = k + 1;
1558  break;
1559  }
1560  }
1561  //cout<<i <<" " <<max << std::endl;
1562  if (ci_nstates < max)
1563  ci_nstates = max;
1564  }
1565 }
std::vector< std::string > currentWords
Definition: SimpleParser.h:49
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
std::streampos pivot_begin
std::vector< double > CIcoeff
unsigned parsewords(const char *inbuf, std::vector< std::string > &slist, const std::string &extra_tokens)
std::vector< std::string > CIalpha
bool lookFor(std::istream &is, const std::string &keyword)
Definition: SimpleParser.h:130
int getwords(std::vector< std::string > &slist, std::istream &fp, std::string &aline)
std::vector< std::string > CIbeta

◆ parse()

void parse ( const std::string &  fname)
overridevirtual

Implements QMCGaussianParserBase.

Definition at line 56 of file GamesAsciiParser.cpp.

References ParticleSet::create(), OhmmsAsciiParser::currentWords, QMCGaussianParserBase::ECP, getCI(), getCSF(), getGaussianCenters(), getGeometry(), getMO(), getORMAS(), QMCGaussianParserBase::GroupName, QMCGaussianParserBase::IonSystem, OhmmsAsciiParser::lookFor(), MOtype, QMCGaussianParserBase::multideterminant, NAC, NEXT, NFZC, NTOT, QMCGaussianParserBase::NumberOfAlpha, QMCGaussianParserBase::NumberOfAtoms, QMCGaussianParserBase::NumberOfBeta, QMCGaussianParserBase::NumberOfEls, QMCGaussianParserBase::numMO, QMCGaussianParserBase::numMO2print, QMCGaussianParserBase::outputFile, parsewords(), pivot_begin, QMCGaussianParserBase::readGuess, QMCGaussianParserBase::readNO, readtype, OhmmsAsciiParser::search(), QMCGaussianParserBase::SizeOfBasisSet, QMCGaussianParserBase::SpinMultiplicity, QMCGaussianParserBase::SpinRestricted, and usingECP.

57 {
58  std::ifstream fin(fname.c_str());
59  if (fin.fail())
60  {
61  std::cerr << "Error when opening file: " << fname << std::endl;
62  abort();
63  }
64  pivot_begin = fin.tellg();
65  std::string aline;
66  // if basis functions are removed, this will be modified below
67  search(fin, "NUMBER OF CARTESIAN GAUSSIAN BASIS FUNCTIONS", aline);
68  parsewords(aline.c_str(), currentWords);
69  SizeOfBasisSet = atoi(currentWords[6].c_str());
70  search(fin, "SPIN MULTIPLICITY", aline);
71  parsewords(aline.c_str(), currentWords);
72  SpinMultiplicity = atoi(currentWords[2].c_str());
73  std::cout << "SPIN MULTIPLICITY: " << SpinMultiplicity << std::endl;
74  search(fin, "TOTAL NUMBER OF ATOMS", aline);
75  parsewords(aline.c_str(), currentWords);
76  NumberOfAtoms = atoi(currentWords[4].c_str());
77  std::cout << "NUMBER OF ATOMS: " << NumberOfAtoms << std::endl;
78  if (lookFor(fin, "SCFTYP=UHF", aline))
79  {
80  SpinRestricted = false;
81  std::cout << "Spin Unrestricted MOs" << std::endl;
82  }
83  else
84  {
85  std::cout << "Spin Restricted MOs" << std::endl;
86  }
87  if (lookFor(fin, "TOTAL NUMBER OF MOS IN VARIATION SPACE=", aline))
88  {
89  parsewords(aline.c_str(), currentWords);
90  numMO = atoi(currentWords[7].c_str());
91  std::cout << "NUMBER OF MOs: " << numMO << std::endl;
92  }
93  else
94  {
95  fin.close();
96  fin.open(fname.c_str());
97  pivot_begin = fin.tellg();
98  if (lookFor(fin, "SET, THE NUMBER OF SPHERICAL HARMONICS KEPT IN THE VARIATION SPACE IS", aline))
99  {
100  parsewords(aline.c_str(), currentWords);
101  numMO = atoi(currentWords[12].c_str());
102  std::cout << "NUMBER OF MOs: " << numMO << std::endl;
103  }
104  else
105  {
106  fin.close();
107  fin.open(fname.c_str());
108  pivot_begin = fin.tellg();
109  std::cout << "Didn't find reduction of variational space, assuming cartesian number of MO's. \n";
111  //abort();
112  }
113  }
114  if (numMO2print <= 0)
115  numMO2print = numMO;
117  GroupName.resize(NumberOfAtoms);
118  getGeometry(fin);
119  fin.seekg(pivot_begin);
120  if (usingECP)
121  {
122  std::cout << "Using ECP." << std::endl;
123  ECP = true;
124  search(fin, "NUMBER OF ELECTRONS KEPT IN THE CALCULATION IS", aline);
125  parsewords(aline.c_str(), currentWords);
126  NumberOfEls = atoi(currentWords[8].c_str());
127  std::cout << "Number of electrons: " << NumberOfEls << std::endl;
128  std::cout.flush();
129  search(fin, "NUMBER OF OCCUPIED ORBITALS (ALPHA) KEPT IS", aline);
130  parsewords(aline.c_str(), currentWords);
131  NumberOfAlpha = atoi(currentWords[7].c_str());
132  std::cout << "Number of alpha electrons: " << NumberOfAlpha << std::endl;
133  search(fin, "NUMBER OF OCCUPIED ORBITALS (BETA ) KEPT IS", aline);
134  parsewords(aline.c_str(), currentWords);
135  NumberOfBeta = atoi(currentWords[8].c_str());
136  std::cout << "Number of beta electrons: " << NumberOfBeta << std::endl;
137  }
138  else
139  {
140  search(fin, "NUMBER OF ELECTRONS ", aline);
141  parsewords(aline.c_str(), currentWords);
142  NumberOfEls = atoi(currentWords[3].c_str());
143  std::cout << "Number of electrons: " << NumberOfEls << std::endl;
144  search(fin, "NUMBER OF OCCUPIED ORBITALS (ALPHA)", aline);
145  parsewords(aline.c_str(), currentWords);
146  NumberOfAlpha = atoi(currentWords[5].c_str());
147  std::cout << "Number of alpha electrons: " << NumberOfAlpha << std::endl;
148  search(fin, "NUMBER OF OCCUPIED ORBITALS (BETA )", aline);
149  parsewords(aline.c_str(), currentWords);
150  NumberOfBeta = atoi(currentWords[6].c_str());
151  std::cout << "Number of beta electrons: " << NumberOfBeta << std::endl;
152  }
153  getGaussianCenters(fin);
154  fin.seekg(pivot_begin);
155  if (readNO > 0)
156  // look for natural orbitals
157  {
158  // output from ALDET and GUGA CI
159  std::cout << "Reading " << readNO << " orbitals from file.\n";
160  numMO = readNO;
161  if (lookFor(fin, "NATURAL ORBITALS IN ATOMIC ORBITAL BASIS"))
162  {
163  MOtype = "NaturalOrbitals";
164  readtype = 1;
165  std::cout << "Reading Natural Orbitals from ALDET/GUGA/FSOCI run output. \n";
166  }
167  else
168  {
169  fin.close();
170  fin.open(fname.c_str());
171  // output from MCSCF run
172  if (lookFor(fin, "MCSCF NATURAL ORBITALS"))
173  {
174  MOtype = "NaturalOrbitals";
175  readtype = 2;
176  std::cout << "Reading Natural Orbitals from MCSCF run output. \n";
177  }
178  else
179  {
180  std::cerr << "Could not find Natural Orbitals. \n";
181  abort();
182  }
183  }
184  }
185  else if (readGuess > 0)
186  {
187  std::cout << "Reading " << readGuess << " orbitals from file.\n";
188  numMO = readGuess;
189  if (lookFor(fin, " INITIAL GUESS ORBITALS"))
190  {
191  MOtype = "InitialGuess";
192  readtype = 0;
193  std::cout << "Reading INITIAL GUESS ORBITALS output. \n";
194  }
195  else
196  {
197  std::cerr << "Could not find INITIAL GUESS ORBITALS. \n";
198  abort();
199  }
200  }
201  else
202  // look for eigenvectors
203  {
204  if (lookFor(fin, " EIGENVECTORS"))
205  {
206  MOtype = "Canonical";
207  readtype = 0;
208  numMO = numMO2print;
209  std::cout << "Reading RHF Canonical Orbitals from Gamess output. \n";
210  }
211  else
212  {
213  fin.close();
214  fin.open(fname.c_str());
215  // output
216  if (lookFor(fin, "MCSCF OPTIMIZED ORBITALS"))
217  {
218  MOtype = "Canonical";
219  readtype = 0;
220  numMO = numMO2print;
221  std::cout << "Reading Optimized Orbitals from MCSCF run output. \n";
222  }
223  else
224  {
225  std::cerr << "Could not find eigenstates. \n";
226  abort();
227  }
228  }
229  }
230  // fin.close(); fin.open(fname.c_str());
231  getMO(fin);
232  fin.close();
233  // using a possibly different output file for ci coefficients
234  if (multideterminant)
235  {
236  fin.open(outputFile.c_str());
237  if (fin.fail())
238  {
239  std::cerr << "Error when opening file: " << outputFile << std::endl;
240  abort();
241  }
242  pivot_begin = fin.tellg();
243  //cout<<"looking for dets " << std::endl;
244  //cout.flush();
245  if (lookFor(fin, "GUGA DISTINCT ROW TABLE"))
246  {
247  std::cout << "Found GUGA ROW TABLE, reading CSF." << std::endl;
248  //cout.flush();
249  if (!lookFor(fin, "SYMMETRIES FOR THE", aline))
250  {
251  std::cerr << "Could not find number of frozen core orbitals in output file.\n";
252  abort();
253  }
254  else
255  {
256  NFZC = atoi(aline.substr(20, 3).c_str());
257  NAC = atoi(aline.substr(30, 3).c_str());
258  NEXT = atoi(aline.substr(42, 3).c_str());
259  NTOT = NEXT + NAC;
260  std::cout << "# core, #active, #external: " << NFZC << " " << NAC << " " << NEXT << std::endl;
261  }
262  //cout.flush();
263  fin.seekg(pivot_begin);
264  getCSF(fin);
265  }
266  else
267  {
268  std::cout << "Could not find GUGA ROW TABLE, looking for Slater Dets." << std::endl;
269  //cout.flush();
270  fin.close();
271  fin.open(outputFile.c_str());
272  pivot_begin = fin.tellg();
273  if (lookFor(fin, "DIRECT DETERMINANT ORMAS-CI"))
274  {
275  std::cout << "Found ORMAS-CI" << std::endl;
276  //cout.flush();
277  fin.close();
278  fin.open(outputFile.c_str());
279  pivot_begin = fin.tellg();
280  getORMAS(fin);
281  }
282  else
283  {
284  std::cout << "Assuming ALDET-CI" << std::endl;
285  //cout.flush();
286  fin.close();
287  fin.open(outputFile.c_str());
288  pivot_begin = fin.tellg();
289  getCI(fin);
290  }
291  }
292  fin.close();
293  }
294 }
void getCI(std::istream &is)
std::vector< std::string > currentWords
Definition: SimpleParser.h:49
void getCSF(std::istream &is)
void getMO(std::istream &is)
std::streampos pivot_begin
std::vector< std::string > GroupName
unsigned parsewords(const char *inbuf, std::vector< std::string > &slist, const std::string &extra_tokens)
int search(std::istream &is, const std::string &keyword)
Definition: SimpleParser.h:89
void getGaussianCenters(std::istream &is)
void create(const std::vector< int > &agroup)
create grouped particles
void getORMAS(std::istream &is)
bool lookFor(std::istream &is, const std::string &keyword)
Definition: SimpleParser.h:130
void getGeometry(std::istream &is)
std::string MOtype

Member Data Documentation

◆ MOtype

std::string MOtype

Definition at line 37 of file GamesAsciiParser.h.

Referenced by GamesAsciiParser(), and parse().

◆ NAC

int NAC

Definition at line 40 of file GamesAsciiParser.h.

Referenced by parse().

◆ NEXT

int NEXT

Definition at line 40 of file GamesAsciiParser.h.

Referenced by parse().

◆ NFZC

int NFZC

Definition at line 40 of file GamesAsciiParser.h.

Referenced by GamesAsciiParser(), getCSF(), and parse().

◆ NTOT

int NTOT

Definition at line 40 of file GamesAsciiParser.h.

Referenced by getCSF(), and parse().

◆ pivot_begin

std::streampos pivot_begin

Definition at line 34 of file GamesAsciiParser.h.

Referenced by getCI(), getCSF(), getGaussianCenters(), getGeometry(), getORMAS(), and parse().

◆ readtype

int readtype

Definition at line 39 of file GamesAsciiParser.h.

Referenced by GamesAsciiParser(), getMO(), getMO_single_set(), and parse().

◆ tags

std::vector<std::string> tags

Definition at line 35 of file GamesAsciiParser.h.

Referenced by getGaussianCenters(), and getGeometry().

◆ usingECP

bool usingECP

Definition at line 36 of file GamesAsciiParser.h.

Referenced by GamesAsciiParser(), getGeometry(), and parse().


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