当前位置: 首页>>代码示例>>C++>>正文


C++ MCWalkerConfiguration::begin方法代码示例

本文整理汇总了C++中MCWalkerConfiguration::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ MCWalkerConfiguration::begin方法的具体用法?C++ MCWalkerConfiguration::begin怎么用?C++ MCWalkerConfiguration::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MCWalkerConfiguration的用法示例。


在下文中一共展示了MCWalkerConfiguration::begin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: accumulate

 //NOTE: weights are not handled nicely.
 //weight should be done carefully, not valid for DMC
 //will add a function to MCWalkerConfiguration to track total weight
 void EstimatorManager::accumulate(MCWalkerConfiguration& W)
 {
   BlockWeight += W.getActiveWalkers();
   RealType norm=1.0/W.getGlobalNumWalkers();
   for(int i=0; i< Estimators.size(); i++) 
     Estimators[i]->accumulate(W,W.begin(),W.end(),norm);
 }
开发者ID:digideskio,项目名称:qmcpack,代码行数:10,代码来源:EstimatorManager.cpp

示例2: branch

  int WalkerControlBase::branch(int iter, MCWalkerConfiguration& W, RealType trigger) {

    int prefill_numwalkers = sortWalkers(W);

    measureProperties(iter);
    W.EnsembleProperty=EnsembleProperty;

    //un-biased variance but we use the saimple one
    //W.EnsembleProperty.Variance=(e2sum*wsum-esum*esum)/(wsum*wsum-w2sum);

    ////add to the accumData for block average: REMOVE THIS
    //accumData[ENERGY_INDEX]     += curData[ENERGY_INDEX]*wgtInv;
    //accumData[ENERGY_SQ_INDEX]  += curData[ENERGY_SQ_INDEX]*wgtInv;
    //accumData[WALKERSIZE_INDEX] += curData[WALKERSIZE_INDEX];
    //accumData[WEIGHT_INDEX]     += curData[WEIGHT_INDEX];

    int nw_tot = copyWalkers(W);

    //set Weight and Multiplicity to default values
    MCWalkerConfiguration::iterator it(W.begin()),it_end(W.end());
    while(it != it_end) {
      (*it)->Weight= 1.0;
      (*it)->Multiplicity=1.0;
      ++it;
    }

    //set the global number of walkers
    W.setGlobalNumWalkers(nw_tot);

    return prefill_numwalkers;
  }
开发者ID:digideskio,项目名称:qmcpack,代码行数:31,代码来源:WalkerControlBase.cpp

示例3: accumulate

/** accumulate Local energies and collectables
 * @param W ensemble
 */
void EstimatorManager::accumulate(MCWalkerConfiguration& W)
{
  BlockWeight += W.getActiveWalkers();
  RealType norm=1.0/W.getGlobalNumWalkers();
  for(int i=0; i< Estimators.size(); i++)
    Estimators[i]->accumulate(W,W.begin(),W.end(),norm);
  if(Collectables)//collectables are normalized by QMC drivers
    Collectables->accumulate_all(W.Collectables,1.0);
}
开发者ID:digideskio,项目名称:qmcpack,代码行数:12,代码来源:EstimatorManager.cpp

示例4: XMLReport

/**  Write the set of walker configurations to the HDF5 file.  
 *@param W set of walker configurations
 *@param ic the number of frames
 *
 * \if ic==-1
 *  use only the last frame for a restart
 * \else if ic>=0
 *  use ic frames from the file for opitimizations
 */
bool  
HDFWalkerInput0::put(MCWalkerConfiguration& W, int ic){

  if(Counter<0) return false;

  int selected = ic;
  if(ic<0) {
    XMLReport("Will use the last set from " << NumSets << " of configurations.")
    selected = NumSets-1;
  }

  typedef MCWalkerConfiguration::PosType PosType;
  typedef MCWalkerConfiguration::PropertyContainer_t ProtertyContainer_t;

  typedef Matrix<PosType>  PosContainer_t;

  int nwt = 0;
  int npt = 0;
  //2D array of PosTypes (x,y,z) indexed by (walker,particle)
  PosContainer_t Pos_temp;

  //open the group
  char GrpName[128];
  sprintf(GrpName,"config%04d",selected);
  hid_t group_id = H5Gopen(h_config,GrpName);
    
  HDFAttribIO<PosContainer_t> Pos_in(Pos_temp);
  //read the dataset
  Pos_in.read(group_id,"coord");
  //close the group
  H5Gclose(group_id);

  /*check to see if the number of walkers and particles is  consistent with W */
  int nptcl = Pos_temp.cols();
  nwt = Pos_temp.rows();

  int curWalker = W.getActiveWalkers();
  if(curWalker) {
    LOGMSG("Adding " << nwt << " walkers to " << curWalker)
    W.createWalkers(nwt);
  } else {
    W.resize(nwt,nptcl); 
  }

  //assign configurations to W
  int iw=0;
  MCWalkerConfiguration::iterator it = W.begin()+curWalker; 
  MCWalkerConfiguration::iterator it_end = W.end(); 
  while(it != it_end) {
    std::copy(Pos_temp[iw],Pos_temp[iw+1], (*it)->R.begin());
    ++it;++iw;
  }

  return true;
}
开发者ID:digideskio,项目名称:qmcpack,代码行数:64,代码来源:HDFWalkerInput0.cpp

示例5: wgtInv

int 
WalkerControlMPI::branch(int iter, MCWalkerConfiguration& W, RealType trigger) {

  std::fill(curData.begin(),curData.end(),0);
  //std::fill(NumPerNode.begin(),NumPerNode.end(),0);
  sortWalkers(W);

  //update the number of walkers for this node
  curData[LE_MAX+MyContext]=NumWalkers;

  int nw = copyWalkers(W);

  myComm->allreduce(curData);

  RealType wgtInv(1.0/curData[WEIGHT_INDEX]);
  accumData[ENERGY_INDEX]     += curData[ENERGY_INDEX]*wgtInv;
  accumData[ENERGY_SQ_INDEX]  += curData[ENERGY_SQ_INDEX]*wgtInv;
  accumData[WALKERSIZE_INDEX] += curData[WALKERSIZE_INDEX];
  accumData[WEIGHT_INDEX]     += curData[WEIGHT_INDEX];

  Cur_pop=0;
  for(int i=0, j=LE_MAX; i<NumContexts; i++,j++) {
    Cur_pop+= NumPerNode[i]=static_cast<int>(curData[j]);
  }

  swapWalkersSimple(W); 

  //Do not need to use a trigger.
  //Cur_min=Nmax; 
  //Cur_max=0; 
  //Cur_pop=0;
  //for(int i=0, j=LE_MAX; i<NumContexts; i++,j++) {
  //  Cur_pop+= NumPerNode[i]=static_cast<int>(curData[j]);
  //  Cur_min = std::min(Cur_min,NumPerNode[i]);
  //  Cur_max = std::max(Cur_max,NumPerNode[i]);
  //}
  //int max_diff = std::max(Cur_max*NumContexts-Cur_pop,Cur_pop-Cur_min*NumContexts);
  //double diff_pop = static_cast<double>(max_diff)/static_cast<double>(Cur_pop);
  //if(diff_pop > trigger) { 
  //  swapWalkersSimple(W); 
  //  //swapWalkersMap(W); 
  //}

  //set Weight and Multiplicity to default values
  MCWalkerConfiguration::iterator it(W.begin()),it_end(W.end());
  while(it != it_end) {
    (*it)->Weight= 1.0;
    (*it)->Multiplicity=1.0;
    ++it;
  }

  //update the global number of walkers
  W.setGlobalNumWalkers(Cur_pop);
  return Cur_pop;
}
开发者ID:digideskio,项目名称:qmcpack,代码行数:55,代码来源:WalkerControlMPI.cpp

示例6:

/**
   @brief accumulate data for all the estimators
*/
void 
ScalarEstimatorManager::accumulate(const MCWalkerConfiguration& W) {

  for(MCWalkerConfiguration::const_iterator it = W.begin(); 
      it != W.end(); it++){    
    RealType wgt = (*it)->Properties(WEIGHT);
    WeightSum += wgt;
    for(int i=0; i< Estimators.size(); i++) 
      Estimators[i]->accumulate(**it,wgt);
  }
}
开发者ID:digideskio,项目名称:qmcpack,代码行数:14,代码来源:ScalarEstimatorManager.cpp

示例7: setWalkerID

 void WalkerControlBase::setWalkerID(MCWalkerConfiguration& walkers)
 {
   start(); //do the normal start
   MCWalkerConfiguration::iterator wit(walkers.begin());
   MCWalkerConfiguration::iterator wit_end(walkers.end());
   for(; wit != wit_end; ++wit)
   {
     if((*wit)->ID==0) 
     {
       (*wit)->ID=(++NumWalkersCreated)*NumContexts+MyContext;
       (*wit)->ParentID=(*wit)->ID;
     }
   }
 }
开发者ID:digideskio,项目名称:qmcpack,代码行数:14,代码来源:WalkerControlBase.cpp

示例8: getCurrentStatistics

 void EstimatorManager::getCurrentStatistics(MCWalkerConfiguration& W
     , RealType& eavg, RealType& var)
 {
   LocalEnergyOnlyEstimator energynow;
   energynow.clear();
   energynow.accumulate(W,W.begin(),W.end(),1.0);
   vector<RealType> tmp(3);
   tmp[0]= energynow.scalars[0].result();
   tmp[1]= energynow.scalars[0].result2();
   tmp[2]= energynow.scalars[0].count();
   myComm->allreduce(tmp);
   eavg=tmp[0]/tmp[2];
   var=tmp[1]/tmp[2]-eavg*eavg;
 }
开发者ID:digideskio,项目名称:qmcpack,代码行数:14,代码来源:EstimatorManager.cpp

示例9: it

/** accumulate data for all the estimators
 */
void 
ScalarEstimatorManager::accumulate(const MCWalkerConfiguration& W) {

  RealType wgt_sum=0;
  MCWalkerConfiguration::const_iterator it(W.begin()),it_end(W.end());
  while(it != it_end) {
    RealType wgt = (*it)->Weight;
    wgt_sum+= wgt;
    for(int i=0; i< Estimators.size(); i++) Estimators[i]->accumulate(**it,wgt);
    ++it;
  }

  MyData[WEIGHT_INDEX]+=wgt_sum;
}
开发者ID:digideskio,项目名称:qmcpack,代码行数:16,代码来源:ScalarEstimatorManager.cpp

示例10: sprintf

bool  
HDFWalkerInput0::append(MCWalkerConfiguration& W, int blocks){

  if(Counter<0) return false;

  //if(nwalkers<0) return put(W,-1);

  typedef MCWalkerConfiguration::PosType PosType;
  typedef Matrix<PosType>  PosContainer_t;
  PosContainer_t Pos_temp;

  int nw_in=0;
  int firstConf=std::max(0,NumSets-blocks);
  if(blocks<0) firstConf=0;

  for(int iconf=firstConf; iconf<NumSets; iconf++) {
    //open the group
    char GrpName[128];
    sprintf(GrpName,"config%04d",iconf);
    hid_t group_id = H5Gopen(h_config,GrpName);
    HDFAttribIO<PosContainer_t> Pos_in(Pos_temp);
    //read the dataset
    Pos_in.read(group_id,"coord");
    //close the group
    H5Gclose(group_id);
    /*check to see if the number of walkers and particles is  consistent with W */
    int nptcl = Pos_temp.cols();
    int nwt = Pos_temp.rows();
    int curWalker=0;
    if(nptcl != W.getParticleNum()) {
      W.resize(nwt,nptcl); 
    } else {
      curWalker=W.getActiveWalkers();
      W.createWalkers(nwt);
    }
    MCWalkerConfiguration::iterator it = W.begin()+curWalker; 
    for(int iw=0; iw<nwt; iw++) {
      //std::copy(Post_temp[iw],Post_temp[iw+1], (*it)->R.begin());
      for(int iat=0; iat < nptcl; iat++){
        (*it)->R(iat) = Pos_temp(iw,iat);
      }
      ++it;
    }
    nw_in += nwt; 
  }

  LOGMSG("Total " << nw_in << " walkers are loaded using " << NumSets-firstConf << " blocks.")
  return true;
}
开发者ID:digideskio,项目名称:qmcpack,代码行数:49,代码来源:HDFWalkerInput0.cpp

示例11: fout

 void Write2XYZ(MCWalkerConfiguration& W)
 {
   ofstream fout("bad.xyz");
   MCWalkerConfiguration::iterator it(W.begin());
   MCWalkerConfiguration::iterator it_end(W.end());
   int nptcls(W.getTotalNum());
   while(it != it_end) {
     fout << nptcls << endl 
       << "# E = " << (*it)->Properties(LOCALENERGY) 
       << " Wgt= " << (*it)->Weight << endl;
     for(int i=0; i<nptcls; i++)
       fout << "H " << (*it)->R[i] << endl;
     ++it;
   }
 }
开发者ID:digideskio,项目名称:qmcpack,代码行数:15,代码来源:WalkerControlBase.cpp

示例12: copyWalkers

  int WalkerControlBase::copyWalkers(MCWalkerConfiguration& W) {
    //clear the WalkerList to populate them with the good walkers
    W.clear();
    W.insert(W.begin(), good_w.begin(), good_w.end());

    int cur_walker = good_w.size();
    for(int i=0; i<good_w.size(); i++) { //,ie+=ncols) {
      for(int j=0; j<ncopy_w[i]; j++, cur_walker++) 
      {
        Walker_t* awalker=new Walker_t(*(good_w[i]));
        awalker->ID=(++NumWalkersCreated)*NumContexts+MyContext;
        awalker->ParentID=good_w[i]->ParentID;
        W.push_back(awalker);
      }
    }

    //clear good_w and ncopy_w for the next branch
    good_w.clear();
    ncopy_w.clear();
    return W.getActiveWalkers();
  }
开发者ID:digideskio,项目名称:qmcpack,代码行数:21,代码来源:WalkerControlBase.cpp

示例13: doNotBranch

int WalkerControlBase::doNotBranch(int iter, MCWalkerConfiguration& W)
{
    MCWalkerConfiguration::iterator it(W.begin());
    MCWalkerConfiguration::iterator it_end(W.end());
    RealType esum=0.0,e2sum=0.0,wsum=0.0,ecum=0.0, w2sum=0.0;
    RealType r2_accepted=0.0,r2_proposed=0.0;
    for(; it!=it_end; ++it)
    {
        r2_accepted+=(*it)->Properties(R2ACCEPTED);
        r2_proposed+=(*it)->Properties(R2PROPOSED);
        RealType e((*it)->Properties(LOCALENERGY));
        int nc= std::min(static_cast<int>((*it)->Multiplicity),MaxCopy);
        RealType wgt((*it)->Weight);
        esum += wgt*e;
        e2sum += wgt*e*e;
        wsum += wgt;
        w2sum += wgt*wgt;
        ecum += e;
    }

    //temp is an array to perform reduction operations
    std::fill(curData.begin(),curData.end(),0);

    curData[ENERGY_INDEX]=esum;
    curData[ENERGY_SQ_INDEX]=e2sum;
    curData[WALKERSIZE_INDEX]=W.getActiveWalkers();
    curData[WEIGHT_INDEX]=wsum;
    curData[EREF_INDEX]=ecum;
    curData[R2ACCEPTED_INDEX]=r2_accepted;
    curData[R2PROPOSED_INDEX]=r2_proposed;

    myComm->allreduce(curData);

    measureProperties(iter);
    trialEnergy=EnsembleProperty.Energy;
    W.EnsembleProperty=EnsembleProperty;

    //return the current data
    return W.getGlobalNumWalkers();
}
开发者ID:svn2github,项目名称:qmcpack,代码行数:40,代码来源:WalkerControlBase.cpp

示例14: wgtInv

int 
WalkerReconfigurationMPI::branch(int iter, MCWalkerConfiguration& W, RealType trigger) {

  int nwkept = swapWalkers(W);

  RealType wgtInv(1.0/curData[WEIGHT_INDEX]);
  accumData[ENERGY_INDEX]     += curData[ENERGY_INDEX]*wgtInv;
  accumData[ENERGY_SQ_INDEX]  += curData[ENERGY_SQ_INDEX]*wgtInv;
  accumData[WALKERSIZE_INDEX] += nwkept;
  //accumData[WALKERSIZE_INDEX] += curData[WALKERSIZE_INDEX];
  accumData[WEIGHT_INDEX]     += curData[WEIGHT_INDEX];

  //set Weight and Multiplicity to default values
  MCWalkerConfiguration::iterator it(W.begin()),it_end(W.end());
  while(it != it_end) {
    (*it)->Weight= 1.0;
    (*it)->Multiplicity=1.0;
    ++it;
  }

  return nwkept;
}
开发者ID:digideskio,项目名称:qmcpack,代码行数:22,代码来源:WalkerReconfigurationMPI.cpp

示例15: it

int 
GlobalWalkerControl::branch(int iter, MCWalkerConfiguration& W, RealType trigger) {

  std::fill(NumPerNode.begin(),NumPerNode.end(),0);

  sortWalkers(W);

  NumPerNode[MyContext] = NumWalkers;

  int nw = copyWalkers(W);

  //wait until everynode comes here
  OHMMS::Controller->barrier();
  gsum(NumPerNode,0);

  Cur_min=Nmax; Cur_max=0; Cur_pop=0;
  for(int i=0; i<NumContexts; i++) {
    Cur_pop+= NumPerNode[i];
    Cur_min = std::min(Cur_min,NumPerNode[i]);
    Cur_max = std::max(Cur_max,NumPerNode[i]);
  }

  int max_diff = std::max(Cur_max*NumContexts-Cur_pop,Cur_pop-Cur_min*NumContexts);
  double diff_pop = static_cast<double>(max_diff)/static_cast<double>(Cur_pop);

  if(diff_pop > trigger) { swapWalkersMap(W); }

  //set Weight and Multiplicity to default values
  MCWalkerConfiguration::iterator it(W.begin()),it_end(W.end());
  while(it != it_end) {
    (*it)->Weight= 1.0;
    (*it)->Multiplicity=1.0;
    ++it;
  }

  return Cur_pop;
}
开发者ID:digideskio,项目名称:qmcpack,代码行数:37,代码来源:GlobalWalkerControl.cpp


注:本文中的MCWalkerConfiguration::begin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。