3 #include "latlib/hypercache.h"
 
   4 #include "latlib/progress.h"
 
   6 #include "latlib/datread.h"
 
   8 o815::sim::sim(o815 *_O815, const int& _confmemSize) {
 
  11   hypercache::initC(O815->programid, O815->comargs.nequi, O815->comargs.nskip, O815->comargs.confcache.first, &confMem, _confmemSize, O815->comargs.confcache.second, log);
 
  12   nequi = O815->comargs.nequi;
 
  13   nskip = O815->comargs.nskip;
 
  14   confmemSize = confmemSize;
 
  16   startConfiguration = NULL;
 
  18   if ( O815->comargs.startconfig != "" ) {
 
  19     *log << "SIM: Fetching startconfig from " << O815->comargs.startconfig << endl;
 
  21     datread dataReader(confmemSize);
 
  22     dataReader.openFile(O815->comargs.startconfig);
 
  24     if ( dataReader.fisopen() ) {
 
  25       startConfiguration = new char[confmemSize];
 
  27       if ( dataReader.readFullBlock(startConfiguration) < 0 ) {
 
  28         *log << "SIM: Error while reading config from " << O815->comargs.startconfig << endl;
 
  29         delete[] startConfiguration;
 
  30         startConfiguration = NULL;
 
  34       *log << "SIM: Could not open startconfigfile " << O815->comargs.startconfig << endl;
 
  42   if (startConfiguration != NULL)
 
  43     delete[] startConfiguration;
 
  46 void o815::sim::nextConfig() {
 
  47   bool readAtLeastOneConfig = hypercache::readC();
 
  49   /* equilibrate if necessary */
 
  50   if (hypercache::getNEquiLeft() > 0) {
 
  51     *log << "SIM: Starting equilibration." << endl << flush;
 
  52     if (hypercache::getNEquiLeft() != nequi)
 
  53       *log << "SIM: " << hypercache::getNEquiLeft() << " of " << nequi << " equilibration steps left after virtual equilibration." << endl << flush;
 
  54     progress equiProg(hypercache::getNEquiLeft());
 
  55     for ( int iequi = 0; iequi < hypercache::getNEquiLeft(); iequi++ ) {
 
  57       while( equiProg.madeStep(iequi) ) *log << "SIM: " << equiProg.done()*100 << "% of equilibration done." << endl << flush;
 
  61   /* make skip if no config could be read or one skip is left after equilibration */
 
  62   if ( (! readAtLeastOneConfig) || (hypercache::getNEquiLeft() >= 0) ) {
 
  63     for (int iskip=0; iskip<nskip; iskip++) {
 
  70 void o815::sim::resetConfig() {
 
  71   if ( startConfiguration != NULL )
 
  72     memcpy(confMem, startConfiguration, confmemSize);