예제 #1
0
  bool OrbitalConstraintsBase::getVariables(xmlNodePtr cur) 
  {

    xmlChar* prnode=xmlGetProp(cur,(const xmlChar*)"print");
    if(prnode != NULL)
    {
      PrintTables = xmlStrEqual(prnode,(const xmlChar*)"yes");
    }

    //save the xml node
    myNode=cur;
    cur = cur->children;
    while(cur != NULL) {
      string cname((const char*)(cur->name));
      if(cname == "correlation") {
        xmlNodePtr cur1=cur->children;
        while(cur1 != NULL) {
          string cname1((const char*)(cur1->name));
          if(cname1 == "parameter") {
            getParam(cur1);
          }
          cur1=cur1->next;
        }
      } else if(cname == "parameter") {
        getParam(cur);
      }
      cur = cur->next;
    } // while cur
    return true;
  }
예제 #2
0
  void PolyConstraints::addSingleBasisPerSpecies(xmlNodePtr cur) 
  {

    RealType rcut=10.0;
    int npts=101;
    RealType step=-1.0;
    if(myGrid) {
      rcut=myGrid->rmax();
      npts = myGrid->size();
    }

    OhmmsAttributeSet gAttrib;
    gAttrib.add(rcut,"rf");
    BasisGroupType* curBG=0;
    cur=cur->children;
    while(cur != NULL)
    {
      string cname((const char*)(cur->name));
      string elementType("e");
      OhmmsAttributeSet aAttrib;
      aAttrib.add(elementType,"elementType");
      aAttrib.put(cur);
      if(cname == "atomicBasisSet")
      {
        xmlNodePtr cur1=cur->children;
        while(cur1 != NULL)
        {
          string cname1((const char*)(cur1->name));
          if(cname1 == "basisGroup")
          {
            createBasisGroup(cur1,elementType,rcut);
          }
          else if(cname1 == "grid")
          {
            gAttrib.put(cur1);
          }
          cur1=cur1->next;
        }
      }
      else if(cname == "basisGroup")
      {
        createBasisGroup(cur,elementType,rcut);
      }
      else if(cname == "grid")
        gAttrib.put(cur);
      cur=cur->next; 
    }
  }
예제 #3
0
void ECPComponentBuilder::addSemiLocal(xmlNodePtr cur)
{
  GridType* grid_semilocal=0;
  RealType rmax= pp_nonloc->Rmax;
  cur=cur->children;
  while(cur != NULL)
  {
    string cname((const char*)cur->name);
    if(cname == "grid")
    {
      grid_semilocal=createGrid(cur);
      rmax=grid_semilocal->rmax();
    }
    else
      if(cname == "vps")
      {
        //should be able to overwrite rmax
        int l=angMon[(const char*)xmlGetProp(cur,(const xmlChar*)"l")];
        Lmax = std::max(l,Lmax);
        xmlNodePtr cur1=cur->children;
        while(cur1 != NULL)
        {
          string cname1((const char*)cur1->name);
          if(cname1 == "basisGroup")
          {
            pp_nonloc->add(l,createVrWithBasisGroup(cur1,grid_semilocal));
          }
          //else if(cname1 == "data")
          //{
          //  pp_nonloc->add(l,createVrWithData(cur1,grid_semilocal));
          //}
          cur1=cur1->next;
        }
        NumNonLocal++;
      }
    cur=cur->next;
  }
  pp_nonloc->lmax=Lmax;
  pp_nonloc->Rmax=rmax;
}
예제 #4
0
GridMolecularOrbitals::BasisSetType*
GridMolecularOrbitals::addBasisSet(xmlNodePtr cur)
{
  if(!BasisSet)
    BasisSet = new BasisSetType(IonSys.getSpeciesSet().getTotalNum());
  QuantumNumberType nlms;
  string rnl;
  //current number of centers
  int ncenters = CenterID.size();
  int activeCenter;
  int gridmode = -1;
  bool addsignforM = false;
  string  sph("default"), Morder("gaussian");
  //go thru the tree
  cur = cur->xmlChildrenNode;
  map<string,RGFBuilderBase*> rbuilderlist;
  while(cur!=NULL)
  {
    string cname((const char*)(cur->name));
    if(cname == basis_tag || cname == "atomicBasisSet")
    {
      int expandlm = GAUSSIAN_EXPAND;
      string abasis("invalid"), btype("Numerical");
      //Register valid attributes attributes
      OhmmsAttributeSet aAttrib;
      aAttrib.add(abasis,"elementType");
      aAttrib.add(abasis,"species");
      aAttrib.add(btype,"type");
      aAttrib.add(sph,"angular");
      aAttrib.add(addsignforM,"expM");
      aAttrib.add(Morder,"expandYlm");
      aAttrib.put(cur);
      if(abasis == "invalid")
        continue;
      if(sph == "spherical")
        addsignforM=1; //include (-1)^m
      if(Morder == "gaussian")
      {
        expandlm = GAUSSIAN_EXPAND;
      }
      else
        if(Morder == "natural")
        {
          expandlm = NATURAL_EXPAND;
        }
        else
          if(Morder == "no")
          {
            expandlm = DONOT_EXPAND;
          }
      if(addsignforM)
        LOGMSG("Spherical Harmonics contain (-1)^m factor")
            else
              LOGMSG("Spherical Harmonics  DO NOT contain (-1)^m factor")
              //search the species name
              map<string,int>::iterator it = CenterID.find(abasis);
      if(it == CenterID.end())
        //add the name to the map CenterID
      {
        if(btype == "Numerical" || btype == "NG" || btype == "HFNG")
        {
          rbuilder = new NumericalRGFBuilder(cur);
        }
        else
        {
          rbuilder = new Any2GridBuilder(cur);
        }
        //CenterID[abasis] = activeCenter = ncenters++;
        CenterID[abasis]=activeCenter=IonSys.getSpeciesSet().findSpecies(abasis);
        int Lmax(0); //maxmimum angular momentum of this center
        int num(0);//the number of localized basis functions of this center
        //process the basic property: maximun angular momentum, the number of basis functions to be added
        vector<xmlNodePtr> radGroup;
        xmlNodePtr cur1 = cur->xmlChildrenNode;
        xmlNodePtr gptr=0;
        while(cur1 != NULL)
        {
          string cname1((const char*)(cur1->name));
          if(cname1 == basisfunc_tag || cname1 == "basisGroup")
          {
            radGroup.push_back(cur1);
            int l=atoi((const char*)(xmlGetProp(cur1, (const xmlChar *)"l")));
            Lmax = max(Lmax,l);
            //expect that only Rnl is given
            if(expandlm)
              num += 2*l+1;
            else
              num++;
          }
          else
            if(cname1 == "grid")
            {
              gptr = cur1;
            }
          cur1 = cur1->next;
        }
        XMLReport("Adding a center " << abasis << " centerid "<< CenterID[abasis])
        XMLReport("Maximum angular momentum    = " << Lmax)
        XMLReport("Number of centered orbitals = " << num)
        //create a new set of atomic orbitals sharing a center with (Lmax, num)
        //if(addsignforM) the basis function has (-1)^m sqrt(2)Re(Ylm)
        CenteredOrbitalType* aos = new CenteredOrbitalType(Lmax,addsignforM);
        aos->LM.resize(num);
        aos->NL.resize(num);
        //Now, add distinct Radial Orbitals and (l,m) channels
        num=0;
        rbuilder->setOrbitalSet(aos,abasis); //assign radial orbitals for the new center
        rbuilder->addGrid(gptr); //assign a radial grid for the new center
        vector<xmlNodePtr>::iterator it(radGroup.begin());
        vector<xmlNodePtr>::iterator it_end(radGroup.end());
        while(it != it_end)
        {
          cur1 = (*it);
          xmlAttrPtr att = cur1->properties;
          while(att != NULL)
          {
            string aname((const char*)(att->name));
            if(aname == "rid" || aname == "id")
              //accept id/rid
            {
              rnl = (const char*)(att->children->content);
            }
            else
            {
              map<string,int>::iterator iit = nlms_id.find(aname);
              if(iit != nlms_id.end())
                //valid for n,l,m,s
              {
                nlms[(*iit).second] = atoi((const char*)(att->children->content));
              }
            }
            att = att->next;
          }
          XMLReport("\n(n,l,m,s) " << nlms[0] << " " << nlms[1] << " " << nlms[2] << " " << nlms[3])
          //add Ylm channels
          num = expandYlm(rnl,nlms,num,aos,cur1,expandlm);
          ++it;
        }
        //add the new atomic basis to the basis set
        BasisSet->add(aos,activeCenter);
#if !defined(HAVE_MPI)
        rbuilder->print(abasis,1);
#endif
        if(rbuilder)
        {
          delete rbuilder;
          rbuilder=0;
        }
      }
      else
      {
        WARNMSG("Species " << abasis << " is already initialized. Ignore the input.")
      }
    }
    cur = cur->next;
  }
예제 #5
0
  GTOMolecularOrbitals::BasisSetType* 
  GTOMolecularOrbitals::addBasisSet(xmlNodePtr cur) {

    if(!BasisSet) 
      BasisSet = new BasisSetType(IonSys.getSpeciesSet().getTotalNum());

    QuantumNumberType nlms;
    string rnl;

    //current number of centers
    int ncenters = CenterID.size();
    int activeCenter;
    int gridmode = -1;
    bool addsignforM = true;
    string  sph("spherical"), Morder("gaussian");

    //go thru the tree
    cur = cur->xmlChildrenNode;
    while(cur!=NULL) {
      string cname((const char*)(cur->name));
      if(cname == basis_tag || cname == "atomicBasisSet") {
        int expandlm = GAUSSIAN_EXPAND;
        string abasis("invalid"), norm("no");

        //Register valid attributes attributes
        OhmmsAttributeSet aAttrib;
        aAttrib.add(abasis,"elementType"); aAttrib.add(abasis,"species");
        aAttrib.add(sph,"angular"); aAttrib.add(addsignforM,"expM"); 
        aAttrib.add(Morder,"expandYlm"); 
        aAttrib.add(norm,"normalized"); 
        aAttrib.put(cur);

        if(norm == "yes") Normalized=true;
        else Normalized=false;

        if(abasis == "invalid") continue;
        if(sph == "spherical") addsignforM=true; //include (-1)^m
        if(sph == "cartesian") addsignforM=false;

        if(Morder == "gaussian") {
          expandlm = GAUSSIAN_EXPAND;
        } else if(Morder == "natural"){
          expandlm = NATURAL_EXPAND;
        } else if(Morder == "no") {
          expandlm = DONOT_EXPAND;
        }

        if(addsignforM) 
          LOGMSG("Spherical Harmonics contain (-1)^m factor")
        else
          LOGMSG("Spherical Harmonics  DO NOT contain (-1)^m factor")

	map<string,int>::iterator it = CenterID.find(abasis); //search the species name
	if(it == CenterID.end()) {//add the name to the map CenterID

	  //CenterID[abasis] = activeCenter = ncenters++;
          CenterID[abasis]=activeCenter=IonSys.getSpeciesSet().findSpecies(abasis);
	  int Lmax(0); //maxmimum angular momentum of this center
          int num(0);//the number of localized basis functions of this center

	  //process the basic property: maximun angular momentum, the number of basis functions to be added
          vector<xmlNodePtr> radGroup;
	  xmlNodePtr cur1 = cur->xmlChildrenNode;
          xmlNodePtr gptr=0;
	  while(cur1 != NULL) {
	    string cname1((const char*)(cur1->name));
	    if(cname1 == basisfunc_tag || cname1 == "basisGroup") {
              radGroup.push_back(cur1);
    	      int l=atoi((const char*)(xmlGetProp(cur1, (const xmlChar *)"l")));
	      Lmax = max(Lmax,l);
	      if(expandlm) 
                num += 2*l+1;
	      else
                num++;
	    } 
	    cur1 = cur1->next;
	  }
	  LOGMSG("Adding a center " << abasis << " centerid "<< CenterID[abasis])
          LOGMSG("Maximum angular momentum    = " << Lmax)
          LOGMSG("Number of centered orbitals = " << num)

	  //create a new set of atomic orbitals sharing a center with (Lmax, num)
          //if(addsignforM) the basis function has (-1)^m sqrt(2)Re(Ylm)
	  CenteredOrbitalType* aos = new CenteredOrbitalType(Lmax,addsignforM);
	  aos->LM.resize(num);
	  aos->NL.resize(num);

          //Now, add distinct Radial Orbitals and (l,m) channels
	  num=0;
          vector<xmlNodePtr>::iterator it(radGroup.begin());
          vector<xmlNodePtr>::iterator it_end(radGroup.end());
          while(it != it_end) {
            cur1 = (*it);
	    xmlAttrPtr att = cur1->properties;
	    while(att != NULL) {
	      string aname((const char*)(att->name));
	      if(aname == "rid" || aname == "id") { //accept id/rid
	        rnl = (const char*)(att->children->content);
	      } else { 
	        map<string,int>::iterator iit = nlms_id.find(aname);
	        if(iit != nlms_id.end()) { //valid for n,l,m,s
	          nlms[(*iit).second] = atoi((const char*)(att->children->content));
	        } 
	      }
	      att = att->next;
	    }
	    LOGMSG("\n(n,l,m,s) " << nlms[0] << " " << nlms[1] << " " << nlms[2] << " " << nlms[3])

            //add Ylm channels
            num = expandYlm(rnl,nlms,num,aos,cur1,expandlm);
            ++it;
          }

          LOGMSG("Checking the order of angular momentum ")
          std::copy(aos->LM.begin(), aos->LM.end(), ostream_iterator<int>(app_log()," "));
          app_log() << endl;

	  //add the new atomic basis to the basis set
	  BasisSet->add(aos,activeCenter);
	}else {
	  WARNMSG("Species " << abasis << " is already initialized. Ignore the input.")
	}
      }
      cur = cur->next;
    }
예제 #6
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);
}
예제 #7
0
  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;
  }