예제 #1
0
TrialWaveFunction* TrialWaveFunction::makeClone(ParticleSet& tqp)  const
{
  TrialWaveFunction* myclone = new TrialWaveFunction(myComm);
  myclone->BufferCursor=BufferCursor;
  for (int i=0; i<Z.size(); ++i)
    myclone->addOrbital(Z[i]->makeClone(tqp),"dummy",Z[i]->IsFermionWF);
  myclone->OneOverM=OneOverM;
  return myclone;
}
예제 #2
0
void
initialize(TrialWaveFunction& Psi, MCWalkerConfiguration& el,
           ParticleBase& ion) {

    enum {Up = 0, Down};

    ///add a distance table for ee IndexTypeeractions
    IndexType iee = DistanceTable::add(el,"ee");
    DistanceTableData* d_ee = DistanceTable::getTable(iee);
    ///add a distance table for ie interactions
    int iei = DistanceTable::add(ion,el,"ie");
    DistanceTableData* d_ei = DistanceTable::getTable(iei);

    ///create molecular orbital
    MolecularOrbitals<SlaterTypeOrbitals_t> *MO =
        new MolecularOrbitals<SlaterTypeOrbitals_t>;

    AtomicOrbitalBuilder<SlaterTypeOrbitals_t> orbitalbuilder;
    for(int iat=0; iat<ion.getTotalNum(); iat++) {
        orbitalbuilder.add("He",*MO);
    }
    MO->setTable(d_ei);

    typedef SlaterDeterminant<MolecularOrbitals<SlaterTypeOrbitals_t> > Det_t;
    Det_t *DetU = new Det_t(*MO,el.first(Up));
    DetU->set(el.first(Up),el.last(Up)-el.first(Up));

    Det_t* DetD = new Det_t(*MO,el.first(Down));
    DetD->set(el.first(Down),el.last(Down)-el.first(Down));

    LinearSlaterDeterminant<MolecularOrbitals<SlaterTypeOrbitals_t> >
    *asymmpsi
        = new LinearSlaterDeterminant<MolecularOrbitals<SlaterTypeOrbitals_t> >;

    asymmpsi->add(DetU);
    asymmpsi->add(DetD);

    Psi.add(asymmpsi,d_ei);

    /*
    OneBodyJastrow<PadeJastrow<ValueType>,FastWalkerIndex> *Jie
      = new OneBodyJastrow<PadeJastrow<ValueType>,FastWalkerIndex>;
    Jie->F.push_back(PadeJastrow<ValueType>(1.0,1.0));
    Psi.add(Jie,d_ei);
    */

    TwoBodyJastrow<PadeJastrow<ValueType>,FastWalkerIndex> *Jee
        = new TwoBodyJastrow<PadeJastrow<ValueType>,FastWalkerIndex>;

    Jee->F.push_back(PadeJastrow<double>(0.5,1.0));
    Jee->F.push_back(PadeJastrow<double>(1.0/6.0,1.0));
    Jee->F.push_back(PadeJastrow<double>(1.0/6.0,1.0));
    Jee->F.push_back(PadeJastrow<double>(0.5,1.0));
    Psi.add(Jee,d_ee);

}
예제 #3
0
  TrialWaveFunction* TrialWaveFunction::makeClone(ParticleSet& tqp)  const
  {
    TrialWaveFunction* myclone = new TrialWaveFunction(myComm);
    for(int i=0; i<Z.size(); ++i)
    {
      myclone->addOrbital(Z[i]->makeClone(tqp),"dummy");
    }
    for(int i=0; i<myTimers.size(); i++)
      myclone->myTimers[i]->set_name(myTimers[i]->get_name());
    myclone->OneOverM=OneOverM;
    return myclone;

  }
예제 #4
0
  void ThreeDimMomDist::updateDistribution(ParticleSet& PtclSet, TrialWaveFunction& Psi, 
					   IndexType NumCycles) {
    TinyVector<IndexType, 3> Indexes;
    for (IndexType cycle = 0; cycle < NumCycles; cycle++) {

      pcp->NewWalker();
      PosType dr;
      for (Indexes[0] = 0; Indexes[0] < NumPts[0]; Indexes[0]++) {
	dr[1] = 0.0;
	for (Indexes[1] = 0; Indexes[1] < NumPts[1]; Indexes[1]++) {
	  dr[2] = 0.0;
	  for (Indexes[2] = 0; Indexes[2] < NumPts[2]; Indexes[2]++) {
	    IndexType partToDisplace = (*pcp)();

	    PtclSet.makeMove(partToDisplace, dr);

	    if (Indexes[0] == 0 && Indexes[1] == 0 && Indexes[2] == 0) {
	      placeIntsInBin(Indexes, 1.0);
	    } else {
	      placeIntsInBin(Indexes, Psi.ratio(PtclSet, partToDisplace));
	    }
	    totalNumSamples++;
	    PtclSet.rejectMove(partToDisplace);

	    dr[2] += Spacing[2];
	  }      
	  dr[1] += Spacing[1];
	}
	dr[0] += Spacing[0];
      }	

    } 
  }
예제 #5
0
  void CloneManager::makeClones(MCWalkerConfiguration& w, 
      TrialWaveFunction& psi, QMCHamiltonian& ham)
  {

    if(wClones.size()) {
      app_log() << "  Cannot make clones again. Use existing " << NumThreads << " clones" << endl;
      return;
    }

    app_log() << "Number of threads = " << NumThreads << endl;
    wClones.resize(NumThreads,0);
    psiClones.resize(NumThreads,0);
    hClones.resize(NumThreads,0);

    wClones[0]=&w;
    psiClones[0]=&psi;
    hClones[0]=&ham;

#if defined(ENABLE_CLONE_PSI_AND_H)
    char pname[16];
    for(int ip=1; ip<NumThreads; ++ip) 
    {
      sprintf(pname,"%s.c%i",w.getName().c_str(),ip);
      wClones[ip]=new MCWalkerConfiguration(w);
      wClones[ip]->setName(pname);
      psiClones[ip]=psi.makeClone(*wClones[ip]);
      hClones[ip]=ham.makeClone(*wClones[ip],*psiClones[ip]);
    }
#else
    cloneEngine.clone(w,psi,ham,wClones,psiClones,hClones);
#endif
  }
예제 #6
0
    void CloneManager::makeClones(TrialWaveFunction& guide)
  {

    if(guideClones.size()) 
    {
      app_log() << "  Cannot make guideClones again. Use existing " << NumThreads << " clones" << endl;
      return;
    }

    guideClones.resize(NumThreads,0);
    guideClones[0]=&guide;

    if(NumThreads==1) return;

    app_log() << "  CloneManager::makeClones makes " << NumThreads << " clones for guide." <<endl;
    OhmmsInfo::Log->turnoff();
    OhmmsInfo::Warn->turnoff();
    char pname[16];
    for(int ip=1; ip<NumThreads; ++ip) 
    {
      guideClones[ip]=guide.makeClone(*wClones[ip]);
    }
    OhmmsInfo::Log->reset();
    OhmmsInfo::Warn->reset();
  }
예제 #7
0
  NonLocalECPComponent::RealType 
  NonLocalECPComponent::evaluate(ParticleSet& W, TrialWaveFunction& psi,int iat, vector<NonLocalData>& Txy) {
    RealType esum=0.0;

    //int iel=0;
    for(int nn=myTable->M[iat],iel=0; nn<myTable->M[iat+1]; nn++,iel++){

      register RealType r(myTable->r(nn));
      if(r>Rmax) continue;

      register RealType rinv(myTable->rinv(nn));
      register PosType  dr(myTable->dr(nn));

      int txyCounter=Txy.size();
      // Compute ratio of wave functions
      for (int j=0; j < nknot ; j++){ 
        PosType deltar(r*rrotsgrid_m[j]-dr);
        PosType newpos(W.makeMove(iel,deltar)); 
        psiratio[j]=psi.ratio(W,iel)*sgridweight_m[j];
        W.rejectMove(iel);
        //psi.rejectMove(iel);
        //first, add a new NonLocalData with ratio
        Txy.push_back(NonLocalData(iel,psiratio[j],deltar));
      }
      // Compute radial potential
      for(int ip=0;ip< nchannel; ip++){
        vrad[ip]=nlpp_m[ip]->splint(r)*wgt_angpp_m[ip];
      }

      // Compute spherical harmonics on grid
      for (int j=0, jl=0; j<nknot ; j++){ 
        RealType zz=dot(dr,rrotsgrid_m[j])*rinv;
        // Forming the Legendre polynomials
        lpol[0]=1.0;
        RealType lpolprev=0.0;
        for (int l=0 ; l< lmax ; l++){
          //Not a big difference
          //lpol[l+1]=(2*l+1)*zz*lpol[l]-l*lpolprev;
          //lpol[l+1]/=(l+1);
          lpol[l+1]=Lfactor1[l]*zz*lpol[l]-l*lpolprev; 
          lpol[l+1]*=Lfactor2[l]; 
          lpolprev=lpol[l];
        }

        //for(int l=0; l <nchannel; l++,jl++) Amat[jl]=lpol[ angpp_m[l] ]; 
        RealType lsum=0;
        for(int l=0; l <nchannel; l++) lsum += vrad[l]*lpol[ angpp_m[l] ]; 
        esum += Txy[txyCounter++].Weight *= lsum;
      } 
     //BLAS::gemv(nknot, nchannel, &Amat[0], &psiratio[0], &wvec[0]);
     //esum += BLAS::dot(nchannel, &vrad[0], &wvec[0]);
    }   /* end loop over electron */
    return esum;

  }
예제 #8
0
  void RandomMomDist::updateDistribution(ParticleSet& PtclSet, TrialWaveFunction& Psi, IndexType NumSamples) {
    pcp->NewWalker();
    for (IndexType i = 0; i < NumSamples; i++) {
      PosType dr = PtclSet.Lattice.toCart(PosType(Random(), Random(), Random()));
      IndexType PtclToDisplace = (*pcp)();
      PtclSet.makeMove(PtclToDisplace, dr);
      ComplexType ratio = Psi.ratio(PtclSet, PtclToDisplace);
      PtclSet.rejectMove(PtclToDisplace);
      totalNumSamples++;
      for (IndexType GVecNum = 0; GVecNum < GVectors.size(); GVecNum++) {
	NofK[GVecNum] += ratio * exp(ComplexType(0,-1.0) * dot(GVectors[GVecNum], dr));
      }
    }
  }
예제 #9
0
  void AveragedOneDimMomDist::updateDistribution(ParticleSet& PtclSet, TrialWaveFunction& Psi, 
						 IndexType NumCycles) {
    IndexType targetNumSamples = totalNumSamples + NumCycles;
    while(totalNumSamples < targetNumSamples) {
      PosType dr;
      for (IndexType i = 0; i < 3; i++) {
	dr += Random() * PtclSet.Lattice.a(i);
      }
      RealType DispVecLength = std::sqrt(dot(dr, dr));
      RealType FracDispVecLength = InvRsLatSize[0] * DispVecLength / 2.0;
      
      IndexType PtclToDisplace = (*pcp)();
      PtclSet.makeMove(PtclToDisplace, dr);
      PlaceCloudInBin(FracDispVecLength, Psi.ratio(PtclSet, PtclToDisplace));
      totalNumSamples++;
      PtclSet.rejectMove(PtclToDisplace);
    }
  }
예제 #10
0
  void OneDimMomDist::updateDistribution(ParticleSet& PtclSet, TrialWaveFunction& Psi, 
					 IndexType NumCycles) {
    for (IndexType cycle = 0; cycle < NumCycles; cycle++) {
      pcp->NewWalker();
      TinyVector<IndexType, 1> Indexes(0.0);
      PosType dr(0,0,0);
      placeIntsInBin(Indexes, 1.0);
      totalNumSamples++;
      for (Indexes[0] = 1; Indexes[0] < NumPts[0]; Indexes[0]++) {
	dr[0] = dr[1] = dr[2] += Spacing[0];
//        dr[0] += Spacing[0];
	IndexType partToDisplace = (*pcp)();
	PtclSet.makeMove(partToDisplace, dr);
        placeIntsInBin(Indexes, Psi.ratio(PtclSet, partToDisplace));
        totalNumSamples++;
	PtclSet.rejectMove(partToDisplace);
      }
    }
  }
예제 #11
0
  void CloneManager::makeClones(MCWalkerConfiguration& w, 
      TrialWaveFunction& psi, QMCHamiltonian& ham)
  {

    if(wClones.size()) 
    {
      app_log() << "  Cannot make clones again. Use existing " << NumThreads << " clones" << endl;
      return;
    }

    wClones.resize(NumThreads,0);
    psiClones.resize(NumThreads,0);
    hClones.resize(NumThreads,0);

    wClones[0]=&w;
    psiClones[0]=&psi;
    hClones[0]=&ham;

    if(NumThreads==1) return;

    app_log() << "  CloneManager::makeClones makes " << NumThreads << " clones for W/Psi/H." <<endl;
#if defined(ENABLE_CLONE_PSI_AND_H)
    app_log() << "  Cloning methods for both Psi and H are used" << endl;
    OhmmsInfo::Log->turnoff();
    OhmmsInfo::Warn->turnoff();
    char pname[16];
    for(int ip=1; ip<NumThreads; ++ip) 
    {
      wClones[ip]=new MCWalkerConfiguration(w);
      psiClones[ip]=psi.makeClone(*wClones[ip]);
      hClones[ip]=ham.makeClone(*wClones[ip],*psiClones[ip]);
    }
    OhmmsInfo::Log->reset();
    OhmmsInfo::Warn->reset();
#else
    app_log() << "Old parse method is used." << endl;
    cloneEngine.clone(w,psi,ham,wClones,psiClones,hClones);
#endif
  }
예제 #12
0
  void HamiltonianPool::clone(const MCWalkerConfiguration& qp, const TrialWaveFunction& psi, const QMCHamiltonian& h,
      vector<MCWalkerConfiguration*>& plist, 
      vector<TrialWaveFunction*>& olist, 
      vector<QMCHamiltonian*>& hlist) 
  {
    int np=omp_get_max_threads();
    {
      ReportEngine PRE("HamiltonianPool","clone");
      app_log() << "Number of threads = " << np << endl;
    }

    //temporarily turnoff stream buffer for the clones
    OhmmsInfo::Log->turnoff();
    OhmmsInfo::Warn->turnoff();

    //clone ParticleSet and TrialWaveFunction
    WaveFunctionFactory* psiFac=psiPool->getWaveFunctionFactory(psi.getName());
    psiFac->setCloneSize(np);

    //capture cloned WaveFunctionFactory*
    vector<WaveFunctionFactory*> otemp;
    otemp.resize(np,0);

    //allocate the data on each thread
//#pragma omp parallel 
//    {
//      int ip=omp_get_thread_num();
//#pragma omp critical 
//      {
//        if(ip) {
//          char pname[16],oname[16];
//          sprintf(pname,"%s.c%i",qp.getName().c_str(),ip);
//          plist[ip]=new MCWalkerConfiguration(qp);
//          plist[ip]->setName(pname);
//
//          sprintf(oname,"%s.c%i",psi.getName().c_str(),ip);
//          otemp[ip]= psiFac->clone(plist[ip],ip,oname);
//        }
//      }
//    }
//    
//    //add the Clones to the pools
//    for(int ip=1; ip<np; ip++) 
//    {
//      ptclPool->addParticleSet(plist[ip]);
//      psiPool->addFactory(otemp[ip]);
//      olist[ip]=otemp[ip]->targetPsi;
//      if(ip%2==1) olist[ip]->reverse();
//    }
//
    
    //add the Clones to the pools
    for(int ip=1; ip<np; ++ip) 
    {
      plist[ip]=new MCWalkerConfiguration(qp);

      char oname[16];
      sprintf(oname,"%s.c%i",psi.getName().c_str(),ip);
      // Don't recreate with a factory anymore
      //otemp[ip]= psiFac->clone(plist[ip],ip,oname);
      //ptclPool->addParticleSet(plist[ip]);
      //psiPool->addFactory(otemp[ip]);
      //olist[ip]=otemp[ip]->targetPsi;

      // Just clone the TrialWaveFunction.
      ptclPool->addParticleSet(plist[ip]);
      olist[ip]=psiFac->targetPsi->makeClone(*plist[ip]);
      olist[ip]->setName(oname);

      //need to add a WaveFunctionFactory so that Hamiltonian can use them
      otemp[ip]=new WaveFunctionFactory(*psiFac);//make a shallow copy
      otemp[ip]->setPsi(olist[ip]);
      psiPool->addFactory(otemp[ip]);
    }

    //find the HamiltonianFactory* to be cloned
    HamiltonianFactory* hFac=0;
    PoolType::iterator hit(myPool.find(h.getName()));
    if(hit == myPool.end()) {
      hFac=(*(myPool.begin())).second;
    } else {
      hFac=(*hit).second;
    }
    hFac->setCloneSize(np);

    vector<HamiltonianFactory*> htemp;
    htemp.resize(np,0);

//#pragma omp parallel 
//    {
//      int ip=omp_get_thread_num();
//#pragma omp critical 
//      {
//        if(ip) {
//          char hname[16];
//          sprintf(hname,"%s.c%i",h.getName().c_str(),ip);
//          htemp[ip]= hFac->clone(plist[ip],olist[ip],ip,hname);
//        }
//      }
//    }
//
//    for(int ip=1; ip<np; ip++) 
//    {
//      myPool[htemp[ip]->getName()]=htemp[ip];
//      hlist[ip]=htemp[ip]->targetH;
//    }

    for(int ip=1; ip<np; ip++) 
    {
      char hname[16];
      sprintf(hname,"%s.c%i",h.getName().c_str(),ip);
      htemp[ip]= hFac->clone(plist[ip],olist[ip],ip,hname);
      myPool[htemp[ip]->getName()]=htemp[ip];
      hlist[ip]=htemp[ip]->targetH;
    }

    //restore stream buffer to the original state
    OhmmsInfo::Log->reset();
    OhmmsInfo::Warn->reset();

  }
예제 #13
0
  /** evaluate the non-local potential of the iat-th ionic center
   * @param W electron configuration
   * @param iat ionic index
   * @param psi trial wavefunction
   * @param return the non-local component
   *
   * Currently, we assume that the ratio-only evaluation does not change the state
   * of the trial wavefunction and do not call psi.rejectMove(ieL).
   */
  NonLocalECPComponent::RealType 
  NonLocalECPComponent::evaluate(ParticleSet& W, int iat, TrialWaveFunction& psi) {
    RealType esum=0.0;
    for(int nn=myTable->M[iat],iel=0; nn<myTable->M[iat+1]; nn++,iel++){

      register RealType r(myTable->r(nn));
      if(r>Rmax) continue;

      register RealType rinv(myTable->rinv(nn));
      register PosType  dr(myTable->dr(nn));

      // Compute ratio of wave functions
      for (int j=0; j < nknot ; j++){ 
        PosType deltar(r*rrotsgrid_m[j]-dr);
        W.makeMove(iel,deltar); 
        psiratio[j]=psi.ratio(W,iel)*sgridweight_m[j];
        W.rejectMove(iel);
        //psi.rejectMove(iel);
      }
      // Compute radial potential
      //int k;
      //RealType rfrac;
      //nlpp_m[0]->locate(r,k,rfrac);
      //for(int ip=0;ip< nchannel; ip++){
      //  vrad[ip]=nlpp_m[ip]->f(k,rfrac)*wgt_angpp_m[ip];
      //}
      for(int ip=0;ip< nchannel; ip++){
        vrad[ip]=nlpp_m[ip]->splint(r)*wgt_angpp_m[ip];
      }

      // Compute spherical harmonics on grid
      for (int j=0, jl=0; j<nknot ; j++){ 
        RealType zz=dot(dr,rrotsgrid_m[j])*rinv;
        // Forming the Legendre polynomials
        lpol[0]=1.0;
        RealType lpolprev=0.0;
        for (int l=0 ; l< lmax ; l++){
          //Not a big difference
          //lpol[l+1]=(2*l+1)*zz*lpol[l]-l*lpolprev;
          //lpol[l+1]/=(l+1);
          lpol[l+1]=Lfactor1[l]*zz*lpol[l]-l*lpolprev; 
          lpol[l+1]*=Lfactor2[l]; 
          lpolprev=lpol[l];
        }
        for(int l=0; l <nchannel; l++,jl++) Amat[jl]=lpol[ angpp_m[l] ]; 
      } 

      if(nchannel==1) {
        esum += vrad[0]*BLAS::dot(nknot, &Amat[0],&psiratio[0]);
      } else {
        BLAS::gemv(nknot, nchannel, &Amat[0], &psiratio[0], &wvec[0]);
        esum += BLAS::dot(nchannel, &vrad[0], &wvec[0]);
      }
      ////////////////////////////////////
      //Original implmentation by S. C.
      //const char TRANS('T');
      //const int ione=1;
      //const RealType one=1.0;
      //const RealType zero=0.0;
      //dgemv(TRANS,nknot,nchannel,one,&Amat[0],nknot,&psiratio[0],ione,zero,&wvec[0],ione);
      //esum += ddot(nchannel,&vrad[0],ione,&wvec[0],ione);
      ////////////////////////////////////
      //iel++;
    }   /* end loop over electron */
    return esum;
  }