HILA
Loading...
Searching...
No Matches
multicanonical.h File Reference

Header for model agnostic implementation of various multicanonical (muca) methods. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

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.
 
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.
 
bool hila::muca::check_weight_iter_flag ()
 Returns the value of the static g_WeightIterationFlag to user.
 
void hila::muca::set_weight_iter_flag (bool YN)
 Sets the static g_WeightIterationFlag to given boolean.
 
void hila::muca::initialise (const string wfile_name)
 Loads parameters and weights for the multicanonical computation.
 

Detailed Description

Header for model agnostic implementation of various multicanonical (muca) methods.

Author
Jaakko Hällfors

Definition in file multicanonical.h.

Function Documentation

◆ accept_reject()

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))

Parameters
OP_oldcurrent order parameter
OP_neworder parameter of proposed configuration
Returns
Boolean indicating whether the update was accepted (true) or rejected (false).

Definition at line 543 of file multicanonical.cpp.

◆ check_weight_iter_flag()

bool hila::muca::check_weight_iter_flag ( )

Returns the value of the static g_WeightIterationFlag to user.

Returns
State of g_WeighITerationFlag

Definition at line 524 of file multicanonical.cpp.

◆ generate_outfile_name()

std::string hila::muca::generate_outfile_name ( )

Generates a time stamped and otherwise appropriate file name for the saved weight function files.

Returns
generated filename string

Definition at line 209 of file multicanonical.cpp.

◆ initialise()

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.

Parameters
wfile_namepath to the weight parameter file

Definition at line 1188 of file multicanonical.cpp.

◆ read_weight_function()

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:

  1. bin edges, of length n + 1
  2. bin centres, of length n
  3. weight values, of length n

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"

Parameters
W_function_filename

Definition at line 329 of file multicanonical.cpp.

◆ read_weight_parameters()

void hila::muca::read_weight_parameters ( string  parameter_file_name)

Parses the weight parameter file and fills the g_WParam struct.

Parameters
parameter_file_nameparameter file name

Definition at line 230 of file multicanonical.cpp.

◆ set_continuous_iteration()

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.

Parameters
YNenable (true) or disable (false) the iteration

Definition at line 1175 of file multicanonical.cpp.

◆ set_direct_iteration_FC()

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.

Parameters
fc_pointerA function pointer to a suitable condition function

Definition at line 688 of file multicanonical.cpp.

◆ set_weight_iter_flag()

void hila::muca::set_weight_iter_flag ( bool  YN)

Sets the static g_WeightIterationFlag to given boolean.

Parameters
YNboolean indicating whether the iteration is to continue

Definition at line 514 of file multicanonical.cpp.

◆ to_file()

template<class K >
void hila::muca::to_file ( std::ofstream &  output_file,
string  fmt,
input_value 
)

Writes a variable to the file, given the format string.

Parameters
output_file
fmtformat string corresponding to input_value
input_valuenumerical value to write to output_file

Definition at line 196 of file multicanonical.cpp.

◆ weight()

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.

◆ weight_function()

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.

Parameters
OPvalue of the order parameter
Returns
The value of the weight.

Definition at line 455 of file multicanonical.cpp.

◆ write_weight_function()

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.

Parameters
W_function_filename
g_WParamstruct of weight iteration parameters

Definition at line 420 of file multicanonical.cpp.