21void create_burn_in_time_data()
25 "output/burn_in_time/unordered_1_0.txt");
27 "output/burn_in_time/ordered_1_0.txt");
29 "output/burn_in_time/unordered_2_4.txt");
31 "output/burn_in_time/ordered_2_4.txt");
34void create_pd_estimate_data()
37 pd_estimate(1.0, 20, 1000000,
"output/pd_estimate/estimate_1_0.txt");
38 pd_estimate(2.4, 20, 1000000,
"output/pd_estimate/estimate_2_4.txt");
41void test_parallel_speedup()
48 for (
size_t i = 0; i < tries; i++)
51 for (
size_t i = 0; i < tries; i++)
55 std::cout <<
"Time serial : " << (t1 - t0) / tries <<
" seconds"
57 std::cout <<
"Time parallel : " << (t2 - t1) / tries <<
" seconds"
59 std::cout <<
"Speedup parallel: " << (t1 - t0) / (t2 - t1) <<
'\n';
62void create_phase_transition_data()
69 "output/phase_transition/size_20.txt");
71 "output/phase_transition/size_40.txt");
73 "output/phase_transition/size_60.txt");
75 "output/phase_transition/size_80.txt");
77 "output/phase_transition/size_100.txt");
80 std::cout <<
"Time: " << t1 - t0 << std::endl;
84int main(
int argc,
char **argv)
87 std::cout <<
"Need at least 1 argument, got " << argc - 1
88 <<
" arguments." << std::endl;
92 int arg = atoi(argv[1]);
96 create_burn_in_time_data();
99 create_pd_estimate_data();
102 test_parallel_speedup();
105 create_phase_transition_data();
108 std::cout <<
"Not a valid option!" << std::endl;
Header for the data_t type.
Functions for monte carlo simulations.
void phase_transition(int L, double start_T, double end_T, int points_T, std::function< data_t(int, double, int)> monte_carlo, std::string outfile)
Perform the MCMC algorithm using a range of temperatures.
data_t monte_carlo_serial(int L, double T, int cycles)
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)
Estimate the probability distribution for the energy.
void monte_carlo_progression(double T, int L, int cycles, const std::string filename)
Write the expected values for each Monte Carlo cycles to file.
data_t monte_carlo_parallel(int L, double T, int cycles)
Execute the Metropolis algorithm for a certain amount of Monte Carlo cycles in parallel.
int main()
The main function.
Function prototypes and macros that are useful.