2
3
4
5
6
7
8
9
10
11
15void progression(
double T,
int L,
int cycles,
const std::string filename,
32 for (size_t i = 0; i < burn_in_time; i++) {
37 for (size_t i = 1; i <= cycles; i++) {
39 tmp = data / (i * n_spins);
40 ofile << i <<
',' << tmp
.E <<
',' << tmp
.E2 <<
',' << tmp
.M <<
','
47 const std::string filename,
int burn_in_time)
59 for (size_t i = 0; i < burn_in_time; i++) {
68 for (size_t i = 1; i <= cycles; i++) {
70 tmp = data / (i * n_spins);
71 ofile << i <<
',' << tmp
.E <<
',' << tmp
.E2 <<
',' << tmp
.M <<
','
77void pd_estimate(
double T,
int L,
int cycles,
const std::string filename,
90 for (size_t i = 0; i < burn_in_time; i++) {
99 for (size_t i = 1; i <= cycles; i++) {
101 ofile << data
.E <<
',' << data
.E2 <<
',' << data
.M <<
',' << data
.M2
102 <<
',' << data
.M_abs <<
'\n';
113 for (size_t i = 0; i < burn_in_time; i++) {
118 for (size_t i = 0; i < (uint)cycles; i++) {
122 double norm = 1. / (
double)cycles;
137 for (size_t i = 0; i < burn_in_time; i++) {
144#pragma omp for schedule(static) reduction(+ : data)
145 for (size_t i = 0; i < (uint)cycles; i++) {
150 double norm = 1. / (
double)cycles;
156 std::function<
data_t(
int,
double,
int,
int)> monte_carlo,
157 std::string outfile,
int burn_in_time)
159 double dt = (end - start) / (
double)points;
168 double temp, CV, X, E_var, M_var;
170 using utils::scientific_format;
171 for (size_t i = 0; i < points; i++) {
172 temp = start + dt * i;
173 data = monte_carlo(L, temp, cycles, burn_in_time);
174 E_var = (data
.E2 - data
.E * data
.E) / (
double)N;
The Ising model in 2 dimensions.
IsingModel(int L, double T, int val)
Constructor for the Ising model.
IsingModel(int L, double T)
Constructor for the Ising model.
data_t Metropolis()
The Metropolis algorithm.
Type to use with the IsingModel class and montecarlo module.
double M_abs
Absolute Magnetization.
data_t & operator+=(const data_t &b)
Overload of the addition equals operator.
double M2
Magnetization squared.
void progression(double T, int L, int cycles, int value, const std::string filename, int burn_in_time=BURN_IN_TIME)
Write the expected values for each Monte Carlo cycles to file.
void phase_transition(int L, double start_T, double end_T, int points_T, int cycles, std::function< data_t(int, double, int, int)> monte_carlo, std::string outfile, int burn_in_time=BURN_IN_TIME)
Perform the MCMC algorithm using a range of temperatures.
void progression(double T, int L, int cycles, const std::string filename, int burn_in_time=BURN_IN_TIME)
Write the expected values for each Monte Carlo cycles to file.
data_t mcmc_parallel(int L, double T, int cycles, int burn_in_time=BURN_IN_TIME)
Execute the Metropolis algorithm for a certain amount of Monte Carlo cycles in parallel.
data_t mcmc_serial(int L, double T, int cycles, int burn_in_time=BURN_IN_TIME)
Execute the Metropolis algorithm for a certain amount of Monte Carlo cycles.
void pd_estimate(double T, int L, int cycles, const std::string filename, int burn_in_time=BURN_IN_TIME)
Estimate the probability distribution for the energy.
bool mkpath(std::string path, int mode=0777)
Make path given.
std::string scientific_format(double d, int width=20, int prec=10)
Turns a double into a string written in scientific format.
std::string dirname(const std::string &path)
Get the directory name of the path.