HILA
|
Model agnostic implementation of various multicanonical methods. More...
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <regex>
#include <cmath>
#include "hila.h"
#include "tools/multicanonical.h"
Go to the source code of this file.
Classes | |
struct | canonical_iteration |
An internal struct parametrising the canonical weight iteration method. More... | |
struct | direct_iteration |
An internal struct parametrising the direct weight iteration method. More... | |
struct | weight_iteration_parameters |
An internal struct parametrising multicanonical methods. More... | |
Namespaces | |
namespace | hila |
Implement hila::swap for gauge fields. | |
Functions | |
template<class K > | |
void | hila::muca::to_file (std::ofstream &output_file, string fmt, K input_value) |
Writes a variable to the file, given the format string. | |
string | hila::muca::generate_outfile_name () |
Generates a time stamped and otherwise appropriate file name for the saved weight function files. | |
void | hila::muca::read_weight_parameters (string parameter_file_name) |
Parses the weight parameter file and fills the g_WParam struct. | |
void | hila::muca::read_weight_function (string W_function_filename) |
Reads a precomputed weight function from file. | |
void | hila::muca::write_weight_function (string W_function_filename) |
Reads the precomputed weight function from run_parameters struct and saves it into a file. | |
double | hila::muca::weight_function (double OP) |
Returns a weight associated to the used order parameter. | |
double | hila::muca::weight (double OP) |
process 0 interface to "weight function" for the user accessing the weights. | |
void | hila::muca::set_weight_iter_flag (bool YN) |
Sets the static g_WeightIterationFlag to given boolean. | |
bool | hila::muca::check_weight_iter_flag () |
Returns the value of the static g_WeightIterationFlag to user. | |
bool | hila::muca::accept_reject (const double OP_old, const double OP_new) |
Accepts/rejects a multicanonical update. | |
void | hila::muca::set_direct_iteration_FC (bool(*fc_pointer)(int_vector &n)) |
Sets a user provided function to the check in the "direct iteration" method. | |
void | hila::muca::set_continuous_iteration (bool YN) |
Enable/disable continuous weight iteration. | |
void | hila::muca::initialise (const string wfile_name) |
Loads parameters and weights for the multicanonical computation. | |
Model agnostic implementation of various multicanonical methods.
TBA
Definition in file multicanonical.cpp.
bool hila::muca::accept_reject | ( | const double | OP_old, |
const double | OP_new | ||
) |
Accepts/rejects a multicanonical update.
Using the values of the old and new order parameters the muca update is accepted with the logarithmic probability log(P) = - (W(OP_new) - W(OP_old))
OP_old | current order parameter |
OP_new | order parameter of proposed configuration |
Definition at line 543 of file multicanonical.cpp.
bool hila::muca::check_weight_iter_flag | ( | ) |
Returns the value of the static g_WeightIterationFlag to user.
Definition at line 524 of file multicanonical.cpp.
std::string hila::muca::generate_outfile_name | ( | ) |
Generates a time stamped and otherwise appropriate file name for the saved weight function files.
Definition at line 209 of file multicanonical.cpp.
void hila::muca::initialise | ( | const string | wfile_name | ) |
Loads parameters and weights for the multicanonical computation.
Sets up iteration variables. Can be called multiple times and must be called at least once before attempting to use any of the muca methods.
wfile_name | path to the weight parameter file |
Definition at line 1188 of file multicanonical.cpp.
void hila::muca::read_weight_function | ( | string | W_function_filename | ) |
Reads a precomputed weight function from file.
The input file is to have three tab-separated columns:
Naturally, column 2 can be determined from the first one but they are considered a separated input anyways.
The header can be whatever* and is always skipped. Regex finds the data by finding first row with the substring "OP_value" and assumes that the following contains the data as specified above.
*Avoid substring "OP_value"
W_function_filename |
Definition at line 329 of file multicanonical.cpp.
void hila::muca::read_weight_parameters | ( | string | parameter_file_name | ) |
Parses the weight parameter file and fills the g_WParam struct.
parameter_file_name | parameter file name |
Definition at line 230 of file multicanonical.cpp.
void hila::muca::set_continuous_iteration | ( | bool | YN | ) |
Enable/disable continuous weight iteration.
Premits the user to enable/disable continuous weight iteration at each call to accept_reject. Simply modifies a flag parameter that is checked in accept_reject.
YN | enable (true) or disable (false) the iteration |
Definition at line 1175 of file multicanonical.cpp.
void hila::muca::set_direct_iteration_FC | ( | bool(*)(int_vector &n) | fc_pointer | ) |
Sets a user provided function to the check in the "direct iteration" method.
The for a given magnitude of update the "direct iteration" method periodically checks whether the MCMC chain has covered enough of the desired order parameter range, before reducing the update magnitude. Some preset methods exist (and should suffice) but when needed, a new condition can be set through this function. The input is a vector of integers indicating the number of visits to each bin, and the output is a boolean telling whether the desired condition has been achieved.
fc_pointer | A function pointer to a suitable condition function |
Definition at line 688 of file multicanonical.cpp.
void hila::muca::set_weight_iter_flag | ( | bool | YN | ) |
Sets the static g_WeightIterationFlag to given boolean.
YN | boolean indicating whether the iteration is to continue |
Definition at line 514 of file multicanonical.cpp.
void hila::muca::to_file | ( | std::ofstream & | output_file, |
string | fmt, | ||
K | input_value | ||
) |
Writes a variable to the file, given the format string.
output_file | |
fmt | format string corresponding to input_value |
input_value | numerical value to write to output_file |
Definition at line 196 of file multicanonical.cpp.
double hila::muca::weight | ( | double | OP | ) |
process 0 interface to "weight function" for the user accessing the weights.
Definition at line 498 of file multicanonical.cpp.
double hila::muca::weight_function | ( | double | OP | ) |
Returns a weight associated to the used order parameter.
The function uses supplied pairs of points to linearly interpolate the function on the interval. This interpolant provides the requested weights to be used as the multicanonical weight.
OP | value of the order parameter |
Definition at line 455 of file multicanonical.cpp.
void hila::muca::write_weight_function | ( | string | W_function_filename | ) |
Reads the precomputed weight function from run_parameters struct and saves it into a file.
The printing happens in an format identical to what is expected by the funciton read_weight_function. See its documentation for details. TBA: Add string input that can contain user specified header data.
W_function_filename | |
g_WParam | struct of weight iteration parameters |
Definition at line 420 of file multicanonical.cpp.