src/QMCDrivers/WalkerControlBase.cpp
/** evaluate curData and mark the bad/good walkers.
 *
 *  Each good walker has a counter registering the
 *  number of copies needed to be generated from this walker.
 *  Bad walkers will be either recycled or removed later.
 */
evaluate curData and mark the bad/good walkers.
Each good walker has a counter registering the
number of copies needed to be generated from this walker.
Bad walkers will be either recycled or removed later.
evaluate curData and mark the bad / good walkers . Each good walker has a counter registering the number of copies needed to be generated from this walker . Bad walkers will be either recycled or removed later .
int WalkerControlBase::sortWalkers(MCWalkerConfiguration& W)
{
  MCWalkerConfiguration::iterator it(W.begin());
  std::vector<Walker_t*> good_rn;
  std::vector<int> ncopy_rn;
  NumWalkers = 0;
  MCWalkerConfiguration::iterator it_end(W.end());
  FullPrecRealType esum = 0.0, e2sum = 0.0, wsum = 0.0, ecum = 0.0, w2sum = 0.0, besum = 0.0, bwgtsum = 0.0;
  FullPrecRealType r2_accepted = 0.0, r2_proposed = 0.0;
  int nfn(0), nrn(0), ngoodfn(0), ncr(0), nc(0);
  while (it != it_end)
  {
    bool inFN = (((*it)->ReleasedNodeAge) == 0);
    nc        = std::min(static_cast<int>((*it)->Multiplicity), MaxCopy);
    if (write_release_nodes_)
    {
      if ((*it)->ReleasedNodeAge == 1)
        ncr += 1;
      else if ((*it)->ReleasedNodeAge == 0)
      {
        nfn += 1;
        ngoodfn += nc;
      }
      r2_accepted += (*it)->Properties(R2ACCEPTED);
      r2_proposed += (*it)->Properties(R2PROPOSED);
      FullPrecRealType local_energy((*it)->Properties(LOCALENERGY));
      FullPrecRealType alternate_energy((*it)->Properties(ALTERNATEENERGY));
      FullPrecRealType wgt   = ((*it)->Weight);
      FullPrecRealType rnwgt = ((*it)->ReleasedNodeWeight);
      esum += wgt * rnwgt * local_energy;
      e2sum += wgt * rnwgt * local_energy * local_energy;
      wsum += rnwgt * wgt;
      w2sum += rnwgt * rnwgt * wgt * wgt;
      ecum += local_energy;
      besum += alternate_energy* wgt;
      bwgtsum += wgt;
    }
    else
    {
      if (nc > 0)
        nfn++;
      else
        ncr++;
      r2_accepted += (*it)->Properties(R2ACCEPTED);
      r2_proposed += (*it)->Properties(R2PROPOSED);
      FullPrecRealType e((*it)->Properties(LOCALENERGY));
      FullPrecRealType wgt = ((*it)->Weight);
      esum += wgt * e;
      e2sum += wgt * e * e;
      wsum += wgt;
      w2sum += wgt * wgt;
      ecum += e;
    }
    if ((nc) && (inFN))
    {
      NumWalkers += nc;
      good_w.push_back(*it);
      ncopy_w.push_back(nc - 1);
    }
    else if (nc)
    {
      NumWalkers += nc;
      nrn += nc;
      good_rn.push_back(*it);
      ncopy_rn.push_back(nc - 1);
    }
    else
    {
      bad_w.push_back(*it);
    }
    ++it;
  }
  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;
  curData[FNSIZE_INDEX]     = good_w.size();
  curData[RNONESIZE_INDEX]  = ncr;
  curData[RNSIZE_INDEX]     = nrn;
  curData[B_ENERGY_INDEX]   = besum;
  curData[B_WGT_INDEX]      = bwgtsum;
  if (write_release_nodes_)
  {
    it     = good_rn.begin();
    it_end = good_rn.end();
    int indy(0);
    while (it != it_end)
    {
      good_w.push_back(*it);
      ncopy_w.push_back(ncopy_rn[indy]);
      it++, indy++;
    }
  }
  return NumWalkers;
}
int WalkerControlBase :: sortWalkers ( MCWalkerConfiguration & W ) { MCWalkerConfiguration :: iterator it ( W . begin ( ) ) ; std :: vector < Walker_t * > good_rn ; std :: vector < int > ncopy_rn ; NumWalkers = 0 ; MCWalkerConfiguration :: iterator it_end ( W . end ( ) ) ; FullPrecRealType esum = 0.0 , e2sum = 0.0 , wsum = 0.0 , ecum = 0.0 , w2sum = 0.0 , besum = 0.0 , bwgtsum = 0.0 ; FullPrecRealType r2_accepted = 0.0 , r2_proposed = 0.0 ; int nfn ( 0 ) , nrn ( 0 ) , ngoodfn ( 0 ) , ncr ( 0 ) , nc ( 0 ) ; while ( it != it_end ) { bool inFN = ( ( ( * it ) -> ReleasedNodeAge ) == 0 ) ; nc = std :: min ( static_cast < int > ( ( * it ) -> Multiplicity ) , MaxCopy ) ; if ( write_release_nodes_ ) { if ( ( * it ) -> ReleasedNodeAge == 1 ) ncr += 1 ; else if ( ( * it ) -> ReleasedNodeAge == 0 ) { nfn += 1 ; ngoodfn += nc ; } r2_accepted += ( * it ) -> Properties ( R2ACCEPTED ) ; r2_proposed += ( * it ) -> Properties ( R2PROPOSED ) ; FullPrecRealType local_energy ( ( * it ) -> Properties ( LOCALENERGY ) ) ; FullPrecRealType alternate_energy ( ( * it ) -> Properties ( ALTERNATEENERGY ) ) ; FullPrecRealType wgt = ( ( * it ) -> Weight ) ; FullPrecRealType rnwgt = ( ( * it ) -> ReleasedNodeWeight ) ; esum += wgt * rnwgt * local_energy ; e2sum += wgt * rnwgt * local_energy * local_energy ; wsum += rnwgt * wgt ; w2sum += rnwgt * rnwgt * wgt * wgt ; ecum += local_energy ; besum += alternate_energy * wgt ; bwgtsum += wgt ; } else { if ( nc > 0 ) nfn ++ ; else ncr ++ ; r2_accepted += ( * it ) -> Properties ( R2ACCEPTED ) ; r2_proposed += ( * it ) -> Properties ( R2PROPOSED ) ; FullPrecRealType e ( ( * it ) -> Properties ( LOCALENERGY ) ) ; FullPrecRealType wgt = ( ( * it ) -> Weight ) ; esum += wgt * e ; e2sum += wgt * e * e ; wsum += wgt ; w2sum += wgt * wgt ; ecum += e ; } if ( ( nc ) && ( inFN ) ) { NumWalkers += nc ; good_w . push_back ( * it ) ; ncopy_w . push_back ( nc - 1 ) ; } else if ( nc ) { NumWalkers += nc ; nrn += nc ; good_rn . push_back ( * it ) ; ncopy_rn . push_back ( nc - 1 ) ; } else { bad_w . push_back ( * it ) ; } ++ it ; } 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 ; curData [ FNSIZE_INDEX ] = good_w . size ( ) ; curData [ RNONESIZE_INDEX ] = ncr ; curData [ RNSIZE_INDEX ] = nrn ; curData [ B_ENERGY_INDEX ] = besum ; curData [ B_WGT_INDEX ] = bwgtsum ; if ( write_release_nodes_ ) { it = good_rn . begin ( ) ; it_end = good_rn . end ( ) ; int indy ( 0 ) ; while ( it != it_end ) { good_w . push_back ( * it ) ; ncopy_w . push_back ( ncopy_rn [ indy ] ) ; it ++ , indy ++ ; } } return NumWalkers ; }
evaluate curData and mark the bad/good walkers.
evaluate curData and mark the bad / good walkers .
//temp is an array to perform reduction operations //update curData // This is really an integral type but is implicitly converted // This is really an integral type but is implicitly converted // This is really an integral type but is implicitly converted ////this should be move //W.EnsembleProperty.NumSamples=curData[WALKERSIZE_INDEX]; //W.EnsembleProperty.Weight=curData[WEIGHT_INDEX]; //W.EnsembleProperty.Energy=(esum/=wsum); //W.EnsembleProperty.Variance=(e2sum/wsum-esum*esum); //W.EnsembleProperty.Variance=(e2sum*wsum-esum*esum)/(wsum*wsum-w2sum);