diff --git a/src/QMCTools/CMakeLists.txt b/src/QMCTools/CMakeLists.txt index 37d02e25d..60bfa315b 100644 --- a/src/QMCTools/CMakeLists.txt +++ b/src/QMCTools/CMakeLists.txt @@ -21,6 +21,7 @@ SET(MOSRCS BMakeFunc.cpp GamesFMOParser.cpp VSVBParser.cpp + QPParser.cpp ) # create libmocommon diff --git a/src/QMCTools/GamesFMOParser.cpp b/src/QMCTools/GamesFMOParser.cpp index f56fba28c..2ad8632f9 100644 --- a/src/QMCTools/GamesFMOParser.cpp +++ b/src/QMCTools/GamesFMOParser.cpp @@ -20,13 +20,12 @@ GamesFMOParser::GamesFMOParser() basisName = "Gaussian-G2"; Normalized = "no"; Mono=false; - BohrUnit=false; + BohrUnit=true; MOtype="Canonical"; angular_type="cartesian"; readtype=0; psi_tag="psi0"; ion_tag="ion0"; - SpinMultiplicity = 1; SpinRestricted=true; TotNumAtom=0; NumMonomer=0; @@ -35,7 +34,7 @@ GamesFMOParser::GamesFMOParser() FMOMethod=0; FMO=true; MonomerID=0; - + FixValence=true; } GamesFMOParser::GamesFMOParser(int argc, char** argv): @@ -44,13 +43,12 @@ GamesFMOParser::GamesFMOParser(int argc, char** argv): basisName = "Gaussian-G2"; Normalized = "no"; Mono=false; - BohrUnit=false; + BohrUnit=true; MOtype="Canonical"; angular_type="cartesian"; readtype=0; psi_tag="psi0"; ion_tag="ion0"; - SpinMultiplicity = 1; SpinRestricted=true; TotNumAtom=0; NumMonomer=0; @@ -59,6 +57,7 @@ GamesFMOParser::GamesFMOParser(int argc, char** argv): FMOMethod=0; FMO=true; MonomerID=0; + FixValence=true; } @@ -79,6 +78,10 @@ void GamesFMOParser::parse(const std::string& fname) fin.seekg(pivot_begin); + search(fin,"NUMBER OF CARTESIAN GAUSSIAN BASIS FUNCTIONS",aline); + parsewords(aline.c_str(),currentWords); + SizeOfBasisSet = atoi(currentWords[6].c_str()); + search(fin,"TOTAL NUMBER OF ATOMS",aline); parsewords(aline.c_str(),currentWords); TotNumAtom = atoi(currentWords[4].c_str()); @@ -110,6 +113,7 @@ void GamesFMOParser::parse(const std::string& fname) readtype=0; TotNumMonomer=NumMonomer; + IDMonomer = new string[NumMonomer]; @@ -132,6 +136,7 @@ void GamesFMOParser::parse(const std::string& fname) pivot= fin.tellg(); for(int i=0;i atomic_number,core; vector q,pos; int natms=0; @@ -418,18 +453,20 @@ void GamesFMOParser::getGeometry(std::istream& is) currentWords[2] == "X" ) { getwords(currentWords,is); - while(currentWords[0] != "------------------------------------------------------------") + while(currentWords[0]!="------------------------------------------------------------") { natms++; double z=atof(currentWords[1].c_str()); int zint = (int)z; // is this dangerous??? atomic_number.push_back(zint); - q.push_back(z); // if using ECPs, change below + q.push_back(z); tags.push_back(currentWords[0]); pos.push_back(atof(currentWords[2].c_str())); pos.push_back(atof(currentWords[3].c_str())); pos.push_back(atof(currentWords[4].c_str())); + //cout<<"Atom number "< basisDataMap; int nUniqAt=0; @@ -511,16 +551,20 @@ void GamesFMOParser::getGaussianCenters(std::istream& is) found=true; } - getwords(currentWords,is); // empty line int currPos=-1; + + while(true) { getwords(currentWords,is); + if(currentWords.empty()) continue; - if(currentWords[0] == "------------------------------------------------------------") + if(currentWords[0] == "TOTAL" && currentWords[1] == "NUMBER" && + currentWords[2] == "OF" && currentWords[3] == "BASIS") { + ng=atoi(currentWords.back().c_str()); break; } if(currentWords.size() == 1) //found Species @@ -570,6 +614,7 @@ void GamesFMOParser::getGaussianCenters(std::istream& is) coef[currPos].push_back(atof(currentWords[4].c_str())); ncoeffpershell[currPos][nshll[currPos]]++; shID[currPos][nshll[currPos]] = currentWords[1]; + if(gsMap[currentWords[1]] == 2) { cerr<<"Can't handle SP basis states yet. Fix later.\n"; @@ -616,7 +661,7 @@ void GamesFMOParser::getGaussianCenters(std::istream& is) gC0.push_back(coef[indx][k]); } gBound[NumberOfAtoms] = gtot; - ng=gShell.size(); +// ng=gShell.size(); } @@ -630,7 +675,8 @@ void GamesFMOParser::getMO(std::istream& is,std::string temp_tag) for(int i=0;i +#include +#include +#include +#include + +using namespace std; + + +QPParser::QPParser() +{ + basisName = "Gaussian-G2"; + Normalized = "no"; + usingECP=false; + BohrUnit=true; + MOtype="Canonical"; + angular_type="cartesian"; + readtype=0; + NFZC=0; + numAO=0; + FixValence=true; + +} + +QPParser::QPParser(int argc, char** argv): + QMCGaussianParserBase(argc,argv) +{ + basisName = "Gaussian-G2"; + Normalized = "no"; + usingECP=false; + BohrUnit=true; + MOtype="Canonical"; + angular_type="cartesian"; + SpinRestricted=true; + readtype=0; + NFZC=0; + numAO=0; + FixValence=true; +} + +void QPParser::parse(const std::string& fname) +{ + std::ifstream fin(fname.c_str()); + pivot_begin= fin.tellg(); + std::string aline; + + search(fin,"do_pseudo",aline); + parsewords(aline.c_str(),currentWords); + if(currentWords[1]=="True") + usingECP=true; + else + usingECP=false; + cout<<"usingECP: " <<(usingECP?("yes"):("no")) < atomic_number,core; + vector q,pos; + int natms=0; + tags.clear(); + is.seekg(pivot_begin); + //read atomic info + bool notfound=true; + + do + { + if(is.eof()) + { + cerr<<"Could not find atomic coordinates. \n"; + abort(); + } + getwords(currentWords,is); + if(currentWords.size() < 4 ) + continue; + if (currentWords.size() == 4) + if(currentWords[0] == "Atomic" && + currentWords[1] == "coord" && + currentWords[2] == "in" && + currentWords[3] == "Bohr" ) + { + notfound=false; + getwords(currentWords,is); + while(currentWords.size() != 0) + { + if(currentWords[0] == "BEGIN_BASIS_SET") + break; + natms++; + double z=atof(currentWords[1].c_str()); + int zint = (int)z; // is this dangerous??? + atomic_number.push_back(zint); + q.push_back(z); // if using ECPs, change below + tags.push_back(currentWords[0]); + pos.push_back(atof(currentWords[2].c_str())); + pos.push_back(atof(currentWords[3].c_str())); + pos.push_back(atof(currentWords[4].c_str())); + getwords(currentWords,is); + } + } + } + while(notfound); + if(natms != NumberOfAtoms) + { + cerr<<"Could not find atomic coordinates for all atoms. \n"; + abort(); + } +//ECP PART!!! + if(usingECP==true){ + is.seekg(pivot_begin); + notfound=true; + + while(notfound) + { + if(is.eof()) + { + cerr<<"Problem looking for ECPs, this should not happen. Contact developers for help. \n"; + abort(); + } + getwords(currentWords,is); +// this should appear below the ECP section in the output file +// so use this to avoid going all the way to the bottom + if(currentWords.size() == 0 ) + continue; + if( currentWords[0] == "BEGIN_PSEUDO") + { + core.resize(NumberOfAtoms); + // getwords(currentWords,is); // ------------- + bool done=false; + while(!done) + { + if(is.eof()) + { + cerr<<"2 Found ECPs, but problem looking ZCORE data.\n"; + abort(); + } + getwords(currentWords,is); + if(currentWords.size() == 0) + continue; + if(currentWords.size() == 1) + { + if(currentWords[0] == "END_PSEUDO") + done=true; + } + if(currentWords[0] == "PARAMETERS" && + currentWords[1] == "FOR" ) + { + //done=true; + std::vector::iterator it,it0; + it = find(currentWords.begin(),currentWords.end(),"ZCORE"); + it0 = find(currentWords.begin(),currentWords.end(),"ATOM"); + if(it0 == currentWords.end()) + { + cerr<<"Problem with ECP data. Didn't found ATOM tag\n"; + cerr<c_str())-1; + if(it != currentWords.end()) + { + it++; + cout<<"Avant nq0="<::iterator it2=it; + it2++; + int nq = atoi(it2->c_str()); + if(nq != nq0+1) + { + cerr<<"Problem with ECP data. ID's don't agree\n"; + cerr<<"Atom: " <c_str()); + core[nq0] = core[nq-1]; + q[nq0] -= core[nq0]; + cout<<"2 Found ECP for atom " < basisDataMap; + int nUniqAt=0; + for(int i=0; i::iterator it(basisDataMap.find(tags[i])); + if(it == basisDataMap.end()) + { + basisDataMap[tags[i]]=nUniqAt++; + } + } + vector > expo(nUniqAt),coef(nUniqAt),coef2(nUniqAt); + vector nshll(nUniqAt,0); //use this to + vector > ncoeffpershell(nUniqAt); + vector > shID(nUniqAt); + std::map gsMap; + gsMap[std::string("S")]=1; + gsMap[std::string("SP")]=2; + gsMap[std::string("P")]=3; + gsMap[std::string("D")]=4; + gsMap[std::string("F")]=5; + gsMap[std::string("G")]=6; + gsMap[std::string("H")]=7; + gsMap[std::string("I")]=8; + is.seekg(pivot_begin); + bool found=false; + while(!found) + { + if(is.eof()) + { + cerr<<"Problem with basis set data.\n"; + abort(); + } + getwords(currentWords,is); + if(currentWords.size() >2) + continue; + if(currentWords[0] == "BEGIN_BASIS_SET") + found=true; + } + + + is.seekg(pivot_begin); + + + int currPos=-1; + lookFor(is,"BEGIN_BASIS_SET"); + int NbCoeffperShell=0; + getwords(currentWords,is); + bool allbase=true; + while(allbase==true) + { + if(currentWords.empty()) getwords(currentWords,is); + if(currentWords.size() ==1) + { + + std::map::iterator it(basisDataMap.find(currentWords[0])); + if(it == basisDataMap.end()) + { + cerr<<"Error in parser.\n"; + abort(); + } + currPos=it->second; + nshll[currPos]=0; + ncoeffpershell[currPos].clear(); + ncoeffpershell[currPos].push_back(0); + shID[currPos].clear(); + shID[currPos].push_back("NONE"); + + bool group=true; + do{ + + getwords(currentWords,is); + if(currentWords[0]=="S"||currentWords[0]=="P"||currentWords[0]=="D"||currentWords[0]=="F"||currentWords[0]=="G"||currentWords[0]=="H"||currentWords[0]=="I") //empty line after the shell + { + shID[currPos].push_back(currentWords[0]); + Shell_temp=currentWords[0]; + NbCoeffperShell=atoi(currentWords[1].c_str()); + ncoeffpershell[currPos][nshll[currPos]]=NbCoeffperShell; + for(int nbcoef=0;nbcoef::iterator it(basisDataMap.find(tags[i])); + if(it == basisDataMap.end()) + { + cerr<<"Error in parser.\n"; + abort(); + } + gBound[i] = gtot; + int indx = it->second; + gtot+=nshll[indx]; + for(int k=0; k dummy(50); + Matrix CartMat(numMO,SizeOfBasisSet); + streampos pivot; + pivot= is.tellg(); + std::vector CartLabels(SizeOfBasisSet); + getwords(currentWords,is); + for(int k=0; k &CartMat, std::vector& EigVal) +{ + int nq = numMO/4; + int rem = numMO%4; + int cnt=0; + for(int i=0; i 0) + { + getwords(currentWords,is); + + for(int k=0; k +#include +#include +#include +#include "OhmmsPETE/TinyVector.h" +#include "OhmmsData/OhmmsElementBase.h" + +class QPParser: public QMCGaussianParserBase, + public OhmmsAsciiParser +{ + +public: + + QPParser(); + + QPParser(int argc, char** argv); + + streampos pivot_begin; + vector tags; + bool usingECP; + std::string MOtype; + int readtype, numAO; + int NFZC, NEXT, NTOT, NAC; + + void parse(const std::string& fname); + + void getGeometry(std::istream& is); + + void getGaussianCenters(std::istream& is); + + void getMO(std::istream& is); + + void getMO_single_set(std::istream& is, Matrix &CartMat, std::vector& EigVal_alpha); + + void getQPCI(std::istream& is); + + +}; +//#endif diff --git a/src/QMCTools/convert4qmc.cpp b/src/QMCTools/convert4qmc.cpp index 7fc6bb26a..1600f1b6c 100644 --- a/src/QMCTools/convert4qmc.cpp +++ b/src/QMCTools/convert4qmc.cpp @@ -2,6 +2,9 @@ #include "QMCTools/GaussianFCHKParser.h" #include "QMCTools/GamesXmlParser.h" #include "QMCTools/GamesAsciiParser.h" +#include "QMCTools/VSVBParser.h" +#include "QMCTools/QPParser.h" +#include "QMCTools/GamesFMOParser.h" #include "QMCTools/BParser.h" #include "Message/Communicate.h" #include "Utilities/OhmmsInfo.h" @@ -13,8 +16,8 @@ int main(int argc, char **argv) { if(argc<2) { - std::cout << "Usage: convert [-gaussian|-casino|-gamesxml|-gamessAscii] filename "; - std::cout << "[-nojastrow -hdf5 -psi_tag psi0 -ion_tag ion0 -gridtype log|log0|linear -first ri -last rf -size npts -ci file.out -threshold cimin -NaturalOrbitals NumToRead -add3BodyJ -prefix title]" + std::cout << "Usage: convert [-gaussian|-casino|-gamesxml|-gamessAscii|-gamessFMO |-VSVB| -QP] filename "; + std::cout << "[-nojastrow -hdf5 -psi_tag psi0 -ion_tag ion0 -gridtype log|log0|linear -first ri -last rf -size npts -ci file.out -threshold cimin -NaturalOrbitals NumToRead -add3BodyJ -prefix title -addCusp]" << std::endl; std::cout << "Defaults : -gridtype log -first 1e-6 -last 100 -size 1001 -ci required -threshold 0.01 -prefix sample" << std::endl; std::cout << "When the input format is missing, the extension of filename is used to determine the parser " << std::endl; @@ -36,7 +39,7 @@ int main(int argc, char **argv) string ion_tag("ion0"); string prefix("sample"); bool usehdf5=false; - bool ci=false,zeroCI=false,orderByExcitation=false; + bool ci=false,zeroCI=false,orderByExcitation=false,VSVB=false, fmo=false,addCusp=false; double thres=0.01; int readNO=0; // if > 0, read Natural Orbitals from gamess output int readGuess=0; // if > 0, read Initial Guess from gamess output @@ -58,6 +61,23 @@ int main(int argc, char **argv) parser = new GamesAsciiParser(argc,argv); in_file =argv[++iargc]; } + else if(a == "-QP") + { + parser = new QPParser(argc,argv); + in_file =argv[++iargc]; + } + else if(a == "-VSVB") + { + parser = new VSVBParser(argc,argv); + in_file =argv[++iargc]; + VSVB=true; + } + else if(a == "-gamessFMO") + { + parser = new GamesFMOParser(argc,argv); + in_file =argv[++iargc]; + fmo=true; + } else if(a == "-casino") { parser = new CasinoParser(argc,argv); @@ -89,6 +109,10 @@ int main(int argc, char **argv) ci=true; punch_file = argv[++iargc]; } + else if(a == "-addCusp" ) + { + addCusp = true; + } else if(a == "-threshold" ) { thres = atof(argv[++iargc]); @@ -155,46 +179,33 @@ int main(int argc, char **argv) exit(1); } } - parser->Title=prefix; - parser->UseHDF5=usehdf5; - parser->IonSystem.setName(ion_tag); - parser->multideterminant=ci; - parser->ci_threshold=thres; - parser->readNO=readNO; - parser->orderByExcitation=orderByExcitation; - parser->zeroCI = zeroCI; - parser->readGuess=readGuess; - parser->outputFile=punch_file; - parser->parse(in_file); - parser->dump(psi_tag, ion_tag); - OHMMS::Controller->finalize(); + if(fmo) + { + parser->Title=prefix; + parser->UseHDF5=usehdf5; + parser->DoCusp=addCusp; + parser->parse(in_file); + + } + else + { + parser->Title=prefix; + parser->DoCusp=addCusp; + parser->UseHDF5=usehdf5; + parser->IonSystem.setName(ion_tag); + parser->multideterminant=ci; + parser->ci_threshold=thres; + parser->readNO=readNO; + parser->orderByExcitation=orderByExcitation; + parser->zeroCI = zeroCI; + parser->readGuess=readGuess; + parser->outputFile=punch_file; + parser->VSVB=VSVB; + parser->parse(in_file); + parser->dump(psi_tag, ion_tag); + OHMMS::Controller->finalize(); + + } return 0; } -/* -int main(int argc, char **argv) { - - char buffer[200]; - std::string _txt; - std::string _data; - double _t; - std::cout.setf(std::ios::scientific, std::ios::floatfield); - std::cout.setf(std::ios::right,std::ios::adjustfield); - std::cout.precision(12); - while(std::cin.getline( buffer, sizeof ( buffer ) ) ){ - std::istringstream stream(buffer); - if(isdigit(buffer[1])) { - while(stream>>_t) { - std::cout << std::setw(21) << _t ; - } - std::cout << std::endl; - } else { - if(stream>>_t) { - std::cout << "probably numbers " << buffer << std::endl; - } else { - std::cout << "probably statement " << buffer << std::endl; - } - } - } -} -*/