HILA
Loading...
Searching...
No Matches
multicanonical.h
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////////////
2/// @file multicanonical.h
3/// @author Jaakko Hällfors
4/// @brief Header for model agnostic implementation of
5/// various multicanonical (muca) methods
6////////////////////////////////////////////////////////////////////////////////
7#ifndef MULTICANONICAL_HEADER
8#define MULTICANONICAL_HEADER
9
10// !OBS!
11// Please see the doxygen documentation from github for further details. The
12// corresponding .cpp file contains the actual implementations and also
13// documents the internal functions (not included in doxygen) in relative
14// detail.
15// Furthermore, the repository will contain a short example program that
16// elucidates the use of the various muca methods.
17
18namespace hila
19{
20// Multicanonical methods are separated to their own namespace
21namespace muca
22{
23// Function pointer to the iteration function
24typedef bool (* iteration_pointer)(const double OP);
25extern iteration_pointer iterate_weights;
26
27// Quick helper function for writing values to a file
28template <class K>
29void to_file(std::ofstream &output_file, std::string fmt, K input_value);
30
31// Generates timestamped file names
32std::string generate_outfile_name();
33
34// Reads parameters for muca computations
35void read_weight_parameters(std::string parameter_file_name);
36
37// Reads weight functions from a file
38void read_weight_function(std::string W_function_filename);
39
40// Writes weight functions to a file
41void write_weight_function(std::string filename);
42
43// Gives the weight as a function of the order parameter
44double weight_function(double OP);
45double weight(double OP);
46
47// Accept/reject determination for pairs of order parameter values
48bool accept_reject(const double OP_old, const double OP_new);
49
50// Set the direct iteration finish condition
51void set_direct_iteration_FC(bool (* fc_pointer)(std::vector<int> &n));
52
53// Set to perform the weight iteration at each call to accept_reject
54void set_continuous_iteration(bool YN);
55
56// For the continuous iteration the finish condition is tracked internally
57// and can be checked and set using the two functions below
59void set_weight_iter_flag(bool YN);
60
61// Initialises the muca computations according to the weight parameter file.
62// This function is to always be called before using any of the above functions
63void initialise(const std::string wfile_name);
64
65////////////////////////////////////////////////////////////////////////////////
66// Static functions are internal to above methods. See .cpp file for details
67////////////////////////////////////////////////////////////////////////////////
68
69static void bin_OP_value(double OP);
70
71static int find_OP_bin_index(double OP);
72
73static bool all_visited(std::vector<int> &n);
74static bool first_last_visited(std::vector<int> &n);
75
76static void overcorrect(std::vector<double> &Weight, std::vector<int> &n_sum);
77
78static void recursive_weight_iteration(std::vector<double> &Weight,
79 std::vector<int> &n,
80 std::vector<int> &g_sum,
81 std::vector<double> &g_log_h_sum);
82
83static void print_iteration_histogram();
84
85static std::vector<double> get_equidistant_bin_limits();
86
87static void setup_equidistant_bins();
88
89static void initialise_weight_vectors();
90
91static bool iterate_weight_function_direct(double OP);
92
93static bool iterate_weight_function_direct_single(double OP);
94
95static void setup_iteration();
96
97}
98}
99
100#endif
void set_continuous_iteration(bool YN)
Enable/disable continuous weight iteration.
void write_weight_function(string W_function_filename)
Reads the precomputed weight function from run_parameters struct and saves it into a file.
void initialise(const string wfile_name)
Loads parameters and weights for the multicanonical computation.
bool accept_reject(const double OP_old, const double OP_new)
Accepts/rejects a multicanonical update.
void to_file(std::ofstream &output_file, string fmt, K input_value)
Writes a variable to the file, given the format string.
void read_weight_function(string W_function_filename)
Reads a precomputed weight function from file.
void set_weight_iter_flag(bool YN)
Sets the static g_WeightIterationFlag to given boolean.
double weight_function(double OP)
Returns a weight associated to the used order parameter.
double weight(double OP)
process 0 interface to "weight function" for the user accessing the weights.
void read_weight_parameters(string parameter_file_name)
Parses the weight parameter file and fills the g_WParam struct.
bool check_weight_iter_flag()
Returns the value of the static g_WeightIterationFlag to user.
string generate_outfile_name()
Generates a time stamped and otherwise appropriate file name for the saved weight function files.
void set_direct_iteration_FC(bool(*fc_pointer)(int_vector &n))
Sets a user provided function to the check in the "direct iteration" method.
Implement hila::swap for gauge fields.
Definition array.h:981
std::ofstream output_file
this is just a hook to store output file, if it is in use
Definition initialize.cpp:8