13#include <rpg/fts/montecarlo/McSimulator.h>
14#include <rpg/fts/compressor/Compressor.h>
15#include <rpg/system/System.h>
88 double oldHamiltonian =
simulator().hamiltonian();
102 compressorTimer_.start();
103 int compress =
simulator().compressor().compress();
105 compressorTimer_.stop();
107 bool isConverged =
false;
115 componentTimer_.start();
127 componentTimer_.stop();
130 hamiltonianTimer_.start();
132 double newHamiltonian =
simulator().hamiltonian();
133 hamiltonianTimer_.stop();
137 decisionTimer_.start();
138 double weight = exp(-(newHamiltonian - oldHamiltonian));
139 accept =
random().metropolis(weight);
146 decisionTimer_.stop();
165 double total = totalTimer_.time();
167 <<
"Total" << std::setw(17) <<
"Per Move" << std::setw(14) <<
"Fraction" <<
"\n";
168 out <<
"Attempt Move: "
172 out <<
"Compressor: "
173 <<
Dbl(compressorTimer_.time(), 9, 3) <<
" s, "
174 <<
Dbl(compressorTimer_.time()/nAttempt_, 9, 3) <<
" s, "
175 <<
Dbl(compressorTimer_.time()/total, 9, 3) <<
"\n";
176 out <<
"Compute eigen-components: "
177 <<
Dbl(componentTimer_.time(), 9, 3) <<
" s, "
178 <<
Dbl(componentTimer_.time()/nAttempt_, 9, 3) <<
" s, "
179 <<
Dbl(componentTimer_.time()/total, 9, 3) <<
"\n";
180 out <<
"Compute Hamiltonian: "
181 <<
Dbl(hamiltonianTimer_.time(), 9, 3) <<
" s, "
182 <<
Dbl(hamiltonianTimer_.time()/nAttempt_, 9, 3) <<
" s, "
183 <<
Dbl(hamiltonianTimer_.time()/total, 9, 3) <<
"\n";
184 out <<
"Accept or Reject: "
185 <<
Dbl(decisionTimer_.time(), 9, 3) <<
" s, "
186 <<
Dbl(decisionTimer_.time()/nAttempt_, 9, 3) <<
" s, "
187 <<
Dbl(decisionTimer_.time()/total, 9, 3) <<
"\n";
188 out <<
"total time: "
189 <<
Dbl(total, 9, 3) <<
" s, "
190 <<
Dbl(total/nAttempt_, 9, 3) <<
" s \n";
198 compressorTimer_.clear();
199 componentTimer_.clear();
200 hamiltonianTimer_.clear();
201 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.