]> git.treefish.org Git - phys/latlib.git/blob - o815/sim.cpp
Implemented 0-observable-mode.
[phys/latlib.git] / o815 / sim.cpp
1 #include "o815.h"
2
3 #include "latlib/hypercache.h"
4 #include "latlib/progress.h"
5
6 o815::sim::sim(o815 *_O815, const int& _confmemSize) {
7   O815 = _O815;
8   log = O815->out->log;
9   hypercache::initC(O815->programid, O815->comargs.nequi, O815->comargs.nskip, O815->comargs.confcache.first, &confMem, _confmemSize, O815->comargs.confcache.second, log);
10   nequi = O815->comargs.nequi;
11   nskip = O815->comargs.nskip;
12   confmemSize = confmemSize;
13 }
14
15 void o815::sim::nextConfig() {
16   bool readAtLeastOneConfig = hypercache::readC();
17
18   /* equilibrate if necessary */
19   if (hypercache::getNEquiLeft() > 0) {
20     *log << "SIM: Starting equilibration." << endl << flush;
21     if (hypercache::getNEquiLeft() != nequi)
22       *log << "SIM: " << hypercache::getNEquiLeft() << " of " << nequi << " equilibration steps left after virtual equilibration." << endl << flush;
23     progress equiProg(hypercache::getNEquiLeft());
24     for ( int iequi = 0; iequi < hypercache::getNEquiLeft(); iequi++ ) {
25       _makeSweep();
26       while( equiProg.madeStep(iequi) ) *log << "SIM: " << equiProg.done()*100 << "% of equilibration done." << endl << flush;
27     }
28   }
29
30   /* make skip if no config could be read or one skip is left after equilibration */
31   if ( (! readAtLeastOneConfig) || (hypercache::getNEquiLeft() >= 0) ) {
32     for (int iskip=0; iskip<nskip; iskip++) {
33       _makeSweep();
34     }
35     hypercache::writeC();
36   }
37 }