13#include <rpg/fts/montecarlo/McSimulator.h>
14#include <rpg/fts/compressor/Compressor.h>
15#include <rpg/system/System.h>
16#include <pscf/cuda/CudaRandom.h>
17#include <util/random/Random.h>
90 double oldHamiltonian =
simulator().hamiltonian();
104 compressorTimer_.start();
105 int compress =
simulator().compressor().compress();
107 compressorTimer_.stop();
109 bool isConverged =
false;
117 componentTimer_.start();
129 componentTimer_.stop();
132 hamiltonianTimer_.start();
134 double newHamiltonian =
simulator().hamiltonian();
135 hamiltonianTimer_.stop();
139 decisionTimer_.start();
140 double weight = exp(-(newHamiltonian - oldHamiltonian));
141 accept =
random().metropolis(weight);
148 decisionTimer_.stop();
167 double total = totalTimer_.time();
169 <<
"Total" << std::setw(17) <<
"Per Move" << std::setw(14) <<
"Fraction" <<
"\n";
170 out <<
"Attempt Move: "
174 out <<
"Compressor: "
175 <<
Dbl(compressorTimer_.time(), 9, 3) <<
" s, "
176 <<
Dbl(compressorTimer_.time()/nAttempt_, 9, 3) <<
" s, "
177 <<
Dbl(compressorTimer_.time()/total, 9, 3) <<
"\n";
178 out <<
"Compute eigen-components: "
179 <<
Dbl(componentTimer_.time(), 9, 3) <<
" s, "
180 <<
Dbl(componentTimer_.time()/nAttempt_, 9, 3) <<
" s, "
181 <<
Dbl(componentTimer_.time()/total, 9, 3) <<
"\n";
182 out <<
"Compute Hamiltonian: "
183 <<
Dbl(hamiltonianTimer_.time(), 9, 3) <<
" s, "
184 <<
Dbl(hamiltonianTimer_.time()/nAttempt_, 9, 3) <<
" s, "
185 <<
Dbl(hamiltonianTimer_.time()/total, 9, 3) <<
"\n";
186 out <<
"Accept or Reject: "
187 <<
Dbl(decisionTimer_.time(), 9, 3) <<
" s, "
188 <<
Dbl(decisionTimer_.time()/nAttempt_, 9, 3) <<
" s, "
189 <<
Dbl(decisionTimer_.time()/total, 9, 3) <<
"\n";
190 out <<
"total time: "
191 <<
Dbl(total, 9, 3) <<
" s, "
192 <<
Dbl(total/nAttempt_, 9, 3) <<
" s \n";
200 compressorTimer_.clear();
201 componentTimer_.clear();
202 hamiltonianTimer_.clear();
203 decisionTimer_.clear();
CudaRandom & cudaRandom()
Get cuda random number generator by reference.
virtual ~McMove()
Destructor.
void incrementNAttempt()
Increment the number of attempted moves.
Random & random()
Get Random number generator of parent System.
virtual void attemptMove()
Attempt unconstrained move.
virtual bool move()
Generate, attempt, and accept or reject a Monte Carlo move.
void readProbability(std::istream &in)
Read the probability from file.
virtual bool needsCc()
Decide whether cc fields need to be saved for move The default implementation is false.
McSimulator< D > & simulator()
Get parent McSimulator object.
virtual void readParameters(std::istream &in)
Read required parameters from file.
System< D > & system()
Get parent System object.
void incrementNAccept()
Increment the number of accepted moves.
void incrementNFail()
Increment the number of failed moves.
virtual void outputTimers(std::ostream &out)
Log output timing results.
virtual void setup()
Setup before the beginning of each simulation run.
McMove(McSimulator< D > &simulator)
Constructor.
Timer attemptMoveTimer_
Timers for McMove.
virtual bool needsDc()
Decide whether dc fields need to be saved for move The default implementation is false.
virtual void clearTimers()
Clear timers.
virtual void output()
Output statistics for this move (at the end of simulation)
Monte-Carlo simulation coordinator.
Wrapper for a double precision number, for formatted ostream output.
ScalarParam< Type > & read(std::istream &in, const char *label, Type &value)
Add and read a new required ScalarParam < Type > object.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
SCFT and PS-FTS with real periodic fields (GPU)
PSCF package top-level namespace.