bool QDwfBuilder::put(xmlNodePtr cur) { typedef DiracDeterminant<SPOSet_t> DDet_t; typedef SlaterDeterminant<SPOSet_t> SDet_t; map<string,QDwf*> qdwfs; int nbasis=0; SDet_t* sdet = new SDet_t; cur = cur->xmlChildrenNode; /// cur->name = DeterminantSet while(cur!=NULL) { string cname((const char*)(cur->name)); if(cname =="SlaterDeterminant") { int first = 0; xmlNodePtr tcur = cur->xmlChildrenNode; while(tcur != NULL) { string cname2((const char*)(tcur->name)); if(cname2 == "Determinant") { SPOSet_t* swfs = new SPOSet_t; int norb =atoi((const char*)(xmlGetProp(tcur, (const xmlChar *)"orbitals"))) ; XMLReport("The number of orbitals for a Dirac Determinant " << norb) xmlNodePtr t = tcur->xmlChildrenNode; while(t != NULL) { string oname((const char*)(t->name)); if(oname == "Orbital") { string orbname((const char*)(xmlGetProp(t, (const xmlChar *)"name"))); map<string,QDwf*>::iterator it = qdwfs.find(orbname); if(it == qdwfs.end()) { XMLReport("Adding a new orbital " << orbname) QDwf *neworb = new QDwf(); neworb->put(t,wfs_ref.VarList); swfs->add(neworb); qdwfs[oname] = neworb; } else { XMLReport("Using an existing " << orbname) swfs->add((*it).second); } } t = t->next; } XMLReport("The number of basis functions " << swfs->size()) DDet_t* ddet = new DDet_t(*swfs,first); ddet->set(first,swfs->size()); XMLReport("Adding a determinant to the SlaterDeterminant of size " << swfs->size() << " begining with orbital " << first) first += swfs->size(); sdet->add(ddet); } //dirac-determinant tcur = tcur->next; } }//slater-determinant cur = cur->next; } wfs_ref.add(sdet); return true; }
void GamesXmlParser::getGaussianCenters(vector<xmlNodePtr>& bPtrList) { //if(bPtrList.size() != aPtrList.size()) gBound.push_back(0); int offset=0; double zeta,c; SizeOfBasisSet=0; for(int i=0; i<bPtrList.size(); i++) { string p; int ng_tot=0,ng; xmlNodePtr cur=bPtrList[i]->children; while(cur != NULL) { string cname((const char*)cur->name); if(cname == "PSHELL") { ng_tot++; xmlNodePtr cur1=cur->children; int gshellType=1; while(cur1!= NULL) { string tname((const char*)cur1->name); if(tname == "PTYPE") { putContent(p,cur1); if(p == "S") { gshellType=1; SizeOfBasisSet+=1; } else if(p == "P") { gshellType=3; SizeOfBasisSet+=3; } else if(p == "D") { gshellType=4; SizeOfBasisSet+=5; } gShell.push_back(gshellType); } else if(tname == "PNGAUSS") { putContent(ng,cur1); gNumber.push_back(ng); // ng_tot+=ng; } else if(tname == "PGAUSSIAN") { xmlNodePtr cur2=cur1->children; while(cur2 != NULL) { string cname2((const char*)cur2->name); if(cname2 == "PZETA") { putContent(zeta,cur2); gExp.push_back(zeta); } else if(cname2 == "PCONE") { putContent(c,cur2); gC0.push_back(c); } cur2=cur2->next; } cout << "zeta,c " << zeta << " " << c << endl; } cur1=cur1->next; } } cur=cur->next; } offset+=ng_tot; gBound.push_back(offset); } cout << "Bound of gauassians " << endl; std::copy(gBound.begin(), gBound.end(),ostream_iterator<int>(cout, " ")); cout << endl; cout << "Number of shell type " << endl; std::copy(gShell.begin(), gShell.end(),ostream_iterator<int>(cout, " ")); cout << endl; cout << "Number of gaussians per shell " << endl; std::copy(gNumber.begin(), gNumber.end(),ostream_iterator<int>(cout, " ")); cout << endl; gC1.resize(gC0.size(),0.0); }
void GamesXmlParser::parse(const std::string& fname) { xmlDocPtr m_doc = xmlParseFile(fname.c_str()); if (m_doc == NULL) { ERRORMSG("File " << fname << " is invalid") xmlFreeDoc(m_doc); return; } xmlNodePtr cur = xmlDocGetRootElement(m_doc); if(!xmlStrEqual(cur->name,(const xmlChar*)"GAMESS")) { ERRORMSG("File " << fname << " does not have GAMESS as its root. Invalid") xmlFreeDoc(m_doc); return; } //xmlNodePtr for atoms vector<xmlNodePtr> aPtrList; //xmlNodePtr for eigvectors vector<xmlNodePtr> ePtrList; //xmlNodePtr for gaussian basis vector<xmlNodePtr> bPtrList; cur=cur->children; while(cur != NULL) { string cname((const char*)cur->name); if(cname == "IN") { xmlNodePtr cur1=cur->children; while(cur1 != NULL) { string cname1((const char*)cur1->name); if(cname1 == "RUN_TITLE") { string atitle; putContent(atitle,cur1); string::size_type wh=atitle.find("..."); if(wh<atitle.size()) atitle.erase(wh,atitle.size()-wh); Title = atitle; } else if(cname1 == "CONTRL") { getControlParameters(cur1); } cur1=cur1->next; }//everything within IN } else if(cname == "OUT") { xmlNodePtr cur1=cur->children; while(cur1 != NULL) { string cname1((const char*)cur1->name); if(cname1 == "SYSTEM_STATE") { //Unit needs to be generalized!! string unitL((const char*)xmlGetProp(cur1,(const xmlChar*)"UNITS")); if(unitL == "ANGS") BohrUnit=false; xmlNodePtr cur2 = cur1->children; while(cur2 != NULL) { string cname2((const char*)cur2->name); if(cname2 == "ATOM") { aPtrList.push_back(cur2); } else if(cname2 == "VEC") { ePtrList.push_back(cur2); } cur2=cur2->next; } } else if(cname1 == "PDATA") { xmlNodePtr cur2 = cur1->children; while(cur2 != NULL) { string cname2((const char*)cur2->name); if(cname2 == "PATOMIC_BASIS_SET") { bPtrList.push_back(cur2); } cur2=cur2->next; } } cur1=cur1->next; }//everything within OUT } cur=cur->next; } //xmlXPathContextPtr m_context = xmlXPathNewContext(m_doc); getGeometry(aPtrList); getGaussianCenters(bPtrList); getEigVectors(ePtrList); //xmlXPathFreeContext(m_context); xmlFreeDoc(m_doc); }
ParticleSet* ParticleSetPool::createESParticleSet(xmlNodePtr cur, const string& target) { TinyVector<int,OHMMS_DIM> tilefactor; Tensor<int,OHMMS_DIM> tilematrix(1,0,0,0,1,0,0,0,1); double lr_cut=10; string h5name; string source("i"); string bc("p p p"); OhmmsAttributeSet attribs; attribs.add(h5name, "href"); attribs.add(tilefactor, "tile"); attribs.add(tilematrix, "tilematrix"); attribs.add(source, "source"); attribs.add(bc, "bconds"); attribs.add(lr_cut, "LR_dim_cutoff"); attribs.put(cur); ParticleSet* ions=getParticleSet(source); if(ions==0) { ions=new MCWalkerConfiguration; ions->setName(source); } //set the boundary condition ions->Lattice.LR_dim_cutoff=lr_cut; std::istringstream is(bc); char c; int idim=0; while(!is.eof() && idim<OHMMS_DIM) { if(is>>c) ions->Lattice.BoxBConds[idim++]=(c=='p'); } //initialize ions from hdf5 hid_t h5=-1; if(myComm->rank()==0) h5 = H5Fopen(h5name.c_str(),H5F_ACC_RDONLY,H5P_DEFAULT); ESHDFIonsParser ap(*ions,h5,myComm); ap.put(cur); ap.expand(tilematrix); if(h5>-1) H5Fclose(h5); //failed to initialize the ions if(ions->getTotalNum() == 0) return 0; typedef ParticleSet::SingleParticleIndex_t SingleParticleIndex_t; vector<SingleParticleIndex_t> grid(OHMMS_DIM,SingleParticleIndex_t(1)); ions->Lattice.reset(); ions->Lattice.makeGrid(grid); if(SimulationCell==0) { SimulationCell = new ParticleSet::ParticleLayout_t(ions->Lattice); } //create the electrons MCWalkerConfiguration* qp = new MCWalkerConfiguration; qp->setName(target); qp->Lattice.copy(ions->Lattice); //qp->Lattice.reset(); //qp->Lattice.makeGrid(grid); app_log() << " Simulation cell radius = " << qp->Lattice.SimulationCellRadius << endl; app_log() << " Wigner-Seitz radius = " << qp->Lattice.WignerSeitzRadius << endl; SimulationCell->print(app_log()); myPool[target]=qp; myPool[source]=ions; //addParticleSet(qp); //addParticleSet(ions); {//get the number of electrons per spin vector<int> num_spin; xmlNodePtr cur1=cur->children; while(cur1!=NULL) { string cname1((const char*)cur1->name); if(cname1 == OrbitalBuilderBase::sd_tag) { num_spin.clear(); xmlNodePtr cur2=cur1->children; while(cur2!=NULL) { string cname2((const char*)cur2->name); if(cname2 == OrbitalBuilderBase::det_tag) { int n=0; OhmmsAttributeSet a; a.add(n,"size"); a.put(cur2); if(num_spin.size()<2) num_spin.push_back(n); } cur2=cur2->next; } } cur1=cur1->next; } //create species SpeciesSet& species=qp->getSpeciesSet(); //add up and down species.addSpecies("u"); if(num_spin.size()>1) species.addSpecies("d"); int chid=species.addAttribute("charge"); for(int i=0; i<num_spin.size(); ++i) species(chid,i)=-1.0; int mid=species.addAttribute("membersize"); for(int i=0; i<num_spin.size(); ++i) species(mid,i)=num_spin[i]; mid=species.addAttribute("mass"); for(int i=0; i<num_spin.size(); ++i) species(mid,i)=1.0; qp->create(num_spin); } //name it with the target qp->setName(target); //assign non-trivial positions for the quanmtum particles if(qp->Lattice.SuperCellEnum) { makeUniformRandom(qp->R); qp->R.setUnit(PosUnit::LatticeUnit); qp->convert2Cart(qp->R); qp->createSK(); } else { InitMolecularSystem mole(this); if(ions->getTotalNum()>1) mole.initMolecule(ions,qp); else mole.initAtom(ions,qp); } //for(int i=0; i<qp->getTotalNum(); ++i) // cout << qp->GroupID[i] << " " << qp->R[i] << endl; if(qp->getTotalNum() == 0 || ions->getTotalNum() == 0) { delete qp; delete ions; APP_ABORT("ParticleSetPool failed to create particlesets for the electron structure calculation"); return 0; } return qp; }