コード例 #1
0
ファイル: NJABBuilder.cpp プロジェクト: digideskio/qmcpack
  /** create Input Analytic function
   *
   * \xmlonly
   * <jastrow name="Jne" 
   *   type="Two-Body|One-Body|Polarization|Three-Body-Geminal"
   *   function="pade|pade2|no-cusp" 
   *   transform="no|yes" spin="no|yes" 
   *   source="ionic system">
   *   <grid/>
   *   <correlation speciesA="sourceSpecies" speciesB="targetSpecies" type="pade|pade2|no-cusp">
   *      <parameter name=" ">value<parameter>
   *   </correlation>
   * </jastrow>
   * \endxmlonly
   */
  bool NJABBuilder::putInFunc(xmlNodePtr cur) {

    string corr_tag("correlation");
    string jastfunction("pade");
    int	ng=1;

    const xmlChar *ftype = xmlGetProp(cur, (const xmlChar *)"function");
    if(ftype != NULL) jastfunction = (const char*) ftype;
    const xmlChar* s=xmlGetProp(cur,(const xmlChar*)"source");
    if(s != NULL) {
      map<string,ParticleSet*>::iterator pa_it(ptclPool.find((const char*)s));
      if(pa_it == ptclPool.end()) return false;
      sourcePtcl = (*pa_it).second;
      ng=sourcePtcl->getSpeciesSet().getTotalNum();
    }

    int ia=0, ib=0, iab=0;
    cur = cur->children;
    while(cur != NULL) {
      string cname((const char*)(cur->name));
      if(cname == "grid") {
        gridPtr=cur; //save the pointer
      } else if(cname == dtable_tag) {
      	string source_name((const char*)(xmlGetProp(cur,(const xmlChar *)"source")));
        map<string,ParticleSet*>::iterator pa_it(ptclPool.find(source_name));
        if(pa_it == ptclPool.end()) return false;
	sourcePtcl=(*pa_it).second;
	ng = sourcePtcl->getSpeciesSet().getTotalNum();
	XMLReport("Number of sources " << ng)
        InFunc.resize(ng,0);
      } else if(cname ==corr_tag) {
        if(sourcePtcl==0) return false;
        string jfunctype(jastfunction);
	string spA((const char*)(xmlGetProp(cur,(const xmlChar *)"speciesA")));
        ftype = xmlGetProp(cur, (const xmlChar *)"type");
        if(ftype) {
          jfunctype=(const char*)ftype;
        }

        ia = sourcePtcl->getSpeciesSet().findSpecies(spA);
	if(!(InFunc[ia])) {
          InFuncType *j1=createInFunc(jfunctype);
	  InFunc[ia]= j1;
	  app_log() <<"   Added Jastrow Correlation ("<<jfunctype 
            << ") between " <<spA<<" and "<<targetPtcl.getName() << endl;
	}
	InFunc[ia]->put(cur);
        InFunc[ia]->addOptimizables(targetPsi.VarList);
      }
      cur = cur->next;
    } // while cur
    
    return true;
  }
コード例 #2
0
ファイル: SHEGPotential.cpp プロジェクト: digideskio/qmcpack
bool SHEGPotential::put(xmlNodePtr cur)
{
  ParameterSet params;
  params.add(Rs,"rs","double");
  params.add(Zext,"Z","double");
  params.add(Zgauss,"Zgauss","double");
  params.add(Sgauss,"Sgauss","double");
  params.put(cur);
  if(Zext<Ntot)
  {
    XMLReport("Invalid background charge Z=" << Zext << "  Overwriting by " << Ntot);
    Zext=Ntot;
  }
  return true;
}
コード例 #3
0
ファイル: SHEGPotential.cpp プロジェクト: digideskio/qmcpack
  RadialPotentialBase::value_type
    SHEGPotential::evaluate(const BasisSetType& psi, 
        RadialOrbitalSet_t& V, 
        int norb) {

      //intialize the external potential
      if(!Vext) {
        integrand=new RadialOrbital_t(psi(0));
        //evaluate Rmax from the density
        Rmax=Rs*std::pow(Ntot,1.0/3.0);

        Qinfty=Zext;//assign Zext to Qinfty
        Rcut=Rmax;//assign Rmax to Rcut 

        value_type normin=-Zext/2.0/Rmax;
        value_type r2=1.0/Rmax/Rmax;

        XMLReport("  Total charge            = " << Ntot);
        XMLReport("  Total background charge = " << Zext);
        XMLReport("  Rs (density)            = " << Rs);
        XMLReport("  Rmax (background)       = " << Rmax);
        XMLReport("  Zgauss (gaussian depth) = " << Zgauss);
        XMLReport("  Sgauss (gaussian width) = " << Sgauss);
        
        Vext = new RadialOrbital_t(psi(0));
        for(int ig=0; ig < psi.m_grid->size(); ++ig)  {
          value_type r=(*psi.m_grid)(ig);
          if(r<=Rmax) 
            (*Vext)(ig)=normin*(3.0-(r*r)*r2)-Zgauss * exp(-r*r/Sgauss/Sgauss);
          else
            (*Vext)(ig)=-Zext/r-Zgauss * exp(-r*r/Sgauss/Sgauss) ;
         
         // cout << r << " " << (*Vext)(ig) << endl;
        }
      }

      for(int ig=0; ig < psi.m_grid->size(); ++ig)  {
        value_type t = (*Vext)(ig);
        value_type sum = 0.0;
        for(int o=0; o < norb; o++) {
          V[o](ig) += t;
          sum += psi(o,ig)*psi(o,ig);
          //sum += pow(psi(o,ig),2);
        }
        (*integrand)(ig) = t*sum;
      }
      return integrate_RK2(*integrand);
    }
コード例 #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
ファイル: JastrowBuilder.cpp プロジェクト: digideskio/qmcpack
  bool 
  JastrowBuilder::createTwoBodySpin(xmlNodePtr cur, JeeType* J2) {
    
    /**\typedef The type of a simple function,e.g., PadeJastrow<double> */
    typedef typename JeeType::FuncType FuncType;

    int cur_var = targetPsi.VarList.size();

    DistanceTableData* d_table = DistanceTable::getTable(DistanceTable::add(targetPtcl));
    int	ng = targetPtcl.groups();

    map<string,FuncType*> jastrowMap;
    vector<FuncType*> jastrow(ng*ng);
    for(int i=0; i<ng*ng; i++) jastrow[i]=0;
    int nj = 0;
    cur = cur->children;
    while(cur != NULL) {
      string cname((const char*)(cur->name));
      //if(cname == dtable_tag) {
      //	string source_name((const char*)(xmlGetProp(cur,(const xmlChar *)"source")));
      //  //int iptcl = 0;
      //  map<string,ParticleSet*>::iterator pit(ptclPool.find(source_name));
      //  if(pit == ptclPool.end()) return false;
      //  ParticleSet* a = (*pit).second;
      //	d_table = DistanceTable::getTable(DistanceTable::add(*a));
      //	ng = a->groups();
      //  //create a Jastrow function for each pair type
      //  //for spin 1/2 particles (up-up, down-up = up-down,
      //  //down-down) 
      //	for(int i=0; i<ng*ng; i++) jastrow.push_back(NULL);
      //} else if(cname ==corr_tag) {
      if(cname ==corr_tag) {
	string spA((const char*)(xmlGetProp(cur,(const xmlChar *)"speciesA")));
	string spB((const char*)(xmlGetProp(cur,(const xmlChar *)"speciesB")));
        const xmlChar* refptr=xmlGetProp(cur,(const xmlChar *)"ref");
        const xmlChar* idptr=xmlGetProp(cur,(const xmlChar *)"id");
	int ia = targetPtcl.getSpeciesSet().findSpecies(spA);
	int ib = targetPtcl.getSpeciesSet().findSpecies(spB);
	int iab = ia*ng+ib;
	if(!(jastrow[iab])) {
	  //create the new Jastrow function
	  FuncType *j2=NULL;
          if(refptr == NULL) {
            j2 = new FuncType;
          } else {
            typename map<string,FuncType*>::iterator it(jastrowMap.find((const char*)refptr));
            if(it != jastrowMap.end()) {
              j2 = new FuncType((*it).second);
            } else { 
              j2 = new FuncType;
            }
          }
          if(idptr == NULL) {
            ostringstream idassigned; idassigned << "j2"<<iab;
            jastrowMap[idassigned.str()]=j2;
          } else {
            jastrowMap[(const char*)idptr]=j2;
          }

	  //initialize
	  j2->put(cur,targetPsi.VarList);
	  jastrow[iab]= j2;
	  if(ia != ib) {//up-down-type pair, treat down-up the same way
	    jastrow[ib*ng+ia] = j2;
	  } else {
	    for(int iaa=0; iaa<ng; iaa++) if(iaa != ia) jastrow[iaa*ng+iaa] = j2;
	  }
	  XMLReport("Added Jastrow Correlation between "<<spA<<" and "<<spB)
	  nj++;
	} else {
	  ERRORMSG("Using an existing Jastrow Correlation "<<spA<<" and "<<spB)
	}
      }
      cur = cur->next;
    } // while cur
コード例 #6
0
ファイル: QDwfBuilder.cpp プロジェクト: jyamu/qmc
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;
}