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

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

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

15
16
	int sweep_ = 0;
	int therm_ = 0;
17

18
19
protected:
	parser param;
20
21
	std::unique_ptr<randomnumbergenerator> rng;

22
	virtual void init() = 0;
23
24
25
	virtual void checkpoint_write(const iodump::group &out) = 0;
	virtual void checkpoint_read(const iodump::group &in) = 0;
	virtual void write_output(const std::string &filename){};
26
	virtual void do_update() = 0;
27
	virtual void do_measurement() = 0;
28
29
30

public:
	double random01();
31
	int sweep() const;
32

33
	virtual void register_evalables(std::vector<evalable> &evalables) = 0;
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();
38
39
	void _write(const std::string &dir);
	bool _read(const std::string &dir);
40

41
	void _write_output(const std::string &filename);
42

43
	void _do_update();
44
	void _do_measurement();
45

46
	bool is_thermalized();
47
48
49
	measurements measure;

	abstract_mc(const std::string &jobfile, const std::string &taskname);
50
	virtual ~abstract_mc() = default;
51
};
Lukas Weber's avatar
Lukas Weber committed
52

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