-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
77 lines (55 loc) · 2.22 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <iostream>
#include <cmath>
#include <memory>
#include <random>
#include <bits/unique_ptr.h>
#include <armadillo>
//#include "Model/Heisenberg.hpp"
#include "Algorithm/MonteCarlo.hpp"
#include "Lattice/Square.hpp"
#include "Lattice/Triangular.hpp"
#include "Lattice/Lattice.hpp"
#include "Model/Ising.hpp"
#include "Plot/MagneticStatePlot.cpp"
#include "Plot/AverageEnergyPlot.cpp"
using namespace arma;
int main(int argc, char **argv) {
std::cout << "Phys-sym v. 0.0" << std::endl;
std::cout << "Simulation software" << std::endl << std::endl;
std::cout << "-----------------------------------------------------" << std::endl << std::endl;
int n_x_in = 60;
int n_y_in = 60;
// std::cout << "Enter number of unit cells in the x-direction: " <<std::endl;
// std::cin >> n_x_in;
Triangular a(n_x_in, n_y_in);
std::cout << "Lattice vector component: " << a.get_a1()[0] << std::endl;
std::random_device rd;
std::mt19937 mt(rd());
std::uniform_int_distribution<int> dist(0, 1);
std::unique_ptr<Model> is(new Ising(a, n_x_in * n_y_in));
is -> create_random_initial_spin_configuration(mt, dist);
is -> get_lattice().set_neighbors();
std::cout << "Generating Monte Carlo algorithm..." << std::endl;
std::unique_ptr<Algorithm> alg(new MonteCarlo);
const int n_itr(100000);
std::vector<double> energy_list;
std::vector<double> temperatures_list;
std::vector<double> accepted_list;
std::vector<double> acceptance_list;
double min_simulation_temperature = 0.05;
double max_simulation_temperature = 2.00;
int number_of_temperature_steps = 1;
for(int i = 0; i < number_of_temperature_steps + 1; i++)
{
temperatures_list.emplace_back(max_simulation_temperature - (max_simulation_temperature - min_simulation_temperature) * i / number_of_temperature_steps);
}
for (auto &temperature: temperatures_list) {
alg->simulate(n_itr, is, temperature, energy_list);
}
std::cout << "The average energy list is: " << std::endl;
for(auto m:energy_list)
std::cout << m << std::endl;
plot_average_energy(temperatures_list, energy_list, "average_energy.png", max_simulation_temperature);
demo_basic(is);
return 0;
}