# 2 Dimensional Ising Model: include/monte_carlo.hpp Source File

Loading...
Searching...
No Matches
monte_carlo.hpp
Go to the documentation of this file.
/** @file monte_carlo.hpp
*
* @author Cory Alexander Balaton (coryab)
* @author Janita Ovidie Sandtrøen Willumsen (janitaws)
*
* @version 1.0
*
* @brief Functions for Monte Carlo simulations.
*
* @bug No known bugs
* */
#ifndef __MONTE_CARLO__
#define __MONTE_CARLO__
#include "IsingModel.hpp"
#include "data_type.hpp"
#include "utils.hpp"
#include <functional>
#include <omp.h>
#include <string>
// #define BURN_IN_TIME 12500
#define BURN_IN_TIME 5000
namespace montecarlo {
/** @brief Write the expected values for each Monte Carlo cycles to file.
*
* @param T Temperature
* @param L The size of the lattice
* @param cycles The amount of Monte Carlo cycles to do
* @param filename The file to write to
* @param burn_in_time The burn-in time to use
* */
void progression(double T, int L, int cycles, const std::string filename,
int burn_in_time = BURN_IN_TIME);
/** @brief Write the expected values for each Monte Carlo cycles to file.
*
* @param T Temperature
* @param L The size of the lattice
* @param cycles The amount of Monte Carlo cycles to do
* @param value The value to set the elements in the lattice
* @param filename The file to write to
* @param burn_in_time The burn-in time to use
* */
void progression(double T, int L, int cycles, int value,
const std::string filename, int burn_in_time = BURN_IN_TIME);
/** @brief Estimate the probability distribution for the energy.
*
* @param T The temperature of the Ising model
* @param L The size of the lattice
* @param cycles The amount of Monte Carlo cycles to do
* @param filename The file to write to
* @param burn_in_time The burn-in time to use
* */
void pd_estimate(double T, int L, int cycles, const std::string filename,
int burn_in_time = BURN_IN_TIME);
/** @brief Execute the Metropolis algorithm for a certain amount of Monte
* Carlo cycles.
*
* @param L The size of the lattice
* @param T The Temperature for the Ising model
* @param cycles The amount of Monte Carlo cycles to do
* @param burn_in_time The burn-in time to use
*
* @return data_t
* */
data_t mcmc_serial(int L, double T, int cycles,
int burn_in_time = BURN_IN_TIME);
/** @brief Execute the Metropolis algorithm for a certain amount of Monte
* Carlo cycles in parallel.
*
* @param L The size of the lattice
* @param T The Temperature for the Ising model
* @param cycles The amount of Monte Carlo cycles to do
* @param burn_in_time The burn-in time to use
*
* @return data_t
* */
data_t mcmc_parallel(int L, double T, int cycles,
int burn_in_time = BURN_IN_TIME);
/** @brief Perform the MCMC algorithm using a range of temperatures.
*
* @param L The size of the lattice
* @param start_T The start temperature
* @param end_T The end temperature
* @param point_T The amount of point to measure
* @param monte_carlo Which Monte Carlo implementation to use
* @param outfile The file to write the data to
* @param burn_in_time The burn-in time to use
* */
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);
}; // namespace montecarlo
#endif
data_t
Type to use with the IsingModel class and montecarlo module.
Definition: data_type.hpp:19
test_parallel_speedup
void test_parallel_speedup()
Test how much Openmp speeds up.
Definition: main.cpp:60
main
int main(int argc, char **argv)
The main function.
Definition: main.cpp:125
create_pd_estimate_data
void create_pd_estimate_data()
Create the data used to estimate the probability distribution for tempratures 1.0 anbd 2....
Definition: main.cpp:37
create_burn_in_time_data
void create_burn_in_time_data()
Create the data for the burn-in time for temperatures 1.0 and 2.4 for both unordered and ordered init...
Definition: main.cpp:21
test_burn_in_time
void test_burn_in_time()
Create data using the same parameters except one uses burn-in time, while the other doesn't.
Definition: main.cpp:49
create_phase_transition_data
void create_phase_transition_data()
Create data for studying phase transition.
Definition: main.cpp:83
usage
void usage(std::string filename)
A function that displays how to use the program and quits.
Definition: main.cpp:110
montecarlo::progression
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.
Definition: monte_carlo.cpp:53
montecarlo::phase_transition
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.
Definition: monte_carlo.cpp:169
BURN_IN_TIME
#define BURN_IN_TIME
Definition: monte_carlo.hpp:24
montecarlo::progression
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.
Definition: monte_carlo.cpp:15
montecarlo::mcmc_parallel
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.
Definition: monte_carlo.cpp:141
montecarlo::mcmc_serial
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.
Definition: monte_carlo.cpp:122
montecarlo::pd_estimate
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.
Definition: monte_carlo.cpp:91