-
Notifications
You must be signed in to change notification settings - Fork 3
/
detqmcparams.cpp
98 lines (87 loc) · 3.71 KB
/
detqmcparams.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. See the enclosed file LICENSE for a copy or if
* that was not distributed with this file, You can obtain one at
* http://mozilla.org/MPL/2.0/.
*
* Copyright 2017 Max H. Gerlach
*
* */
#include <vector>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#pragma GCC diagnostic ignored "-Wshadow"
#include "boost/assign/std/vector.hpp"
#pragma GCC diagnostic pop
#include "tools.h"
#include "detqmcparams.h"
#include "exceptions.h"
void DetQMCParams::check() {
//check parameters
using namespace boost::assign;
std::vector<std::string> neededMCPars;
neededMCPars += "sweeps", "thermalization", "jkBlocks", "timeseries", "measureInterval";
for (auto p = neededMCPars.cbegin(); p != neededMCPars.cend(); ++p) {
if (specified.count(*p) == 0) {
throw_ParameterMissing(*p);
}
}
if (specified.count("saveInterval") == 0) {
saveInterval = sweeps; //only save at end
}
if (sweeps % 2 != 0) {
throw_ParameterWrong_message("Parameter sweeps must be even [else serialization consistency cannot be guaranteed]");
}
if (thermalization % 2 != 0) {
throw_ParameterWrong_message("Parameter thermalization must be even [else serialization consistency cannot be guaranteed]");
}
if (saveInterval % 2 != 0) {
throw_ParameterWrong_message("Parameter saveInterval must be even [else serialization consistency cannot be guaranteed]");
}
if (greenUpdateType_string == "simple") {
greenUpdateType = GreenUpdateTypeSimple;
} else if (greenUpdateType_string == "stabilized") {
greenUpdateType = GreenUpdateTypeStabilized;
} else {
throw_ParameterWrong("greenUpdateType", greenUpdateType_string);
}
//some parameter consistency checking:
if (sweeps % jkBlocks != 0) {
throw_ParameterWrong_message("Number of jackknife blocks " + numToString(jkBlocks)
+ " does not match number of sweeps " + numToString(sweeps));
}
if ((measureInterval > sweeps) or
(sweeps % measureInterval != 0)) {
throw_ParameterWrong_message("Measurement interval " + numToString(measureInterval)
+ " ill-chosen for number of sweeps " + numToString(sweeps));
}
if (sweeps % saveInterval != 0) {
throw_ParameterWrong_message("saveInterval (" + numToString(saveInterval) +
") needs to be a divisor of sweeps (" + numToString(sweeps) + ")");
}
if (specified.count("saveConfigurationStreamInterval") and
(saveConfigurationStreamInterval % measureInterval != 0)) {
throw_ParameterWrong_message("saveConfigurationStreamInterval must be an integer multiple of measureInterval");
}
if (not specified.count("saveConfigurationStreamInterval")) {
saveConfigurationStreamInterval = measureInterval;
}
}
MetadataMap DetQMCParams::prepareMetadataMap() const {
MetadataMap meta;
#define META_INSERT(VAR) meta[#VAR] = numToString(VAR)
META_INSERT(greenUpdateType_string);
META_INSERT(simindex);
META_INSERT(sweeps);
META_INSERT(thermalization);
META_INSERT(jkBlocks);
META_INSERT(measureInterval);
META_INSERT(saveInterval);
META_INSERT(saveConfigurationStreamInterval);
META_INSERT(rngSeed);
#undef META_INSERT
meta["timeseries"] = (timeseries ? "true" : "false");
meta["saveConfigurationStreamText"] = (saveConfigurationStreamText ? "true" : "false");
meta["saveConfigurationStreamBinary"] = (saveConfigurationStreamBinary ? "true" : "false");
meta["stateFileName"] = stateFileName;
return meta;
}