Commit 8e58d325 authored by Lukas Weber's avatar Lukas Weber
Browse files

make sweeps accessible by mc

parent 989ac7b1
...@@ -43,6 +43,10 @@ void abstract_mc::random_clear() { ...@@ -43,6 +43,10 @@ void abstract_mc::random_clear() {
double abstract_mc::random01() { double abstract_mc::random01() {
return rng->d(); return rng->d();
} }
int abstract_mc::sweep() const {
return _sweep;
}
void abstract_mc::_init() { void abstract_mc::_init() {
random_init(); random_init();
...@@ -50,20 +54,20 @@ void abstract_mc::_init() { ...@@ -50,20 +54,20 @@ void abstract_mc::_init() {
} }
void abstract_mc::_do_update() { void abstract_mc::_do_update() {
sweep++; _sweep++;
do_update(); do_update();
} }
void abstract_mc::_write(std::string dir) { void abstract_mc::_write(std::string dir) {
odump d(dir+"dump"); odump d(dir+"dump");
random_write(d); random_write(d);
d.write(sweep); d.write(_sweep);
write(d); write(d);
d.close(); d.close();
seed_write(dir+"seed"); seed_write(dir+"seed");
dir+="sweeps"; dir+="sweeps";
ofstream f; f.open(dir.c_str()); ofstream f; f.open(dir.c_str());
f << ( (is_thermalized()) ? sweep-therm : 0 ) << " " << sweep <<endl; f << ( (is_thermalized()) ? _sweep-therm : 0 ) << " " << _sweep <<endl;
f.close(); f.close();
} }
...@@ -72,7 +76,7 @@ bool abstract_mc::_read(std::string dir) { ...@@ -72,7 +76,7 @@ bool abstract_mc::_read(std::string dir) {
if (!d) if (!d)
return false; return false;
random_read(d); random_read(d);
d.read(sweep); d.read(_sweep);
if(!read(d)) if(!read(d))
return false; return false;
...@@ -90,6 +94,6 @@ void abstract_mc::_write_output(std::string filename) { ...@@ -90,6 +94,6 @@ void abstract_mc::_write_output(std::string filename) {
} }
bool abstract_mc::is_thermalized() { bool abstract_mc::is_thermalized() {
return sweep>therm; return _sweep>therm;
} }
...@@ -22,7 +22,7 @@ class abstract_mc ...@@ -22,7 +22,7 @@ class abstract_mc
void random_read(idump& d); void random_read(idump& d);
void random_init(); void random_init();
int sweep = 0; int _sweep = 0;
int therm = 0; int therm = 0;
protected: protected:
parser param; parser param;
...@@ -34,6 +34,7 @@ class abstract_mc ...@@ -34,6 +34,7 @@ class abstract_mc
virtual void do_update() = 0; virtual void do_update() = 0;
public: public:
double random01(); double random01();
int sweep() const;
virtual void do_measurement() = 0; virtual void do_measurement() = 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment