mc.h 1.17 KB
Newer Older
1
2
#pragma once

3
#include <memory>
4
5
#include <vector>
#include <string>
Lukas Weber's avatar
Lukas Weber committed
6
#include <functional>
7
8
9
10
#include "measurements.h"
#include "random.h"
#include "parser.h"

Lukas Weber's avatar
Lukas Weber committed
11

12
13
14
class abstract_mc {
private:
        void random_init();
15

16
17
18
19
20
21
22
	int sweep_ = 0;
	int therm_ = 0;
protected:
	parser param;
        std::unique_ptr<randomnumbergenerator> rng;
	
	virtual void init() = 0;
23
24
	virtual void checkpoint_write(const iodump::group& out) = 0;
	virtual void checkpoint_read(const iodump::group& in) = 0;
25
26
27
28
29
	virtual void write_output(const std::string& filename) = 0;
	virtual void do_update() = 0;
public:	
        double random01();
	int sweep() const;
30

31
	virtual void do_measurement() = 0;
32

33
34
35
36
37
	// these functions do a little more, like taking care of the
	// random number generator state, then call the child class versions.
	void _init();
	void _write(const std::string& dir);
	bool _read(const std::string& dir);
38

39
	void _write_output(const std::string& filename);
40

41
42
43
44
45
	void _do_update();
	
	bool is_thermalized();
	measurements measure;	
	
Lukas Weber's avatar
Lukas Weber committed
46
	abstract_mc(const std::string& jobfile, const std::string& taskname);
47
	virtual ~abstract_mc();
48
};
Lukas Weber's avatar
Lukas Weber committed
49
50

typedef std::function<abstract_mc *(const std::string&, const std::string&)> mc_factory;