\section{Diffusion Monte Carlo}\label{sec:dmc}
Main input parameters are given in Table \ref{tab:dmcmain}, additional in Table \ref{tab:dmcadditional}.
\begin{table}[h]
\begin{center}
  \caption{Main DMC input parameters}
  \label{tab:dmcmain}
\begin{tabularx}{\textwidth}{l l l l l X }
\hline
\multicolumn{6}{l}{\texttt{dmc} method} \\
\hline
\multicolumn{2}{l}{parameters}  & \multicolumn{4}{l}{}\\
   &   \bfseries name     & \bfseries datatype & \bfseries values & \bfseries default   & \bfseries description \\
   &   \texttt{targetwalkers       } &  integer  & $> 0$ & dep.   & Overall total number of walkers \\
   &   \texttt{blocks              } &  integer  & $\ge 0$ & 1   & Number of blocks \\
   &   \texttt{steps               } &  integer  & $\ge 0$ & 1   & Number of steps per block\\
   &   \texttt{warmupsteps         } &  integer  & $\ge 0$ & 0   & Number of steps for warming up\\
   &   \texttt{timestep            } &  real     & $> 0$   & 0.1 & Time step for each electron move \\
   &   \texttt{nonlocalmoves       } &  string   & yes,no,v0,v1,v3 & no   & Run with T-moves  \\
   &   \texttt{branching\_cutoff\_scheme} & string    & classic/DRV/ZSGMA/YL & classic & Branch cutoff scheme \\
   &   \texttt{maxcpusecs          } &  real     & $\ge 0$ & 3.6e5   & Maximum allowed walltime in seconds \\
   &   \texttt{blocks\_between\_recompute} &  integer  & $\ge 0$ & dep.  & Wavefunction recompute frequency  \\
   \hline
  \end{tabularx}
  \end{center}
  \end{table}

  \begin{table}[h]
    \begin{center}
      \caption{Additional DMC input parameters}
      \label{tab:dmcadditional}
      \begin{tabularx}{\textwidth}{l l l l l X }
    \hline
    \multicolumn{6}{l}{\texttt{dmc} method} \\
    \hline
    \multicolumn{2}{l}{parameters}  & \multicolumn{4}{l}{}\\    
   &   \bfseries name     & \bfseries datatype & \bfseries values & \bfseries default   & \bfseries description \\
   &   \texttt{energyUpdateInterval} &  integer  & $\ge 0$ & 0   & Trial energy update interval \\
   &   \texttt{refEnergy           } &  real     & all values & dep.   & Reference energy in atomic units  \\
   &   \texttt{feedback            } &  double   & $\ge 0$ & 1.0   & Population feedback on the trial energy \\
   &   \texttt{sigmaBound          } &  double   & $\ge 0$ & 10   & Parameter to cutoff large weights  \\
   &   \texttt{killnode            } &  string   & yes/other & no   & Kill or reject walkers that cross nodes  \\
   &   \texttt{warmupByReconfiguration} & option & yes,no  & 0   & Warm up with a fixed population  \\
   &   \texttt{reconfiguration     } &  string   & yes/pure/other & no   & Fixed population technique  \\
   &   \texttt{branchInterval      } &  integer  & $\ge 0$ & 1   & Branching interval \\
   &   \texttt{substeps            } &  integer  & $\ge 0$ & 1   & Branching interval \\
   &   \texttt{MaxAge              } &  double   & $\ge 0$ & 10   & Kill persistent walkers  \\
   &   \texttt{MaxCopy             } &  double   & $\ge 0$ & 2   & Limit population growth \\
   &   \texttt{maxDisplSq          } &  real     & all values & -1   & Maximum particle move  \\
   &   \texttt{scaleweight         } &  string   & yes/other & yes   & Scale weights (CUDA only)  \\
   &   \texttt{checkproperties     } &  integer  & $\ge 0$ & 100   & Number of steps between walker updates  \\
   &   \texttt{fastgrad            } &  text     & yes/other & yes   & Fast gradients  \\
   &   \texttt{storeconfigs        } &  integer  & all values & 0   & Store configurations  \\
   &   \texttt{use\_nonblocking    } &  string   & yes/no     & yes   & Using nonblocking send/recv \\
   \hline
  \end{tabularx}
  \end{center}
  \end{table}
% Legacy/unused/deprecated input parameters:
%   &   \texttt{samples             } &  real  & $\ge 0$ & 0   & total number of samples \\
%   &   \texttt{stepsbetweensamples } &  integer  & $> 0$ & 1   & period of the sample accumulation\\
%   &   \texttt{samplesperthread    } &  real  & $\ge 0$ & 0   & number of samples per thread  \\
%   &   \texttt{rewind              } &  integer  & $\ge 0$ & 0   & number of blocks to roll back   \\
%   &   \texttt{storeconfigs        } &  integer  & $\ge 0$ & 0   & whether to store samples  \\
%  &   \texttt{recordwalkers       } &  integer  & $\ge 0$ & 0   & number of steps between saving a sample configuration. (only for VMC)  \\
%   &   \texttt{recordconfigs       } &  integer  & $\ge 0$ & 0   & number of steps between dumping a configuration to h5  \\
%   &   \texttt{current             } &  integer  & $\ge 0$ & 0   & current step (only used in optimization runs)  \\
%   &   \texttt{dmcwalkersperthread } &  real  & $\ge 0$ & 0   & number of samples per thread  \\
%  &   \texttt{energyBound         } &  double  & $\ge 0$ & 0   & number of samples per thread  \\
% &   \texttt{benchmark           } &  string  & $\ge 0$ & 0   & number of sample \\
%  &   \texttt{printderivs         } &  text  & $\ge 0$ & 0   & number of samples per  thread  \\
%  &   \texttt{wlen                } &  integer  & $\ge 0$ & 0   & number of samples per  thread  \\




Additional information:
\begin{itemize}
\item \texttt{targetwalkers}:  A DMC run can be considered a restart run or a new run.  A restart run is considered to be any method block beyond the first one, such as when a DMC method block follows a VMC block.  Alternatively,  a user reading in configurations from disk would also considered a restart run.  In the case of a restart run, the DMC driver will use the configurations from the previous run, and this variable will not be used.  For a new run, if the number of walkers is less than the number of threads, then the number of walkers will be set equal to the number of threads.  

\item \texttt{blocks}: This is the number of blocks run during a DMC method block.  A block consists of a number of DMC steps (steps), after which all the statistics accumulated in the block are written to disk.

\item \texttt{steps}: This is the number of DMC steps in a block.

\item \texttt{warmupsteps}: These are the steps at the beginning of a DMC run in which the 
instantaneous average energy is used to update the trial energy.  During regular steps, E$_{ref}$ is used.

\item \texttt{timestep}: The \texttt{timestep} determines the accuracy of the imaginary time propagator.  Generally, multiple time steps are used to extrapolate to the infinite time step limit.   A good range of time steps  in which to perform time step extrapolation will typically have a minimum of 99\% acceptance probability for each step.

\item \texttt{checkproperties}:  When using a particle-by-particle driver, this variable specifies how often to reset all the variables kept in the buffer.

\item \texttt{maxcpusecs}: The default is 100 hours. Once the specified time has elapsed, the program will finalize the simulation even if all blocks are not  completed.

\item \texttt{energyUpdateInterval}: The default is to update the trial energy at every step. Otherwise the trial energy is updated every \texttt{energyUpdateInterval} step.

\[
E_{\text{trial}}=
\textrm{refEnergy}+\textrm{feedback}\cdot(\ln\texttt{targetWalkers}-\ln N)\:,
\]
where $N$ is the current population.

\item \texttt{refEnergy}: The default reference energy is taken from the VMC run that precedes the DMC run. This value is updated to the current mean whenever branching happens.

\item \texttt{feedback}: This variable is used to determine how strong to react to population fluctuations when doing population control.  See the equation in energyUpdateInterval for more details.

\item \texttt{useBareTau}: The same time step is used whether or not a move is rejected. The default is to use an effective time step when a move is rejected.

\item \texttt{warmupByReconfiguration}:  Warmup DMC is done with a fixed population.

\item \texttt{sigmaBound}:  This determines the branch cutoff to limit wild weights based on the sigma and \texttt{sigmaBound}.

\item \texttt{killnode}:  When running fixed-node, if a walker attempts to cross a node, the move will normally be rejected.  If \texttt{killnode} = ``yes," then walkers are destroyed when they cross a node.

%\item \texttt{benchmark}. 

\item \texttt{reconfiguration}:  If \texttt{reconfiguration} is ``yes," then run with a fixed walker population using the reconfiguration technique.  

\item \texttt{branchInterval}: This is the number of steps between branching.  The total number of DMC steps in a block will be \texttt{BranchInterval}*Steps.   

\item \texttt{substeps}:  This is the same as \texttt{BranchInterval}.


\item \texttt{nonlocalmoves}: Evaluate pseudopotentials using one of the nonlocal move algorithms such as T-moves.
\begin{itemize}
\item no(default): Imposes the locality approximation.
\item yes/v0: Implements the algorithm in the 2006 Casula paper~\cite{Casula2006}
\item v1: Implements the v1 algorithm in the 2010 Casula paper~\cite{Casula2010}.
\item v2: Is \textbf{not implemented} and is \textbf{skipped} to avoid any confusion with the v2 algorithm in the 2010 Casula paper~\cite{Casula2010}.
\item v3: (Experimental) Implements an algorithm similar to v1 but is much faster. v1 computes the transition probability before each single electron T-move selection because of the acceptance of previous T-moves. v3 mostly reuses the transition probability computed during the evaluation of nonlocal pseudopotentials for the local energy, namely before accepting any T-moves, and only recomputes the transition probability of the electrons within the same pseudopotential region of any electrons touched by T-moves. This is an approximation to v1 and results in a slightly different time step error, but it significantly reduces the computational cost. v1 and v3 agree at zero time step. This faster algorithm is the topic of a paper in preparation.
\end{itemize}
The v1 and v3 algorithms are size-consistent and are important advances over the previous v0 non-size-consistent algorithm. We highly recommend investigating the importance of size-consistency.

\item \texttt{scaleweight}: This is the scaling weight per Umrigar/Nightengale.  CUDA only.

\item \texttt{MaxAge}: Set the weight of a walker to min(currentweight,0.5) after a walker has not moved for \texttt{MaxAge} steps.  Needed if persistent walkers appear during the course of a run.

\item \texttt{MaxCopy}: When determining the number of copies of a walker to branch, set the number of copies equal to min(Multiplicity,MaxCopy).

\item \texttt{fastgrad}: This calculates gradients with either the fast version or the full-ratio version.

\item \texttt{maxDisplSq}:  When running a DMC calculation with particle by particle, this sets the maximum displacement allowed for a single particle move.  All distance displacements larger than the max are rejected.  If initialized to a negative value, it becomes equal to Lattice(LR/rc).

\item \texttt{sigmaBound}:  This determines the branch cutoff to limit wild weights based on the sigma and \texttt{sigmaBound}.

%\item \texttt{rewind}. \textit{This input is recorded by QMCDriver.cpp, but is never used anywhere else.}

\item \texttt{storeconfigs}: If \texttt{storeconfigs} is set to a nonzero value, then electron configurations during the DMC run will be saved. This option is disabled for the OpenMP version of DMC.

\item \texttt{blocks\_between\_recompute}: See details in Section~\ref{sec:vmc}, Variational Monte Carlo.

%\item \texttt{recordwalkers}. In VMC this is equivalent for \texttt{stepsbetweensamples}. \textit{This input is not used in DMC.}

%\item \texttt{recordconfigs}. \textit{This input is recorded by QMCDriver.cpp, but is never used anywhere else.}

%\item \texttt{current}. \textit{Only used in QMCLinearOptimize.cpp and QMCOptimize.cpp
%}
%\item \texttt{dmcwalkersperthread}. \textit{This input is only used in VMC.} It is equivalent to \texttt{samplesperthread}.

%\item \texttt{usedrift}. The VMC is implemented in two algorithms with or without drift. In the no-drift algorithm, the move of each electron is proposed with a Gaussian distribution. The standard deviation is chosen as the timestep input. In the drift algorithm, electrons are moved by langevin dynamics.




%\item \texttt{stepsbetweensamples}. Due to the fact that samples generated by consecutive steps might be still correlated. Having stepsbetweensamples larger than 1 reduces that correlation. In practice, using larger substeps is cheaper than using stepsbetweensamples to decorrelate samples.

%\item \texttt{samples}. This is the total amount of samples generated in the current VMC session. This parameter is not important for VMC only calculation but necessary if optimization or DMC follows.
%\[
%\textrm{samples}=
%\frac{\textrm{blocks}\cdot\textrm{steps}\cdot\textrm{walkers}}{\textrm{stepsbetweensamples}}\cdot\textrm{number of MPI tasks}
%\]

%\item \texttt{samplesperthread}. This is an alternative way to set the target amount of samples. More useful in the VMC session preparing the population for the following DMC calculation.
%\[
%\textrm{samplesperthread}=
%\frac{\textrm{blocks}\cdot\textrm{steps}}{\textrm{stepsbetweensamples}}
%\]

\item \texttt{branching\_cutoff\_scheme:} Modifies how the branching factor is computed so as to avoid divergences and stability
problems near nodal surfaces. 
\begin{itemize}
  \item classic (default): The implementation found in QMCPACK v3.0.0 and earlier.
	  $E_{\rm cut}=\mathrm{min}(\mathrm{max}(\sigma^2 \times \mathrm{sigmaBound},\mathrm{maxSigma}),2.5/\sqrt{\tau})$,
  where $\sigma^2$ is the variance and $\mathrm{maxSigma}$ is set to 50 during warmup (equilibration) and 10 thereafter.
  \item DRV: Implements the algorithm of DePasquale et al., Eq.~3 in Ref.~\cite{DePasqualeReliable1988} or Eq.~9 of Ref.~\cite{Umrigar1993}.
  $E_{\rm cut}=2.0/\sqrt{\tau}$.
  \item ZSGMA: Implements the ``ZSGMA'' algorithm of Ref.~\cite{ZenBoosting2016} with $\alpha=0.2$. The cutoff energy is modified by a factor including the
  electron count, $E_{\rm cut}=\alpha \sqrt{N/\tau}$, which greatly improves size consistency over Eq.~39 of Ref.~\cite{Umrigar1993}. See Eq.~6 in Ref.~\cite{ZenBoosting2016} and for
  an application to molecular crystals Ref.~\cite{ZenFast2018}.
  \item YL: An unpublished algorithm due to Ye Luo. $E_{\rm cut}=\sigma\times\mathrm{min}(\mathrm{sigmaBound},\sqrt{1/\tau})$. This option takes into account both size consistency and wavefunction quality via the term $\sigma$. $\mathrm{maxSigma}$ is default to 10.
\end{itemize}

\end{itemize}

\begin{lstlisting}[style=QMCPXML,caption=The following is an example of a very simple DMC section. ]
  <qmc method="dmc" move="pbyp" target="e">
    <parameter name="blocks">100</parameter>
    <parameter name="steps">400</parameter>
    <parameter name="timestep">0.010</parameter>
    <parameter name="warmupsteps">100</parameter>
  </qmc>
\end{lstlisting}
The time step should be individually adjusted for each problem.  Please refer to the theory section
on diffusion Monte Carlo.


\begin{lstlisting}[style=QMCPXML,caption=The following is an example of running a simulation that can be restarted. ]
  <qmc method="dmc" move="pbyp"  checkpoint="0">
    <parameter name="timestep">         0.004  </parameter>
    <parameter name="blocks">           100   </parameter>
    <parameter name="steps">            400    </parameter>
  </qmc>
\end{lstlisting}
The checkpoint flag instructs QMCPACK to output walker configurations.  This also
works in VMC.  This will output an h5 file with the name \texttt{projectid.run-number.config.h5}.
Check that this file exists before attempting a restart.
To read in this file for a continuation run, specify the following:
\begin{lstlisting}[caption=Restart (read walkers from previous run) ]
 <mcwalkerset fileroot="BH.s002" version="0 6" collected="yes"/>
\end{lstlisting}
BH is the project id, and s002 is the calculation number to read in the walkers from the previous run.\\

Combining VMC and DMC in a single run (wavefunction optimization can be combined in this way too) is the standard way in which QMCPACK is typically run.   There is no need to run two separate jobs since method sections can be stacked and walkers are transferred between them.

\begin{lstlisting}[style=QMCPXML,caption=Combined VMC and DMC run. ]
  <qmc method="vmc" move="pbyp" target="e">
    <parameter name="blocks">100</parameter>
    <parameter name="steps">4000</parameter>
    <parameter name="warmupsteps">100</parameter>
    <parameter name="samples">1920</parameter>
    <parameter name="walkers">1</parameter>
    <parameter name="timestep">0.5</parameter>
  </qmc>
  <qmc method="dmc" move="pbyp" target="e">
    <parameter name="blocks">100</parameter>
    <parameter name="steps">400</parameter>
    <parameter name="timestep">0.010</parameter>
    <parameter name="warmupsteps">100</parameter>
  </qmc>
  <qmc method="dmc" move="pbyp" target="e">
    <parameter name="warmupsteps">500</parameter>
    <parameter name="blocks">50</parameter>
    <parameter name="steps">100</parameter>
    <parameter name="timestep">0.005</parameter>
  </qmc>
\end{lstlisting}




