QMCPACK
SimpleFixedNodeBranch Struct Reference

Manages the state of QMC sections and handles population control for DMCs. More...

+ Inheritance diagram for SimpleFixedNodeBranch:
+ Collaboration diagram for SimpleFixedNodeBranch:

Classes

struct  VParams
 controlling parameters of full precision real type More...
 

Public Types

enum  {
  B_DMC = 0, B_DMCSTAGE = 1, B_POPCONTROL = 2, B_USETAUEFF = 3,
  B_CLEARHISTORY = 4, B_KILLNODES = 5, B_RESTART = 6, B_RMC = 7,
  B_RMCSTAGE = 8, B_MODE_MAX = 10
}
 
enum  {
  B_WARMUPSTEPS = 0, B_ENERGYUPDATEINTERVAL = 1, B_COUNTER = 2, B_TARGETWALKERS = 3,
  B_MAXWALKERS = 4, B_MINWALKERS = 5, B_BRANCHINTERVAL = 6, B_IPARAM_MAX = 8
}
 
enum  SimpleBranchVectorParameter {
  TAU = 0, TAUEFF, ETRIAL, EREF,
  ENOW, BRANCHMAX, BRANCHCUTOFF, BRANCHFILTER,
  SIGMA2, ACC_ENERGY, ACC_SAMPLES, FEEDBACK,
  FILTERSCALE, VPARAM_MAX = 17
}
 enum for vParam More...
 
using ThisType = SimpleFixedNodeBranch
 
using MCPWalker = Walker< QMCTraits, PtclOnLatticeTraits >
 
using BranchModeType = std::bitset< B_MODE_MAX >
 booleans to set the branch modes More...
 
using IParamType = TinyVector< int, B_IPARAM_MAX >
 input parameters of integer types More...
 
using SBVP = SimpleBranchVectorParameter
 
using VParamType = VParams< SBVP >
 
- Public Types inherited from QMCTraits
enum  { DIM = OHMMS_DIM, DIM_VGL = OHMMS_DIM + 2 }
 
using QTBase = QMCTypes< OHMMS_PRECISION, DIM >
 
using QTFull = QMCTypes< OHMMS_PRECISION_FULL, DIM >
 
using RealType = QTBase::RealType
 
using ComplexType = QTBase::ComplexType
 
using ValueType = QTBase::ValueType
 
using PosType = QTBase::PosType
 
using GradType = QTBase::GradType
 
using TensorType = QTBase::TensorType
 
using IndexType = OHMMS_INDEXTYPE
 define other types More...
 
using FullPrecRealType = QTFull::RealType
 
using FullPrecValueType = QTFull::ValueType
 
using PropertySetType = RecordNamedProperty< FullPrecRealType >
 define PropertyList_t More...
 
using PtclGrpIndexes = std::vector< std::pair< int, int > >
 

Public Member Functions

 SimpleFixedNodeBranch (RealType tau, int nideal)
 Constructor. More...
 
 SimpleFixedNodeBranch (const SimpleFixedNodeBranch &abranch)
 copy constructor More...
 
 ~SimpleFixedNodeBranch ()
 
bool phaseChanged (RealType psi0) const
 
void advanceQMCCounter ()
 increment QMCCounter More...
 
void regressQMCCounter ()
 
EstimatorManagerBasegetEstimatorManager ()
 get the EstimatorManager More...
 
void setEstimatorManager (std::unique_ptr< EstimatorManagerBase > est)
 set the EstimatorManager More...
 
int initWalkerController (MCWalkerConfiguration &mcwc, bool fixW, bool killwalker)
 initialize the WalkerController More...
 
void initReptile (MCWalkerConfiguration &w)
 initialize reptile stats More...
 
void checkParameters (MCWalkerConfiguration &w)
 determine trial and reference energies More...
 
RealType branchWeightBare (RealType enew, RealType eold) const
 return the bare branch weight More...
 
RealType branchWeight (FullPrecRealType enew, FullPrecRealType eold) const
 return the bare branch weight with a filtering using an energy window More...
 
RealType symLinkAction (RealType logGf, RealType logGb, RealType enew, RealType eold) const
 
RealType symLinkActionBare (RealType logGf, RealType logGb, RealType enew, RealType eold) const
 
RealType DMCLinkAction (RealType enew, RealType eold) const
 
RealType branchWeight (RealType enew, RealType eold, RealType scnew, RealType scold) const
 return the branch weight according to JCP1993 Umrigar et al. More...
 
RealType branchWeight (RealType enew, RealType eold, RealType scnew, RealType scold, RealType p) const
 return the branch weight according to JCP1993 Umrigar et al. More...
 
RealType branchWeightTau (RealType enew, RealType eold, RealType scnew, RealType scold, RealType taueff)
 return the branch weight according to JCP1993 Umrigar et al. More...
 
RealType getEref () const
 
RealType getEtrial () const
 
RealType getTau () const
 
RealType getTauEff () const
 
void branch (int iter, MCWalkerConfiguration &w)
 perform branching More...
 
void collect (int iter, MCWalkerConfiguration &w)
 update RMC counters and running averages. More...
 
void flush (int counter)
 restart averaging More...
 
void reset ()
 reset the internal parameters More...
 
int resetRun (xmlNodePtr cur)
 reset the internal parameters More...
 
bool put (xmlNodePtr cur)
 Parse the xml file for parameters. More...
 
void write (const std::string &fname, bool overwrite=true)
 write the state More...
 
void read (const std::string &fname)
 
void registerParameters ()
 create map between the parameter name and variables More...
 
void start (const std::string &froot, bool append=false)
 start a run More...
 
void finalize (MCWalkerConfiguration &w)
 finalize the simulation More...
 

Public Attributes

BranchModeType BranchMode
 
IParamType iParam
 
VParamType vParam
 
int ToDoSteps
 number of remaning steps for a specific tasks More...
 
FullPrecRealType logN
 Feed*log(N) More...
 
xmlNodePtr myNode
 save xml element More...
 
std::unique_ptr< WalkerControlBaseWalkerController
 WalkerController. More...
 
std::unique_ptr< WalkerControlBaseBackupWalkerController
 Backup WalkerController for mixed DMC. More...
 
std::unique_ptr< EstimatorManagerBaseMyEstimator
 
accumulator_set< FullPrecRealTypeEnergyHist
 a simple accumulator for energy More...
 
accumulator_set< FullPrecRealTypeVarianceHist
 a simple accumulator for variance More...
 
accumulator_set< RealTypeR2Accepted
 a simple accumulator for energy More...
 
accumulator_set< RealTypeR2Proposed
 a simple accumulator for energy More...
 
accumulator_set< RealTypeR2Center
 a simple accumulator for reptation's center slice More...
 
std::string RootName
 root name More...
 
std::string branching_cutoff_scheme
 scheme of branching cutoff More...
 
ParameterSet m_param
 set of parameters More...
 
std::vector< std::string > sParam
 string parameters More...
 
FullPrecRealType ScaleSum
 Used for the average scaling. More...
 
unsigned long ScaleNum
 
RealType LogJacobRef
 LogJacob. More...
 
std::vector< RealTypeLogNorm
 LogNorm. More...
 

Private Member Functions

void setBranchCutoff (FullPrecRealType variance, FullPrecRealType targetSigma, FullPrecRealType maxSigma, int Nelec=0)
 set branch cutoff, max, filter More...
 

Private Attributes

std::string debug_disable_branching_
 disable branching for debugging More...
 

Detailed Description

Manages the state of QMC sections and handles population control for DMCs.

Todo:

: Remove Estimator dependency, only has come dependency. Express accumulate in the actual DMC algorithm (i.e. in DMCBatched.cpp)

: Remove duplicate reading of Driver XML section with own copies of input parameters.

: Rename, it is the only branching class so its name is too much

: Use normal types for data members, don't be clever, the parameter enums violate KISS and make debugging annoying

: Remove as much state as possible.

QMCDriver object owns a SimpleFixedNodeBranch to keep track of the progress of a qmc section. It implements several methods to control the population and trial energy during a DMC and evaluate the properties of a population, e.g., energy, variance, population etc. It owns WalkerController (pointer to a WalkerControlBase object) which manages the population (killing and duplicating walkers) and load balancing among multiple MPI tasks.

See also
{http://qmcpack.cmscc.org/qmc-basics}

Steps in 'Legacy' SFNB states machine

  1. Construction (gets global walker number (rank or section wide?)
  2. setEstimatorManager (also makes bootstrapping SFNB state dependent on valid Communicate*)
  3. put(reads driver XML node yet again)
  4. setWalkerController (Maybe a WalkerController pointer is passed in)
  5. InitWalkerController a. Creates walkercontroller if WalkerController is a nullptr b. If TargetWalkers isn't known aa. allreduce and updates MCMW globalWalkers. bb. resets walker offsets cc. sets target walkers to whatever current total active walkers is. c. resets WalkerController d. If not a restart aa. saves fixW and killWalker to internal params, otherwise just discards. bb. updates SFNB copy of MAX/MINWALKRS from walker controller, these were set in constructer but I guess thats ony if this is a restart e. setWalkerId aa. call start()
    1. Which calls reset which crucially calculates and update logN state. bb. updates all the walker id's of walkers in MCWC.
  6. checkParameters a. getApproximateEnergyVariance from SFNB's estimator b. set ETrial, EREF, SIGMA2 from estimator c. clear EnergyHist and VarianceHist

Finally branch can be called! It will be called once each step.

  1. call branch (iter and MCMW) a. Not first iter during warmup then call WalkerController branch. else call WC doNotBranch, returns pop_now b. copy a bunch a state from WC to SFNB (should be with respect to pop_now - number of released nodes) c. If using taueff update that based on acceptance ration and current tau. d. If not warmup calculate ETRIAL based on EREF and feedback * log(TargetWalkers) - log(pop_now) e. set WC's TrialEnergy d. multiply walkers.Colelctables *= the inverse weight. f. call SFNB's estimator accumilator on MCWC

Definition at line 99 of file SimpleFixedNodeBranch.h.

Member Typedef Documentation

◆ BranchModeType

using BranchModeType = std::bitset<B_MODE_MAX>

booleans to set the branch modes

Since
2008-05-05

Definition at line 133 of file SimpleFixedNodeBranch.h.

◆ IParamType

input parameters of integer types

Since
2008-05-05

Definition at line 164 of file SimpleFixedNodeBranch.h.

◆ MCPWalker

◆ SBVP

Definition at line 189 of file SimpleFixedNodeBranch.h.

◆ ThisType

Definition at line 101 of file SimpleFixedNodeBranch.h.

◆ VParamType

Definition at line 202 of file SimpleFixedNodeBranch.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

enum for booleans

Since
2008-05-05
Enumerator
B_DMC 

1 for dmc, 0 for anything else

B_DMCSTAGE 

1 for main, 0 for wamrup

B_POPCONTROL 

1 for the standard dmc, 0 for the comb method

B_USETAUEFF 

1 to use taueff accordning to JCP 93, 0 to use tau

B_CLEARHISTORY 

1 to clear the history

B_KILLNODES 

1 to kill walkers when a node crossing is detected

B_RESTART 

1 if restarting

B_RMC 

1 for rmc, 0 for anything else

B_RMCSTAGE 

1 for main, 0 for warmup

B_MODE_MAX 

size of BranchMode

Definition at line 107 of file SimpleFixedNodeBranch.h.

108  {
109  B_DMC = 0 /**< 1 for dmc, 0 for anything else */
110  ,
111  B_DMCSTAGE = 1 /**< 1 for main, 0 for wamrup */
112  ,
113  B_POPCONTROL = 2 /**< 1 for the standard dmc, 0 for the comb method */
114  ,
115  B_USETAUEFF = 3 /**< 1 to use taueff accordning to JCP 93, 0 to use tau */
116  ,
117  B_CLEARHISTORY = 4 /**< 1 to clear the history */
118  ,
119  B_KILLNODES = 5 /**< 1 to kill walkers when a node crossing is detected */
120  ,
121  B_RESTART = 6 /**< 1 if restarting */
122  ,
123  B_RMC = 7 /**< 1 for rmc, 0 for anything else */
124  ,
125  B_RMCSTAGE = 8 /**< 1 for main, 0 for warmup */
126  ,
127  B_MODE_MAX = 10 /**< size of BranchMode */
128  };
1 to use taueff accordning to JCP 93, 0 to use tau
1 to kill walkers when a node crossing is detected
1 for the standard dmc, 0 for the comb method

◆ anonymous enum

anonymous enum

enum for iParam std::bitset<B_IPARAM_MAX>

Since
2008-05-05

When introducing a new iParam, check if B_IPARAM_MAX is sufficiently large. Use multiples of 8 Why? Much easier to use bool flags. Are these ever serialized?

Enumerator
B_WARMUPSTEPS 

warmup steps, valid when BranchMode[D_DMCSTAGE] == 0

B_ENERGYUPDATEINTERVAL 

frequency of the trial energy updates, default 1

B_COUNTER 

counter for tracking object state

B_TARGETWALKERS 

target total number of walkers per mpi group

B_MAXWALKERS 

maximum number of walkers per node

B_MINWALKERS 

minimum number of walkers per node

B_BRANCHINTERVAL 

interval between branch, see population control

B_IPARAM_MAX 

size of iParam

Definition at line 142 of file SimpleFixedNodeBranch.h.

143  {
144  B_WARMUPSTEPS = 0 /**< warmup steps, valid when BranchMode[D_DMCSTAGE] == 0 */
145  ,
146  B_ENERGYUPDATEINTERVAL = 1 /**< frequency of the trial energy updates, default 1 */
147  ,
148  B_COUNTER = 2 /**< counter for tracking object state */
149  ,
150  B_TARGETWALKERS = 3 /**< target total number of walkers per mpi group */
151  ,
152  B_MAXWALKERS = 4 /**< maximum number of walkers per node */
153  ,
154  B_MINWALKERS = 5 /**< minimum number of walkers per node */
155  ,
156  B_BRANCHINTERVAL = 6 /**< interval between branch, see population control */
157  ,
158  B_IPARAM_MAX = 8 /**< size of iParam */
159  };
frequency of the trial energy updates, default 1
warmup steps, valid when BranchMode[D_DMCSTAGE] == 0
interval between branch, see population control
target total number of walkers per mpi group

◆ SimpleBranchVectorParameter

enum for vParam

Easy serialization is a relatively minor concern compared to the annoyance this causes elsewhere.

Enumerator
TAU 
TAUEFF 
ETRIAL 
EREF 
ENOW 
BRANCHMAX 
BRANCHCUTOFF 
BRANCHFILTER 
SIGMA2 
ACC_ENERGY 
ACC_SAMPLES 
FEEDBACK 
FILTERSCALE 
VPARAM_MAX 

Definition at line 172 of file SimpleFixedNodeBranch.h.

173  {
174  TAU = 0,
175  TAUEFF,
176  ETRIAL,
177  EREF,
178  ENOW,
179  BRANCHMAX,
180  BRANCHCUTOFF,
181  BRANCHFILTER,
182  SIGMA2,
183  ACC_ENERGY,
184  ACC_SAMPLES,
185  FEEDBACK,
186  FILTERSCALE,
187  VPARAM_MAX = 17 // four extra, why? Sloppy or undocumented hack?
188  };

Constructor & Destructor Documentation

◆ SimpleFixedNodeBranch() [1/2]

SimpleFixedNodeBranch ( RealType  tau,
int  nideal 
)

Constructor.

Definition at line 45 of file SimpleFixedNodeBranch.cpp.

References SimpleFixedNodeBranch::B_BRANCHINTERVAL, SimpleFixedNodeBranch::B_CLEARHISTORY, SimpleFixedNodeBranch::B_COUNTER, SimpleFixedNodeBranch::B_DMCSTAGE, SimpleFixedNodeBranch::B_ENERGYUPDATEINTERVAL, SimpleFixedNodeBranch::B_KILLNODES, SimpleFixedNodeBranch::B_MAXWALKERS, SimpleFixedNodeBranch::B_MINWALKERS, SimpleFixedNodeBranch::B_POPCONTROL, SimpleFixedNodeBranch::B_TARGETWALKERS, SimpleFixedNodeBranch::B_USETAUEFF, SimpleFixedNodeBranch::B_WARMUPSTEPS, SimpleFixedNodeBranch::branching_cutoff_scheme, SimpleFixedNodeBranch::BranchMode, qmcplusplus::DUMMYOPT, qmcplusplus::Units::charge::e, SimpleFixedNodeBranch::FEEDBACK, SimpleFixedNodeBranch::FILTERSCALE, SimpleFixedNodeBranch::iParam, SimpleFixedNodeBranch::R2Accepted, SimpleFixedNodeBranch::R2Proposed, SimpleFixedNodeBranch::registerParameters(), SimpleFixedNodeBranch::reset(), SimpleFixedNodeBranch::sParam, SimpleFixedNodeBranch::TAU, SimpleFixedNodeBranch::TAUEFF, and SimpleFixedNodeBranch::vParam.

46 {
47  BranchMode.set(B_DMCSTAGE, 0); //warmup stage
48  BranchMode.set(B_POPCONTROL, 1); //use standard DMC
49  BranchMode.set(B_USETAUEFF, 1); //use taueff
50  BranchMode.set(B_CLEARHISTORY, 0); //clear history and start with the current average
51  BranchMode.set(B_KILLNODES, 0); //when killing walkers at nodes etrial is updated differently
52  vParam.fill(1.0);
53  vParam[SBVP::TAU] = tau;
54  vParam[SBVP::TAUEFF] = tau;
55  vParam[SBVP::FEEDBACK] = 1.0;
57  R2Accepted(1.0e-10);
58  R2Proposed(1.0e-10);
59  //set the default values for integer parameters
60  iParam[B_WARMUPSTEPS] = 200;
64  iParam[B_MAXWALKERS] = nideal;
65  iParam[B_MINWALKERS] = nideal;
66  iParam[B_COUNTER] = -1;
67  //default is no
68  sParam.resize(DUMMYOPT, "no");
69  //default is classic
70  branching_cutoff_scheme = "classic";
72  reset();
73 }
void reset()
reset the internal parameters
std::string branching_cutoff_scheme
scheme of branching cutoff
accumulator_set< RealType > R2Proposed
a simple accumulator for energy
1 to use taueff accordning to JCP 93, 0 to use tau
frequency of the trial energy updates, default 1
1 to kill walkers when a node crossing is detected
1 for the standard dmc, 0 for the comb method
warmup steps, valid when BranchMode[D_DMCSTAGE] == 0
void registerParameters()
create map between the parameter name and variables
std::vector< std::string > sParam
string parameters
interval between branch, see population control
accumulator_set< RealType > R2Accepted
a simple accumulator for energy
target total number of walkers per mpi group

◆ SimpleFixedNodeBranch() [2/2]

copy constructor

Copy only selected data members and WalkerController is never copied.

Definition at line 79 of file SimpleFixedNodeBranch.cpp.

References SimpleFixedNodeBranch::registerParameters(), and SimpleFixedNodeBranch::reset().

80  : BranchMode(abranch.BranchMode),
81  iParam(abranch.iParam),
82  vParam(abranch.vParam),
83  branching_cutoff_scheme(abranch.branching_cutoff_scheme),
84  sParam(abranch.sParam)
85 {
87  reset();
88 }
void reset()
reset the internal parameters
std::string branching_cutoff_scheme
scheme of branching cutoff
void registerParameters()
create map between the parameter name and variables
std::vector< std::string > sParam
string parameters

◆ ~SimpleFixedNodeBranch()

~SimpleFixedNodeBranch ( )
default

Member Function Documentation

◆ advanceQMCCounter()

void advanceQMCCounter ( )
inline

increment QMCCounter

QMCCounter is the number of times any QMC section is processed.

Definition at line 274 of file SimpleFixedNodeBranch.h.

References SimpleFixedNodeBranch::B_COUNTER, and SimpleFixedNodeBranch::iParam.

Referenced by qmcplusplus::TEST_CASE().

◆ branch()

void branch ( int  iter,
MCWalkerConfiguration w 
)

perform branching

Parameters
itercurrent step
wWalker configuration

Definition at line 281 of file SimpleFixedNodeBranch.cpp.

References qmcplusplus::app_log(), SimpleFixedNodeBranch::B_DMCSTAGE, SimpleFixedNodeBranch::B_ENERGYUPDATEINTERVAL, SimpleFixedNodeBranch::B_KILLNODES, SimpleFixedNodeBranch::B_POPCONTROL, SimpleFixedNodeBranch::B_USETAUEFF, SimpleFixedNodeBranch::B_WARMUPSTEPS, SimpleFixedNodeBranch::BackupWalkerController, SimpleFixedNodeBranch::BRANCHCUTOFF, SimpleFixedNodeBranch::BRANCHMAX, SimpleFixedNodeBranch::BranchMode, accumulator_set< T, typename >::clear(), SimpleFixedNodeBranch::debug_disable_branching_, SimpleFixedNodeBranch::EnergyHist, SimpleFixedNodeBranch::ENOW, SimpleFixedNodeBranch::EREF, SimpleFixedNodeBranch::ETRIAL, SimpleFixedNodeBranch::FEEDBACK, SimpleFixedNodeBranch::iParam, qmcplusplus::log(), SimpleFixedNodeBranch::logN, accumulator_set< T, typename >::mean(), qmcplusplus::MIXDMCOPT, SimpleFixedNodeBranch::MyEstimator, SimpleFixedNodeBranch::R2Accepted, SimpleFixedNodeBranch::R2Proposed, accumulator_set< T, typename >::result(), SimpleFixedNodeBranch::setBranchCutoff(), SimpleFixedNodeBranch::SIGMA2, SimpleFixedNodeBranch::sParam, SimpleFixedNodeBranch::TAU, SimpleFixedNodeBranch::TAUEFF, SimpleFixedNodeBranch::ToDoSteps, SimpleFixedNodeBranch::VarianceHist, SimpleFixedNodeBranch::vParam, SimpleFixedNodeBranch::WalkerController, and qmcplusplus::hdf::walkers.

282 {
283  //collect the total weights and redistribute the walkers accordingly, using a fixed tolerance
284 
285  FullPrecRealType pop_now;
286  if (debug_disable_branching_ == "no" && (BranchMode[B_DMCSTAGE] || iter))
287  pop_now = WalkerController->branch(iter, walkers, 0.1);
288  else
289  pop_now = WalkerController->doNotBranch(iter, walkers); //do not branch for the first step of a warmup
290 
291  //population for trial energy modification should not include any released node walkers.
292  pop_now -= WalkerController->get_ensemble_property().RNSamples;
293  //current energy
294  vParam[SBVP::ENOW] = WalkerController->get_ensemble_property().Energy;
295  VarianceHist(WalkerController->get_ensemble_property().Variance);
296  R2Accepted(WalkerController->get_ensemble_property().R2Accepted);
297  R2Proposed(WalkerController->get_ensemble_property().R2Proposed);
298  //PopHist(pop_now);
299  vParam[SBVP::EREF] = EnergyHist.mean(); //current mean
300  if (BranchMode[B_USETAUEFF])
302 
303  if (BranchMode[B_KILLNODES])
305  std::log(WalkerController->get_ensemble_property().LivingFraction) / vParam[SBVP::TAUEFF]);
306  else
308 
309  if (BranchMode[B_DMCSTAGE]) // main stage
310  {
312  {
313  if (ToDoSteps > 0)
314  --ToDoSteps;
315  else
316  {
319  }
320  }
321  else
323  }
324  else //warmup
325  {
326  if (BranchMode[B_USETAUEFF])
329  {
330  //RealType emix=((iParam[B_WARMUPSTEPS]-ToDoSteps)<100)?(0.25*vParam[SBVP::EREF]+0.75*vParam[SBVP::ENOW]):vParam[SBVP::EREF];
331  //vParam[SBVP::ETRIAL]=emix+Feedback*(logN-std::log(pop_now));
332  //vParam[SBVP::ETRIAL]=vParam[SBVP::EREF]+Feedback*(logN-std::log(pop_now));
333  if (BranchMode[B_KILLNODES])
334  vParam[SBVP::ETRIAL] = (0.00 * vParam[SBVP::EREF] + 1.0 * vParam[SBVP::ENOW]) +
335  vParam[SBVP::FEEDBACK] * (logN - std::log(pop_now)) -
336  std::log(WalkerController->get_ensemble_property().LivingFraction) / vParam[SBVP::TAU];
337  else
339  }
340  else
342  --ToDoSteps;
343  if (ToDoSteps == 0) //warmup is done
344  {
346  setBranchCutoff(vParam[SBVP::SIGMA2], WalkerController->get_target_sigma(), 10, walkers.R.size());
347  app_log() << "\n Warmup is completed after " << iParam[B_WARMUPSTEPS] << std::endl;
348  if (BranchMode[B_USETAUEFF])
349  app_log() << "\n TauEff = " << vParam[SBVP::TAUEFF]
350  << "\n TauEff/Tau = " << vParam[SBVP::TAUEFF] / vParam[SBVP::TAU];
351  else
352  app_log() << "\n TauEff proposed = " << vParam[SBVP::TAUEFF] * R2Accepted.result() / R2Proposed.result();
353  app_log() << "\n Etrial = " << vParam[SBVP::ETRIAL] << std::endl;
354  app_log() << " Running average of energy = " << EnergyHist.mean() << std::endl;
355  app_log() << " Variance = " << vParam[SBVP::SIGMA2] << std::endl;
356  app_log() << "branch cutoff = " << vParam[SBVP::BRANCHCUTOFF] << " " << vParam[SBVP::BRANCHMAX] << std::endl;
358  iParam[B_WARMUPSTEPS] = 0;
359  BranchMode.set(B_DMCSTAGE, 1); //set BranchModex to main stage
360  //reset the histogram
361  EnergyHist.clear();
363  if (sParam[MIXDMCOPT] == "yes")
364  {
365  app_log() << "Switching to DMC with fluctuating populations" << std::endl;
366  BranchMode.set(B_POPCONTROL, 1); //use standard DMC
370  app_log() << " Etrial = " << vParam[SBVP::ETRIAL] << std::endl;
371  WalkerController->start();
372  }
373  //This is not necessary
374  //EnergyHist(DMCEnergyHist.mean());
375  }
376  }
377  WalkerController->setTrialEnergy(vParam[SBVP::ETRIAL]);
378  //accumulate collectables and energies for scalar.dat
379  FullPrecRealType wgt_inv = WalkerController->get_num_contexts() / WalkerController->get_ensemble_property().Weight;
380  walkers.Collectables *= wgt_inv;
381  MyEstimator->accumulate(walkers);
382 }
std::ostream & app_log()
Definition: OutputManager.h:65
accumulator_set< RealType > R2Proposed
a simple accumulator for energy
const char walkers[]
Definition: HDFVersion.h:36
accumulator_set< FullPrecRealType > EnergyHist
a simple accumulator for energy
void setBranchCutoff(FullPrecRealType variance, FullPrecRealType targetSigma, FullPrecRealType maxSigma, int Nelec=0)
set branch cutoff, max, filter
FullPrecRealType logN
Feed*log(N)
std::unique_ptr< WalkerControlBase > BackupWalkerController
Backup WalkerController for mixed DMC.
1 to use taueff accordning to JCP 93, 0 to use tau
frequency of the trial energy updates, default 1
1 to kill walkers when a node crossing is detected
1 for the standard dmc, 0 for the comb method
warmup steps, valid when BranchMode[D_DMCSTAGE] == 0
MakeReturn< UnaryNode< FnLog, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t log(const Vector< T1, C1 > &l)
return_type mean() const
return the mean
Definition: accumulators.h:126
return_type result() const
return the sum
Definition: accumulators.h:108
std::vector< std::string > sParam
string parameters
QTFull::RealType FullPrecRealType
Definition: Configuration.h:66
std::unique_ptr< EstimatorManagerBase > MyEstimator
std::unique_ptr< WalkerControlBase > WalkerController
WalkerController.
accumulator_set< RealType > R2Accepted
a simple accumulator for energy
int ToDoSteps
number of remaning steps for a specific tasks
accumulator_set< FullPrecRealType > VarianceHist
a simple accumulator for variance
std::string debug_disable_branching_
disable branching for debugging

◆ branchWeight() [1/3]

RealType branchWeight ( FullPrecRealType  enew,
FullPrecRealType  eold 
) const
inline

return the bare branch weight with a filtering using an energy window

Cutoff values are set by the variance

Definition at line 317 of file SimpleFixedNodeBranch.h.

References SimpleFixedNodeBranch::BRANCHCUTOFF, SimpleFixedNodeBranch::BRANCHFILTER, SimpleFixedNodeBranch::BRANCHMAX, SimpleFixedNodeBranch::EREF, SimpleFixedNodeBranch::ETRIAL, qmcplusplus::exp(), SimpleFixedNodeBranch::TAUEFF, and SimpleFixedNodeBranch::vParam.

Referenced by DMCUpdateAllWithRejection::advanceWalker(), SODMCUpdatePbyPWithRejectionFast::advanceWalker(), DMCUpdatePbyPWithRejectionFast::advanceWalker(), DMCUpdatePbyPL2::advanceWalker(), and DMCUpdateAllWithKill::advanceWalker().

◆ branchWeight() [2/3]

RealType branchWeight ( RealType  enew,
RealType  eold,
RealType  scnew,
RealType  scold 
) const
inline

return the branch weight according to JCP1993 Umrigar et al.

Appendix A p=1, q=0

Parameters
enewnew energy
eoldold energy
scnew$ V_{sc}(R_{new})/V(R_{new}) $
scold$ V_{sc}(R_{old})/V(R_{old}) $

Definition at line 367 of file SimpleFixedNodeBranch.h.

References SimpleFixedNodeBranch::EREF, SimpleFixedNodeBranch::ETRIAL, qmcplusplus::exp(), SimpleFixedNodeBranch::TAUEFF, and SimpleFixedNodeBranch::vParam.

368  {
369  FullPrecRealType s1 = (vParam[SBVP::ETRIAL] - vParam[SBVP::EREF]) + (vParam[SBVP::EREF] - enew) * scnew;
370  FullPrecRealType s0 = (vParam[SBVP::ETRIAL] - vParam[SBVP::EREF]) + (vParam[SBVP::EREF] - eold) * scold;
371  return std::exp(vParam[SBVP::TAUEFF] * 0.5 * (s1 + s0));
372  }
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
QTFull::RealType FullPrecRealType
Definition: Configuration.h:66

◆ branchWeight() [3/3]

RealType branchWeight ( RealType  enew,
RealType  eold,
RealType  scnew,
RealType  scold,
RealType  p 
) const
inline

return the branch weight according to JCP1993 Umrigar et al.

Appendix A

Parameters
enewnew energy
eoldold energy
scnew$ V_{sc}(R_{new})/V(R_{new}) $
scold$ V_{sc}(R_{old})/V(R_{old}) $
pacceptance ratio

Definition at line 381 of file SimpleFixedNodeBranch.h.

References SimpleFixedNodeBranch::EREF, SimpleFixedNodeBranch::ETRIAL, qmcplusplus::exp(), SimpleFixedNodeBranch::TAUEFF, and SimpleFixedNodeBranch::vParam.

382  {
383  FullPrecRealType s1 = (vParam[SBVP::ETRIAL] - vParam[SBVP::EREF]) + (vParam[SBVP::EREF] - enew) * scnew;
384  FullPrecRealType s0 = (vParam[SBVP::ETRIAL] - vParam[SBVP::EREF]) + (vParam[SBVP::EREF] - eold) * scold;
385  return std::exp(vParam[SBVP::TAUEFF] * (p * 0.5 * (s1 - s0) + s0));
386  //return std::exp(TauEff*(p*0.5*(sp-sq)+sq));
387  }
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
QTFull::RealType FullPrecRealType
Definition: Configuration.h:66

◆ branchWeightBare()

RealType branchWeightBare ( RealType  enew,
RealType  eold 
) const
inline

return the bare branch weight

This is equivalent to calling branchWeight(enew,eold,1.0,1.0)

Definition at line 308 of file SimpleFixedNodeBranch.h.

References SimpleFixedNodeBranch::ETRIAL, qmcplusplus::exp(), SimpleFixedNodeBranch::TAUEFF, and SimpleFixedNodeBranch::vParam.

309  {
310  return std::exp(vParam[SBVP::TAUEFF] * (vParam[SBVP::ETRIAL] - 0.5 * (enew + eold)));
311  }
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)

◆ branchWeightTau()

RealType branchWeightTau ( RealType  enew,
RealType  eold,
RealType  scnew,
RealType  scold,
RealType  taueff 
)
inline

return the branch weight according to JCP1993 Umrigar et al.

Appendix A p=1, q=0

Parameters
enewnew energy
eoldold energy
scnew$ V_{sc}(R_{new})/V(R_{new}) $
scold$ V_{sc}(R_{old})/V(R_{old}) $
taueff

Definition at line 396 of file SimpleFixedNodeBranch.h.

References SimpleFixedNodeBranch::EREF, SimpleFixedNodeBranch::ETRIAL, qmcplusplus::exp(), SimpleFixedNodeBranch::ScaleNum, SimpleFixedNodeBranch::ScaleSum, and SimpleFixedNodeBranch::vParam.

397  {
398  ScaleSum += scnew + scold;
399  ScaleNum += 2;
400  FullPrecRealType scavg = (ScaleNum > 10000) ? ScaleSum / (RealType)ScaleNum : 1.0;
401  FullPrecRealType s1 = (vParam[SBVP::ETRIAL] - vParam[SBVP::EREF]) + (vParam[SBVP::EREF] - enew) * scnew / scavg;
402  FullPrecRealType s0 = (vParam[SBVP::ETRIAL] - vParam[SBVP::EREF]) + (vParam[SBVP::EREF] - eold) * scold / scavg;
403  return std::exp(taueff * 0.5 * (s1 + s0));
404  }
FullPrecRealType ScaleSum
Used for the average scaling.
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
QMCTraits::RealType RealType
QTFull::RealType FullPrecRealType
Definition: Configuration.h:66

◆ checkParameters()

void checkParameters ( MCWalkerConfiguration w)

determine trial and reference energies

Definition at line 642 of file SimpleFixedNodeBranch.cpp.

References qmcplusplus::app_log(), SimpleFixedNodeBranch::B_DMCSTAGE, SimpleFixedNodeBranch::BranchMode, accumulator_set< T, typename >::clear(), qmcplusplus::Units::charge::e, SimpleFixedNodeBranch::EnergyHist, SimpleFixedNodeBranch::EREF, SimpleFixedNodeBranch::ETRIAL, SimpleFixedNodeBranch::MyEstimator, SimpleFixedNodeBranch::SIGMA2, SimpleFixedNodeBranch::VarianceHist, and SimpleFixedNodeBranch::vParam.

643 {
644  std::ostringstream o;
645  if (!BranchMode[B_DMCSTAGE])
646  {
647  FullPrecRealType e, sigma2;
648  MyEstimator->getApproximateEnergyVariance(e, sigma2);
650  vParam[SBVP::SIGMA2] = sigma2;
651  EnergyHist.clear();
653  //DMCEnergyHist.clear();
656  //DMCEnergyHist(vParam[SBVP::EREF]);
657  o << "SimpleFixedNodeBranch::checkParameters " << std::endl;
658  o << " Average Energy of a population = " << e << std::endl;
659  o << " Energy Variance = " << vParam[SBVP::SIGMA2] << std::endl;
660  }
661  app_log() << o.str() << std::endl;
662  app_log().flush();
663 }
std::ostream & app_log()
Definition: OutputManager.h:65
accumulator_set< FullPrecRealType > EnergyHist
a simple accumulator for energy
QTFull::RealType FullPrecRealType
Definition: Configuration.h:66
std::unique_ptr< EstimatorManagerBase > MyEstimator
accumulator_set< FullPrecRealType > VarianceHist
a simple accumulator for variance

◆ collect()

void collect ( int  iter,
MCWalkerConfiguration w 
)

update RMC counters and running averages.

Parameters
iterthe iteration
wthe walker ensemble

Definition at line 387 of file SimpleFixedNodeBranch.cpp.

References qmcplusplus::app_log(), SimpleFixedNodeBranch::B_ENERGYUPDATEINTERVAL, SimpleFixedNodeBranch::B_RMCSTAGE, SimpleFixedNodeBranch::B_USETAUEFF, SimpleFixedNodeBranch::B_WARMUPSTEPS, SimpleFixedNodeBranch::BRANCHCUTOFF, SimpleFixedNodeBranch::BRANCHMAX, SimpleFixedNodeBranch::BranchMode, accumulator_set< T, typename >::clear(), SimpleFixedNodeBranch::EnergyHist, SimpleFixedNodeBranch::ENOW, SimpleFixedNodeBranch::EREF, SimpleFixedNodeBranch::ETRIAL, SimpleFixedNodeBranch::FILTERSCALE, Reptile::getHead(), Reptile::getTail(), SimpleFixedNodeBranch::iParam, accumulator_set< T, typename >::mean(), SimpleFixedNodeBranch::MyEstimator, qmcplusplus::pow(), Walker< t_traits, p_traits >::Properties, ParticleSet::R, SimpleFixedNodeBranch::R2Accepted, SimpleFixedNodeBranch::R2Proposed, MCWalkerConfiguration::reptile, accumulator_set< T, typename >::result(), SimpleFixedNodeBranch::setBranchCutoff(), SimpleFixedNodeBranch::SIGMA2, SimpleFixedNodeBranch::TAU, SimpleFixedNodeBranch::TAUEFF, SimpleFixedNodeBranch::ToDoSteps, SimpleFixedNodeBranch::VarianceHist, and SimpleFixedNodeBranch::vParam.

388 {
389  //Update the current energy and accumulate.
390  MCWalkerConfiguration::Walker_t& head = W.reptile->getHead();
391  MCWalkerConfiguration::Walker_t& tail = W.reptile->getTail();
392  vParam[SBVP::ENOW] = 0.5 * (head.Properties(WP::LOCALENERGY) + tail.Properties(WP::LOCALENERGY));
393  // app_log()<<"IN SimpleFixedNodeBranch::collect\n";
394  // app_log()<<"\tvParam[SBVP::ENOW]="<<vParam[SBVP::ENOW]<< std::endl;
397  // app_log()<<"\tvParam[SBVP::EREF]="<<vParam[SBVP::EREF]<< std::endl;
398  //Update the energy variance and R2 for effective timestep and filtering.
400  R2Accepted(head.Properties(WP::R2ACCEPTED));
401  R2Proposed(head.Properties(WP::R2PROPOSED));
402  // app_log()<<"\thead.Properties(R2ACCEPTED)="<<head.Properties(R2ACCEPTED)<< std::endl;
403  // app_log()<<"\thead.Properties(R2PROPOSED)="<<head.Properties(R2PROPOSED)<< std::endl;
404  // app_log()<<"\tR2Accepted="<<R2Accepted.result()<< std::endl;
405  // app_log()<<"\tR2Proposed="<<R2Proposed.result()<< std::endl;
406  // app_log()<<"\tR2Accept/R2Prop="<<R2Accepted.result()/R2Proposed.result()<< std::endl;
407  // app_log()<<"\t <E^2> = "<<VarianceHist.mean()<< std::endl;
408  // app_log()<<"\t <E> = "<<EnergyHist.mean()<< std::endl;
409  // app_log()<<"\t <E>^2 = "<<std::pow(EnergyHist.mean(),2)<< std::endl;
410  // app_log()<<"\t var = "<<VarianceHist.mean()-pow(EnergyHist.mean(),2)<< std::endl;
411  // app_log()<<"--------------\n";
412  //current mean
413  if (BranchMode[B_USETAUEFF])
414  {
415  //app_log()<<" BRANCHMODE = "<<BranchMode[B_USETAUEFF]<< std::endl;
417  // app_log()<<"\tvParam[SBVP::TAU]="<<vParam[SBVP::TAU]<<" "<<vParam[SBVP::TAUEFF]<< std::endl;
418  }
419  /*
420  if(BranchMode[B_RMCSTAGE]) // main stage
421  {
422  if(BranchMode[B_POPCONTROL])
423  {
424  if(ToDoSteps>0)
425  --ToDoSteps;
426  else
427  {
428  vParam[SBVP::ETRIAL]=vParam[SBVP::EREF]+vParam[SBVP::FEEDBACK]*(logN-std::log(pop_now));
429  ToDoSteps=iParam[B_ENERGYUPDATEINTERVAL]-1;
430  }
431  }
432  else
433  vParam[SBVP::ETRIAL]=vParam[SBVP::EREF];
434  }*/
435  //app_log()<<"BranchMode[B_RMCSTAGE]="<<BranchMode[B_RMCSTAGE]<< std::endl;
436  if (!BranchMode[B_RMCSTAGE]) //warmup
437  {
438  if (BranchMode[B_USETAUEFF])
440  // app_log()<<"\t <E^2> = "<<VarianceHist.mean()<< std::endl;
441  // app_log()<<"\t <E> = "<<EnergyHist.mean()<< std::endl;
442  // app_log()<<"\t <E>^2 = "<<std::pow(EnergyHist.mean(),2)<< std::endl;
443  //app_log()<<"\t var = "<<VarianceHist.mean()-std::pow(EnergyHist.mean(),2)<< std::endl;
444  // app_log()<<"\t var = "<<VarianceHist.mean()<< std::endl;
445  // app_log()<<"----\n";
446  //app_log()<<"ToDoSteps="<<ToDoSteps<< std::endl;
448  --ToDoSteps;
449  if (ToDoSteps == 0) //warmup is done
450  {
454  app_log() << "\n Warmup is completed after " << iParam[B_WARMUPSTEPS] << " steps." << std::endl;
455  if (BranchMode[B_USETAUEFF])
456  app_log() << "\n TauEff = " << vParam[SBVP::TAUEFF]
457  << "\n TauEff/Tau = " << vParam[SBVP::TAUEFF] / vParam[SBVP::TAU];
458  else
459  app_log() << "\n TauEff proposed = " << vParam[SBVP::TAUEFF] * R2Accepted.result() / R2Proposed.result();
460  app_log() << "\n Running average of energy = " << EnergyHist.mean() << std::endl;
461  app_log() << "\n Variance = " << vParam[SBVP::SIGMA2] << std::endl;
462  app_log() << "\nbranch cutoff = " << vParam[SBVP::BRANCHCUTOFF] << " " << vParam[SBVP::BRANCHMAX] << std::endl;
464  iParam[B_WARMUPSTEPS] = 0;
465  BranchMode.set(B_RMCSTAGE, 1); //set BranchModex to main stage
466  //reset the histogram
467  EnergyHist.clear();
469  }
470  }
471  //accumulate collectables and energies for scalar.dat
472  MyEstimator->accumulate(W);
473 }
std::ostream & app_log()
Definition: OutputManager.h:65
accumulator_set< RealType > R2Proposed
a simple accumulator for energy
accumulator_set< FullPrecRealType > EnergyHist
a simple accumulator for energy
void setBranchCutoff(FullPrecRealType variance, FullPrecRealType targetSigma, FullPrecRealType maxSigma, int Nelec=0)
set branch cutoff, max, filter
MakeReturn< BinaryNode< FnPow, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t, typename CreateLeaf< Vector< T2, C2 > >::Leaf_t > >::Expression_t pow(const Vector< T1, C1 > &l, const Vector< T2, C2 > &r)
1 to use taueff accordning to JCP 93, 0 to use tau
frequency of the trial energy updates, default 1
warmup steps, valid when BranchMode[D_DMCSTAGE] == 0
WalkerConfigurations::Walker_t Walker_t
return_type mean() const
return the mean
Definition: accumulators.h:126
return_type result() const
return the sum
Definition: accumulators.h:108
std::unique_ptr< EstimatorManagerBase > MyEstimator
accumulator_set< RealType > R2Accepted
a simple accumulator for energy
int ToDoSteps
number of remaning steps for a specific tasks
accumulator_set< FullPrecRealType > VarianceHist
a simple accumulator for variance

◆ DMCLinkAction()

◆ finalize()

void finalize ( MCWalkerConfiguration w)

finalize the simulation

Definition at line 665 of file SimpleFixedNodeBranch.cpp.

References qmcplusplus::app_log(), SimpleFixedNodeBranch::B_COUNTER, SimpleFixedNodeBranch::B_MAXWALKERS, SimpleFixedNodeBranch::B_MINWALKERS, SimpleFixedNodeBranch::B_RMC, SimpleFixedNodeBranch::B_TARGETWALKERS, SimpleFixedNodeBranch::BRANCHCUTOFF, SimpleFixedNodeBranch::BRANCHMAX, SimpleFixedNodeBranch::BranchMode, qmcplusplus::Units::charge::e, SimpleFixedNodeBranch::EnergyHist, SimpleFixedNodeBranch::EREF, SimpleFixedNodeBranch::ETRIAL, SimpleFixedNodeBranch::FEEDBACK, SimpleFixedNodeBranch::iParam, SimpleFixedNodeBranch::MyEstimator, SimpleFixedNodeBranch::RootName, SimpleFixedNodeBranch::SIGMA2, SimpleFixedNodeBranch::TAU, SimpleFixedNodeBranch::TAUEFF, SimpleFixedNodeBranch::vParam, SimpleFixedNodeBranch::WalkerController, and SimpleFixedNodeBranch::write().

666 {
667  std::ostringstream o;
668  if (WalkerController)
669  {
670  o << "====================================================";
671  o << "\n SimpleFixedNodeBranch::finalize after a DMC block";
672  o << "\n QMC counter = " << iParam[B_COUNTER];
673  o << "\n time step = " << vParam[SBVP::TAU];
674  o << "\n effective time step = " << vParam[SBVP::TAUEFF];
675  o << "\n trial energy = " << vParam[SBVP::ETRIAL];
676  o << "\n reference energy = " << vParam[SBVP::EREF];
677  o << "\n reference variance = " << vParam[SBVP::SIGMA2];
678  o << "\n target walkers = " << iParam[B_TARGETWALKERS];
679  o << "\n branch cutoff = " << vParam[SBVP::BRANCHCUTOFF] << " " << vParam[SBVP::BRANCHMAX];
680  o << "\n Max and minimum walkers per node= " << iParam[B_MAXWALKERS] << " " << iParam[B_MINWALKERS];
681  o << "\n Feedback = " << vParam[SBVP::FEEDBACK];
682  o << "\n QMC Status (BranchMode) = " << BranchMode;
683  o << "\n====================================================";
684  }
685  //running RMC
686  else if (BranchMode[B_RMC])
687  {
688  o << "====================================================";
689  o << "\n SimpleFixedNodeBranch::finalize after a RMC block";
690  o << "\n QMC counter = " << iParam[B_COUNTER];
691  o << "\n time step = " << vParam[SBVP::TAU];
692  o << "\n effective time step = " << vParam[SBVP::TAUEFF];
693  o << "\n reference energy = " << vParam[SBVP::EREF];
694  o << "\n reference variance = " << vParam[SBVP::SIGMA2];
695  o << "\n cutoff energy = " << vParam[SBVP::BRANCHCUTOFF] << " " << vParam[SBVP::BRANCHMAX];
696  o << "\n QMC Status (BranchMode) = " << BranchMode;
697  o << "\n====================================================";
698  }
699  else
700  {
701  //running VMC
702  FullPrecRealType e, sigma2;
703  MyEstimator->getApproximateEnergyVariance(e, sigma2);
705  vParam[SBVP::SIGMA2] = sigma2;
706  //this is just to avoid diving by n-1 == 0
708  //add Eref to the DMCEnergyHistory
709  //DMCEnergyHist(vParam[SBVP::EREF]);
710  o << "====================================================";
711  o << "\n SimpleFixedNodeBranch::finalize after a VMC block";
712  o << "\n QMC counter = " << iParam[B_COUNTER];
713  o << "\n time step = " << vParam[SBVP::TAU];
714  o << "\n reference energy = " << vParam[SBVP::EREF];
715  o << "\n reference variance = " << vParam[SBVP::SIGMA2];
716  o << "\n====================================================";
717  }
718  app_log() << o.str() << std::endl;
719  write(RootName, true);
720 }
std::ostream & app_log()
Definition: OutputManager.h:65
void write(const std::string &fname, bool overwrite=true)
write the state
accumulator_set< FullPrecRealType > EnergyHist
a simple accumulator for energy
QTFull::RealType FullPrecRealType
Definition: Configuration.h:66
std::unique_ptr< EstimatorManagerBase > MyEstimator
std::unique_ptr< WalkerControlBase > WalkerController
WalkerController.
target total number of walkers per mpi group

◆ flush()

void flush ( int  counter)

restart averaging

Parameters
counterCounter to determine the cummulative average will be reset.

Definition at line 275 of file SimpleFixedNodeBranch.cpp.

References SimpleFixedNodeBranch::WalkerController.

276 {
277  if (counter == 0 && WalkerController)
278  WalkerController->reset();
279 }
std::unique_ptr< WalkerControlBase > WalkerController
WalkerController.

◆ getEref()

◆ getEstimatorManager()

EstimatorManagerBase* getEstimatorManager ( )
inline

get the EstimatorManager

Definition at line 278 of file SimpleFixedNodeBranch.h.

References SimpleFixedNodeBranch::MyEstimator.

Referenced by qmcplusplus::TEST_CASE().

278 { return MyEstimator.get(); }
std::unique_ptr< EstimatorManagerBase > MyEstimator

◆ getEtrial()

◆ getTau()

◆ getTauEff()

◆ initReptile()

void initReptile ( MCWalkerConfiguration w)

initialize reptile stats

Definition at line 217 of file SimpleFixedNodeBranch.cpp.

References qmcplusplus::app_log(), SimpleFixedNodeBranch::B_COUNTER, SimpleFixedNodeBranch::B_RESTART, SimpleFixedNodeBranch::B_RMC, SimpleFixedNodeBranch::B_RMCSTAGE, SimpleFixedNodeBranch::B_WARMUPSTEPS, SimpleFixedNodeBranch::BRANCHCUTOFF, SimpleFixedNodeBranch::branching_cutoff_scheme, SimpleFixedNodeBranch::BRANCHMAX, SimpleFixedNodeBranch::BranchMode, SimpleFixedNodeBranch::EREF, SimpleFixedNodeBranch::FEEDBACK, SimpleFixedNodeBranch::iParam, SimpleFixedNodeBranch::MyEstimator, ParticleSet::R, SimpleFixedNodeBranch::R2Accepted, SimpleFixedNodeBranch::R2Proposed, SimpleFixedNodeBranch::reset(), accumulator_set< T, typename >::result(), SimpleFixedNodeBranch::setBranchCutoff(), SimpleFixedNodeBranch::SIGMA2, SimpleFixedNodeBranch::TAU, SimpleFixedNodeBranch::TAUEFF, SimpleFixedNodeBranch::vParam, and SimpleFixedNodeBranch::WalkerController.

218 {
219  RealType allowedFlux = 50.0;
220  BranchMode.set(B_RMC, 1); //set RMC
221  BranchMode.set(B_RMCSTAGE, iParam[B_WARMUPSTEPS] == 0); //use warmup
222  //this is not necessary
223  //check if tau is different and set the initial values
224  //vParam[SBVP::TAU]=tau;
225  bool fromscratch = false;
227  //this is the first time DMC is used
228  if (WalkerController == 0)
229  {
230  // if(iParam[B_TARGETWALKERS]==0)
231  // {
232  // Communicate* acomm=MyEstimator->getCommunicator();
233  // int ncontexts=acomm->size();
234  // std::vector<int> nw(ncontexts,0),nwoff(ncontexts+1,0);
235  // nw[acomm->rank()]=W.getActiveWalkers();
236  // acomm->allreduce(nw);
237  // for(int ip=0; ip<ncontexts; ++ip)
238  // nwoff[ip+1]=nwoff[ip]+nw[ip];
239  // W.setWalkerOffsets(nwoff);
240  // iParam[B_TARGETWALKERS]=nwoff[ncontexts];
241  // }
242  if (!BranchMode[B_RESTART])
243  {
244  fromscratch = true;
245  app_log() << " START ALL OVER " << std::endl;
246  vParam[SBVP::TAUEFF] = tau;
247  //PopHist.clear();
248  //PopHist.reserve(std::max(iParam[B_ENERGYUPDATEINTERVAL],5));
249  }
250  }
251  //else
252  //{
253  // BranchMode.set(B_DMCSTAGE,0);//always reset warmup
254  //}
255  MyEstimator->reset();
256  this->reset();
257  if (fromscratch)
258  {
259  //determine the branch cutoff to limit wild weights based on the sigma and sigmaBound
260  setBranchCutoff(vParam[SBVP::SIGMA2], allowedFlux, 50, W.R.size());
262  }
263  //reset controller
264  app_log() << " QMC counter = " << iParam[B_COUNTER] << std::endl;
265  app_log() << " time step = " << vParam[SBVP::TAU] << std::endl;
266  app_log() << " effective time step = " << vParam[SBVP::TAUEFF] << std::endl;
267  app_log() << " reference energy = " << vParam[SBVP::EREF] << std::endl;
268  app_log() << " Feedback = " << vParam[SBVP::FEEDBACK] << std::endl;
269  app_log() << " reference variance = " << vParam[SBVP::SIGMA2] << std::endl;
270  app_log() << " branching cutoff scheme " << branching_cutoff_scheme << std::endl;
271  app_log() << " branch cutoff = " << vParam[SBVP::BRANCHCUTOFF] << " " << vParam[SBVP::BRANCHMAX] << std::endl;
272  app_log() << " QMC Status (BranchMode) = " << BranchMode << std::endl;
273 }
void reset()
reset the internal parameters
std::ostream & app_log()
Definition: OutputManager.h:65
std::string branching_cutoff_scheme
scheme of branching cutoff
accumulator_set< RealType > R2Proposed
a simple accumulator for energy
void setBranchCutoff(FullPrecRealType variance, FullPrecRealType targetSigma, FullPrecRealType maxSigma, int Nelec=0)
set branch cutoff, max, filter
warmup steps, valid when BranchMode[D_DMCSTAGE] == 0
QMCTraits::RealType RealType
return_type result() const
return the sum
Definition: accumulators.h:108
QTFull::RealType FullPrecRealType
Definition: Configuration.h:66
std::unique_ptr< EstimatorManagerBase > MyEstimator
std::unique_ptr< WalkerControlBase > WalkerController
WalkerController.
accumulator_set< RealType > R2Accepted
a simple accumulator for energy

◆ initWalkerController()

int initWalkerController ( MCWalkerConfiguration mcwc,
bool  fixW,
bool  killwalker 
)

initialize the WalkerController

Parameters
mcwcWalkers
fixWtrue, if reconfiguration with the fixed number of walkers is used
killwalker
Returns
number of copies to make in case targetwalkers changed

Definition at line 126 of file SimpleFixedNodeBranch.cpp.

References Communicate::allreduce(), qmcplusplus::app_log(), SimpleFixedNodeBranch::B_COUNTER, SimpleFixedNodeBranch::B_DMC, SimpleFixedNodeBranch::B_DMCSTAGE, SimpleFixedNodeBranch::B_KILLNODES, SimpleFixedNodeBranch::B_MAXWALKERS, SimpleFixedNodeBranch::B_MINWALKERS, SimpleFixedNodeBranch::B_POPCONTROL, SimpleFixedNodeBranch::B_RESTART, SimpleFixedNodeBranch::B_TARGETWALKERS, SimpleFixedNodeBranch::B_WARMUPSTEPS, SimpleFixedNodeBranch::BackupWalkerController, SimpleFixedNodeBranch::BRANCHCUTOFF, SimpleFixedNodeBranch::branching_cutoff_scheme, SimpleFixedNodeBranch::BRANCHMAX, SimpleFixedNodeBranch::BranchMode, qmcplusplus::createWalkerController(), SimpleFixedNodeBranch::debug_disable_branching_, SimpleFixedNodeBranch::EREF, SimpleFixedNodeBranch::ETRIAL, SimpleFixedNodeBranch::FEEDBACK, SimpleFixedNodeBranch::iParam, qmcplusplus::MIXDMCOPT, SimpleFixedNodeBranch::MyEstimator, SimpleFixedNodeBranch::myNode, SimpleFixedNodeBranch::R2Accepted, SimpleFixedNodeBranch::R2Proposed, Communicate::rank(), SimpleFixedNodeBranch::reset(), accumulator_set< T, typename >::result(), SimpleFixedNodeBranch::setBranchCutoff(), SimpleFixedNodeBranch::SIGMA2, Communicate::size(), SimpleFixedNodeBranch::sParam, SimpleFixedNodeBranch::TAU, SimpleFixedNodeBranch::TAUEFF, SimpleFixedNodeBranch::vParam, SimpleFixedNodeBranch::WalkerController, and qmcplusplus::hdf::walkers.

127 {
128  BranchMode.set(B_DMC, 1); //set DMC
129  BranchMode.set(B_DMCSTAGE, iParam[B_WARMUPSTEPS] == 0); //use warmup
130  //this is not necessary
131  //check if tau is different and set the initial values
132  //vParam[SBVP::TAU]=tau;
133  bool fromscratch = false;
135 
136  int nwtot_now = walkers.getGlobalNumWalkers();
137 
138  //this is the first time DMC is used
139  if (WalkerController == nullptr)
140  {
141  if (iParam[B_TARGETWALKERS] == 0)
142  {
143  Communicate* acomm = MyEstimator->getCommunicator();
144  int ncontexts = acomm->size();
145  std::vector<int> nw(ncontexts, 0), nwoff(ncontexts + 1, 0);
146  nw[acomm->rank()] = walkers.getActiveWalkers();
147  acomm->allreduce(nw);
148  for (int ip = 0; ip < ncontexts; ++ip)
149  nwoff[ip + 1] = nwoff[ip] + nw[ip];
150  walkers.setWalkerOffsets(nwoff);
151  iParam[B_TARGETWALKERS] = nwoff[ncontexts];
152  }
153  // \todo reparsing XML nodes is an antipattern, remove.
155  if (!BranchMode[B_RESTART])
156  {
157  fromscratch = true;
158  app_log() << " START ALL OVER " << std::endl;
159  vParam[SBVP::TAUEFF] = tau;
160  BranchMode.set(B_POPCONTROL, !fixW); //fixW -> 0
161  BranchMode.set(B_KILLNODES, killwalker);
162  iParam[B_MAXWALKERS] = WalkerController->get_n_max();
163  iParam[B_MINWALKERS] = WalkerController->get_n_min();
164  if (!fixW && sParam[MIXDMCOPT] == "yes")
165  {
166  app_log() << "Warmup DMC is done with a fixed population " << iParam[B_TARGETWALKERS] << std::endl;
167  BackupWalkerController = std::move(WalkerController); //save the main controller
168  // \todo: Not likely to be ok to call reset on a moved from WalkerController!
169  WalkerController.reset(
170  createWalkerController(iParam[B_TARGETWALKERS], MyEstimator->getCommunicator(), myNode, true));
171  BranchMode.set(B_POPCONTROL, 0);
172  }
173  //PopHist.clear();
174  //PopHist.reserve(std::max(iParam[B_ENERGYUPDATEINTERVAL],5));
175  }
176  WalkerController->setWalkerID(walkers);
177  }
178  //else
179  //{
180  // BranchMode.set(B_DMCSTAGE,0);//always reset warmup
181  //}
182  MyEstimator->reset();
183  //update the simulation parameters
184  WalkerController->put(myNode);
185  //assign current Eref and a large number for variance
186  WalkerController->setTrialEnergy(vParam[SBVP::ETRIAL]);
187  this->reset();
188  if (fromscratch)
189  {
190  //determine the branch cutoff to limit wild weights based on the sigma and sigmaBound
191  setBranchCutoff(vParam[SBVP::SIGMA2], WalkerController->get_target_sigma(), 50, walkers.R.size());
193  }
194  //reset controller
195  WalkerController->reset();
197  BackupWalkerController->reset();
198  app_log() << " QMC counter = " << iParam[B_COUNTER] << std::endl;
199  app_log() << " time step = " << vParam[SBVP::TAU] << std::endl;
200  app_log() << " effective time step = " << vParam[SBVP::TAUEFF] << std::endl;
201  app_log() << " trial energy = " << vParam[SBVP::ETRIAL] << std::endl;
202  app_log() << " reference energy = " << vParam[SBVP::EREF] << std::endl;
203  app_log() << " Feedback = " << vParam[SBVP::FEEDBACK] << std::endl;
204  app_log() << " reference variance = " << vParam[SBVP::SIGMA2] << std::endl;
205  app_log() << " target walkers = " << iParam[B_TARGETWALKERS] << std::endl;
206  app_log() << " branching cutoff scheme " << branching_cutoff_scheme << std::endl;
207  app_log() << " branch cutoff = " << vParam[SBVP::BRANCHCUTOFF] << " " << vParam[SBVP::BRANCHMAX] << std::endl;
208  app_log() << " Max and minimum walkers per node= " << iParam[B_MAXWALKERS] << " " << iParam[B_MINWALKERS]
209  << std::endl;
210  app_log() << " QMC Status (BranchMode) = " << BranchMode << std::endl;
211  if (debug_disable_branching_ == "yes")
212  app_log() << " Disable branching for debugging as the user input request." << std::endl;
213 
214  return int(round(double(iParam[B_TARGETWALKERS]) / double(nwtot_now)));
215 }
int rank() const
return the rank
Definition: Communicate.h:116
void reset()
reset the internal parameters
std::ostream & app_log()
Definition: OutputManager.h:65
std::string branching_cutoff_scheme
scheme of branching cutoff
accumulator_set< RealType > R2Proposed
a simple accumulator for energy
const char walkers[]
Definition: HDFVersion.h:36
xmlNodePtr myNode
save xml element
int size() const
return the number of tasks
Definition: Communicate.h:118
void setBranchCutoff(FullPrecRealType variance, FullPrecRealType targetSigma, FullPrecRealType maxSigma, int Nelec=0)
set branch cutoff, max, filter
Wrapping information on parallelism.
Definition: Communicate.h:68
void allreduce(T &)
std::unique_ptr< WalkerControlBase > BackupWalkerController
Backup WalkerController for mixed DMC.
1 to kill walkers when a node crossing is detected
1 for the standard dmc, 0 for the comb method
warmup steps, valid when BranchMode[D_DMCSTAGE] == 0
return_type result() const
return the sum
Definition: accumulators.h:108
std::vector< std::string > sParam
string parameters
QTFull::RealType FullPrecRealType
Definition: Configuration.h:66
std::unique_ptr< EstimatorManagerBase > MyEstimator
std::unique_ptr< WalkerControlBase > WalkerController
WalkerController.
accumulator_set< RealType > R2Accepted
a simple accumulator for energy
target total number of walkers per mpi group
WalkerControlBase * createWalkerController(int nwtot, Communicate *comm, xmlNodePtr cur, bool reconfig)
function to create WalkerControlBase or its derived class
std::string debug_disable_branching_
disable branching for debugging

◆ phaseChanged()

bool phaseChanged ( RealType  psi0) const
inline

Definition at line 260 of file SimpleFixedNodeBranch.h.

References qmcplusplus::cos().

Referenced by DMCUpdateAllWithRejection::advanceWalker(), SODMCUpdatePbyPWithRejectionFast::advanceWalker(), DMCUpdatePbyPWithRejectionFast::advanceWalker(), DMCUpdatePbyPL2::advanceWalker(), DMCUpdateAllWithKill::advanceWalker(), RMCUpdatePbyPWithDrift::advanceWalkersRMC(), RMCUpdateAllWithDrift::advanceWalkersRMC(), RMCUpdatePbyPWithDrift::advanceWalkersVMC(), and RMCUpdateAllWithDrift::advanceWalkersVMC().

261  {
262 // TODO: remove ifdef
263 #if defined(QMC_COMPLEX)
264  return false;
265 #else
266  return std::cos(psi0) < std::numeric_limits<RealType>::epsilon();
267 #endif
268  }
MakeReturn< UnaryNode< FnCos, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t cos(const Vector< T1, C1 > &l)

◆ put()

bool put ( xmlNodePtr  cur)

Parse the xml file for parameters.

Parameters
curcurrent xmlNode

Few important parameters are:

  • en_ref: a reference energy
  • num_gen: number of generations $N_G$ to reach equilibrium, used in the feedback parameter $ feed = \frac{1}{N_G \tau} $

Definition at line 732 of file SimpleFixedNodeBranch.cpp.

References SimpleFixedNodeBranch::m_param, SimpleFixedNodeBranch::MyEstimator, SimpleFixedNodeBranch::myNode, ParameterSet::put(), and SimpleFixedNodeBranch::reset().

733 {
734  //save it
735  myNode = cur;
736  //check dmc/vmc and decide to create WalkerControllerBase
737  m_param.put(cur);
738  reset();
739  MyEstimator->setCollectionMode(true); //always collect
740  return true;
741 }
void reset()
reset the internal parameters
xmlNodePtr myNode
save xml element
bool put(std::istream &is) override
read from std::istream
Definition: ParameterSet.h:42
ParameterSet m_param
set of parameters
std::unique_ptr< EstimatorManagerBase > MyEstimator

◆ read()

void read ( const std::string &  fname)

Definition at line 756 of file SimpleFixedNodeBranch.cpp.

References SimpleFixedNodeBranch::ACC_ENERGY, SimpleFixedNodeBranch::ACC_SAMPLES, qmcplusplus::app_log(), SimpleFixedNodeBranch::B_POPCONTROL, SimpleFixedNodeBranch::B_RESTART, SimpleFixedNodeBranch::BranchMode, accumulator_set< T, typename >::count(), SimpleFixedNodeBranch::EnergyHist, accumulator_set< T, typename >::good(), accumulator_set< T, typename >::mean(), SimpleFixedNodeBranch::MyEstimator, SimpleFixedNodeBranch::R2Accepted, SimpleFixedNodeBranch::R2Proposed, accumulator_set< T, typename >::result(), SimpleFixedNodeBranch::VarianceHist, and SimpleFixedNodeBranch::vParam.

757 {
758  BranchMode.set(B_RESTART, 0);
759  if (fname.empty())
760  return;
763  BranchIO<SimpleFixedNodeBranch> hh(*this, MyEstimator->getCommunicator());
764  BranchModeType bmode(BranchMode);
765  bool success = hh.read(fname);
766  if (success && R2Proposed.good() && bmode[B_POPCONTROL] == BranchMode[B_POPCONTROL])
767  {
768  BranchMode.set(B_RESTART, 1);
769  app_log() << " Restarting, cummulative properties:"
770  << "\n energy = " << EnergyHist.mean() << "\n variance = " << VarianceHist.mean()
771  << "\n r2accepted = " << R2Accepted.mean() << "\n r2proposed = " << R2Proposed.mean()
772  << std::endl;
773  }
774  else
775  {
776  if (BranchMode[B_POPCONTROL] != bmode[B_POPCONTROL])
777  {
778  app_log() << " Population control method has changed from " << BranchMode[B_POPCONTROL] << " to "
779  << bmode[B_POPCONTROL] << std::endl;
781  }
782  }
783 
784  app_log().flush();
785 }
std::bitset< B_MODE_MAX > BranchModeType
booleans to set the branch modes
std::ostream & app_log()
Definition: OutputManager.h:65
accumulator_set< RealType > R2Proposed
a simple accumulator for energy
bool good() const
return true if Weight!= 0
Definition: accumulators.h:103
accumulator_set< FullPrecRealType > EnergyHist
a simple accumulator for energy
1 for the standard dmc, 0 for the comb method
return_type mean() const
return the mean
Definition: accumulators.h:126
return_type result() const
return the sum
Definition: accumulators.h:108
return_type count() const
return the count
Definition: accumulators.h:116
std::unique_ptr< EstimatorManagerBase > MyEstimator
accumulator_set< RealType > R2Accepted
a simple accumulator for energy
accumulator_set< FullPrecRealType > VarianceHist
a simple accumulator for variance

◆ registerParameters()

void registerParameters ( )

create map between the parameter name and variables

Definition at line 92 of file SimpleFixedNodeBranch.cpp.

References ParameterSet::add(), SimpleFixedNodeBranch::B_BRANCHINTERVAL, SimpleFixedNodeBranch::B_ENERGYUPDATEINTERVAL, SimpleFixedNodeBranch::B_TARGETWALKERS, SimpleFixedNodeBranch::B_WARMUPSTEPS, SimpleFixedNodeBranch::branching_cutoff_scheme, SimpleFixedNodeBranch::debug_disable_branching_, SimpleFixedNodeBranch::EREF, SimpleFixedNodeBranch::FEEDBACK, SimpleFixedNodeBranch::FILTERSCALE, SimpleFixedNodeBranch::iParam, SimpleFixedNodeBranch::m_param, qmcplusplus::MIXDMCOPT, SimpleFixedNodeBranch::sParam, SimpleFixedNodeBranch::TAU, qmcplusplus::USETAUOPT, and SimpleFixedNodeBranch::vParam.

Referenced by SimpleFixedNodeBranch::SimpleFixedNodeBranch().

93 {
94  m_param.add(iParam[B_WARMUPSTEPS], "warmupSteps");
95  m_param.add(iParam[B_WARMUPSTEPS], "warmupsteps");
96  m_param.add(iParam[B_ENERGYUPDATEINTERVAL], "energyUpdateInterval");
97  m_param.add(iParam[B_BRANCHINTERVAL], "branchInterval");
98  m_param.add(iParam[B_TARGETWALKERS], "targetWalkers");
99  m_param.add(iParam[B_TARGETWALKERS], "targetwalkers");
100  m_param.add(iParam[B_TARGETWALKERS], "target_walkers");
101  //trial energy
102  m_param.add(vParam[SBVP::EREF], "refEnergy");
103  m_param.add(vParam[SBVP::EREF], "ref_energy");
104  m_param.add(vParam[SBVP::EREF], "en_ref");
105  m_param.add(vParam[SBVP::TAU], "tau");
106  m_param.add(vParam[SBVP::TAU], "timestep");
107  m_param.add(vParam[SBVP::TAU], "timeStep");
108  m_param.add(vParam[SBVP::TAU], "TimeStep");
109  //filterscale: sets the filtercutoff to sigma*filterscale
110  m_param.add(vParam[SBVP::FILTERSCALE], "filterscale");
111  //feed back parameter for population control
112  m_param.add(vParam[SBVP::FEEDBACK], "feedback");
113  //turn on/off effective tau onl for time-step error comparisons
114  m_param.add(sParam[USETAUOPT], "useBareTau");
115  m_param.add(sParam[MIXDMCOPT], "warmupByReconfiguration");
116  m_param.add(branching_cutoff_scheme, "branching_cutoff_scheme");
117  m_param.add(debug_disable_branching_, "debug_disable_branching", {"no", "yes"});
118 }
std::string branching_cutoff_scheme
scheme of branching cutoff
ParameterSet m_param
set of parameters
frequency of the trial energy updates, default 1
warmup steps, valid when BranchMode[D_DMCSTAGE] == 0
void add(PDT &aparam, const std::string &aname_in, std::vector< PDT > candidate_values={}, TagStatus status=TagStatus::OPTIONAL)
add a new parameter corresponding to an xmlNode <parameter>
std::vector< std::string > sParam
string parameters
interval between branch, see population control
target total number of walkers per mpi group
std::string debug_disable_branching_
disable branching for debugging

◆ regressQMCCounter()

void regressQMCCounter ( )
inline

◆ reset()

void reset ( )

reset the internal parameters

Calculates and saves various action components, also does necessary updates for running averages.

Definition at line 478 of file SimpleFixedNodeBranch.cpp.

References SimpleFixedNodeBranch::B_DMCSTAGE, SimpleFixedNodeBranch::B_ENERGYUPDATEINTERVAL, SimpleFixedNodeBranch::B_POPCONTROL, SimpleFixedNodeBranch::B_RMC, SimpleFixedNodeBranch::B_RMCSTAGE, SimpleFixedNodeBranch::B_TARGETWALKERS, SimpleFixedNodeBranch::B_USETAUEFF, SimpleFixedNodeBranch::B_WARMUPSTEPS, SimpleFixedNodeBranch::BranchMode, SimpleFixedNodeBranch::EREF, SimpleFixedNodeBranch::ETRIAL, SimpleFixedNodeBranch::FEEDBACK, SimpleFixedNodeBranch::iParam, qmcplusplus::log(), SimpleFixedNodeBranch::logN, SimpleFixedNodeBranch::sParam, SimpleFixedNodeBranch::ToDoSteps, qmcplusplus::USETAUOPT, SimpleFixedNodeBranch::vParam, and SimpleFixedNodeBranch::WalkerController.

Referenced by SimpleFixedNodeBranch::initReptile(), SimpleFixedNodeBranch::initWalkerController(), SimpleFixedNodeBranch::put(), and SimpleFixedNodeBranch::SimpleFixedNodeBranch().

479 {
480  //use effective time step of BranchInterval*Tau
481  //Feed = 1.0/(static_cast<RealType>(NumGeneration*BranchInterval)*Tau);
482  //logN = Feed*std::log(static_cast<RealType>(Nideal));
483  //JNKIM passive
484  //BranchMode.set(B_DMC,1);//set DMC
485  //BranchMode.set(B_DMCSTAGE,0);//set warmup
486  if (WalkerController)
487  {
488  //this is to compare the time step errors
489  BranchMode.set(B_USETAUEFF, sParam[USETAUOPT] == "no");
490  if (BranchMode[B_DMCSTAGE]) //
492  else
495  {
496  //logN = Feedback*std::log(static_cast<RealType>(iParam[B_TARGETWALKERS]));
497  logN = std::log(static_cast<FullPrecRealType>(iParam[B_TARGETWALKERS]));
498  if (vParam[SBVP::FEEDBACK] == 0.0)
499  vParam[SBVP::FEEDBACK] = 1.0;
500  }
501  else
502  {
503  //may set Eref to a safe value
504  //if(EnergyHistory.count()<5) Eref -= vParam[EnergyWindowIndex];
506  vParam[SBVP::FEEDBACK] = 0.0;
507  logN = 0.0;
508  }
509  // vParam(abranch.vParam)
510  WalkerController->start();
511  }
512  if (BranchMode[B_RMC])
513  {
514  //this is to compare the time step errors
515  // BranchMode.set(B_USETAUEFF,sParam[USETAUOPT]=="no");
516  if (BranchMode[B_RMCSTAGE]) //
518  else
520  }
521 }
FullPrecRealType logN
Feed*log(N)
1 to use taueff accordning to JCP 93, 0 to use tau
frequency of the trial energy updates, default 1
1 for the standard dmc, 0 for the comb method
warmup steps, valid when BranchMode[D_DMCSTAGE] == 0
MakeReturn< UnaryNode< FnLog, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t log(const Vector< T1, C1 > &l)
std::vector< std::string > sParam
string parameters
std::unique_ptr< WalkerControlBase > WalkerController
WalkerController.
target total number of walkers per mpi group
int ToDoSteps
number of remaning steps for a specific tasks

◆ resetRun()

int resetRun ( xmlNodePtr  cur)

reset the internal parameters

Returns
new target population over old target population

only used by legacy drivers

Definition at line 523 of file SimpleFixedNodeBranch.cpp.

References ParameterSet::add(), APP_ABORT, qmcplusplus::app_log(), SimpleFixedNodeBranch::B_DMC, SimpleFixedNodeBranch::B_DMCSTAGE, SimpleFixedNodeBranch::B_MAXWALKERS, SimpleFixedNodeBranch::B_MINWALKERS, SimpleFixedNodeBranch::B_POPCONTROL, SimpleFixedNodeBranch::B_TARGETWALKERS, SimpleFixedNodeBranch::B_WARMUPSTEPS, SimpleFixedNodeBranch::BackupWalkerController, TinyVector< T, D >::begin(), SimpleFixedNodeBranch::branching_cutoff_scheme, SimpleFixedNodeBranch::BranchMode, accumulator_set< T, typename >::clear(), qmcplusplus::createWalkerController(), TinyVector< T, D >::end(), SimpleFixedNodeBranch::EREF, SimpleFixedNodeBranch::ETRIAL, SimpleFixedNodeBranch::FEEDBACK, SimpleFixedNodeBranch::iParam, SimpleFixedNodeBranch::m_param, SimpleFixedNodeBranch::MyEstimator, SimpleFixedNodeBranch::myNode, ParameterSet::put(), SimpleFixedNodeBranch::R2Accepted, SimpleFixedNodeBranch::R2Proposed, SimpleFixedNodeBranch::setBranchCutoff(), SimpleFixedNodeBranch::SIGMA2, SimpleFixedNodeBranch::ToDoSteps, SimpleFixedNodeBranch::vParam, and SimpleFixedNodeBranch::WalkerController.

524 {
525  app_log() << "BRANCH resetRun" << std::endl;
526  //estimator is always reset
527  MyEstimator->reset();
528  MyEstimator->setCollectionMode(true);
529  std::bitset<B_MODE_MAX> bmode(BranchMode);
530  IParamType iparam_old(iParam);
531  VParamType vparam_old(vParam);
532  myNode = cur;
533  //store old target
534  int nw_target = iParam[B_TARGETWALKERS];
535  m_param.put(cur);
536 
537  int target_min = -1;
538  ParameterSet p;
539  p.add(target_min, "minimumtargetwalkers"); //p.add(target_min,"minimumTargetWalkers");
540  p.add(target_min, "minimumsamples"); //p.add(target_min,"minimumSamples");
541  p.put(cur);
542 
543  if (iParam[B_TARGETWALKERS] < target_min)
544  {
545  iParam[B_TARGETWALKERS] = target_min;
546  }
547 
548  bool same_wc = true;
550  {
551  std::string reconfig("no");
552  // method is actually IndexType so conceivably indicates much more that reconfig="yes" or "no"
553  if (WalkerController->get_method())
554  reconfig = "runwhileincorrect"; // forces SR during warmup?
555  std::string reconfig_prev(reconfig);
556  ParameterSet p;
557  p.add(reconfig, "reconfiguration");
558  p.put(cur);
559  if (reconfig != "no" && reconfig != "runwhileincorrect")
560  {
561  // remove this once bug is fixed
562  throw std::runtime_error("Reconfiguration is currently broken and gives incorrect results. Use dynamic "
563  "population control by setting reconfiguration=\"no\" or removing the reconfiguration "
564  "option from the DMC input section. If accessing the broken reconfiguration code path "
565  "is still desired, set reconfiguration to \"runwhileincorrect\" instead of \"yes\".");
566  }
567  same_wc = (reconfig == reconfig_prev);
568  }
569 
570  //everything is the same, do nothing
571  if (same_wc && bmode == BranchMode && std::equal(iParam.begin(), iParam.end(), iparam_old.begin()) &&
572  std::equal(vParam.begin(), vParam.end(), vparam_old.begin()))
573  {
574  app_log() << " Continue with the same input as the previous block." << std::endl;
575  app_log().flush();
576  //return 1;
577  }
578  app_log() << " SimpleFixedNodeBranch::resetRun detected changes in <parameter>'s " << std::endl;
579  app_log() << " BranchMode : " << bmode << " " << BranchMode << std::endl;
580 
581  //vmc does not need to do anything with WalkerController
582  if (!BranchMode[B_DMC])
583  {
584  app_log() << " iParam (old): " << iparam_old << std::endl;
585  app_log() << " iParam (new): " << iParam << std::endl;
586  app_log() << " vParam (old): " << vparam_old << std::endl;
587  app_log() << " vParam (new): " << vParam << std::endl;
588  app_log().flush();
589  return 1;
590  }
591 
592  if (WalkerController == nullptr)
593  {
594  APP_ABORT("SimpleFixedNodeBranch::resetRun cannot initialize WalkerController");
595  }
596 
597  if (!same_wc)
598  {
599  app_log() << "Destroy WalkerController. Existing method " << WalkerController->get_method() << std::endl;
600  ;
602  app_log().flush();
603 
604  BranchMode[B_POPCONTROL] = (WalkerController->get_method() == 0);
606  {
608  if (vParam[SBVP::FEEDBACK] == 0.0)
609  vParam[SBVP::FEEDBACK] = 1.0;
610  }
611  }
612 
613  //always add a warmup step using default 10 steps
614  R2Accepted.clear();
615  R2Proposed.clear();
616  //R2Accepted(1.0e-12);
617  //R2Proposed(1.0e-12);
618  BranchMode[B_DMCSTAGE] = 0;
619  WalkerController->put(myNode);
621  setBranchCutoff(vParam[SBVP::SIGMA2], WalkerController->get_target_sigma(), 10);
622  WalkerController->reset();
624  BackupWalkerController->reset();
625 
626  iParam[B_MAXWALKERS] = WalkerController->get_n_max();
627  iParam[B_MINWALKERS] = WalkerController->get_n_min();
628 
629  app_log() << " iParam (old): " << iparam_old << std::endl;
630  app_log() << " iParam (new): " << iParam << std::endl;
631  app_log() << " vParam (old): " << vparam_old << std::endl;
632  app_log() << " vParam (new): " << vParam << std::endl;
633 
634  app_log() << std::endl << " Using branching cutoff scheme " << branching_cutoff_scheme << std::endl;
635 
636  app_log().flush();
637 
638  // return static_cast<int>(iParam[B_TARGETWALKERS]*1.01/static_cast<double>(nw_target));
639  return static_cast<int>(round(static_cast<double>(iParam[B_TARGETWALKERS] / static_cast<double>(nw_target))));
640 }
std::ostream & app_log()
Definition: OutputManager.h:65
std::string branching_cutoff_scheme
scheme of branching cutoff
accumulator_set< RealType > R2Proposed
a simple accumulator for energy
xmlNodePtr myNode
save xml element
bool put(std::istream &is) override
read from std::istream
Definition: ParameterSet.h:42
void setBranchCutoff(FullPrecRealType variance, FullPrecRealType targetSigma, FullPrecRealType maxSigma, int Nelec=0)
set branch cutoff, max, filter
ParameterSet m_param
set of parameters
std::unique_ptr< WalkerControlBase > BackupWalkerController
Backup WalkerController for mixed DMC.
class to handle a set of parameters
Definition: ParameterSet.h:27
1 for the standard dmc, 0 for the comb method
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
warmup steps, valid when BranchMode[D_DMCSTAGE] == 0
void add(PDT &aparam, const std::string &aname_in, std::vector< PDT > candidate_values={}, TagStatus status=TagStatus::OPTIONAL)
add a new parameter corresponding to an xmlNode <parameter>
TinyVector< int, B_IPARAM_MAX > IParamType
input parameters of integer types
std::unique_ptr< EstimatorManagerBase > MyEstimator
std::unique_ptr< WalkerControlBase > WalkerController
WalkerController.
accumulator_set< RealType > R2Accepted
a simple accumulator for energy
target total number of walkers per mpi group
WalkerControlBase * createWalkerController(int nwtot, Communicate *comm, xmlNodePtr cur, bool reconfig)
function to create WalkerControlBase or its derived class
int ToDoSteps
number of remaning steps for a specific tasks

◆ setBranchCutoff()

void setBranchCutoff ( FullPrecRealType  variance,
FullPrecRealType  targetSigma,
FullPrecRealType  maxSigma,
int  Nelec = 0 
)
private

set branch cutoff, max, filter

Definition at line 787 of file SimpleFixedNodeBranch.cpp.

References APP_ABORT, SimpleFixedNodeBranch::BRANCHCUTOFF, SimpleFixedNodeBranch::BRANCHFILTER, SimpleFixedNodeBranch::branching_cutoff_scheme, SimpleFixedNodeBranch::BRANCHMAX, omptarget::min(), qmcplusplus::sqrt(), SimpleFixedNodeBranch::TAU, and SimpleFixedNodeBranch::vParam.

Referenced by SimpleFixedNodeBranch::branch(), SimpleFixedNodeBranch::collect(), SimpleFixedNodeBranch::initReptile(), SimpleFixedNodeBranch::initWalkerController(), and SimpleFixedNodeBranch::resetRun().

791 {
792  if (branching_cutoff_scheme == "DRV")
793  {
794  // eq.(3), J. Chem. Phys. 89, 3629 (1988).
795  // eq.(9), J. Chem. Phys. 99, 2865 (1993).
797  }
798  else if (branching_cutoff_scheme == "ZSGMA")
799  {
800  // eq.(6), Phys. Rev. B 93, 241118(R) (2016)
801  // do nothing if Nelec is not passed in.
802  if (Nelec > 0)
804  }
805  else if (branching_cutoff_scheme == "YL")
806  {
807  // a scheme from Ye Luo.
808  vParam[SBVP::BRANCHCUTOFF] = std::sqrt(variance) * std::min(targetSigma, std::sqrt(1.0 / vParam[SBVP::TAU]));
809  }
810  else if (branching_cutoff_scheme == "classic")
811  {
812  // default QMCPACK choice which is the same as v3.0.0 and before.
813  vParam[SBVP::BRANCHCUTOFF] = std::min(std::max(variance * targetSigma, maxSigma), 2.5 / vParam[SBVP::TAU]);
814  }
815  else
816  APP_ABORT("SimpleFixedNodeBranch::setBranchCutoff unknown branching cutoff scheme " + branching_cutoff_scheme);
817 
820 }
std::string branching_cutoff_scheme
scheme of branching cutoff
T min(T a, T b)
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
MakeReturn< UnaryNode< FnSqrt, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sqrt(const Vector< T1, C1 > &l)

◆ setEstimatorManager()

void setEstimatorManager ( std::unique_ptr< EstimatorManagerBase est)
inline

set the EstimatorManager

Parameters
estestimator created by the first QMCDriver this assumes estimator managers are reused section to section

Definition at line 284 of file SimpleFixedNodeBranch.h.

References SimpleFixedNodeBranch::MyEstimator.

Referenced by qmcplusplus::TEST_CASE().

284 { MyEstimator = std::move(est); }
std::unique_ptr< EstimatorManagerBase > MyEstimator

◆ start()

void start ( const std::string &  froot,
bool  append = false 
)

start a run

Definition at line 120 of file SimpleFixedNodeBranch.cpp.

References SimpleFixedNodeBranch::MyEstimator, and SimpleFixedNodeBranch::RootName.

121 {
122  RootName = froot;
123  MyEstimator->reset();
124 }
std::unique_ptr< EstimatorManagerBase > MyEstimator

◆ symLinkAction()

RealType symLinkAction ( RealType  logGf,
RealType  logGb,
RealType  enew,
RealType  eold 
) const
inline

◆ symLinkActionBare()

RealType symLinkActionBare ( RealType  logGf,
RealType  logGb,
RealType  enew,
RealType  eold 
) const
inline

Definition at line 342 of file SimpleFixedNodeBranch.h.

References SimpleFixedNodeBranch::TAUEFF, and SimpleFixedNodeBranch::vParam.

343  {
344  RealType driftaction = -0.5 * (logGf + logGb);
345  RealType taueff_ = vParam[SBVP::TAUEFF] * 0.5;
346  RealType energyaction = taueff_ * (enew + eold);
347  // RealType wavefunctionaction= -psinew + psiold;
348  return driftaction + energyaction;
349  }
QMCTraits::RealType RealType

◆ write()

void write ( const std::string &  fname,
bool  overwrite = true 
)

write the state

Parameters
fnamename of the configuration file
overwriteNOT USED

Definition at line 743 of file SimpleFixedNodeBranch.cpp.

References SimpleFixedNodeBranch::ACC_ENERGY, SimpleFixedNodeBranch::ACC_SAMPLES, accumulator_set< T, typename >::count(), SimpleFixedNodeBranch::EnergyHist, SimpleFixedNodeBranch::MyEstimator, accumulator_set< T, typename >::result(), SimpleFixedNodeBranch::RootName, SimpleFixedNodeBranch::vParam, and BranchIO< SFNB >::write().

Referenced by SimpleFixedNodeBranch::finalize().

744 {
745  RootName = fname;
746  if (MyEstimator->is_manager())
747  {
748  //\since 2008-06-24
751  BranchIO<SimpleFixedNodeBranch> hh(*this, MyEstimator->getCommunicator());
752  bool success = hh.write(fname);
753  }
754 }
accumulator_set< FullPrecRealType > EnergyHist
a simple accumulator for energy
return_type result() const
return the sum
Definition: accumulators.h:108
return_type count() const
return the count
Definition: accumulators.h:116
std::unique_ptr< EstimatorManagerBase > MyEstimator

Member Data Documentation

◆ BackupWalkerController

std::unique_ptr<WalkerControlBase> BackupWalkerController

◆ branching_cutoff_scheme

◆ BranchMode

◆ debug_disable_branching_

std::string debug_disable_branching_
private

◆ EnergyHist

◆ iParam

◆ LogJacobRef

RealType LogJacobRef

LogJacob.

Definition at line 248 of file SimpleFixedNodeBranch.h.

◆ logN

Feed*log(N)

Definition at line 211 of file SimpleFixedNodeBranch.h.

Referenced by SimpleFixedNodeBranch::branch(), and SimpleFixedNodeBranch::reset().

◆ LogNorm

std::vector<RealType> LogNorm

LogNorm.

Definition at line 250 of file SimpleFixedNodeBranch.h.

◆ m_param

◆ MyEstimator

◆ myNode

xmlNodePtr myNode

◆ R2Accepted

◆ R2Center

a simple accumulator for reptation's center slice

Definition at line 229 of file SimpleFixedNodeBranch.h.

◆ R2Proposed

◆ RootName

std::string RootName

◆ ScaleNum

unsigned long ScaleNum

Definition at line 245 of file SimpleFixedNodeBranch.h.

Referenced by SimpleFixedNodeBranch::branchWeightTau().

◆ ScaleSum

FullPrecRealType ScaleSum

Used for the average scaling.

Definition at line 244 of file SimpleFixedNodeBranch.h.

Referenced by SimpleFixedNodeBranch::branchWeightTau().

◆ sParam

◆ ToDoSteps

int ToDoSteps

number of remaning steps for a specific tasks

set differently for BranchMode[B_DMCSTAGE]

Definition at line 209 of file SimpleFixedNodeBranch.h.

Referenced by SimpleFixedNodeBranch::branch(), SimpleFixedNodeBranch::collect(), SimpleFixedNodeBranch::reset(), and SimpleFixedNodeBranch::resetRun().

◆ VarianceHist

◆ vParam

◆ WalkerController


The documentation for this struct was generated from the following files: