]> git.treefish.org Git - phys/latlib.git/blobdiff - o815/sim.cpp
...
[phys/latlib.git] / o815 / sim.cpp
diff --git a/o815/sim.cpp b/o815/sim.cpp
new file mode 100644 (file)
index 0000000..2e68ae2
--- /dev/null
@@ -0,0 +1,35 @@
+#include "o815.h"
+
+#include "latlib/hypercache.h"
+#include "latlib/progress.h"
+
+o815::sim::sim(o815 *_O815, const int& confmemSize) {
+  O815 = _O815;
+  log = O815->out->log;
+  hypercache::initC(O815->programid, O815->comargs.nequi, O815->comargs.nskip, O815->comargs.confcache.first, &confMem, confmemSize, O815->comargs.confcache.second, log);
+  toEquilibrate = true;
+  nequi = O815->comargs.nequi;
+  nskip = O815->comargs.nskip;
+}
+
+void o815::sim::nextConfig() {
+  int nequileft = hypercache::readC();
+
+  if ( nequileft != -1 ) {
+    if(toEquilibrate) {
+      _reset();
+      *log << "SIM: Starting equilibration." << endl << flush;
+      if (nequileft != nequi)
+       *log << "SIM: " << nequileft << " of " << nequi << " equilibration steps left after virtual equilibration." << endl << flush;
+      progress equiProg(nequileft);
+      for( int iequi=0; iequi<nequileft; iequi++ ) {
+       _makeSweep(1);
+       while( equiProg.madeStep(iequi) ) *log << "SIM: " << equiProg.done()*100 << "% of equilibration done." << endl << flush;
+      }
+    }  
+    _makeSweep(nskip);
+    hypercache::writeC();
+  }
+  
+  toEquilibrate = false;
+}