1void Initialize_WangLandauIteration(
LAMBDA& lambda);
2void Sample_WangLandauIteration(
LAMBDA& lambda);
3void Finalize_WangLandauIteration(
LAMBDA& lambda);
4void Adjust_WangLandauIteration(
LAMBDA& lambda);
6double get_lambda(
LAMBDA& lambda);
7int selectNewBin(
LAMBDA& lambda);
9void Initialize_WangLandauIteration(
LAMBDA& lambda)
11 lambda.WangLandauScalingFactor = 1.0;
12 std::fill(lambda.Histogram.begin(), lambda.Histogram.end(), 0.0);
13 std::fill(lambda.biasFactor.begin(), lambda.biasFactor.end(), 0.0);
14 printf(
"Initialize WL\n");
17void Sample_WangLandauIteration(
LAMBDA& lambda)
20 lambda.biasFactor[lambda.currentBin] -= lambda.WangLandauScalingFactor;
22 lambda.Histogram[lambda.currentBin] += 1.0;
29void Adjust_WangLandauIteration(
LAMBDA& lambda)
32 std::vector<double>::iterator minValueIterator = std::min_element(lambda.Histogram.begin(), lambda.Histogram.end());
33 double minimumValue = *minValueIterator;
35 if(minimumValue>0.01 && lambda.WangLandauScalingFactor > 1e-3)
38 double sumOfHistogram = std::accumulate(lambda.Histogram.begin(), lambda.Histogram.end(), 0.0);
39 if(minimumValue / sumOfHistogram > 0.01)
41 lambda.WangLandauScalingFactor *= 0.5;
44 std::fill(lambda.Histogram.begin(), lambda.Histogram.end(), 0.0);
48void Finalize_WangLandauIteration(
LAMBDA& lambda)
52 double normalize = lambda.biasFactor[0];
53 for(
double &bias : lambda.biasFactor)
57 printf(
"Finalize WL\n");
60inline double get_lambda(
LAMBDA& lambda)
62 return static_cast<double>(lambda.currentBin) * lambda.delta;
65inline int selectNewBin(
LAMBDA& lambda)
67 return lambda.currentBin +
static_cast<int>(
static_cast<double>(lambda.binsize) * (Get_Uniform_Random() - 0.5));
70inline int selectNewBinTMMC(
LAMBDA& lambda)
74 int delta = 1;
if(Get_Uniform_Random() < 0.5) delta = -1;
75 return lambda.currentBin + delta;
Definition data_struct.h:73