Example #1
0
  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;
  }
void polyDensityFadeBounded::controlAfterForces()
{
    insertionScheme_.checkFractions(molCloud_);
    
    controlTimeIndex_++;

    // sampling
    measureProperties();
    
    // control on the first time-step of the write interval
    if(controlTimeIndex_ > nControlSteps_)
    {
        Info << "polyDensityFadeBounded: control ... " << endl;
        
        averageProperties();
        
        label molsToControl = noOfMolsToControl();
        
        label totalMols = molsToControl;
        
        if(mag(totalMols) > 0)
        {        
            nMolsToInsert(molsToControl);
            
            Pout << "mols to control = " << molsToControl << endl; 
            
            List<vector> molPositions(molPoints_.size(), vector::zero);
        
            forAll(molPoints_, i)
            {
                molPositions[i] = molPoints_[i];
            }
        
            insertionScheme_.controlMolecules
            (
                molCloud_,
                molsToControl,
                bbcontrol_,
                molPositions 
            );

            if(deltaN_)
            {
                label nInserted = insertionScheme_.nInserted();
                label nDeleted = insertionScheme_.nDeleted();
        
                molsControlled_ += nInserted;
                molsControlled_ -= nDeleted;
            } 
        }
Example #3
0
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();
}
Example #4
0
  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, besum=0.0, bwgtsum=0.0;
    RealType r2_accepted=0.0,r2_proposed=0.0;
    int nrn(0),ncr(0),nfn(0),ngoodfn(0);
    for(; it!=it_end;++it)
    {
      bool inFN=(((*it)->ReleasedNodeAge)==0);
      int nc= std::min(static_cast<int>((*it)->Multiplicity),MaxCopy);
      
      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);
      RealType e((*it)->Properties(LOCALENERGY));
      RealType bfe((*it)->Properties(ALTERNATEENERGY));
      RealType rnwgt(0.0);
      if (inFN)
        rnwgt=((*it)->Properties(SIGN));
      else
        nrn+=nc;
      //       RealType wgt((*it)->Weight);
      RealType wgt(0.0);
      if (inFN)
        wgt=((*it)->Weight); 
      
      esum += wgt*e;
      e2sum += wgt*e*e;
      wsum += wgt;
      w2sum += wgt*wgt;
      ecum += e;
      besum += bfe*rnwgt*wgt;
      bwgtsum += rnwgt*wgt;
    }

    //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;
    curData[FNSIZE_INDEX]=static_cast<RealType>(nfn);
    curData[RNONESIZE_INDEX]=static_cast<RealType>(ncr);
    curData[RNSIZE_INDEX]=nrn;
    curData[B_ENERGY_INDEX]=besum;
    curData[B_WGT_INDEX]=bwgtsum;

    myComm->allreduce(curData);

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

    return W.getActiveWalkers();
  }