diff --git a/docs/IsingModel_8cpp.html b/docs/IsingModel_8cpp.html index 45e898a..3b1eba4 100644 --- a/docs/IsingModel_8cpp.html +++ b/docs/IsingModel_8cpp.html @@ -105,8 +105,6 @@ $(document).ready(function(){initNavTree('IsingModel_8cpp.html',''); initResizab

The implementation of the Ising model. More...

#include "IsingModel.hpp"
-#include <cmath>
-#include <random>

Go to the source code of this file.

Detailed Description

@@ -115,7 +113,7 @@ $(document).ready(function(){initNavTree('IsingModel_8cpp.html',''); initResizab
Janita Ovidie Sandtrøen Willumsen (janitaws)
Version
0.1
-
Bug:
No known bugs
+
Bug:
No known bugs

Definition in file IsingModel.cpp.

diff --git a/docs/IsingModel_8cpp_source.html b/docs/IsingModel_8cpp_source.html index 84b95ce..786afe0 100644 --- a/docs/IsingModel_8cpp_source.html +++ b/docs/IsingModel_8cpp_source.html @@ -101,157 +101,175 @@ $(document).ready(function(){initNavTree('IsingModel_8cpp_source.html',''); init
IsingModel.cpp
-Go to the documentation of this file.
1
-
12#include "IsingModel.hpp"
+Go to the documentation of this file.
1/** @file IsingModel.cpp
+
2 *
+
3 * @author Cory Alexander Balaton (coryab)
+
4 * @author Janita Ovidie Sandtrøen Willumsen (janitaws)
+
5 *
+
6 * @version 0.1
+
7 *
+
8 * @brief The implementation of the Ising model
+
9 *
+
10 * @bug No known bugs
+
11 * */
+
12#include "IsingModel.hpp"
13
-
14#include <cmath>
-
15#include <random>
-
16
- -
18{
-
19}
-
20
-
21IsingModel::IsingModel(int L, double T)
-
22{
-
23 this->L = L;
-
24 this->T = T;
-
25 this->initialize_lattice();
- - - -
29 this->initialize_energy();
-
30}
-
31
-
32IsingModel::IsingModel(int L, double T, int val)
-
33{
-
34 this->L = L;
-
35 this->T = T;
-
36 this->lattice.set_size(this->L, this->L);
-
37 this->lattice.fill(val);
- - - -
41 this->initialize_energy();
-
42}
-
43
- -
45{
-
46 this->lattice.set_size(this->L, this->L);
-
47 std::random_device rd{};
-
48 std::mt19937 engine{rd()};
-
49
-
50 std::uniform_int_distribution<> coin_flip(0, 1);
-
51
-
52 for (size_t i = 0; i < this->lattice.n_elem; i++)
-
53 this->lattice(i) = 2 * coin_flip(engine) - 1;
-
54}
-
55
- -
57{
-
58 this->neighbors.set_size(this->L, 2);
-
59
-
60 // Having i as a signed integer is necessary in this case.
-
61 for (int i = 0; i < (int)this->L; i++) {
-
62 this->neighbors(i, UP) = INDEX(i - 1, this->L);
-
63 this->neighbors(i, DOWN) = INDEX(i + 1, this->L);
-
64 }
-
65}
-
66
- -
68{
-
69 for (int i = -8; i <= 8; i += 4) {
-
70 this->energy_diff.insert({i, std::exp(-(double)i / this->T)});
-
71 }
-
72}
+ +
15{
+ +
17}
+
18
+
19IsingModel::IsingModel(int L, double T)
+
20{
+
21 this->L = L;
+
22 this->T = T;
+ + + + + + +
29}
+
30
+
31IsingModel::IsingModel(int L, double T, int val)
+
32{
+
33 this->L = L;
+
34 this->T = T;
+ + + + + + +
41}
+
42
+ +
44{
+
45 std::random_device rd{};
+
46 this->engine = std::mt19937{rd()};
+
47}
+
48
+ +
50{
+
51 this->lattice.set_size(this->L, this->L);
+
52
+
53 std::uniform_int_distribution<> coin_flip(0, 1);
+
54
+
55 for (size_t i = 0; i < this->lattice.n_elem; i++)
+
56 this->lattice(i) = 2 * coin_flip(this->engine) - 1;
+
57}
+
58
+ +
60{
+
61 // If val is neither 1 or -1, then initialize random values.
+
62 if (val != 1 && val != -1) {
+ +
64 return;
+
65 }
+
66 this->lattice.set_size(this->L, this->L);
+
67 this->lattice.fill(val);
+
68}
+
69
+ +
71{
+
72 this->neighbors.set_size(this->L, 2);
73
- -
75{
-
76 this->M = 0.;
-
77 for (size_t i = 0; i < this->lattice.n_elem; i++) {
-
78 this->M += this->lattice(i);
-
79 }
-
80}
-
81
- -
83{
-
84 this->E = 0.;
-
85
-
86 // Loop through the matrix
-
87 for (size_t j = 0; j < this->L; j++) {
-
88 for (size_t i = 0; i < this->L; i++) {
-
89 this->E -= this->lattice(i, j)
-
90 * (this->lattice(i, this->neighbors(j, RIGHT))
-
91 + this->lattice(this->neighbors(i, DOWN), j));
-
92 }
+
74 // Having i as a signed integer is necessary in this case.
+
75 for (int i = 0; i < (int)this->L; i++) {
+
76 this->neighbors(i, UP) = INDEX(i - 1, this->L);
+
77 this->neighbors(i, DOWN) = INDEX(i + 1, this->L);
+
78 }
+
79}
+
80
+ +
82{
+
83 for (int i = -8; i <= 8; i += 4) {
+
84 this->energy_diff[i+8] = std::exp(-(double)i / this->T);
+
85 }
+
86}
+
87
+ +
89{
+
90 this->M = 0.;
+
91 for (size_t i = 0; i < this->lattice.n_elem; i++) {
+
92 this->M += this->lattice(i);
93 }
94}
95
- +
97{
-
98 std::random_device rd{};
-
99 std::mt19937_64 engine{rd()};
-
100
-
101 int ri, rj;
-
102 int dE;
-
103
-
104 // Create random distribution for indeces
-
105 std::uniform_int_distribution<> random_index(0, this->L - 1);
-
106 // Create random distribution for acceptance
-
107 std::uniform_real_distribution<> random_number(0., 1.);
-
108
-
109 // Loop over the number of spins
-
110 for (size_t i = 0; i < this->lattice.n_elem; i++) {
-
111 // Get random indeces
-
112 ri = random_index(engine);
-
113 rj = random_index(engine);
+
98 this->E = 0.;
+
99
+
100 // Loop through the matrix
+
101 for (size_t j = 0; j < this->L; j++) {
+
102 for (size_t i = 0; i < this->L; i++) {
+
103 this->E -= this->lattice(i, j)
+
104 * (this->lattice(i, this->neighbors(j, RIGHT))
+
105 + this->lattice(this->neighbors(i, DOWN), j));
+
106 }
+
107 }
+
108}
+
109
+ +
111{
+
112 int ri, rj;
+
113 int dE;
114
-
115 // Calculate the difference in energy
-
116 dE = 2 * this->lattice(ri, rj)
-
117 * (this->lattice(ri, this->neighbors(rj, LEFT))
-
118 + this->lattice(ri, this->neighbors(rj, RIGHT))
-
119 + this->lattice(this->neighbors(ri, UP), rj)
-
120 + this->lattice(this->neighbors(ri, DOWN), rj));
-
121
-
122 // Choose whether or not to accept the new configuration
-
123 if (random_number(engine) <= this->energy_diff[dE]) {
-
124 // Update if the configuration is accepted
-
125 this->lattice(ri, rj) *= -1;
-
126 this->M += 2 * this->lattice(ri, rj);
-
127 this->E += dE;
-
128 }
-
129 }
-
130
-
131 return data_t((double)this->E, (double)(this->E * this->E), (double)this->M,
-
132 (double)(this->M * this->M), std::fabs((double)this->M));
-
133}
-
134
- -
136{
-
137 return this->E;
-
138}
-
139
- -
141{
-
142 return this->M;
-
143}
-
The definition of the Ising model.
-
int M
The current magnetic strength. unit: Unitless.
Definition: IsingModel.hpp:72
-
std::unordered_map< int, double > energy_diff
A hash map containing all possible energy changes.
Definition: IsingModel.hpp:56
-
double T
The temperature of the model.
Definition: IsingModel.hpp:60
-
int L
Size of the lattice.
Definition: IsingModel.hpp:64
-
arma::Mat< int > lattice
matrix where element .
Definition: IsingModel.hpp:42
-
void initialize_lattice()
Initialize the lattice with a random distribution of 1s and -1s.
Definition: IsingModel.cpp:44
-
data_t Metropolis()
The Metropolis algorithm.
Definition: IsingModel.cpp:96
-
void initialize_energy()
Initialize the energy.
Definition: IsingModel.cpp:82
-
void initialize_neighbors()
initialize the neighbors matrix.
Definition: IsingModel.cpp:56
-
void initialize_magnetization()
Initialize the magnetization.
Definition: IsingModel.cpp:74
-
arma::Mat< int > neighbors
matrix with the neighbors of each element .
Definition: IsingModel.hpp:52
-
int get_M()
Get the current magnetization.
Definition: IsingModel.cpp:140
-
int get_E()
Get the current energy.
Definition: IsingModel.cpp:135
-
IsingModel()
Constructor used for testing.
Definition: IsingModel.cpp:17
-
int E
The current energy state. unit: .
Definition: IsingModel.hpp:68
-
void initialize_energy_diff()
Initialize the hashmap with the correct values.
Definition: IsingModel.cpp:67
- +
115 // Create random distribution for indeces
+
116 std::uniform_int_distribution<> random_index(0, this->L - 1);
+
117 // Create random distribution for acceptance
+
118 std::uniform_real_distribution<> random_number(0., 1.);
+
119
+
120 // Loop over the number of spins
+
121 for (size_t i = 0; i < this->lattice.n_elem; i++) {
+
122 // Get random indeces
+
123 ri = random_index(engine);
+
124 rj = random_index(engine);
+
125
+
126 // Calculate the difference in energy
+
127 dE = 2 * this->lattice(ri, rj)
+
128 * (this->lattice(ri, this->neighbors(rj, LEFT))
+
129 + this->lattice(ri, this->neighbors(rj, RIGHT))
+
130 + this->lattice(this->neighbors(ri, UP), rj)
+
131 + this->lattice(this->neighbors(ri, DOWN), rj));
+
132
+
133 // Choose whether or not to accept the new configuration
+
134 if (random_number(engine) <= this->energy_diff[dE+8]) {
+
135 // Update if the configuration is accepted
+
136 this->lattice(ri, rj) *= -1;
+
137 this->M += 2 * this->lattice(ri, rj);
+
138 this->E += dE;
+
139 }
+
140 }
+
141
+
142 return data_t((double)this->E, (double)(this->E * this->E), (double)this->M,
+
143 (double)(this->M * this->M), std::fabs((double)this->M));
+
144}
+
#define UP
Used for the neighbor matrix in the class.
Definition: IsingModel.hpp:26
+
#define INDEX(I, N)
I modulo N.
Definition: IsingModel.hpp:23
+
#define DOWN
Used for the neighbor matrix in the class.
Definition: IsingModel.hpp:28
+
#define LEFT
Used for the neighbor matrix in the class.
Definition: IsingModel.hpp:27
+
#define RIGHT
Used for the neighbor matrix in the class.
Definition: IsingModel.hpp:29
+
The Ising model in 2 dimensions.
Definition: IsingModel.hpp:36
+
std::mt19937 engine
The RNG that is used for the Metropolis algorithm.
Definition: IsingModel.hpp:78
+
int64_t E
The current energy state. unit: .
Definition: IsingModel.hpp:70
+
double T
The temperature of the model.
Definition: IsingModel.hpp:62
+
int L
Size of the lattice.
Definition: IsingModel.hpp:66
+
void initialize_lattice()
Initialize the lattice with a random distribution of 1s and -1s.
Definition: IsingModel.cpp:49
+
IsingModel(int L, double T, int val)
Constructor for the Ising model.
Definition: IsingModel.cpp:31
+
IsingModel(int L, double T)
Constructor for the Ising model.
Definition: IsingModel.cpp:19
+
data_t Metropolis()
The Metropolis algorithm.
Definition: IsingModel.cpp:110
+
void initialize_energy()
Initialize the energy of the system.
Definition: IsingModel.cpp:96
+
void initialize_neighbors()
initialize the neighbors matrix.
Definition: IsingModel.cpp:70
+
double energy_diff[17]
An array containing all possible energy differences.
Definition: IsingModel.hpp:58
+
void initialize_magnetization()
Initialize the magnetization of the system.
Definition: IsingModel.cpp:88
+
void initialize_engine()
Initialize the RNG.
Definition: IsingModel.cpp:43
+
void initialize_lattice(int val)
Initialize the lattice with a specific value.
Definition: IsingModel.cpp:59
+
IsingModel()
Constructor used for testing.
Definition: IsingModel.cpp:14
+
int64_t M
The current magnetic strength. unit: Unitless.
Definition: IsingModel.hpp:74
+
void initialize_energy_diff()
Initialize the energy_diff array with the correct values.
Definition: IsingModel.cpp:81
+
Type to use with the IsingModel class and montecarlo module.
Definition: data_type.hpp:19
+
data_t(double E, double E2, double M, double M2, double M_abs)
Constructor with parameters.
Definition: data_type.hpp:45
diff --git a/docs/IsingModel_8hpp.html b/docs/IsingModel_8hpp.html index 06ffc00..fb00296 100644 --- a/docs/IsingModel_8hpp.html +++ b/docs/IsingModel_8hpp.html @@ -107,11 +107,10 @@ $(document).ready(function(){initNavTree('IsingModel_8hpp.html',''); initResizab

The definition of the Ising model. More...

-
#include "constants.hpp"
-#include "data_type.hpp"
-#include "typedefs.hpp"
+
#include "data_type.hpp"
#include "utils.hpp"
#include <armadillo>
+#include <cstdint>
#include <random>
#include <unordered_map>
@@ -126,14 +125,19 @@ Classes

Macros

#define INDEX(I, N)   (I + N) % N + I modulo N.
  #define UP   0 + Used for the neighbor matrix in the class.
  #define LEFT   0 + Used for the neighbor matrix in the class.
  #define DOWN   1 + Used for the neighbor matrix in the class.
  #define RIGHT   1 + Used for the neighbor matrix in the class.
 

Detailed Description

@@ -142,7 +146,7 @@ Macros
Janita Ovidie Sandtrøen Willumsen (janitaws)
Version
0.1
-
Bug:
No known bugs
+
Bug:
No known bugs

Definition in file IsingModel.hpp.

Macro Definition Documentation

@@ -158,7 +162,9 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
-

Definition at line 29 of file IsingModel.hpp.

+

Used for the neighbor matrix in the class.

+ +

Definition at line 28 of file IsingModel.hpp.

@@ -188,7 +194,9 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
-

Definition at line 24 of file IsingModel.hpp.

+

I modulo N.

+ +

Definition at line 23 of file IsingModel.hpp.

@@ -204,7 +212,9 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
-

Definition at line 28 of file IsingModel.hpp.

+

Used for the neighbor matrix in the class.

+ +

Definition at line 27 of file IsingModel.hpp.

@@ -220,7 +230,9 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
-

Definition at line 30 of file IsingModel.hpp.

+

Used for the neighbor matrix in the class.

+ +

Definition at line 29 of file IsingModel.hpp.

@@ -236,7 +248,9 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
-

Definition at line 27 of file IsingModel.hpp.

+

Used for the neighbor matrix in the class.

+ +

Definition at line 26 of file IsingModel.hpp.

diff --git a/docs/IsingModel_8hpp.js b/docs/IsingModel_8hpp.js index 616fe52..d0a391a 100644 --- a/docs/IsingModel_8hpp.js +++ b/docs/IsingModel_8hpp.js @@ -1,4 +1,9 @@ var IsingModel_8hpp = [ - [ "IsingModel", "classIsingModel.html", "classIsingModel" ] + [ "IsingModel", "classIsingModel.html", "classIsingModel" ], + [ "DOWN", "IsingModel_8hpp.html#a4193cd1c8c2e6ebd0e056fa2364a663f", null ], + [ "INDEX", "IsingModel_8hpp.html#a3039ac753f46401767c38f867787fae6", null ], + [ "LEFT", "IsingModel_8hpp.html#a437ef08681e7210d6678427030446a54", null ], + [ "RIGHT", "IsingModel_8hpp.html#a80fb826a684cf3f0d306b22aa100ddac", null ], + [ "UP", "IsingModel_8hpp.html#a1965eaca47dbf3f87acdafc2208f04eb", null ] ]; \ No newline at end of file diff --git a/docs/IsingModel_8hpp_source.html b/docs/IsingModel_8hpp_source.html index 6282c69..b3123e4 100644 --- a/docs/IsingModel_8hpp_source.html +++ b/docs/IsingModel_8hpp_source.html @@ -101,92 +101,168 @@ $(document).ready(function(){initNavTree('IsingModel_8hpp_source.html',''); init
IsingModel.hpp
-Go to the documentation of this file.
1
-
12#ifndef __ISING_MODEL__
-
13#define __ISING_MODEL__
+Go to the documentation of this file.
1/** @file IsingModel.hpp
+
2 *
+
3 * @author Cory Alexander Balaton (coryab)
+
4 * @author Janita Ovidie Sandtrøen Willumsen (janitaws)
+
5 *
+
6 * @version 0.1
+
7 *
+
8 * @brief The definition of the Ising model.
+
9 *
+
10 * @bug No known bugs
+
11 * */
+
12#ifndef __ISING_MODEL__
+
13#define __ISING_MODEL__
14
-
15#include "constants.hpp"
-
16#include "data_type.hpp"
-
17#include "typedefs.hpp"
-
18#include "utils.hpp"
-
19
-
20#include <armadillo>
-
21#include <random>
-
22#include <unordered_map>
-
23
-
24#define INDEX(I, N) (I + N) % N
-
25
-
26// Indeces for the neighbor matrix.
-
27#define UP 0
-
28#define LEFT 0
-
29#define DOWN 1
-
30#define RIGHT 1
-
31
- -
38private:
-
39 friend class IsingModelTest;
-
42 arma::Mat<int> lattice;
-
43
-
52 arma::Mat<int> neighbors;
-
53
-
56 std::unordered_map<int, double> energy_diff;
-
57
-
60 double T;
-
61
-
64 int L;
-
65
-
68 int E;
-
69
-
72 int M;
-
73
-
77 void initialize_lattice();
-
78
- -
82
- -
86
- -
90
-
93 void initialize_energy();
-
94
-
97 IsingModel();
-
98
-
99public:
-
105 IsingModel(int L, double T);
-
106
-
113 IsingModel(int L, double T, int val);
-
114
- -
118
-
123 int get_E();
-
124
-
129 int get_M();
-
130};
-
131
-
132#endif
-
Test class for the Ising model.
Definition: test_suite.cpp:30
-
The Ising model in 2 dimensions.
Definition: IsingModel.hpp:37
-
int M
The current magnetic strength. unit: Unitless.
Definition: IsingModel.hpp:72
-
std::unordered_map< int, double > energy_diff
A hash map containing all possible energy changes.
Definition: IsingModel.hpp:56
-
double T
The temperature of the model.
Definition: IsingModel.hpp:60
-
int L
Size of the lattice.
Definition: IsingModel.hpp:64
-
arma::Mat< int > lattice
matrix where element .
Definition: IsingModel.hpp:42
-
void initialize_lattice()
Initialize the lattice with a random distribution of 1s and -1s.
Definition: IsingModel.cpp:44
-
data_t Metropolis()
The Metropolis algorithm.
Definition: IsingModel.cpp:96
-
void initialize_energy()
Initialize the energy.
Definition: IsingModel.cpp:82
-
void initialize_neighbors()
initialize the neighbors matrix.
Definition: IsingModel.cpp:56
-
void initialize_magnetization()
Initialize the magnetization.
Definition: IsingModel.cpp:74
-
arma::Mat< int > neighbors
matrix with the neighbors of each element .
Definition: IsingModel.hpp:52
-
int get_M()
Get the current magnetization.
Definition: IsingModel.cpp:140
-
int get_E()
Get the current energy.
Definition: IsingModel.cpp:135
-
IsingModel()
Constructor used for testing.
Definition: IsingModel.cpp:17
-
int E
The current energy state. unit: .
Definition: IsingModel.hpp:68
-
void initialize_energy_diff()
Initialize the hashmap with the correct values.
Definition: IsingModel.cpp:67
- -
Library of constants.
-
Header for the data_t type.
-
Useful typedefs for cleaner code.
-
Function prototypes and macros that are useful.
+
15#include "data_type.hpp"
+
16#include "utils.hpp"
+
17
+
18#include <armadillo>
+
19#include <cstdint>
+
20#include <random>
+
21#include <unordered_map>
+
22
+
23#define INDEX(I, N) (I + N) % N ///< I modulo N
+
24
+
25// Indeces for the neighbor matrix.
+
26#define UP 0 ///< Used for the neighbor matrix in the class
+
27#define LEFT 0 ///< Used for the neighbor matrix in the class
+
28#define DOWN 1 ///< Used for the neighbor matrix in the class
+
29#define RIGHT 1 ///< Used for the neighbor matrix in the class
+
30
+
31/** @brief The Ising model in 2 dimensions.
+
32 *
+
33 * @details None of the methods are parallelized, as there is very little
+
34 * benefit in doing so.
+
35 * */
+ +
37private:
+
38 /** @brief Give access to private members to the test class IsingModelTest.
+
39 * */
+
40 friend class IsingModelTest;
+
41
+
42 /** @brief \f$ L \times L \f$ matrix where element \f$ x \in {-1, 1}\f$.
+
43 * */
+
44 arma::Mat<int> lattice;
+
45
+
46 /** @brief \f$ L \times 2 \f$ matrix with the neighbors of each element
+
47 * \f$ x_i \f$.
+
48 *
+
49 * @details The reason why it's \f$ L \times 2 \f$ instead of
+
50 * \f$ L \times 2 \f$, is that we can see that we can use the same column
+
51 * for the left and upper neighbor, and we can use the same column for the
+
52 * right and lower neighbor.
+
53 * */
+
54 arma::Mat<int> neighbors;
+
55
+
56 /** @brief An array containing all possible energy differences.
+
57 * */
+
58 double energy_diff[17];
+
59
+
60 /** @brief The temperature of the model.
+
61 * */
+
62 double T;
+
63
+
64 /** @brief Size of the lattice.
+
65 * */
+
66 int L;
+
67
+
68 /** @brief The current energy state. unit: \f$ J \f$.
+
69 * */
+
70 int64_t E;
+
71
+
72 /** @brief The current magnetic strength. unit: Unitless.
+
73 * */
+
74 int64_t M;
+
75
+
76 /** @brief The RNG that is used for the Metropolis algorithm
+
77 * */
+
78 std::mt19937 engine;
+
79
+
80 /** @brief Initialize the RNG.
+
81 * */
+
82 void initialize_engine();
+
83
+
84 /** @brief Initialize the lattice with a random distribution of 1s and
+
85 * -1s.
+
86 * */
+
87 void initialize_lattice();
+
88
+
89 /** @brief Initialize the lattice with a specific value.
+
90 * */
+
91 void initialize_lattice(int val);
+
92
+
93 /** @brief initialize the neighbors matrix.
+
94 * */
+ +
96
+
97 /** @brief Initialize the energy_diff array with the correct values.
+
98 * */
+ +
100
+
101 /** @brief Initialize the magnetization of the system.
+
102 * */
+ +
104
+
105 /** @brief Initialize the energy of the system.
+
106 * */
+
107 void initialize_energy();
+
108
+
109 /** @brief Constructor used for testing.
+
110 * */
+
111 IsingModel();
+
112
+
113public:
+
114 /** @brief Constructor for the Ising model.
+
115 *
+
116 * @param L The size of the lattice.
+
117 * @param T The temperature for the system.
+
118 * */
+
119 IsingModel(int L, double T);
+
120
+
121 /** @brief Constructor for the Ising model.
+
122 *
+
123 * @param L The size of the lattice.
+
124 * @param T The temperature for the system.
+
125 * @param val The value to set for all spins.
+
126 * */
+
127 IsingModel(int L, double T, int val);
+
128
+
129 /** @brief The Metropolis algorithm.
+
130 * */
+ +
132};
+
133
+
134#endif
+
#define UP
Used for the neighbor matrix in the class.
Definition: IsingModel.hpp:26
+
#define INDEX(I, N)
I modulo N.
Definition: IsingModel.hpp:23
+
#define DOWN
Used for the neighbor matrix in the class.
Definition: IsingModel.hpp:28
+
#define LEFT
Used for the neighbor matrix in the class.
Definition: IsingModel.hpp:27
+
#define RIGHT
Used for the neighbor matrix in the class.
Definition: IsingModel.hpp:29
+
Test class for the Ising model.
Definition: test_suite.cpp:36
+
The Ising model in 2 dimensions.
Definition: IsingModel.hpp:36
+
std::mt19937 engine
The RNG that is used for the Metropolis algorithm.
Definition: IsingModel.hpp:78
+
int64_t E
The current energy state. unit: .
Definition: IsingModel.hpp:70
+
double T
The temperature of the model.
Definition: IsingModel.hpp:62
+
int L
Size of the lattice.
Definition: IsingModel.hpp:66
+
arma::Mat< int > lattice
matrix where element .
Definition: IsingModel.hpp:44
+
void initialize_lattice()
Initialize the lattice with a random distribution of 1s and -1s.
Definition: IsingModel.cpp:49
+
IsingModel(int L, double T, int val)
Constructor for the Ising model.
Definition: IsingModel.cpp:31
+
IsingModel(int L, double T)
Constructor for the Ising model.
Definition: IsingModel.cpp:19
+
data_t Metropolis()
The Metropolis algorithm.
Definition: IsingModel.cpp:110
+
void initialize_energy()
Initialize the energy of the system.
Definition: IsingModel.cpp:96
+
void initialize_neighbors()
initialize the neighbors matrix.
Definition: IsingModel.cpp:70
+
double energy_diff[17]
An array containing all possible energy differences.
Definition: IsingModel.hpp:58
+
void initialize_magnetization()
Initialize the magnetization of the system.
Definition: IsingModel.cpp:88
+
arma::Mat< int > neighbors
matrix with the neighbors of each element .
Definition: IsingModel.hpp:54
+
void initialize_engine()
Initialize the RNG.
Definition: IsingModel.cpp:43
+
void initialize_lattice(int val)
Initialize the lattice with a specific value.
Definition: IsingModel.cpp:59
+
IsingModel()
Constructor used for testing.
Definition: IsingModel.cpp:14
+
int64_t M
The current magnetic strength. unit: Unitless.
Definition: IsingModel.hpp:74
+
void initialize_energy_diff()
Initialize the energy_diff array with the correct values.
Definition: IsingModel.cpp:81
+
Type to use with the IsingModel class and montecarlo module.
Definition: data_type.hpp:19
+
data_t(double E, double E2, double M, double M2, double M_abs)
Constructor with parameters.
Definition: data_type.hpp:45
diff --git a/docs/README_8md.html b/docs/README_8md.html new file mode 100644 index 0000000..1e5e6d8 --- /dev/null +++ b/docs/README_8md.html @@ -0,0 +1,114 @@ + + + + + + + +2 Dimensional Ising Model: README.md File Reference + + + + + + + + + + + + + + + + +
+
+ + + + + + +
+
2 Dimensional Ising Model +
+
Simulate the change in energy and magnetization in a ferro magnet
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+
README.md File Reference
+
+
+
+
+ + + + diff --git a/docs/annotated.html b/docs/annotated.html index 751b997..bd0ed41 100644 --- a/docs/annotated.html +++ b/docs/annotated.html @@ -103,7 +103,7 @@ $(document).ready(function(){initNavTree('annotated.html',''); initResizable();
Here are the classes, structs, unions and interfaces with brief descriptions:
- +
 Cdata_t
 Cdata_tType to use with the IsingModel class and montecarlo module
 CIsingModelThe Ising model in 2 dimensions
 CIsingModelTestTest class for the Ising model
diff --git a/docs/annotated_dup.js b/docs/annotated_dup.js index 74285eb..fa4ef24 100644 --- a/docs/annotated_dup.js +++ b/docs/annotated_dup.js @@ -1,6 +1,6 @@ var annotated_dup = [ - [ "data_t", "classdata__t.html", null ], + [ "data_t", "classdata__t.html", "classdata__t" ], [ "IsingModel", "classIsingModel.html", "classIsingModel" ], [ "IsingModelTest", "classIsingModelTest.html", "classIsingModelTest" ] ]; \ No newline at end of file diff --git a/docs/bug.html b/docs/bug.html index e17d575..d6f2015 100644 --- a/docs/bug.html +++ b/docs/bug.html @@ -102,34 +102,38 @@ $(document).ready(function(){initNavTree('bug.html',''); initResizable(); });
-
File constants.hpp
-
No known bugs
File data_type.cpp
-
No known bugs
+
No known bugs
File data_type.hpp
No known bugs
File IsingModel.cpp
-
No known bugs
-
File IsingModel.hpp
No known bugs
-
File main.cpp
-
No known bugs
-
File monte_carlo.cpp
-
No known bugs
-
File monte_carlo.hpp
+
File IsingModel.hpp
No known bugs
+
File main.cpp
+
No known bugs
+
File mcmc_progression.cpp
+
No known bugs
+
File monte_carlo.cpp
+
No known bugs
+
File monte_carlo.hpp
+
No known bugs
+
File pd_estimate.cpp
+
No known bugs
+
File phase_transition.cpp
+
No known bugs
File phase_transition_mpi.cpp
No known bugs
File test_suite.cpp
No known bugs
File testlib.cpp
-
No known bugs
-
File testlib.hpp
-
No known bugs
-
File typedefs.hpp
-
No known bugs
-
File utils.cpp
No known bugs
+
File testlib.hpp
+
No known bugs
+
File time.cpp
+
No known bugs
+
File utils.cpp
+
No known bugs
File utils.hpp
No known bugs
diff --git a/docs/classIsingModel-members.html b/docs/classIsingModel-members.html index 46d1990..081260e 100644 --- a/docs/classIsingModel-members.html +++ b/docs/classIsingModel-members.html @@ -104,25 +104,26 @@ $(document).ready(function(){initNavTree('classIsingModel.html',''); initResizab

This is the complete list of members for IsingModel, including all inherited members.

- - - - - - + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + +
EIsingModelprivate
energy_diffIsingModelprivate
get_E()IsingModel
get_M()IsingModel
initialize_energy()IsingModelprivate
initialize_energy_diff()IsingModelprivate
EIsingModelprivate
energy_diffIsingModelprivate
engineIsingModelprivate
initialize_energy()IsingModelprivate
initialize_energy_diff()IsingModelprivate
initialize_engine()IsingModelprivate
initialize_lattice()IsingModelprivate
initialize_magnetization()IsingModelprivate
initialize_neighbors()IsingModelprivate
IsingModel()IsingModelprivate
IsingModel(int L, double T)IsingModel
IsingModel(int L, double T, int val)IsingModel
IsingModelTest (defined in IsingModel)IsingModelfriend
LIsingModelprivate
latticeIsingModelprivate
MIsingModelprivate
Metropolis()IsingModel
neighborsIsingModelprivate
TIsingModelprivate
initialize_lattice(int val)IsingModelprivate
initialize_magnetization()IsingModelprivate
initialize_neighbors()IsingModelprivate
IsingModel()IsingModelprivate
IsingModel(int L, double T)IsingModel
IsingModel(int L, double T, int val)IsingModel
IsingModelTestIsingModelfriend
LIsingModelprivate
latticeIsingModelprivate
MIsingModelprivate
Metropolis()IsingModel
neighborsIsingModelprivate
TIsingModelprivate
diff --git a/docs/classIsingModel.html b/docs/classIsingModel.html index e2a27b6..2cd97d0 100644 --- a/docs/classIsingModel.html +++ b/docs/classIsingModel.html @@ -124,29 +124,29 @@ Public Member Functions data_t Metropolis ()  The Metropolis algorithm.
  -int get_E () - Get the current energy.
-  -int get_M () - Get the current magnetization.
-  + + + + + + - + - + - + @@ -160,32 +160,36 @@ Private Attributes - - - + + + - - - - - - + + + + + + + + +

Private Member Functions

void initialize_engine ()
 Initialize the RNG.
 
void initialize_lattice ()
 Initialize the lattice with a random distribution of 1s and -1s.
 
void initialize_lattice (int val)
 Initialize the lattice with a specific value.
 
void initialize_neighbors ()
 initialize the neighbors matrix.
 
void initialize_energy_diff ()
 Initialize the hashmap with the correct values.
 Initialize the energy_diff array with the correct values.
 
void initialize_magnetization ()
 Initialize the magnetization.
 Initialize the magnetization of the system.
 
void initialize_energy ()
 Initialize the energy.
 Initialize the energy of the system.
 
 IsingModel ()
 Constructor used for testing.
arma::Mat< int > neighbors
 \( L \times 2 \) matrix with the neighbors of each element \( x_i \).
 
std::unordered_map< int, double > energy_diff
 A hash map containing all possible energy changes.
 
double energy_diff [17]
 An array containing all possible energy differences.
 
double T
 The temperature of the model.
 
int L
 Size of the lattice.
 
int E
 The current energy state. unit: \( J \).
 
int M
 The current magnetic strength. unit: Unitless.
 
int64_t E
 The current energy state. unit: \( J \).
 
int64_t M
 The current magnetic strength. unit: Unitless.
 
std::mt19937 engine
 The RNG that is used for the Metropolis algorithm.
 
+

Friends

class IsingModelTest
 Give access to private members to the test class IsingModelTest.
 

Detailed Description

The Ising model in 2 dimensions.

None of the methods are parallelized, as there is very little benefit in doing so.

-

Definition at line 37 of file IsingModel.hpp.

+

Definition at line 36 of file IsingModel.hpp.

Constructor & Destructor Documentation

◆ IsingModel() [1/3]

@@ -212,7 +216,7 @@ Friends

Constructor used for testing.

-

Definition at line 17 of file IsingModel.cpp.

+

Definition at line 14 of file IsingModel.cpp.

@@ -251,7 +255,7 @@ Friends -

Definition at line 21 of file IsingModel.cpp.

+

Definition at line 19 of file IsingModel.cpp.

@@ -297,55 +301,11 @@ Friends -

Definition at line 32 of file IsingModel.cpp.

+

Definition at line 31 of file IsingModel.cpp.

Member Function Documentation

- -

◆ get_E()

- -
-
- - - - - - - -
int IsingModel::get_E ()
-
- -

Get the current energy.

-
Returns
double
- -

Definition at line 135 of file IsingModel.cpp.

- -
-
- -

◆ get_M()

- -
-
- - - - - - - -
int IsingModel::get_M ()
-
- -

Get the current magnetization.

-
Returns
double
- -

Definition at line 140 of file IsingModel.cpp.

- -
-

◆ initialize_energy()

@@ -369,9 +329,9 @@ Friends
-

Initialize the energy.

+

Initialize the energy of the system.

-

Definition at line 82 of file IsingModel.cpp.

+

Definition at line 96 of file IsingModel.cpp.

@@ -398,14 +358,43 @@ Friends
-

Initialize the hashmap with the correct values.

+

Initialize the energy_diff array with the correct values.

-

Definition at line 67 of file IsingModel.cpp.

+

Definition at line 81 of file IsingModel.cpp.

+ +
+ + +

◆ initialize_engine()

+ +
+
+ + + + + +
+ + + + + + + +
void IsingModel::initialize_engine ()
+
+private
+
+ +

Initialize the RNG.

+ +

Definition at line 43 of file IsingModel.cpp.

-

◆ initialize_lattice()

+

◆ initialize_lattice() [1/2]

@@ -429,7 +418,37 @@ Friends

Initialize the lattice with a random distribution of 1s and -1s.

-

Definition at line 44 of file IsingModel.cpp.

+

Definition at line 49 of file IsingModel.cpp.

+ +
+
+ +

◆ initialize_lattice() [2/2]

+ +
+
+ + + + + +
+ + + + + + + + +
void IsingModel::initialize_lattice (int val)
+
+private
+
+ +

Initialize the lattice with a specific value.

+ +

Definition at line 59 of file IsingModel.cpp.

@@ -456,9 +475,9 @@ Friends
-

Initialize the magnetization.

+

Initialize the magnetization of the system.

-

Definition at line 74 of file IsingModel.cpp.

+

Definition at line 88 of file IsingModel.cpp.

@@ -487,7 +506,7 @@ Friends

initialize the neighbors matrix.

-

Definition at line 56 of file IsingModel.cpp.

+

Definition at line 70 of file IsingModel.cpp.

@@ -508,7 +527,7 @@ Friends

The Metropolis algorithm.

-

Definition at line 96 of file IsingModel.cpp.

+

Definition at line 110 of file IsingModel.cpp.

@@ -533,13 +552,15 @@ Friends
-

Definition at line 39 of file IsingModel.hpp.

+

Give access to private members to the test class IsingModelTest.

+ +

Definition at line 40 of file IsingModel.hpp.

Member Data Documentation

- -

◆ E

+ +

◆ E

@@ -548,7 +569,7 @@ Friends - +
int IsingModel::Eint64_t IsingModel::E
@@ -560,12 +581,12 @@ Friends

The current energy state. unit: \( J \).

-

Definition at line 68 of file IsingModel.hpp.

+

Definition at line 70 of file IsingModel.hpp.

- -

◆ energy_diff

+ +

◆ energy_diff

@@ -574,7 +595,7 @@ Friends - +
std::unordered_map<int, double> IsingModel::energy_diffdouble IsingModel::energy_diff[17]
@@ -584,9 +605,35 @@ Friends
-

A hash map containing all possible energy changes.

+

An array containing all possible energy differences.

-

Definition at line 56 of file IsingModel.hpp.

+

Definition at line 58 of file IsingModel.hpp.

+ +
+
+ +

◆ engine

+ +
+
+ + + + + +
+ + + + +
std::mt19937 IsingModel::engine
+
+private
+
+ +

The RNG that is used for the Metropolis algorithm.

+ +

Definition at line 78 of file IsingModel.hpp.

@@ -612,7 +659,7 @@ Friends

Size of the lattice.

-

Definition at line 64 of file IsingModel.hpp.

+

Definition at line 66 of file IsingModel.hpp.

@@ -638,12 +685,12 @@ Friends

\( L \times L \) matrix where element \( x \in {-1, 1}\).

-

Definition at line 42 of file IsingModel.hpp.

+

Definition at line 44 of file IsingModel.hpp.

- -

◆ M

+ +

◆ M

@@ -652,7 +699,7 @@ Friends - +
int IsingModel::Mint64_t IsingModel::M
@@ -664,7 +711,7 @@ Friends

The current magnetic strength. unit: Unitless.

-

Definition at line 72 of file IsingModel.hpp.

+

Definition at line 74 of file IsingModel.hpp.

@@ -691,7 +738,7 @@ Friends

\( L \times 2 \) matrix with the neighbors of each element \( x_i \).

The reason why it's \( L \times 2 \) instead of \( L \times 2 \), is that we can see that we can use the same column for the left and upper neighbor, and we can use the same column for the right and lower neighbor.

-

Definition at line 52 of file IsingModel.hpp.

+

Definition at line 54 of file IsingModel.hpp.

@@ -717,7 +764,7 @@ Friends

The temperature of the model.

-

Definition at line 60 of file IsingModel.hpp.

+

Definition at line 62 of file IsingModel.hpp.

diff --git a/docs/classIsingModel.js b/docs/classIsingModel.js index 8a0ca5c..6b41adc 100644 --- a/docs/classIsingModel.js +++ b/docs/classIsingModel.js @@ -3,19 +3,21 @@ var classIsingModel = [ "IsingModel", "classIsingModel.html#acf281f6f5ed02911ca6ab07004449864", null ], [ "IsingModel", "classIsingModel.html#a4a39ee7fbfbbf566f75bc28900ca9ea5", null ], [ "IsingModel", "classIsingModel.html#a46c9446e94854452f715d307c77c1c15", null ], - [ "get_E", "classIsingModel.html#aaa0787d964b004a17869811a5e947ff5", null ], - [ "get_M", "classIsingModel.html#aa5701496e6483bc4668c486d6d3af625", null ], [ "initialize_energy", "classIsingModel.html#a59fced38c695e2fa647f53be81b9d2a1", null ], [ "initialize_energy_diff", "classIsingModel.html#aff9a1201933fd5408845a1447e4895b4", null ], + [ "initialize_engine", "classIsingModel.html#aaedc25b7284e04849269f31291590bf5", null ], [ "initialize_lattice", "classIsingModel.html#a34a4710949b4a70f3e37ca223aefcf8a", null ], + [ "initialize_lattice", "classIsingModel.html#acc86effd6889bea199a3d70a9f38dc78", null ], [ "initialize_magnetization", "classIsingModel.html#a926cf4964d190d2ce23e5a17201787a4", null ], [ "initialize_neighbors", "classIsingModel.html#a6776109105051597c275670dabd0054a", null ], [ "Metropolis", "classIsingModel.html#a56559d68dc9aaff1976d84b157f43488", null ], - [ "E", "classIsingModel.html#ae9f872ca2054992161d53306119979dd", null ], - [ "energy_diff", "classIsingModel.html#a1a4ceb1bb2593dbd20c51ed04100cbcd", null ], + [ "IsingModelTest", "classIsingModel.html#a2b1cf104e0bda1fce78ed366e1ec7287", null ], + [ "E", "classIsingModel.html#a1c8a2a4331c7e60c3e1350c0cf8300b9", null ], + [ "energy_diff", "classIsingModel.html#a7112dd6433b1bb9512150cbdc1a0b77e", null ], + [ "engine", "classIsingModel.html#a1bbe0cb10abee98058e7b45b22b9cd0a", null ], [ "L", "classIsingModel.html#a2b8ac43baefeb386186266d5aa4de348", null ], [ "lattice", "classIsingModel.html#a2c3c76c79717c968d7c227c58b46df41", null ], - [ "M", "classIsingModel.html#a0d373a61baca6b0faa607bb12d82cc47", null ], + [ "M", "classIsingModel.html#aef7232b28df08e064ef58eb5ef32f738", null ], [ "neighbors", "classIsingModel.html#a94093aaf30facca62737f2ac381fdbcd", null ], [ "T", "classIsingModel.html#a20fc4c0c99d8a119f70a1614784d4e5c", null ] ]; \ No newline at end of file diff --git a/docs/classIsingModelTest.html b/docs/classIsingModelTest.html index 055b598..2a5fc3f 100644 --- a/docs/classIsingModelTest.html +++ b/docs/classIsingModelTest.html @@ -111,7 +111,7 @@ $(document).ready(function(){initNavTree('classIsingModelTest.html',''); initRes

Public Member Functions

void test_init_functions () - Test That initializing works as intended.
+ Test that initializing works as intended.
  int test_2x2_lattice (double tol, int max_cycles)  Test numerical data with analytical data.
@@ -120,7 +120,7 @@ Public Member Functions

Detailed Description

Test class for the Ising model.

-

Definition at line 30 of file test_suite.cpp.

+

Definition at line 36 of file test_suite.cpp.

Member Function Documentation

◆ test_2x2_lattice()

@@ -166,7 +166,7 @@ Public Member Functions

return int

-

Definition at line 70 of file test_suite.cpp.

+

Definition at line 76 of file test_suite.cpp.

@@ -193,9 +193,9 @@ Public Member Functions
-

Test That initializing works as intended.

+

Test that initializing works as intended.

-

Definition at line 34 of file test_suite.cpp.

+

Definition at line 40 of file test_suite.cpp.

diff --git a/docs/classdata__t-members.html b/docs/classdata__t-members.html index 83e7c4a..adefef9 100644 --- a/docs/classdata__t-members.html +++ b/docs/classdata__t-members.html @@ -104,20 +104,19 @@ $(document).ready(function(){initNavTree('classdata__t.html',''); initResizable(

This is the complete list of members for data_t, including all inherited members.

- - - - - - - - - - - - - - + + + + + + + + + + + + +
data_t() (defined in data_t)data_tinline
data_t(double E, double E2, double M, double M2, double M_abs) (defined in data_t)data_tinline
E (defined in data_t)data_t
E2 (defined in data_t)data_t
M (defined in data_t)data_t
M2 (defined in data_t)data_t
M_abs (defined in data_t)data_t
operator*(T num) (defined in data_t)data_tinline
operator*=(T num) (defined in data_t)data_tinline
operator+(const data_t &b) (defined in data_t)data_tinline
operator+=(const data_t &b) (defined in data_t)data_tinline
operator/(T num) (defined in data_t)data_tinline
operator/=(T num) (defined in data_t)data_tinline
operator=(T num) (defined in data_t)data_tinline
data_t()data_tinline
data_t(double E, double E2, double M, double M2, double M_abs)data_tinline
Edata_t
E2data_t
Mdata_t
M2data_t
M_absdata_t
operator*(T num)data_tinline
operator*=(T num)data_tinline
operator+(const data_t &b)data_tinline
operator+=(const data_t &b)data_tinline
operator/(T num)data_tinline
operator/=(T num)data_tinline
diff --git a/docs/classdata__t.html b/docs/classdata__t.html index 4c8e8cb..076fd0c 100644 --- a/docs/classdata__t.html +++ b/docs/classdata__t.html @@ -105,47 +105,65 @@ $(document).ready(function(){initNavTree('classdata__t.html',''); initResizable(
data_t Class Reference
+ +

Type to use with the IsingModel class and montecarlo module. + More...

+ +

#include <data_type.hpp>

- + + + + + + + + + + + - - -

Public Member Functions

 data_t (double E, double E2, double M, double M2, double M_abs)
 data_t ()
 constructor with no parameters.
 
 data_t (double E, double E2, double M, double M2, double M_abs)
 Constructor with parameters.
 
template<class T >
data_t operator/ (T num)
 Overload of the division operator.
 
template<class T >
data_toperator/= (T num)
 Overload of the division equals operator.
 
template<class T >
data_t operator* (T num)
 Overload of the multiply operator.
 
template<class T >
data_toperator*= (T num)
 Overload of the multiply equals operator.
 
data_t operator+ (const data_t &b)
 Overload of the addition operator.
 
data_toperator+= (const data_t &b)
 Overload of the addition equals operator.
 
template<class T >
void operator= (T num)
 
+ + + + +

Public Attributes

double E
 Energy.
 
double M
 Magnetization.
 
double E2
 Energy squared.
 
double M2
 Magnetization squared.
 
double M_abs
 Absolute Magnetization.
 

Detailed Description

-
-

Definition at line 18 of file data_type.hpp.

+

Type to use with the IsingModel class and montecarlo module.

+ +

Definition at line 19 of file data_type.hpp.

Constructor & Destructor Documentation

◆ data_t() [1/2]

@@ -170,7 +188,9 @@ Public Attributes
-

Definition at line 22 of file data_type.hpp.

+

constructor with no parameters.

+ +

Definition at line 29 of file data_type.hpp.

@@ -226,7 +246,19 @@ Public Attributes
-

Definition at line 31 of file data_type.hpp.

+

Constructor with parameters.

+
Parameters
+ + + + + + +
EInitial energy
E2Initial energy squared
MInitial magnetization
M2Initial magnetization squared
M_absInitial absolute magnetization
+
+
+ +

Definition at line 45 of file data_type.hpp.

@@ -257,7 +289,16 @@ template<class T >
-

Definition at line 63 of file data_type.hpp.

+

Overload of the multiply operator.

+
Parameters
+ + +
numThe number to multiply each field by.
+
+
+
Returns
data_t
+ +

Definition at line 96 of file data_type.hpp.

@@ -287,7 +328,16 @@ template<class T >
-

Definition at line 75 of file data_type.hpp.

+

Overload of the multiply equals operator.

+
Parameters
+ + +
numThe number to multiply each field by.
+
+
+
Returns
data_t
+ +

Definition at line 114 of file data_type.hpp.

@@ -315,7 +365,16 @@ template<class T >
-

Definition at line 86 of file data_type.hpp.

+

Overload of the addition operator.

+
Parameters
+ + +
bThe data_t field to add.
+
+
+
Returns
data_t
+ +

Definition at line 132 of file data_type.hpp.

@@ -343,7 +402,16 @@ template<class T >
-

Definition at line 98 of file data_type.hpp.

+

Overload of the addition equals operator.

+
Parameters
+ + +
bThe data_t field to add.
+
+
+
Returns
data_t
+ +

Definition at line 150 of file data_type.hpp.

@@ -373,7 +441,16 @@ template<class T >
-

Definition at line 40 of file data_type.hpp.

+

Overload of the division operator.

+
Parameters
+ + +
numThe number to divide each field by.
+
+
+
Returns
data_t
+ +

Definition at line 60 of file data_type.hpp.

@@ -403,37 +480,16 @@ template<class T >
-

Definition at line 52 of file data_type.hpp.

+

Overload of the division equals operator.

+
Parameters
+ + +
numThe number to divide each field by.
+
+
+
Returns
data_t
-
- - -

◆ operator=()

- -
-
-
-template<class T >
- - - - - -
- - - - - - - - -
void data_t::operator= (num)
-
-inline
-
- -

Definition at line 109 of file data_type.hpp.

+

Definition at line 79 of file data_type.hpp.

@@ -450,7 +506,9 @@ template<class T >
-

Definition at line 20 of file data_type.hpp.

+

Energy.

+ +

Definition at line 21 of file data_type.hpp.

@@ -466,7 +524,9 @@ template<class T >
-

Definition at line 20 of file data_type.hpp.

+

Energy squared.

+ +

Definition at line 23 of file data_type.hpp.

@@ -482,7 +542,9 @@ template<class T >
-

Definition at line 20 of file data_type.hpp.

+

Magnetization.

+ +

Definition at line 22 of file data_type.hpp.

@@ -498,7 +560,9 @@ template<class T >
-

Definition at line 20 of file data_type.hpp.

+

Magnetization squared.

+ +

Definition at line 24 of file data_type.hpp.

@@ -514,7 +578,9 @@ template<class T >
-

Definition at line 20 of file data_type.hpp.

+

Absolute Magnetization.

+ +

Definition at line 25 of file data_type.hpp.

diff --git a/docs/classdata__t.js b/docs/classdata__t.js new file mode 100644 index 0000000..b18f779 --- /dev/null +++ b/docs/classdata__t.js @@ -0,0 +1,16 @@ +var classdata__t = +[ + [ "data_t", "classdata__t.html#aa2690d3e5d711b4baf3c8f8b9095faf7", null ], + [ "data_t", "classdata__t.html#a3f2d19ab309e696ba91a2000479bcb83", null ], + [ "operator*", "classdata__t.html#a7954efc97086ea50e10c33113b203085", null ], + [ "operator*=", "classdata__t.html#a6ddf3a7372730ef2393aee8bbcb34992", null ], + [ "operator+", "classdata__t.html#a13bc1d73eadeb39c507e89f5872d726f", null ], + [ "operator+=", "classdata__t.html#a6cb96b4ff750ab29041038ca53f307cb", null ], + [ "operator/", "classdata__t.html#a429a11c53ee7fe08f6a4e75db524521d", null ], + [ "operator/=", "classdata__t.html#a88da5be78439fbdecfa473ec007dffd8", null ], + [ "E", "classdata__t.html#a6c1a196d96e177b11ca98c61fae35a2e", null ], + [ "E2", "classdata__t.html#abb622f9c6cc5ffb9dddb151d2e202f72", null ], + [ "M", "classdata__t.html#ad08d2488bf913c626157471cf6e8a46a", null ], + [ "M2", "classdata__t.html#a71ae3cd4460f2c66239500c11804e70b", null ], + [ "M_abs", "classdata__t.html#a586475e0f71322dffda2e75f228ab24b", null ] +]; \ No newline at end of file diff --git a/docs/data__type_8cpp.html b/docs/data__type_8cpp.html index e40f949..7bf8d17 100644 --- a/docs/data__type_8cpp.html +++ b/docs/data__type_8cpp.html @@ -102,18 +102,18 @@ $(document).ready(function(){initNavTree('data__type_8cpp.html',''); initResizab
-

Implementation for the data_t type. +

Implementation for the data_t type. More...

#include "data_type.hpp"

Go to the source code of this file.

Detailed Description

-

Implementation for the data_t type.

+

Implementation for the data_t type.

Author
Cory Alexander Balaton (coryab)
Janita Ovidie Sandtrøen Willumsen (janitaws)
Version
1.0
-
Bug:
No known bugs
+
Bug:
No known bugs

Definition in file data_type.cpp.

diff --git a/docs/data__type_8cpp_source.html b/docs/data__type_8cpp_source.html index 087ddc0..d8eb459 100644 --- a/docs/data__type_8cpp_source.html +++ b/docs/data__type_8cpp_source.html @@ -101,9 +101,18 @@ $(document).ready(function(){initNavTree('data__type_8cpp_source.html',''); init
data_type.cpp
-Go to the documentation of this file.
1
-
12#include "data_type.hpp"
-
Header for the data_t type.
+Go to the documentation of this file.
1/** @file data_type.cpp
+
2 *
+
3 * @author Cory Alexander Balaton (coryab)
+
4 * @author Janita Ovidie Sandtrøen Willumsen (janitaws)
+
5 *
+
6 * @version 1.0
+
7 *
+
8 * @brief Implementation for the data_t type.
+
9 *
+
10 * @bug No known bugs
+
11 * */
+
12#include "data_type.hpp"
diff --git a/docs/data__type_8hpp.html b/docs/data__type_8hpp.html index 02f1bd4..dd44aac 100644 --- a/docs/data__type_8hpp.html +++ b/docs/data__type_8hpp.html @@ -104,7 +104,7 @@ $(document).ready(function(){initNavTree('data__type_8hpp.html',''); initResizab
-

Header for the data_t type. +

Header for the data_t type. More...

#include <sys/types.h>
#include <type_traits>
@@ -114,10 +114,11 @@ $(document).ready(function(){initNavTree('data__type_8hpp.html',''); initResizab

Classes

class  data_t + Type to use with the IsingModel class and montecarlo module. More...
 

Detailed Description

-

Header for the data_t type.

+

Header for the data_t type.

Author
Cory Alexander Balaton (coryab)
Janita Ovidie Sandtrøen Willumsen (janitaws)
diff --git a/docs/data__type_8hpp.js b/docs/data__type_8hpp.js index 80d6066..8bdb337 100644 --- a/docs/data__type_8hpp.js +++ b/docs/data__type_8hpp.js @@ -1,4 +1,4 @@ var data__type_8hpp = [ - [ "data_t", "classdata__t.html", null ] + [ "data_t", "classdata__t.html", "classdata__t" ] ]; \ No newline at end of file diff --git a/docs/data__type_8hpp_source.html b/docs/data__type_8hpp_source.html index 30b1e71..b028bf3 100644 --- a/docs/data__type_8hpp_source.html +++ b/docs/data__type_8hpp_source.html @@ -101,116 +101,185 @@ $(document).ready(function(){initNavTree('data__type_8hpp_source.html',''); init
data_type.hpp
-Go to the documentation of this file.
1
-
12#ifndef __DATA_TYPE__
-
13#define __DATA_TYPE__
+Go to the documentation of this file.
1/** @file data_type.hpp
+
2 *
+
3 * @author Cory Alexander Balaton (coryab)
+
4 * @author Janita Ovidie Sandtrøen Willumsen (janitaws)
+
5 *
+
6 * @version 1.0
+
7 *
+
8 * @brief Header for the data_t type.
+
9 *
+
10 * @bug No known bugs
+
11 * */
+
12#ifndef __DATA_TYPE__
+
13#define __DATA_TYPE__
14
-
15#include <sys/types.h>
-
16#include <type_traits>
+
15#include <sys/types.h>
+
16#include <type_traits>
17
-
18class data_t {
-
19public:
-
20 double E, M, E2, M2, M_abs;
-
21
-
22 data_t()
-
23 {
-
24 this->E = 0.;
-
25 this->E2 = 0.;
-
26 this->M = 0.;
-
27 this->M2 = 0.;
-
28 this->M_abs = 0.;
-
29 }
-
30
-
31 data_t(double E, double E2, double M, double M2, double M_abs)
-
32 {
-
33 this->E = E;
-
34 this->E2 = E2;
-
35 this->M = M;
-
36 this->M2 = M2;
-
37 this->M_abs = M_abs;
-
38 }
-
39
-
40 template <class T> data_t operator/(T num)
-
41 {
-
42 data_t res;
-
43 res.E = this->E / (double)num;
-
44 res.E2 = this->E2 / (double)num;
-
45 res.M = this->M / (double)num;
-
46 res.M2 = this->M2 / (double)num;
-
47 res.M_abs = this->M_abs / (double)num;
-
48
-
49 return res;
-
50 }
-
51
-
52 template <class T> data_t& operator/=(T num)
-
53 {
-
54 this->E /= (double)num;
-
55 this->E2 /= (double)num;
-
56 this->M /= (double)num;
-
57 this->M2 /= (double)num;
-
58 this->M_abs /= (double)num;
-
59
-
60 return *this;
-
61 }
-
62
-
63 template <class T> data_t operator*(T num)
-
64 {
-
65 data_t res;
-
66 res.E = this->E * (double)num;
-
67 res.E2 = this->E2 * (double)num;
-
68 res.M = this->M * (double)num;
-
69 res.M2 = this->M2 * (double)num;
-
70 res.M_abs = this->M_abs * (double)num;
+
18/** @brief Type to use with the IsingModel class and montecarlo module.*/
+
19class data_t {
+
20public:
+
21 double E; ///< Energy
+
22 double M; ///< Magnetization
+
23 double E2; ///< Energy squared
+
24 double M2; ///< Magnetization squared
+
25 double M_abs; ///< Absolute Magnetization
+
26
+
27 /** @brief constructor with no parameters.
+
28 * */
+ +
30 {
+
31 this->E = 0.;
+
32 this->E2 = 0.;
+
33 this->M = 0.;
+
34 this->M2 = 0.;
+
35 this->M_abs = 0.;
+
36 }
+
37
+
38 /** @brief Constructor with parameters.
+
39 *
+
40 * @param E Initial energy
+
41 * @param E2 Initial energy squared
+
42 * @param M Initial magnetization
+
43 * @param M2 Initial magnetization squared
+
44 * @param M_abs Initial absolute magnetization*/
+
45 data_t(double E, double E2, double M, double M2, double M_abs)
+
46 {
+
47 this->E = E;
+
48 this->E2 = E2;
+
49 this->M = M;
+
50 this->M2 = M2;
+
51 this->M_abs = M_abs;
+
52 }
+
53
+
54 /** @brief Overload of the division operator.
+
55 *
+
56 * @param num The number to divide each field by.
+
57 *
+
58 * @return data_t
+
59 * */
+
60 template <class T> data_t operator/(T num)
+
61 {
+
62 data_t res;
+
63 res.E = this->E / (double)num;
+
64 res.E2 = this->E2 / (double)num;
+
65 res.M = this->M / (double)num;
+
66 res.M2 = this->M2 / (double)num;
+
67 res.M_abs = this->M_abs / (double)num;
+
68
+
69 return res;
+
70 }
71
-
72 return res;
-
73 }
-
74
-
75 template <class T> data_t& operator*=(T num)
-
76 {
-
77 this->E *= (double)num;
-
78 this->E2 *= (double)num;
-
79 this->M *= (double)num;
-
80 this->M2 *= (double)num;
-
81 this->M_abs *= (double)num;
-
82
-
83 return *this;
-
84 }
-
85
-
86 data_t operator+(const data_t &b)
-
87 {
-
88 data_t res;
-
89 res.E = this->E + b.E;
-
90 res.E2 = this->E2 + b.E2;
-
91 res.M = this->M + b.M;
-
92 res.M2 = this->M2 + b.M2;
-
93 res.M_abs = this->M_abs + b.M_abs;
-
94
-
95 return res;
-
96 }
-
97
-
98 data_t& operator+=(const data_t &b)
-
99 {
-
100 this->E += b.E;
-
101 this->E2 += b.E2;
-
102 this->M += b.M;
-
103 this->M2 += b.M2;
-
104 this->M_abs += b.M_abs;
-
105
-
106 return *this;
-
107 }
-
108
-
109 template <class T> void operator=(T num)
-
110 {
-
111 this->E = (double)num;
-
112 this->E2 = (double)num;
-
113 this->M = (double)num;
-
114 this->M2 = (double)num;
-
115 this->M_abs = (double)num;
-
116 }
-
117};
-
118
-
119#endif
- +
72
+
73 /** @brief Overload of the division equals operator.
+
74 *
+
75 * @param num The number to divide each field by.
+
76 *
+
77 * @return data_t
+
78 * */
+
79 template <class T> data_t &operator/=(T num)
+
80 {
+
81 this->E /= (double)num;
+
82 this->E2 /= (double)num;
+
83 this->M /= (double)num;
+
84 this->M2 /= (double)num;
+
85 this->M_abs /= (double)num;
+
86
+
87 return *this;
+
88 }
+
89
+
90 /** @brief Overload of the multiply operator.
+
91 *
+
92 * @param num The number to multiply each field by.
+
93 *
+
94 * @return data_t
+
95 * */
+
96 template <class T> data_t operator*(T num)
+
97 {
+
98 data_t res;
+
99 res.E = this->E * (double)num;
+
100 res.E2 = this->E2 * (double)num;
+
101 res.M = this->M * (double)num;
+
102 res.M2 = this->M2 * (double)num;
+
103 res.M_abs = this->M_abs * (double)num;
+
104
+
105 return res;
+
106 }
+
107
+
108 /** @brief Overload of the multiply equals operator.
+
109 *
+
110 * @param num The number to multiply each field by.
+
111 *
+
112 * @return data_t
+
113 * */
+
114 template <class T> data_t &operator*=(T num)
+
115 {
+
116 this->E *= (double)num;
+
117 this->E2 *= (double)num;
+
118 this->M *= (double)num;
+
119 this->M2 *= (double)num;
+
120 this->M_abs *= (double)num;
+
121
+
122 return *this;
+
123 }
+
124
+
125
+
126 /** @brief Overload of the addition operator.
+
127 *
+
128 * @param b The data_t field to add.
+
129 *
+
130 * @return data_t
+
131 * */
+ +
133 {
+
134 data_t res;
+
135 res.E = this->E + b.E;
+
136 res.E2 = this->E2 + b.E2;
+
137 res.M = this->M + b.M;
+
138 res.M2 = this->M2 + b.M2;
+
139 res.M_abs = this->M_abs + b.M_abs;
+
140
+
141 return res;
+
142 }
+
143
+
144 /** @brief Overload of the addition equals operator.
+
145 *
+
146 * @param b The data_t field to add.
+
147 *
+
148 * @return data_t
+
149 * */
+
150 data_t &operator+=(const data_t &b)
+
151 {
+
152 this->E += b.E;
+
153 this->E2 += b.E2;
+
154 this->M += b.M;
+
155 this->M2 += b.M2;
+
156 this->M_abs += b.M_abs;
+
157
+
158 return *this;
+
159 }
+
160};
+
161
+
162// Declare a custom reduction for the data_t type.
+
163#pragma omp declare reduction(+ : data_t : omp_out += omp_in)
+
164
+
165#endif
+
Type to use with the IsingModel class and montecarlo module.
Definition: data_type.hpp:19
+
data_t operator+(const data_t &b)
Overload of the addition operator.
Definition: data_type.hpp:132
+
data_t(double E, double E2, double M, double M2, double M_abs)
Constructor with parameters.
Definition: data_type.hpp:45
+
data_t operator/(T num)
Overload of the division operator.
Definition: data_type.hpp:60
+
double M_abs
Absolute Magnetization.
Definition: data_type.hpp:25
+
double E
Energy.
Definition: data_type.hpp:21
+
data_t & operator+=(const data_t &b)
Overload of the addition equals operator.
Definition: data_type.hpp:150
+
data_t & operator*=(T num)
Overload of the multiply equals operator.
Definition: data_type.hpp:114
+
double M2
Magnetization squared.
Definition: data_type.hpp:24
+
data_t operator*(T num)
Overload of the multiply operator.
Definition: data_type.hpp:96
+
data_t & operator/=(T num)
Overload of the division equals operator.
Definition: data_type.hpp:79
+
data_t()
constructor with no parameters.
Definition: data_type.hpp:29
+
double E2
Energy squared.
Definition: data_type.hpp:23
+
double M
Magnetization.
Definition: data_type.hpp:22
diff --git a/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.html b/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.html index 75f9ece..1fa9679 100644 --- a/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.html +++ b/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.html @@ -102,15 +102,10 @@ $(document).ready(function(){initNavTree('dir_68267d1309a1af8e8297ef4c3efbcdba.h
- - - -

-Directories

directory  scripts
 
- + @@ -118,9 +113,18 @@ Files + + + + + + + + + @@ -130,6 +134,9 @@ Files + + + diff --git a/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.js b/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.js index 90dbe2d..284e098 100644 --- a/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.js +++ b/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.js @@ -1,12 +1,15 @@ var dir_68267d1309a1af8e8297ef4c3efbcdba = [ - [ "scripts", "dir_634e799a3947388232110823971192a8.html", "dir_634e799a3947388232110823971192a8" ], [ "data_type.cpp", "data__type_8cpp.html", null ], [ "IsingModel.cpp", "IsingModel_8cpp.html", null ], [ "main.cpp", "main_8cpp.html", "main_8cpp" ], + [ "mcmc_progression.cpp", "mcmc__progression_8cpp.html", "mcmc__progression_8cpp" ], [ "monte_carlo.cpp", "monte__carlo_8cpp.html", "monte__carlo_8cpp" ], + [ "pd_estimate.cpp", "pd__estimate_8cpp.html", "pd__estimate_8cpp" ], + [ "phase_transition.cpp", "phase__transition_8cpp.html", "phase__transition_8cpp" ], [ "phase_transition_mpi.cpp", "phase__transition__mpi_8cpp.html", "phase__transition__mpi_8cpp" ], [ "test_suite.cpp", "test__suite_8cpp.html", "test__suite_8cpp" ], [ "testlib.cpp", "testlib_8cpp.html", "testlib_8cpp" ], + [ "time.cpp", "time_8cpp.html", "time_8cpp" ], [ "utils.cpp", "utils_8cpp.html", "utils_8cpp" ] ]; \ No newline at end of file diff --git a/docs/dir_d44c64559bbebec7f509842c48db8b23.html b/docs/dir_d44c64559bbebec7f509842c48db8b23.html index 9348629..c234ca2 100644 --- a/docs/dir_d44c64559bbebec7f509842c48db8b23.html +++ b/docs/dir_d44c64559bbebec7f509842c48db8b23.html @@ -104,24 +104,18 @@ $(document).ready(function(){initNavTree('dir_d44c64559bbebec7f509842c48db8b23.h

Files

file  data_type.cpp [code]
 Implementation for the data_t type.
 Implementation for the data_t type.
 
file  IsingModel.cpp [code]
 The implementation of the Ising model.
file  main.cpp [code]
 The main program.
 
file  mcmc_progression.cpp [code]
 Execute the mcmc algorithm and write data to file after each Monte Carlo cycle.
 
file  monte_carlo.cpp [code]
 Implementation of the monte carlo functions.
 
file  pd_estimate.cpp [code]
 execute the mcmc algorithm and write data to file after each Monte Carlo cycles.
 
file  phase_transition.cpp [code]
 Sweep over different temperatures and generate data.
 
file  phase_transition_mpi.cpp [code]
 Sweep over different temperatures and generate data.
 
file  testlib.cpp [code]
 Implementation of the testing library.
 
file  time.cpp [code]
 Timing various things.
 
file  utils.cpp [code]
 Implementation of the utils.
 
- - - - + - + - - - diff --git a/docs/dir_d44c64559bbebec7f509842c48db8b23.js b/docs/dir_d44c64559bbebec7f509842c48db8b23.js index aeac9c5..4a229eb 100644 --- a/docs/dir_d44c64559bbebec7f509842c48db8b23.js +++ b/docs/dir_d44c64559bbebec7f509842c48db8b23.js @@ -1,10 +1,8 @@ var dir_d44c64559bbebec7f509842c48db8b23 = [ - [ "constants.hpp", "constants_8hpp.html", "constants_8hpp" ], [ "data_type.hpp", "data__type_8hpp.html", "data__type_8hpp" ], [ "IsingModel.hpp", "IsingModel_8hpp.html", "IsingModel_8hpp" ], [ "monte_carlo.hpp", "monte__carlo_8hpp.html", "monte__carlo_8hpp" ], [ "testlib.hpp", "testlib_8hpp.html", "testlib_8hpp" ], - [ "typedefs.hpp", "typedefs_8hpp.html", null ], [ "utils.hpp", "utils_8hpp.html", "utils_8hpp" ] ]; \ No newline at end of file diff --git a/docs/files.html b/docs/files.html index 8e299ae..fa07684 100644 --- a/docs/files.html +++ b/docs/files.html @@ -102,28 +102,26 @@ $(document).ready(function(){initNavTree('files.html',''); initResizable(); });
Here is a list of all documented files with brief descriptions:
-
[detail level 123]

Files

file  constants.hpp [code]
 Library of constants.
 
file  data_type.hpp [code]
 Header for the data_t type.
 Header for the data_t type.
 
file  IsingModel.hpp [code]
 The definition of the Ising model.
 
file  monte_carlo.hpp [code]
 Functions for monte carlo simulations.
 Functions for Monte Carlo simulations.
 
file  testlib.hpp [code]
 A small test library.
 
file  typedefs.hpp [code]
 Useful typedefs for cleaner code.
 
file  utils.hpp [code]
 Function prototypes and macros that are useful.
 
+
[detail level 12]
- - - - - - - + + + + + - - - - - - - - - - - - + + + + + + + + + + + +
  include
 constants.hppLibrary of constants
 data_type.hppHeader for the data_t type
 IsingModel.hppThe definition of the Ising model
 monte_carlo.hppFunctions for monte carlo simulations
 testlib.hppA small test library
 typedefs.hppUseful typedefs for cleaner code
 utils.hppFunction prototypes and macros that are useful
 data_type.hppHeader for the data_t type
 IsingModel.hppThe definition of the Ising model
 monte_carlo.hppFunctions for Monte Carlo simulations
 testlib.hppA small test library
 utils.hppFunction prototypes and macros that are useful
  src
  scripts
 burn_in_time.py
 pd_estimate.py
 phase_transition.py
 data_type.cppImplementation for the data_t type
 IsingModel.cppThe implementation of the Ising model
 main.cppThe main program
 monte_carlo.cppImplementation of the monte carlo functions
 phase_transition_mpi.cppSweep over different temperatures and generate data
 test_suite.cppSweep over different temperatures and generate data
 testlib.cppImplementation of the testing library
 utils.cppImplementation of the utils
 data_type.cppImplementation for the data_t type
 IsingModel.cppThe implementation of the Ising model
 main.cppThe main program
 mcmc_progression.cppExecute the mcmc algorithm and write data to file after each Monte Carlo cycle
 monte_carlo.cppImplementation of the monte carlo functions
 pd_estimate.cppExecute the mcmc algorithm and write data to file after each Monte Carlo cycles
 phase_transition.cppSweep over different temperatures and generate data
 phase_transition_mpi.cppSweep over different temperatures and generate data
 test_suite.cppSweep over different temperatures and generate data
 testlib.cppImplementation of the testing library
 time.cppTiming various things
 utils.cppImplementation of the utils
diff --git a/docs/functions.html b/docs/functions.html index ac97e55..9e98403 100644 --- a/docs/functions.html +++ b/docs/functions.html @@ -98,22 +98,63 @@ $(document).ready(function(){initNavTree('functions.html',''); initResizable();
-
Here is a list of all documented class members with links to the class documentation for each member:
diff --git a/docs/globals_func.html b/docs/globals_func.html index 08348b6..b21e4cb 100644 --- a/docs/globals_func.html +++ b/docs/globals_func.html @@ -99,13 +99,15 @@ $(document).ready(function(){initNavTree('globals_func.html',''); initResizable(
 
diff --git a/docs/index.html b/docs/index.html index d282042..9f3ba18 100644 --- a/docs/index.html +++ b/docs/index.html @@ -126,8 +126,6 @@ Operating systems Tools

Compiling

-

Compiling is as easy as running this command while being inside the src directory:

+

The commands shown here should be run from the root of this project.

+

+Normal binaries

+

Compiling regular binaries is as easy as running this command:

make
-

-Running programs

+

The binaries will then be inside the **./bin** directory.

+Profiling binaries

+

If you want to profile the programs (specifically the MPI program), then run this command

+
make profile
+

The binaries will then be inside the **./prof** directory.

+

+Debugging binaries

+

If you want to debug the code, then use this command:

+
make debug
+

The binaries will then be inside the **./debug** directory.

+

+Running programs

+

C++ binaries

-

To run main or test_suite, just run this command while being inside src:

-
./<program-name>
-

+

To run any of the programs, just use the following command:

+
./<bin|prof|debug>/<program-name> <args>
+

If you need help with any of the programs, you can use the -h or –help flag to show you how to use the programs. Here is an example:

+
./bin/main --help
+

Python scripts

-

+

Install libraries

Before running the scripts, make sure that all libraries are installed. Using pip, you can install all requirements like this:

pip install -r requirements.txt

This recursively install all the packages that are listed in requirements.txt.

-

+

Running scripts

-

For the Python scripts, run them from the src directory like this:

-
python scripts/<script-name>
+

For the Python scripts, run them from the root of the project:

+
python python_scripts/<script-name>

If you have any problems running the scripts, you might have to run this instead:

-
python3 scripts/<script-name>
-

+
python3 python_scripts/<script-name>
+

Batch system

-

For the phase_transition_mpi program, there are scripts in the src/jobs directory that come along with it. This is to be able to run it on a batch system using Slurm if you have access to one. This is the recommended way to use this program as it takes approximately 90 minutes to complete when using 8 processes where each process has 10 threads.

-

If you happen to have such a system available to you, then you should clone this repo on that system, then compile it by running:

-
make phase_transition_mpi
-

You might have to load the Armadillo library using the module system before compiling.

-

After compiling, you can schedule it by running:

-
sbatch jobs/<script-name>
-

+

For the phase_transition_mpi program, there are scripts in the **./slurm_scripts** directory that come along with it. This is to be able to run it on a batch system using Slurm if you have access to one. The only program that should be executed by the user is the **./slurm_scripts/execute.script** script. You can see how to use this script by doing:

+
./slurm_scripts/execute.script --help
+

This is the recommended way to use this program as it takes approximately 90 minutes to complete when using 8 processes where each process has 10 threads.

+

If you happen to have such a system available to you, then you should clone this repo on that system, then compile the MPI program like this:

+
make bin/phase_transition_mpi
+

After compiling, you can schedule it by using the **./slurm_scripts/execute.script**:

+
./slurm_scripts/execute.script <parameters>
+

Performance

-

This section aims to give an idea to the time it takes for the program to run so that you know a bit what to expect if you decide to run it for yourself.

-

+

This section aims to give an idea to the time it takes for the phase transition program to run so that you know a bit what to expect if you decide to run it for yourself.

+

CPU

The times mentioned here are times achieved on a computer with these specifications:

-

+

Times

-

+

Note that all times here are recorded using the OpenMP implementation of the MCMC algorithm.

+ + + + + + + + + +
lattice size points samples burn-in time time (seconds)
20 20 100000 0 3.20
20 40 100000 0 6.17
20 80 100000 0 12.11
+ + + + + + + + + +
lattice size points samples burn-in time time (seconds)
20 20 100000 0 3.20
40 20 100000 0 11.91
80 20 100000 0 47.88
+ + + + + + + + + +
lattice size points samples burn-in time time (seconds)
20 20 100000 0 3.20
20 20 1000000 0 29.95
20 20 10000000 0 305.849
+ + + + + + + + + +
lattice size points samples burn-in time time (seconds)
20 20 100000 0 3.20
20 20 100000 5000 4.93
20 20 100000 10000 6.58
+

We can see that changing the number of points, samples and burn-in time changes the time in a linear fashion, while changing the size of the lattice changes the time in a square fashion.

+

Credits

The Doxygen theme used here is doxygen-awesome-css.

diff --git a/docs/index.js b/docs/index.js index 6788a1b..db22cce 100644 --- a/docs/index.js +++ b/docs/index.js @@ -5,18 +5,22 @@ var index = [ "Tools", "index.html#autotoc_md3", null ], [ "Libraries", "index.html#autotoc_md4", null ] ] ], - [ "Compiling", "index.html#autotoc_md5", null ], - [ "Running programs", "index.html#autotoc_md6", [ - [ "C++ binaries", "index.html#autotoc_md7", null ], - [ "Python scripts", "index.html#autotoc_md8", [ - [ "Install libraries", "index.html#autotoc_md9", null ], - [ "Running scripts", "index.html#autotoc_md10", null ] + [ "Compiling", "index.html#autotoc_md5", [ + [ "Normal binaries", "index.html#autotoc_md6", null ], + [ "Profiling binaries", "index.html#autotoc_md7", null ], + [ "Debugging binaries", "index.html#autotoc_md8", null ] + ] ], + [ "Running programs", "index.html#autotoc_md9", [ + [ "C++ binaries", "index.html#autotoc_md10", null ], + [ "Python scripts", "index.html#autotoc_md11", [ + [ "Install libraries", "index.html#autotoc_md12", null ], + [ "Running scripts", "index.html#autotoc_md13", null ] ] ], - [ "Batch system", "index.html#autotoc_md11", null ] + [ "Batch system", "index.html#autotoc_md14", null ] ] ], - [ "Performance", "index.html#autotoc_md12", [ - [ "CPU", "index.html#autotoc_md13", null ], - [ "Times", "index.html#autotoc_md14", null ] + [ "Performance", "index.html#autotoc_md15", [ + [ "CPU", "index.html#autotoc_md16", null ], + [ "Times", "index.html#autotoc_md17", null ] ] ], - [ "Credits", "index.html#autotoc_md15", null ] + [ "Credits", "index.html#autotoc_md18", null ] ]; \ No newline at end of file diff --git a/docs/main_8cpp.html b/docs/main_8cpp.html index 45bb8b4..a5e86df 100644 --- a/docs/main_8cpp.html +++ b/docs/main_8cpp.html @@ -109,23 +109,30 @@ $(document).ready(function(){initNavTree('main_8cpp.html',''); initResizable();
#include "data_type.hpp"
#include "monte_carlo.hpp"
#include "utils.hpp"
-#include <csignal>
-#include <cstdlib>
-#include <iostream>
-#include <omp.h>
+#include <getopt.h>

Go to the source code of this file.

+ + + + + + + + + + @@ -136,7 +143,7 @@ Functions
Janita Ovidie Sandtrøen Willumsen (janitaws)
Version
0.1
-
Bug:
No known bugs
+
Bug:
No known bugs

Definition in file main.cpp.

Function Documentation

@@ -155,6 +162,8 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)

Functions

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 initial states.
 
void create_pd_estimate_data ()
 Create the data used to estimate the probability distribution for tempratures 1.0 anbd 2.4.
 
void test_burn_in_time ()
 Create data using the same parameters except one uses burn-in time, while the other doesn't.
 
void test_parallel_speedup ()
 Test how much Openmp speeds up.
 
void create_phase_transition_data ()
 Create data for studying phase transition.
 
void usage (std::string filename)
 A function that displays how to use the program and quits.
 
int main (int argc, char **argv)
 The main function.
 
+

Create the data for the burn-in time for temperatures 1.0 and 2.4 for both unordered and ordered initial states.

+

Definition at line 21 of file main.cpp.

@@ -174,7 +183,9 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
-

Definition at line 34 of file main.cpp.

+

Create the data used to estimate the probability distribution for tempratures 1.0 anbd 2.4.

+ +

Definition at line 37 of file main.cpp.

@@ -193,7 +204,9 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
-

Definition at line 62 of file main.cpp.

+

Create data for studying phase transition.

+ +

Definition at line 83 of file main.cpp.

@@ -225,7 +238,28 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)

The main function.

-

Definition at line 84 of file main.cpp.

+

Definition at line 125 of file main.cpp.

+ + + + +

◆ 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 at line 49 of file main.cpp.

@@ -244,7 +278,31 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
-

Definition at line 41 of file main.cpp.

+

Test how much Openmp speeds up.

+ +

Definition at line 60 of file main.cpp.

+ +
+ + +

◆ usage()

+ +
+
+ + + + + + + + +
void usage (std::string filename)
+
+ +

A function that displays how to use the program and quits.

+ +

Definition at line 110 of file main.cpp.

diff --git a/docs/main_8cpp.js b/docs/main_8cpp.js index 89e321a..07b4fb6 100644 --- a/docs/main_8cpp.js +++ b/docs/main_8cpp.js @@ -1,4 +1,10 @@ var main_8cpp = [ - [ "main", "main_8cpp.html#a3c04138a5bfe5d72780bb7e82a18e627", null ] + [ "create_burn_in_time_data", "main_8cpp.html#a68406fc2dd8de5849c3984658c171f32", null ], + [ "create_pd_estimate_data", "main_8cpp.html#a4f8ea24364d72024915d3753a572cc5b", null ], + [ "create_phase_transition_data", "main_8cpp.html#a9d62cf1399596f4c5a39abdd3196d76d", null ], + [ "main", "main_8cpp.html#a3c04138a5bfe5d72780bb7e82a18e627", null ], + [ "test_burn_in_time", "main_8cpp.html#a746d8dc451b2b2536abbb1ff1acaf861", null ], + [ "test_parallel_speedup", "main_8cpp.html#a0dfa85080578dffff23b68e372cece95", null ], + [ "usage", "main_8cpp.html#ac907e18135856c90366aaa599a9e10b1", null ] ]; \ No newline at end of file diff --git a/docs/main_8cpp_source.html b/docs/main_8cpp_source.html index 5a6dd8e..727245f 100644 --- a/docs/main_8cpp_source.html +++ b/docs/main_8cpp_source.html @@ -101,118 +101,195 @@ $(document).ready(function(){initNavTree('main_8cpp_source.html',''); initResiza
main.cpp
-Go to the documentation of this file.
1
-
12#include "data_type.hpp"
-
13#include "monte_carlo.hpp"
-
14#include "utils.hpp"
+Go to the documentation of this file.
1/** @file main.cpp
+
2 *
+
3 * @author Cory Alexander Balaton (coryab)
+
4 * @author Janita Ovidie Sandtrøen Willumsen (janitaws)
+
5 *
+
6 * @version 0.1
+
7 *
+
8 * @brief The main program
+
9 *
+
10 * @bug No known bugs
+
11 * */
+
12#include "data_type.hpp"
+
13#include "monte_carlo.hpp"
+
14#include "utils.hpp"
15
-
16#include <csignal>
-
17#include <cstdlib>
-
18#include <iostream>
-
19#include <omp.h>
-
20
-
21void create_burn_in_time_data()
+
16#include <getopt.h>
+
17
+
18/** @brief Create the data for the burn-in time for temperatures 1.0 and 2.4
+
19 * for both unordered and ordered initial states.
+
20 * */
+
22{
23 // Test burn-in time
-
24 monte_carlo_progression(1.0, 20, 20000,
-
25 "output/burn_in_time/unordered_1_0.txt");
-
26 monte_carlo_progression(1.0, 20, 20000, 1,
-
27 "output/burn_in_time/ordered_1_0.txt");
-
28 monte_carlo_progression(2.4, 20, 20000,
-
29 "output/burn_in_time/unordered_2_4.txt");
-
30 monte_carlo_progression(2.4, 20, 20000, 1,
-
31 "output/burn_in_time/ordered_2_4.txt");
+
24 montecarlo::progression(1.0, 20, 20000,
+
25 "../output/burn_in_time/unordered_1_0.txt");
+
26 montecarlo::progression(1.0, 20, 20000, 1,
+
27 "../output/burn_in_time/ordered_1_0.txt");
+
28 montecarlo::progression(2.4, 20, 20000,
+
29 "../output/burn_in_time/unordered_2_4.txt");
+
30 montecarlo::progression(2.4, 20, 20000, 1,
+
31 "../output/burn_in_time/ordered_2_4.txt");
32}
33
-
34void create_pd_estimate_data()
-
35{
-
36 // Estimate pd
-
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");
-
39}
-
40
-
41void test_parallel_speedup()
-
42{
-
43 // Test the openmp speedup
-
44 data_t data;
-
45 double t0, t1, t2;
-
46 int tries = 5;
-
47 t0 = omp_get_wtime();
-
48 for (size_t i = 0; i < tries; i++)
-
49 monte_carlo_serial(20, 1.0, 10000);
-
50 t1 = omp_get_wtime();
-
51 for (size_t i = 0; i < tries; i++)
-
52 monte_carlo_parallel(20, 1.0, 10000);
-
53 t2 = omp_get_wtime();
-
54
-
55 std::cout << "Time serial : " << (t1 - t0) / tries << " seconds"
-
56 << '\n';
-
57 std::cout << "Time parallel : " << (t2 - t1) / tries << " seconds"
-
58 << '\n';
-
59 std::cout << "Speedup parallel: " << (t1 - t0) / (t2 - t1) << '\n';
-
60}
-
61
-
62void create_phase_transition_data()
-
63{
-
64 double t0, t1;
-
65
+
34/** @brief Create the data used to estimate the probability distribution
+
35 * for tempratures 1.0 anbd 2.4.
+
36 * */
+ +
38{
+
39 // Estimate pd
+
40 montecarlo::pd_estimate(1.0, 20, 1000000,
+
41 "../output/pd_estimate/estimate_1_0.txt");
+
42 montecarlo::pd_estimate(2.4, 20, 1000000,
+
43 "../output/pd_estimate/estimate_2_4.txt");
+
44}
+
45
+
46/** @brief Create data using the same parameters except one uses burn-in time,
+
47 * while the other doesn't.
+
48 * */
+ +
50{
+
51 montecarlo::phase_transition(
+
52 100, 2.1, 2.4, 40, 1e5, montecarlo::mcmc_serial,
+
53 "../output/test_burn_in_time/burn_in.txt", 5000);
+
54 montecarlo::phase_transition(
+
55 100, 2.1, 2.4, 40, 1e5, montecarlo::mcmc_serial,
+
56 "../output/test_burn_in_time/no_burn_in.txt", 0);
+
57}
+
58
+
59/** @brief Test how much Openmp speeds up.*/
+ +
61{
+
62 // Test the openmp speedup
+
63 data_t data;
+
64 double t0, t1, t2;
+
65 int tries = 5;
66 t0 = omp_get_wtime();
-
67 // Phase transition
-
68 phase_transition(20, 2.1, 2.4, 40, monte_carlo_parallel,
-
69 "output/phase_transition/size_20.txt");
-
70 phase_transition(40, 2.1, 2.4, 40, monte_carlo_parallel,
-
71 "output/phase_transition/size_40.txt");
-
72 phase_transition(60, 2.1, 2.4, 40, monte_carlo_parallel,
-
73 "output/phase_transition/size_60.txt");
-
74 phase_transition(80, 2.1, 2.4, 40, monte_carlo_parallel,
-
75 "output/phase_transition/size_80.txt");
-
76 phase_transition(100, 2.1, 2.4, 40, monte_carlo_parallel,
-
77 "output/phase_transition/size_100.txt");
-
78 t1 = omp_get_wtime();
-
79
-
80 std::cout << "Time: " << t1 - t0 << std::endl;
-
81}
-
82
-
84int main(int argc, char **argv)
-
85{
-
86 if (argc < 2) {
-
87 std::cout << "Need at least 1 argument, got " << argc - 1
-
88 << " arguments." << std::endl;
-
89 abort();
-
90 }
-
91
-
92 int arg = atoi(argv[1]);
-
93
-
94 switch (arg) {
-
95 case 1:
-
96 create_burn_in_time_data();
-
97 break;
-
98 case 2:
-
99 create_pd_estimate_data();
-
100 break;
-
101 case 3:
-
102 test_parallel_speedup();
-
103 break;
-
104 case 4:
-
105 create_phase_transition_data();
-
106 break;
-
107 default:
-
108 std::cout << "Not a valid option!" << std::endl;
-
109 abort();
-
110 }
-
111
-
112 return 0;
-
113}
- -
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.
Definition: monte_carlo.cpp:85
-
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.
Definition: monte_carlo.cpp:17
-
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.
Definition: test_suite.cpp:148
-
Function prototypes and macros that are useful.
+
67 for (size_t i = 0; i < tries; i++)
+
68 montecarlo::mcmc_serial(20, 1.0, 10000);
+
69 t1 = omp_get_wtime();
+
70 for (size_t i = 0; i < tries; i++)
+
71 montecarlo::mcmc_parallel(20, 1.0, 10000);
+
72 t2 = omp_get_wtime();
+
73
+
74 std::cout << "Time serial : " << (t1 - t0) / tries << " seconds"
+
75 << '\n';
+
76 std::cout << "Time parallel : " << (t2 - t1) / tries << " seconds"
+
77 << '\n';
+
78 std::cout << "Speedup parallel: " << (t1 - t0) / (t2 - t1) << '\n';
+
79}
+
80
+
81/** @brief Create data for studying phase transition.
+
82 * */
+ +
84{
+
85 double t0, t1;
+
86
+
87 t0 = omp_get_wtime();
+
88 // Phase transition
+
89 montecarlo::phase_transition(20, 2.1, 2.4, 40, 1e4,
+
90 montecarlo::mcmc_parallel,
+
91 "../output/phase_transition/size_20.txt");
+
92 montecarlo::phase_transition(40, 2.1, 2.4, 40, 1e4,
+
93 montecarlo::mcmc_parallel,
+
94 "../output/phase_transition/size_40.txt");
+
95 montecarlo::phase_transition(60, 2.1, 2.4, 40, 1e4,
+
96 montecarlo::mcmc_parallel,
+
97 "../output/phase_transition/size_60.txt");
+
98 montecarlo::phase_transition(80, 2.1, 2.4, 40, 1e4,
+
99 montecarlo::mcmc_parallel,
+
100 "../output/phase_transition/size_80.txt");
+
101 montecarlo::phase_transition(100, 2.1, 2.4, 40, 1e4,
+
102 montecarlo::mcmc_parallel,
+
103 "../output/phase_transition/size_100.txt");
+
104 t1 = omp_get_wtime();
+
105
+
106 std::cout << "Time: " << t1 - t0 << std::endl;
+
107}
+
108
+
109/** @brief A function that displays how to use the program and quits.*/
+
110void usage(std::string filename)
+
111{
+
112 std::cout << "Usage: " << filename << " OPTION ...\n"
+
113 << "At least one option should be used.\n\n"
+
114 << "\t[ -h | --help ]\n"
+
115 << "\t[ --all ]\n"
+
116 << "\t[ --create-burn-in-data ]\n"
+
117 << "\t[ --create-pd-estimate-data ]\n"
+
118 << "\t[ --create-phase-transition-data ]\n"
+
119 << "\t[ --test-parallel-speedup ]\n"
+
120 << "\t[ --test-burn-in-time ]\n";
+
121 exit(-1);
+
122}
+
123
+
124/** @brief The main function.*/
+
125int main(int argc, char **argv)
+
126{
+
127 static struct option long_options[] = {
+
128 {"all", no_argument, 0, 0},
+
129 {"create-burn-in-data", no_argument, 0, 0},
+
130 {"create-pd-estimate-data", no_argument, 0, 0},
+
131 {"test-parallel-speedup", no_argument, 0, 0},
+
132 {"create-phase-transition-data", no_argument, 0, 0},
+
133 {"test-burn-in-time", no_argument, 0, 0},
+
134 {"help", no_argument, 0, 0}};
+
135
+
136 int option_index = -1;
+
137 int c;
+
138
+
139 while (true) {
+
140 c = getopt_long(argc, argv, "h", long_options, &option_index);
+
141
+
142 if (c == -1)
+
143 break;
+
144 else if (c == 'h')
+
145 usage(argv[0]);
+
146
+
147 switch (option_index) {
+
148 case 0:
+ + + + + +
154 break;
+
155 case 1:
+ +
157 break;
+
158 case 2:
+ +
160 break;
+
161 case 3:
+ +
163 break;
+
164 case 4:
+ +
166 break;
+
167 case 5:
+ +
169 break;
+
170 case 6: // Not a mistake. This just goes to the default.
+
171 default:
+
172 usage(argv[0]);
+
173 }
+
174 }
+
175
+
176 return 0;
+
177}
+
Type to use with the IsingModel class and montecarlo module.
Definition: data_type.hpp:19
+
void test_parallel_speedup()
Test how much Openmp speeds up.
Definition: main.cpp:60
+
int main(int argc, char **argv)
The main function.
Definition: main.cpp:125
+
void create_pd_estimate_data()
Create the data used to estimate the probability distribution for tempratures 1.0 anbd 2....
Definition: main.cpp:37
+
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
+
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
+
void create_phase_transition_data()
Create data for studying phase transition.
Definition: main.cpp:83
+
void usage(std::string filename)
A function that displays how to use the program and quits.
Definition: main.cpp:110
+
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.
+
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.
Definition: monte_carlo.cpp:91
diff --git a/docs/mcmc__progression_8cpp.html b/docs/mcmc__progression_8cpp.html new file mode 100644 index 0000000..af5487d --- /dev/null +++ b/docs/mcmc__progression_8cpp.html @@ -0,0 +1,201 @@ + + + + + + + +2 Dimensional Ising Model: src/mcmc_progression.cpp File Reference + + + + + + + + + + + + + + + + +
+
+ + + + + + +
+
2 Dimensional Ising Model +
+
Simulate the change in energy and magnetization in a ferro magnet
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
mcmc_progression.cpp File Reference
+
+
+ +

Execute the mcmc algorithm and write data to file after each Monte Carlo cycle. +More...

+
#include "data_type.hpp"
+#include "monte_carlo.hpp"
+#include "utils.hpp"
+#include <getopt.h>
+#include <omp.h>
+#include <string>
+
+

Go to the source code of this file.

+ + + + + + + + +

+Functions

void usage (std::string filename)
 A function that displays how to use the program and quits.
 
int main (int argc, char **argv)
 The main function.
 
+

Detailed Description

+

Execute the mcmc algorithm and write data to file after each Monte Carlo cycle.

+
Author
Cory Alexander Balaton (coryab)
+
+Janita Ovidie Sandtrøen Willumsen (janitaws)
+
Version
1.0
+
Bug:
No known bugs
+ +

Definition in file mcmc_progression.cpp.

+

Function Documentation

+ +

◆ main()

+ +
+
+ + + + + + + + + + + + + + + + + + +
int main (int argc,
char ** argv 
)
+
+ +

The main function.

+ +

Definition at line 32 of file mcmc_progression.cpp.

+ +
+
+ +

◆ usage()

+ +
+
+ + + + + + + + +
void usage (std::string filename)
+
+ +

A function that displays how to use the program and quits.

+ +

Definition at line 22 of file mcmc_progression.cpp.

+ +
+
+
+
+ + + + diff --git a/docs/mcmc__progression_8cpp.js b/docs/mcmc__progression_8cpp.js new file mode 100644 index 0000000..4ebaaf6 --- /dev/null +++ b/docs/mcmc__progression_8cpp.js @@ -0,0 +1,5 @@ +var mcmc__progression_8cpp = +[ + [ "main", "mcmc__progression_8cpp.html#a3c04138a5bfe5d72780bb7e82a18e627", null ], + [ "usage", "mcmc__progression_8cpp.html#ac907e18135856c90366aaa599a9e10b1", null ] +]; \ No newline at end of file diff --git a/docs/mcmc__progression_8cpp_source.html b/docs/mcmc__progression_8cpp_source.html new file mode 100644 index 0000000..8ce6821 --- /dev/null +++ b/docs/mcmc__progression_8cpp_source.html @@ -0,0 +1,194 @@ + + + + + + + +2 Dimensional Ising Model: src/mcmc_progression.cpp Source File + + + + + + + + + + + + + + + + +
+
+ + + + + + +
+
2 Dimensional Ising Model +
+
Simulate the change in energy and magnetization in a ferro magnet
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+
mcmc_progression.cpp
+
+
+Go to the documentation of this file.
1/** @file mcmc_progression.cpp
+
2 *
+
3 * @author Cory Alexander Balaton (coryab)
+
4 * @author Janita Ovidie Sandtrøen Willumsen (janitaws)
+
5 *
+
6 * @version 1.0
+
7 *
+
8 * @brief Execute the mcmc algorithm and write data to file after each
+
9 * Monte Carlo cycle.
+
10 *
+
11 * @bug No known bugs
+
12 * */
+
13#include "data_type.hpp"
+
14#include "monte_carlo.hpp"
+
15#include "utils.hpp"
+
16
+
17#include <getopt.h>
+
18#include <omp.h>
+
19#include <string>
+
20
+
21/** @brief A function that displays how to use the program and quits.*/
+
22void usage(std::string filename)
+
23{
+
24 std::cout << "Usage: " << filename
+
25 << " <temperature> <lattice size> "
+
26 "<cycles> <burn-in-time> <output file>\n\n"
+
27 << "\t[ -h | --help ]\n";
+
28 exit(-1);
+
29}
+
30
+
31/** @brief The main function.*/
+
32int main(int argc, char **argv)
+
33{
+
34 // Command options
+
35 struct option long_options[] = {{"help", 0, 0, 0}, {NULL, 0, NULL, 0}};
+
36
+
37 int option_index = -1;
+
38 int c;
+
39
+
40 while (true) {
+
41 c = getopt_long(argc, argv, "h", long_options, &option_index);
+
42
+
43 if (c == -1)
+
44 break;
+
45
+
46 switch (c) {
+
47 case 0:
+
48 switch (option_index) {
+
49 case 0: // Not a mistake. This just goes to the default.
+
50 default:
+
51 usage(argv[0]);
+
52 }
+
53 break;
+
54 case 'h':
+
55 default:
+
56 usage(argv[0]);
+
57 }
+
58 }
+
59 // Check that the number of arguments is at least 8.
+
60 if (argc < 6) {
+
61 usage(argv[0]);
+
62 }
+
63
+
64 // Timing variables
+
65 double t0, t1;
+
66 t0 = omp_get_wtime();
+
67
+
68 // Define/initialize variables
+
69 double temp = atoi(argv[1]);
+
70 int L = atoi(argv[2]), cycles = atoi(argv[3]), burn_in_time = atoi(argv[4]);
+
71 std::string outfile = argv[5];
+
72
+
73 montecarlo::progression(temp, L, cycles, outfile, burn_in_time);
+
74
+
75 t1 = omp_get_wtime();
+
76
+
77 std::cout << "Time: " << t1 - t0 << " seconds\n";
+
78}
+
int main(int argc, char **argv)
The main function.
Definition: main.cpp:125
+
void usage(std::string filename)
A function that displays how to use the program and quits.
Definition: main.cpp:110
+
+
+ + + + diff --git a/docs/menudata.js b/docs/menudata.js index 64b7dfd..3eb3787 100644 --- a/docs/menudata.js +++ b/docs/menudata.js @@ -29,12 +29,33 @@ var menudata={children:[ {text:"Class List",url:"annotated.html"}, {text:"Class Index",url:"classes.html"}, {text:"Class Members",url:"functions.html",children:[ -{text:"All",url:"functions.html"}, +{text:"All",url:"functions.html",children:[ +{text:"d",url:"functions.html#index_d"}, +{text:"e",url:"functions.html#index_e"}, +{text:"i",url:"functions.html#index_i"}, +{text:"l",url:"functions.html#index_l"}, +{text:"m",url:"functions.html#index_m"}, +{text:"n",url:"functions.html#index_n"}, +{text:"o",url:"functions.html#index_o"}, +{text:"t",url:"functions.html#index_t"}]}, {text:"Functions",url:"functions_func.html"}, -{text:"Variables",url:"functions_vars.html"}]}]}, +{text:"Variables",url:"functions_vars.html"}, +{text:"Related Functions",url:"functions_rela.html"}]}]}, {text:"Files",url:"files.html",children:[ {text:"File List",url:"files.html"}, {text:"File Members",url:"globals.html",children:[ -{text:"All",url:"globals.html"}, +{text:"All",url:"globals.html",children:[ +{text:"_",url:"globals.html#index__5F"}, +{text:"a",url:"globals.html#index_a"}, +{text:"c",url:"globals.html#index_c"}, +{text:"d",url:"globals.html#index_d"}, +{text:"e",url:"globals.html#index_e"}, +{text:"i",url:"globals.html#index_i"}, +{text:"l",url:"globals.html#index_l"}, +{text:"m",url:"globals.html#index_m"}, +{text:"r",url:"globals.html#index_r"}, +{text:"t",url:"globals.html#index_t"}, +{text:"u",url:"globals.html#index_u"}, +{text:"x",url:"globals.html#index_x"}]}, {text:"Functions",url:"globals_func.html"}, {text:"Macros",url:"globals_defs.html"}]}]}]} diff --git a/docs/monte__carlo_8cpp.html b/docs/monte__carlo_8cpp.html index f0385af..4676787 100644 --- a/docs/monte__carlo_8cpp.html +++ b/docs/monte__carlo_8cpp.html @@ -107,31 +107,29 @@ $(document).ready(function(){initNavTree('monte__carlo_8cpp.html',''); initResiz

Implementation of the monte carlo functions. More...

#include "monte_carlo.hpp"
-#include <cmath>
-#include <cstdint>

Go to the source code of this file.

- - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + +

Functions

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.
 
void monte_carlo_progression (double T, int L, int cycles, int value, const std::string filename)
 Write the expected values for each Monte Carlo cycles to file.
 
void pd_estimate (double T, int L, int cycles, const std::string filename)
 Estimate the probability distribution for the energy.
 
data_t monte_carlo_serial (int L, double T, int cycles)
 Execute the Metropolis algorithm for a certain amount of Monte Carlo cycles.
 
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.
 
void phase_transition (int L, double start, double end, int points, std::function< data_t(int, double, int)> monte_carlo, std::string outfile)
 Perform the MCMC algorithm using a range of temperatures.
 
void montecarlo::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.
 
void montecarlo::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 montecarlo::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.
 
data_t montecarlo::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.
 
data_t montecarlo::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.
 
void montecarlo::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.
 

Detailed Description

Implementation of the monte carlo functions.

@@ -139,18 +137,18 @@ Functions
Janita Ovidie Sandtrøen Willumsen (janitaws)
Version
1.0
-
Bug:
No known bugs
+
Bug:
No known bugs

Definition in file monte_carlo.cpp.

Function Documentation

- -

◆ monte_carlo_parallel()

+ +

◆ mcmc_parallel()

- + @@ -165,7 +163,13 @@ Janita Ovidie Sandtrøen Willumsen (janitaws) - + + + + + + + @@ -180,24 +184,79 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
data_t monte_carlo_parallel data_t montecarlo::mcmc_parallel ( int  L, int cycles cycles,
int burn_in_time = BURN_IN_TIME 
- + +
LThe size of the lattice
TThe Temperature for the Ising model
cyclesThe amount of Monte Carlo cycles to do
cyclesThe amount of Monte Carlo cycles to do
burn_in_timeThe burn-in time to use
-
Returns
data_t
+
Returns
data_t
-

Definition at line 128 of file monte_carlo.cpp.

+

Definition at line 141 of file monte_carlo.cpp.

- -

◆ monte_carlo_progression() [1/2]

+ +

◆ mcmc_serial()

- + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void monte_carlo_progression data_t montecarlo::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.

+
Parameters
+ + + + + +
LThe size of the lattice
TThe Temperature for the Ising model
cyclesThe amount of Monte Carlo cycles to do
burn_in_timeThe burn-in time to use
+
+
+
Returns
data_t
+ +

Definition at line 122 of file monte_carlo.cpp.

+ +
+
+ +

◆ pd_estimate()

+ +
+
+ + + @@ -218,7 +277,153 @@ Janita Ovidie Sandtrøen Willumsen (janitaws) - + + + + + + + + + + + + + +
void montecarlo::pd_estimate ( double  T, const std::string filename filename,
int burn_in_time = BURN_IN_TIME 
)
+
+ +

Estimate the probability distribution for the energy.

+
Parameters
+ + + + + + +
TThe temperature of the Ising model
LThe size of the lattice
cyclesThe amount of Monte Carlo cycles to do
filenameThe file to write to
burn_in_timeThe burn-in time to use
+
+
+ +

Definition at line 91 of file monte_carlo.cpp.

+ +
+
+ +

◆ phase_transition()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void montecarlo::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.

+
Parameters
+ + + + + + + + +
LThe size of the lattice
start_TThe start temperature
end_TThe end temperature
point_TThe amount of point to measure
monte_carloWhich Monte Carlo implementation to use
outfileThe file to write the data to
burn_in_timeThe burn-in time to use
+
+
+ +

Definition at line 169 of file monte_carlo.cpp.

+ +
+
+ +

◆ progression() [1/2]

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -235,22 +440,23 @@ Janita Ovidie Sandtrøen Willumsen (janitaws) +
void montecarlo::progression (double T,
int L,
int cycles,
const std::string filename,
int burn_in_time = BURN_IN_TIME 
LThe size of the lattice
cyclesThe amount of Monte Carlo cycles to do
filenameThe file to write to
burn_in_timeThe burn-in time to use
-

Definition at line 17 of file monte_carlo.cpp.

+

Definition at line 15 of file monte_carlo.cpp.

- -

◆ monte_carlo_progression() [2/2]

+ +

◆ progression() [2/2]

- + @@ -277,7 +483,13 @@ Janita Ovidie Sandtrøen Willumsen (janitaws) - + + + + + + + @@ -295,178 +507,12 @@ Janita Ovidie Sandtrøen Willumsen (janitaws) +
void monte_carlo_progression void montecarlo::progression ( double  T, const std::string filename filename,
int burn_in_time = BURN_IN_TIME 
cyclesThe amount of Monte Carlo cycles to do
valueThe value to set the elements in the lattice
filenameThe file to write to
burn_in_timeThe burn-in time to use
-

Definition at line 51 of file monte_carlo.cpp.

- -
-
- -

◆ monte_carlo_serial()

- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
data_t monte_carlo_serial (int L,
double T,
int cycles 
)
-
- -

Execute the Metropolis algorithm for a certain amount of Monte Carlo cycles.

-
Parameters
- - - - -
LThe size of the lattice
TThe Temperature for the Ising model
cyclesThe amount of Monte Carlo cycles to do
-
-
-
Returns
data_t
- -

Definition at line 111 of file monte_carlo.cpp.

- -
-
- -

◆ pd_estimate()

- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void pd_estimate (double T,
int L,
int cycles,
const std::string filename 
)
-
- -

Estimate the probability distribution for the energy.

-
Parameters
- - - - - -
TThe temperature of the Ising model
LThe size of the lattice
cyclesThe amount of Monte Carlo cycles to do
filenameThe file to write to
-
-
- -

Definition at line 85 of file monte_carlo.cpp.

- -
-
- -

◆ phase_transition()

- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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.

-
Parameters
- - - - - - - -
LThe size of the lattice
start_TThe start temperature
end_TThe end temperature
point_TThe amount of point to measure
monte_carloWhich Monte Carlo implementation to use
outfileThe file to write the data to
-
-
- -

Definition at line 156 of file monte_carlo.cpp.

+

Definition at line 53 of file monte_carlo.cpp.

diff --git a/docs/monte__carlo_8cpp.js b/docs/monte__carlo_8cpp.js index f43bc7d..aacefc6 100644 --- a/docs/monte__carlo_8cpp.js +++ b/docs/monte__carlo_8cpp.js @@ -1,9 +1,9 @@ var monte__carlo_8cpp = [ - [ "monte_carlo_parallel", "monte__carlo_8cpp.html#acc34e2049a5030874f6f548f3adab958", null ], - [ "monte_carlo_progression", "monte__carlo_8cpp.html#ac97d0de27f2f0d50fc6ecf3a79f32826", null ], - [ "monte_carlo_progression", "monte__carlo_8cpp.html#a89ddd777796c65eb2b289af11fc0ce09", null ], - [ "monte_carlo_serial", "monte__carlo_8cpp.html#a8f8d4c5e032ed8565a3ac518b32c6aed", null ], - [ "pd_estimate", "monte__carlo_8cpp.html#a962f704ab35208bf6541eb3b707a9559", null ], - [ "phase_transition", "monte__carlo_8cpp.html#a7df22ace588b4d229d1029ce766d0009", null ] + [ "mcmc_parallel", "monte__carlo_8cpp.html#ae1e7f904ecfc3d8f3c4dd1ef155dd771", null ], + [ "mcmc_serial", "monte__carlo_8cpp.html#ae67483ff00d1b0594d543261c8283ffd", null ], + [ "pd_estimate", "monte__carlo_8cpp.html#aea2dd1b5fac7c45633bc6f8dc4541226", null ], + [ "phase_transition", "monte__carlo_8cpp.html#a34e9c3e24f26760693266b8a7b6b3d21", null ], + [ "progression", "monte__carlo_8cpp.html#a781d946de16211ba18ad6671a5b6838d", null ], + [ "progression", "monte__carlo_8cpp.html#a1549fc386bd3cdd1cdbe0261b9dd8415", null ] ]; \ No newline at end of file diff --git a/docs/monte__carlo_8cpp_source.html b/docs/monte__carlo_8cpp_source.html index 801427d..cf453d5 100644 --- a/docs/monte__carlo_8cpp_source.html +++ b/docs/monte__carlo_8cpp_source.html @@ -101,191 +101,225 @@ $(document).ready(function(){initNavTree('monte__carlo_8cpp_source.html',''); in
monte_carlo.cpp
-Go to the documentation of this file.
1
-
12#include "monte_carlo.hpp"
+Go to the documentation of this file.
1/** @file monte_carlo.cpp
+
2 *
+
3 * @author Cory Alexander Balaton (coryab)
+
4 * @author Janita Ovidie Sandtrøen Willumsen (janitaws)
+
5 *
+
6 * @version 1.0
+
7 *
+
8 * @brief Implementation of the monte carlo functions
+
9 *
+
10 * @bug No known bugs
+
11 * */
+
12#include "monte_carlo.hpp"
13
-
14#include <cmath>
-
15#include <cstdint>
-
16
-
17void monte_carlo_progression(double T, int L, int cycles,
-
18 const std::string filename)
-
19{
-
20 // Set some variables
-
21 data_t data, tmp;
-
22 int n_spins = L * L;
-
23
-
24 // File stuff
-
25 std::string directory = utils::dirname(filename);
-
26 std::ofstream ofile;
-
27
-
28 // Create random engine using the mersenne twister
-
29 std::random_device rd;
-
30 uint32_t rd_sample = rd();
-
31 std::mt19937 engine(rd_sample);
+
14namespace montecarlo {
+
15void progression(double T, int L, int cycles, const std::string filename,
+
16 int burn_in_time)
+
17{
+
18 // Set some variables
+
19 data_t data, tmp;
+
20 int n_spins = L * L;
+
21
+
22 // File stuff
+
23 std::string directory = utils::dirname(filename);
+
24 std::ofstream ofile;
+
25
+
26 // Create random engine using the mersenne twister
+
27 std::random_device rd;
+
28 uint32_t rd_sample = rd();
+
29 std::mt19937 engine(rd_sample);
+
30
+
31 std::cout << "Seed: " << rd_sample << std::endl;
32
-
33 std::cout << "Seed: " << rd_sample << std::endl;
+
33 IsingModel ising(L, T);
34
-
35 IsingModel ising(L, T);
-
36
-
37 // Create path and open file
-
38 utils::mkpath(directory);
-
39 ofile.open(filename);
-
40
-
41 // Loop through cycles
-
42 for (size_t i = 1; i <= cycles; i++) {
-
43 data += ising.Metropolis();
-
44 tmp = data / (i * n_spins);
-
45 ofile << i << ',' << tmp.E << ',' << tmp.E2 << ',' << tmp.M << ','
-
46 << tmp.M2 << ',' << tmp.M_abs << '\n';
-
47 }
-
48 ofile.close();
-
49}
-
50
-
51void monte_carlo_progression(double T, int L, int cycles, int value,
-
52 const std::string filename)
-
53{
-
54 // Set some variables
-
55 data_t data, tmp;
-
56 int n_spins = L * L;
-
57
-
58 // File stuff
-
59 std::string directory = utils::dirname(filename);
-
60 std::ofstream ofile;
-
61
-
62 // Create random engine using the mersenne twister
-
63 std::random_device rd;
-
64 uint32_t rd_sample = rd();
-
65 std::mt19937 engine(rd());
-
66
-
67 std::cout << "Seed: " << rd_sample << std::endl;
+
35 // Create path and open file
+
36 utils::mkpath(directory);
+
37 ofile.open(filename);
+
38
+
39 for (size_t i = 0; i < burn_in_time; i++) {
+
40 ising.Metropolis();
+
41 }
+
42
+
43 // Loop through cycles
+
44 for (size_t i = 1; i <= cycles; i++) {
+
45 data += ising.Metropolis();
+
46 tmp = data / (i * n_spins);
+
47 ofile << i << ',' << tmp.E << ',' << tmp.E2 << ',' << tmp.M << ','
+
48 << tmp.M2 << ',' << tmp.M_abs << '\n';
+
49 }
+
50 ofile.close();
+
51}
+
52
+
53void progression(double T, int L, int cycles, int value,
+
54 const std::string filename, int burn_in_time)
+
55{
+
56 // Set some variables
+
57 data_t data, tmp;
+
58 int n_spins = L * L;
+
59
+
60 // File stuff
+
61 std::string directory = utils::dirname(filename);
+
62 std::ofstream ofile;
+
63
+
64 // Create random engine using the mersenne twister
+
65 std::random_device rd;
+
66 uint32_t rd_sample = rd();
+
67 std::mt19937 engine(rd());
68
-
69 IsingModel ising(L, T, value);
+
69 std::cout << "Seed: " << rd_sample << std::endl;
70
-
71 // Create path and open file
-
72 utils::mkpath(directory);
-
73 ofile.open(filename);
-
74
-
75 // Loop through cycles
-
76 for (size_t i = 1; i <= cycles; i++) {
-
77 data += ising.Metropolis();
-
78 tmp = data / (i * n_spins);
-
79 ofile << i << ',' << tmp.E << ',' << tmp.E2 << ',' << tmp.M << ','
-
80 << tmp.M2 << ',' << tmp.M_abs << '\n';
-
81 }
-
82 ofile.close();
-
83}
-
84
-
85void pd_estimate(double T, int L, int cycles, const std::string filename)
-
86{
-
87 // Set some variables
-
88 data_t data, tmp;
-
89 int n_spins = L * L;
+
71 IsingModel ising(L, T, value);
+
72
+
73 for (size_t i = 0; i < burn_in_time; i++) {
+
74 ising.Metropolis();
+
75 }
+
76
+
77 // Create path and open file
+
78 utils::mkpath(directory);
+
79 ofile.open(filename);
+
80
+
81 // Loop through cycles
+
82 for (size_t i = 1; i <= cycles; i++) {
+
83 data += ising.Metropolis();
+
84 tmp = data / (i * n_spins);
+
85 ofile << i << ',' << tmp.E << ',' << tmp.E2 << ',' << tmp.M << ','
+
86 << tmp.M2 << ',' << tmp.M_abs << '\n';
+
87 }
+
88 ofile.close();
+
89}
90
-
91 // File stuff
-
92 std::string directory = utils::dirname(filename);
-
93 std::ofstream ofile;
-
94
-
95 IsingModel ising(L, T);
-
96
-
97 // Create path and open file
-
98 utils::mkpath(directory);
-
99 ofile.open(filename);
-
100
-
101 // Loop through cycles
-
102 for (size_t i = 1; i <= cycles; i++) {
-
103 data = ising.Metropolis() / n_spins;
-
104 ofile << data.E << ',' << data.E2 << ',' << data.M << ',' << data.M2
-
105 << ',' << data.M_abs << '\n';
+
91void pd_estimate(double T, int L, int cycles, const std::string filename,
+
92 int burn_in_time)
+
93{
+
94 // Set some variables
+
95 data_t data, tmp;
+
96 int n_spins = L * L;
+
97
+
98 // File stuff
+
99 std::string directory = utils::dirname(filename);
+
100 std::ofstream ofile;
+
101
+
102 IsingModel ising(L, T);
+
103
+
104 for (size_t i = 0; i < burn_in_time; i++) {
+
105 ising.Metropolis();
106 }
-
107 ofile.close();
-
108}
-
109
-
110// Code for seeing phase transitions.
-
111data_t monte_carlo_serial(int L, double T, int cycles)
-
112{
-
113 data_t data;
-
114 IsingModel model(L, T);
-
115
-
116 for (size_t i = 0; i < BURN_IN_TIME; i++) {
-
117 model.Metropolis();
-
118 }
-
119
-
120 double E, M;
-
121 for (size_t i = 0; i < (uint)cycles; i++) {
-
122 data += model.Metropolis();
-
123 }
-
124
-
125 return data;
-
126}
-
127
-
128data_t monte_carlo_parallel(int L, double T, int cycles)
-
129{
-
130 data_t data;
-
131#pragma omp parallel
-
132 {
-
133 // Each thread creates an instance of IsingModel.
-
134 IsingModel model(L, T);
+
107
+
108 // Create path and open file
+
109 utils::mkpath(directory);
+
110 ofile.open(filename);
+
111
+
112 // Loop through cycles
+
113 for (size_t i = 1; i <= cycles; i++) {
+
114 data = ising.Metropolis() / n_spins;
+
115 ofile << data.E << ',' << data.E2 << ',' << data.M << ',' << data.M2
+
116 << ',' << data.M_abs << '\n';
+
117 }
+
118 ofile.close();
+
119}
+
120
+
121// Code for seeing phase transitions.
+
122data_t mcmc_serial(int L, double T, int cycles, int burn_in_time)
+
123{
+
124 data_t data;
+
125 IsingModel model(L, T);
+
126
+
127 for (size_t i = 0; i < burn_in_time; i++) {
+
128 model.Metropolis();
+
129 }
+
130
+
131 double E, M;
+
132 for (size_t i = 0; i < (uint)cycles; i++) {
+
133 data += model.Metropolis();
+
134 }
135
-
136 // Each thread runs the Metropolis algorithm before starting to collect
-
137 // samples
-
138 for (size_t i = 0; i < BURN_IN_TIME; i++) {
-
139 model.Metropolis();
-
140 }
-
141
-
142 // Now each thread work on one loop together, but using their own
-
143 // instances of things, but the total of cycles add up.
-
144 // static ensure that each thread gets the same amount of iterations
-
145#pragma omp for schedule(static) reduction(+ : data)
-
146 for (size_t i = 0; i < (uint)cycles; i++) {
-
147 data += model.Metropolis();
-
148 }
-
149 }
-
150
-
151 double norm = 1. / (double)cycles;
-
152
-
153 return data * norm;
-
154}
-
155
-
156void phase_transition(int L, double start, double end, int points,
-
157 std::function<data_t(int, double, int)> monte_carlo,
-
158 std::string outfile)
-
159{
-
160 double dt = (end - start) / (double)points;
-
161 int cycles = 10000;
-
162 int N = L * L;
-
163 std::ofstream ofile;
-
164
-
165 data_t data;
-
166
-
167 utils::mkpath(utils::dirname(outfile));
-
168 ofile.open(outfile);
-
169
-
170 double temp, CV, X, E_var, M_var;
-
171
-
172 using utils::scientific_format;
-
173 for (size_t i = 0; i < points; i++) {
-
174 temp = start + dt * i;
-
175 data = monte_carlo(L, temp, cycles);
-
176 E_var = (data.E2 - data.E * data.E) / (double)N;
-
177 M_var = (data.M2 - data.M_abs * data.M_abs) / (double)N;
+
136 double norm = 1. / (double)cycles;
+
137
+
138 return data * norm;
+
139}
+
140
+
141data_t mcmc_parallel(int L, double T, int cycles, int burn_in_time)
+
142{
+
143 data_t data;
+
144#pragma omp parallel
+
145 {
+
146 // Each thread creates an instance of IsingModel.
+
147 IsingModel model(L, T);
+
148
+
149 // Each thread runs the Metropolis algorithm before starting to collect
+
150 // samples
+
151 for (size_t i = 0; i < burn_in_time; i++) {
+
152 model.Metropolis();
+
153 }
+
154
+
155 // Now each thread work on one loop together, but using their own
+
156 // instances of things, but the total of cycles add up.
+
157 // static ensure that each thread gets the same amount of iterations
+
158#pragma omp for schedule(static) reduction(+ : data)
+
159 for (size_t i = 0; i < (uint)cycles; i++) {
+
160 data += model.Metropolis();
+
161 }
+
162 }
+
163
+
164 double norm = 1. / (double)cycles;
+
165
+
166 return data * norm;
+
167}
+
168
+
169void phase_transition(int L, double start, double end, int points, int cycles,
+
170 std::function<data_t(int, double, int, int)> monte_carlo,
+
171 std::string outfile, int burn_in_time)
+
172{
+
173 double dt = (end - start) / (double)points;
+
174 int N = L * L;
+
175 std::ofstream ofile;
+
176
+
177 data_t data;
178
-
179 ofile << scientific_format(temp) << ','
-
180 << scientific_format(data.E / (double)N) << ','
-
181 << scientific_format(data.M_abs / N) << ','
-
182 << scientific_format(E_var / (temp * temp)) << ','
-
183 << scientific_format(M_var / temp) << '\n';
-
184 }
-
185 ofile.close();
-
186}
-
The Ising model in 2 dimensions.
Definition: IsingModel.hpp:37
-
data_t Metropolis()
The Metropolis algorithm.
Definition: IsingModel.cpp:96
- -
data_t monte_carlo_serial(int L, double T, int cycles)
Execute the Metropolis algorithm for a certain amount of Monte Carlo cycles.
-
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.
Definition: monte_carlo.cpp:17
-
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.
-
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.
-
void pd_estimate(double T, int L, int cycles, const std::string filename)
Estimate the probability distribution for the energy.
Definition: monte_carlo.cpp:85
+
179 utils::mkpath(utils::dirname(outfile));
+
180 ofile.open(outfile);
+
181
+
182 double temp, CV, X, E_var, M_var;
+
183
+
184 using utils::scientific_format;
+
185 for (size_t i = 0; i < points; i++) {
+
186 temp = start + dt * i;
+
187 data = monte_carlo(L, temp, cycles, burn_in_time);
+
188 E_var = (data.E2 - data.E * data.E) / (double)N;
+
189 M_var = (data.M2 - data.M_abs * data.M_abs) / (double)N;
+
190
+
191 ofile << scientific_format(temp) << ','
+
192 << scientific_format(data.E / (double)N) << ','
+
193 << scientific_format(data.M_abs / N) << ','
+
194 << scientific_format(E_var / (temp * temp)) << ','
+
195 << scientific_format(M_var / temp) << '\n';
+
196 }
+
197 ofile.close();
+
198}
+
199} // namespace montecarlo
+
The Ising model in 2 dimensions.
Definition: IsingModel.hpp:36
+
IsingModel(int L, double T, int val)
Constructor for the Ising model.
Definition: IsingModel.cpp:31
+
IsingModel(int L, double T)
Constructor for the Ising model.
Definition: IsingModel.cpp:19
+
data_t Metropolis()
The Metropolis algorithm.
Definition: IsingModel.cpp:110
+
Type to use with the IsingModel class and montecarlo module.
Definition: data_type.hpp:19
+
double M_abs
Absolute Magnetization.
Definition: data_type.hpp:25
+
double E
Energy.
Definition: data_type.hpp:21
+
data_t & operator+=(const data_t &b)
Overload of the addition equals operator.
Definition: data_type.hpp:150
+
double M2
Magnetization squared.
Definition: data_type.hpp:24
+
double E2
Energy squared.
Definition: data_type.hpp:23
+
double M
Magnetization.
Definition: data_type.hpp:22
+
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
+
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.
Definition: monte_carlo.cpp:15
+
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.
Definition: monte_carlo.cpp:91
+
bool mkpath(std::string path, int mode=0777)
Make path given.
Definition: utils.cpp:32
+
std::string scientific_format(double d, int width=20, int prec=10)
Turns a double into a string written in scientific format.
Definition: utils.cpp:16
+
std::string dirname(const std::string &path)
Get the directory name of the path.
Definition: utils.cpp:58
diff --git a/docs/monte__carlo_8hpp.html b/docs/monte__carlo_8hpp.html index 698a623..8810cbd 100644 --- a/docs/monte__carlo_8hpp.html +++ b/docs/monte__carlo_8hpp.html @@ -105,14 +105,14 @@ $(document).ready(function(){initNavTree('monte__carlo_8hpp.html',''); initResiz
-

Functions for monte carlo simulations. +

Functions for Monte Carlo simulations. More...

#include "IsingModel.hpp"
#include "data_type.hpp"
#include "utils.hpp"
#include <functional>
-#include <string>
#include <omp.h>
+#include <string>

Go to the source code of this file.

@@ -123,35 +123,32 @@ Macros
- - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + +

Functions

int test_2x2_lattice (double tol, int max_cycles)
 Test numerical data with analytical data.
 
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.
 
void monte_carlo_progression (double T, int L, int cycles, int value, const std::string filename)
 Write the expected values for each Monte Carlo cycles to file.
 
void pd_estimate (double T, int L, int cycles, const std::string filename)
 Estimate the probability distribution for the energy.
 
data_t monte_carlo_serial (int L, double T, int cycles)
 Execute the Metropolis algorithm for a certain amount of Monte Carlo cycles.
 
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.
 
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.
 
void montecarlo::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.
 
void montecarlo::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 montecarlo::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.
 
data_t montecarlo::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.
 
data_t montecarlo::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.
 
void montecarlo::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.
 

Detailed Description

-

Functions for monte carlo simulations.

+

Functions for Monte Carlo simulations.

Author
Cory Alexander Balaton (coryab)
Janita Ovidie Sandtrøen Willumsen (janitaws)
Version
1.0
-
Bug:
No known bugs
+
Bug:
No known bugs

Definition in file monte_carlo.hpp.

Macro Definition Documentation

@@ -172,14 +169,14 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)

Function Documentation

- -

◆ monte_carlo_parallel()

+ +

◆ mcmc_parallel()

- + @@ -194,7 +191,13 @@ Janita Ovidie Sandtrøen Willumsen (janitaws) - + + + + + + + @@ -209,24 +212,79 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
data_t monte_carlo_parallel data_t montecarlo::mcmc_parallel ( int  L, int cycles cycles,
int burn_in_time = BURN_IN_TIME 
- + +
LThe size of the lattice
TThe Temperature for the Ising model
cyclesThe amount of Monte Carlo cycles to do
cyclesThe amount of Monte Carlo cycles to do
burn_in_timeThe burn-in time to use
-
Returns
data_t
+
Returns
data_t
-

Definition at line 128 of file monte_carlo.cpp.

+

Definition at line 141 of file monte_carlo.cpp.

- -

◆ monte_carlo_progression() [1/2]

+ +

◆ mcmc_serial()

- + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void monte_carlo_progression data_t montecarlo::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.

+
Parameters
+ + + + + +
LThe size of the lattice
TThe Temperature for the Ising model
cyclesThe amount of Monte Carlo cycles to do
burn_in_timeThe burn-in time to use
+
+
+
Returns
data_t
+ +

Definition at line 122 of file monte_carlo.cpp.

+ +
+
+ +

◆ pd_estimate()

+ +
+
+ + + @@ -247,7 +305,153 @@ Janita Ovidie Sandtrøen Willumsen (janitaws) - + + + + + + + + + + + + + +
void montecarlo::pd_estimate ( double  T, const std::string filename filename,
int burn_in_time = BURN_IN_TIME 
)
+
+ +

Estimate the probability distribution for the energy.

+
Parameters
+ + + + + + +
TThe temperature of the Ising model
LThe size of the lattice
cyclesThe amount of Monte Carlo cycles to do
filenameThe file to write to
burn_in_timeThe burn-in time to use
+
+
+ +

Definition at line 91 of file monte_carlo.cpp.

+ +
+
+ +

◆ phase_transition()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void montecarlo::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.

+
Parameters
+ + + + + + + + +
LThe size of the lattice
start_TThe start temperature
end_TThe end temperature
point_TThe amount of point to measure
monte_carloWhich Monte Carlo implementation to use
outfileThe file to write the data to
burn_in_timeThe burn-in time to use
+
+
+ +

Definition at line 169 of file monte_carlo.cpp.

+ +
+
+ +

◆ progression() [1/2]

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -264,22 +468,23 @@ Janita Ovidie Sandtrøen Willumsen (janitaws) +
void montecarlo::progression (double T,
int L,
int cycles,
const std::string filename,
int burn_in_time = BURN_IN_TIME 
LThe size of the lattice
cyclesThe amount of Monte Carlo cycles to do
filenameThe file to write to
burn_in_timeThe burn-in time to use
-

Definition at line 17 of file monte_carlo.cpp.

+

Definition at line 15 of file monte_carlo.cpp.

- -

◆ monte_carlo_progression() [2/2]

+ +

◆ progression() [2/2]

- + @@ -306,7 +511,13 @@ Janita Ovidie Sandtrøen Willumsen (janitaws) - + + + + + + + @@ -324,216 +535,12 @@ Janita Ovidie Sandtrøen Willumsen (janitaws) +
void monte_carlo_progression void montecarlo::progression ( double  T, const std::string filename filename,
int burn_in_time = BURN_IN_TIME 
cyclesThe amount of Monte Carlo cycles to do
valueThe value to set the elements in the lattice
filenameThe file to write to
burn_in_timeThe burn-in time to use
-

Definition at line 51 of file monte_carlo.cpp.

- -
-
- -

◆ monte_carlo_serial()

- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
data_t monte_carlo_serial (int L,
double T,
int cycles 
)
-
- -

Execute the Metropolis algorithm for a certain amount of Monte Carlo cycles.

-
Parameters
- - - - -
LThe size of the lattice
TThe Temperature for the Ising model
cyclesThe amount of Monte Carlo cycles to do
-
-
-
Returns
data_t
- -

Definition at line 111 of file monte_carlo.cpp.

- -
-
- -

◆ pd_estimate()

- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void pd_estimate (double T,
int L,
int cycles,
const std::string filename 
)
-
- -

Estimate the probability distribution for the energy.

-
Parameters
- - - - - -
TThe temperature of the Ising model
LThe size of the lattice
cyclesThe amount of Monte Carlo cycles to do
filenameThe file to write to
-
-
- -

Definition at line 85 of file monte_carlo.cpp.

- -
-
- -

◆ phase_transition()

- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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.

-
Parameters
- - - - - - - -
LThe size of the lattice
start_TThe start temperature
end_TThe end temperature
point_TThe amount of point to measure
monte_carloWhich Monte Carlo implementation to use
outfileThe file to write the data to
-
-
- -

Definition at line 156 of file monte_carlo.cpp.

- -
-
- -

◆ test_2x2_lattice()

- -
-
- - - - - - - - - - - - - - - - - - -
int test_2x2_lattice (double tol,
int max_cycles 
)
-
- -

Test numerical data with analytical data.

-
Parameters
- - - -
tolThe tolerance between the analytical and numerical solution.
max_cyclesThe max number of Monte Carlo cycles.
-
-
-

return int

+

Definition at line 53 of file monte_carlo.cpp.

diff --git a/docs/monte__carlo_8hpp.js b/docs/monte__carlo_8hpp.js index 800643a..d0e1ec0 100644 --- a/docs/monte__carlo_8hpp.js +++ b/docs/monte__carlo_8hpp.js @@ -1,10 +1,9 @@ var monte__carlo_8hpp = [ - [ "monte_carlo_parallel", "monte__carlo_8hpp.html#acc34e2049a5030874f6f548f3adab958", null ], - [ "monte_carlo_progression", "monte__carlo_8hpp.html#ac97d0de27f2f0d50fc6ecf3a79f32826", null ], - [ "monte_carlo_progression", "monte__carlo_8hpp.html#a89ddd777796c65eb2b289af11fc0ce09", null ], - [ "monte_carlo_serial", "monte__carlo_8hpp.html#a8f8d4c5e032ed8565a3ac518b32c6aed", null ], - [ "pd_estimate", "monte__carlo_8hpp.html#a962f704ab35208bf6541eb3b707a9559", null ], - [ "phase_transition", "monte__carlo_8hpp.html#a2dfe843fbb80e10a763f3260131a148e", null ], - [ "test_2x2_lattice", "monte__carlo_8hpp.html#aa8b4fc86b26f0e3e253ba5556d2d14dc", null ] + [ "mcmc_parallel", "monte__carlo_8hpp.html#ae1e7f904ecfc3d8f3c4dd1ef155dd771", null ], + [ "mcmc_serial", "monte__carlo_8hpp.html#ae67483ff00d1b0594d543261c8283ffd", null ], + [ "pd_estimate", "monte__carlo_8hpp.html#aea2dd1b5fac7c45633bc6f8dc4541226", null ], + [ "phase_transition", "monte__carlo_8hpp.html#a34e9c3e24f26760693266b8a7b6b3d21", null ], + [ "progression", "monte__carlo_8hpp.html#a781d946de16211ba18ad6671a5b6838d", null ], + [ "progression", "monte__carlo_8hpp.html#a1549fc386bd3cdd1cdbe0261b9dd8415", null ] ]; \ No newline at end of file diff --git a/docs/monte__carlo_8hpp_source.html b/docs/monte__carlo_8hpp_source.html index feae31e..b04f385 100644 --- a/docs/monte__carlo_8hpp_source.html +++ b/docs/monte__carlo_8hpp_source.html @@ -101,53 +101,124 @@ $(document).ready(function(){initNavTree('monte__carlo_8hpp_source.html',''); in
monte_carlo.hpp
-Go to the documentation of this file.
1
-
12#ifndef __MONTE_CARLO__
-
13#define __MONTE_CARLO__
+Go to the documentation of this file.
1/** @file monte_carlo.hpp
+
2 *
+
3 * @author Cory Alexander Balaton (coryab)
+
4 * @author Janita Ovidie Sandtrøen Willumsen (janitaws)
+
5 *
+
6 * @version 1.0
+
7 *
+
8 * @brief Functions for Monte Carlo simulations.
+
9 *
+
10 * @bug No known bugs
+
11 * */
+
12#ifndef __MONTE_CARLO__
+
13#define __MONTE_CARLO__
14
-
15#include "IsingModel.hpp"
-
16#include "data_type.hpp"
-
17#include "utils.hpp"
+
15#include "IsingModel.hpp"
+
16#include "data_type.hpp"
+
17#include "utils.hpp"
18
-
19#include <functional>
-
20#include <string>
-
21#include <omp.h>
+
19#include <functional>
+
20#include <omp.h>
+
21#include <string>
22
-
23//#define BURN_IN_TIME 12500
-
24#define BURN_IN_TIME 5000
+
23// #define BURN_IN_TIME 12500
+
24#define BURN_IN_TIME 5000
25
-
26#pragma omp declare reduction(+: data_t: omp_out += omp_in)
-
27
-
35int test_2x2_lattice(double tol, int max_cycles);
-
36
-
44void monte_carlo_progression(double T, int L, int cycles,
-
45 const std::string filename);
-
46
-
55void monte_carlo_progression(double T, int L, int cycles, int value,
-
56 const std::string filename);
-
57
-
65void pd_estimate(double T, int L, int cycles, const std::string filename);
-
66
-
76data_t monte_carlo_serial(int L, double T, int cycles);
-
77
-
87data_t monte_carlo_parallel(int L, double T, int cycles);
-
88
- -
99 int L, double start_T, double end_T, int points_T,
-
100 std::function<data_t(int, double, int)> monte_carlo,
-
101 std::string outfile);
+
26namespace montecarlo {
+
27/** @brief Write the expected values for each Monte Carlo cycles to file.
+
28 *
+
29 * @param T Temperature
+
30 * @param L The size of the lattice
+
31 * @param cycles The amount of Monte Carlo cycles to do
+
32 * @param filename The file to write to
+
33 * @param burn_in_time The burn-in time to use
+
34 * */
+
35void progression(double T, int L, int cycles, const std::string filename,
+
36 int burn_in_time = BURN_IN_TIME);
+
37
+
38/** @brief Write the expected values for each Monte Carlo cycles to file.
+
39 *
+
40 * @param T Temperature
+
41 * @param L The size of the lattice
+
42 * @param cycles The amount of Monte Carlo cycles to do
+
43 * @param value The value to set the elements in the lattice
+
44 * @param filename The file to write to
+
45 * @param burn_in_time The burn-in time to use
+
46 * */
+
47void progression(double T, int L, int cycles, int value,
+
48 const std::string filename, int burn_in_time = BURN_IN_TIME);
+
49
+
50/** @brief Estimate the probability distribution for the energy.
+
51 *
+
52 * @param T The temperature of the Ising model
+
53 * @param L The size of the lattice
+
54 * @param cycles The amount of Monte Carlo cycles to do
+
55 * @param filename The file to write to
+
56 * @param burn_in_time The burn-in time to use
+
57 * */
+
58void pd_estimate(double T, int L, int cycles, const std::string filename,
+
59 int burn_in_time = BURN_IN_TIME);
+
60
+
61/** @brief Execute the Metropolis algorithm for a certain amount of Monte
+
62 * Carlo cycles.
+
63 *
+
64 * @param L The size of the lattice
+
65 * @param T The Temperature for the Ising model
+
66 * @param cycles The amount of Monte Carlo cycles to do
+
67 * @param burn_in_time The burn-in time to use
+
68 *
+
69 * @return data_t
+
70 * */
+
71data_t mcmc_serial(int L, double T, int cycles,
+
72 int burn_in_time = BURN_IN_TIME);
+
73
+
74/** @brief Execute the Metropolis algorithm for a certain amount of Monte
+
75 * Carlo cycles in parallel.
+
76 *
+
77 * @param L The size of the lattice
+
78 * @param T The Temperature for the Ising model
+
79 * @param cycles The amount of Monte Carlo cycles to do
+
80 * @param burn_in_time The burn-in time to use
+
81 *
+
82 * @return data_t
+
83 * */
+
84data_t mcmc_parallel(int L, double T, int cycles,
+
85 int burn_in_time = BURN_IN_TIME);
+
86
+
87/** @brief Perform the MCMC algorithm using a range of temperatures.
+
88 *
+
89 * @param L The size of the lattice
+
90 * @param start_T The start temperature
+
91 * @param end_T The end temperature
+
92 * @param point_T The amount of point to measure
+
93 * @param monte_carlo Which Monte Carlo implementation to use
+
94 * @param outfile The file to write the data to
+
95 * @param burn_in_time The burn-in time to use
+
96 * */
+
97void phase_transition(int L, double start_T, double end_T, int points_T,
+
98 int cycles,
+
99 std::function<data_t(int, double, int, int)> monte_carlo,
+
100 std::string outfile, int burn_in_time = BURN_IN_TIME);
+
101}; // namespace montecarlo
102
-
103#endif
-
The definition of the Ising model.
- -
Header for the data_t type.
-
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.
Definition: monte_carlo.cpp:85
-
int test_2x2_lattice(double tol, int max_cycles)
Test numerical data with analytical data.
-
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.
Definition: monte_carlo.cpp:17
-
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.
-
Function prototypes and macros that are useful.
+
103#endif
+
Type to use with the IsingModel class and montecarlo module.
Definition: data_type.hpp:19
+
void test_parallel_speedup()
Test how much Openmp speeds up.
Definition: main.cpp:60
+
int main(int argc, char **argv)
The main function.
Definition: main.cpp:125
+
void create_pd_estimate_data()
Create the data used to estimate the probability distribution for tempratures 1.0 anbd 2....
Definition: main.cpp:37
+
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
+
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
+
void create_phase_transition_data()
Create data for studying phase transition.
Definition: main.cpp:83
+
void usage(std::string filename)
A function that displays how to use the program and quits.
Definition: main.cpp:110
+
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
+
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.
+
#define BURN_IN_TIME
Definition: monte_carlo.hpp:24
+
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
+
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.
Definition: monte_carlo.cpp:91
diff --git a/docs/namespacedetails.html b/docs/namespacedetails.html new file mode 100644 index 0000000..3275c50 --- /dev/null +++ b/docs/namespacedetails.html @@ -0,0 +1,233 @@ + + + + + + + +2 Dimensional Ising Model: details Namespace Reference + + + + + + + + + + + + + + + + +
+
+ + + + + + +
+
2 Dimensional Ising Model +
+
Simulate the change in energy and magnetization in a ferro magnet
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
details Namespace Reference
+
+
+ + + + + + + + +

+Functions

void m_assert (bool expr, std::string expr_str, std::string func, std::string file, int line, std::string msg)
 Test an expression, confirm that test is ok, or abort execution.
 
std::string methodName (const std::string &pretty_function)
 Takes in the PRETTY_FUNCTION string and removes the return type.
 
+

Function Documentation

+ +

◆ m_assert()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void details::m_assert (bool expr,
std::string expr_str,
std::string func,
std::string file,
int line,
std::string msg 
)
+
+ +

Test an expression, confirm that test is ok, or abort execution.

+

This function takes in an expression and prints an OK message if it's true, or it prints a fail message and aborts execution if it fails.

+
Parameters
+ + + + + + + +
exprThe expression to be evaluated
expr_strThe stringified version of the expression
funcThe function name of the caller
fileThe file of the caller
lineThe line number where this function is called from
msgThe message to be displayed
+
+
+ +

Definition at line 15 of file testlib.cpp.

+ +
+
+ +

◆ methodName()

+ +
+
+ + + + + +
+ + + + + + + + +
std::string details::methodName (const std::string & pretty_function)
+
+inline
+
+ +

Takes in the PRETTY_FUNCTION string and removes the return type.

+

This function should only be used for the METHOD_NAME macro, since it takes the output from PRETTY_FUNCTION and strips the return type.

+
Parameters
+ + +
pretty_functionThe string from PRETTY_FUNCTION
+
+
+
Returns
std::string
+ +

Definition at line 58 of file utils.hpp.

+ +
+
+
+
+ + + + diff --git a/docs/namespacemembers.html b/docs/namespacemembers.html new file mode 100644 index 0000000..7b1cf67 --- /dev/null +++ b/docs/namespacemembers.html @@ -0,0 +1,126 @@ + + + + + + + +2 Dimensional Ising Model: Namespace Members + + + + + + + + + + + + + + + + +
+
+ + + + + + +
+
2 Dimensional Ising Model +
+
Simulate the change in energy and magnetization in a ferro magnet
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+
Here is a list of all namespace members with links to the namespace documentation for each member:
+
+
+ + + + diff --git a/docs/namespacemembers_func.html b/docs/namespacemembers_func.html new file mode 100644 index 0000000..6438db1 --- /dev/null +++ b/docs/namespacemembers_func.html @@ -0,0 +1,126 @@ + + + + + + + +2 Dimensional Ising Model: Namespace Members + + + + + + + + + + + + + + + + +
+
+ + + + + + +
+
2 Dimensional Ising Model +
+
Simulate the change in energy and magnetization in a ferro magnet
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+
+
+ + + + diff --git a/docs/namespacemontecarlo.html b/docs/namespacemontecarlo.html new file mode 100644 index 0000000..3fb63c7 --- /dev/null +++ b/docs/namespacemontecarlo.html @@ -0,0 +1,514 @@ + + + + + + + +2 Dimensional Ising Model: montecarlo Namespace Reference + + + + + + + + + + + + + + + + +
+
+ + + + + + +
+
2 Dimensional Ising Model +
+
Simulate the change in energy and magnetization in a ferro magnet
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
montecarlo Namespace Reference
+
+
+ + + + + + + + + + + + + + + + + + + + +

+Functions

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.
 
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 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.
 
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.
 
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.
 
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.
 
+

Function Documentation

+ +

◆ mcmc_parallel()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
data_t montecarlo::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.

+
Parameters
+ + + + + +
LThe size of the lattice
TThe Temperature for the Ising model
cyclesThe amount of Monte Carlo cycles to do
burn_in_timeThe burn-in time to use
+
+
+
Returns
data_t
+ +

Definition at line 141 of file monte_carlo.cpp.

+ +
+
+ +

◆ mcmc_serial()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
data_t montecarlo::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.

+
Parameters
+ + + + + +
LThe size of the lattice
TThe Temperature for the Ising model
cyclesThe amount of Monte Carlo cycles to do
burn_in_timeThe burn-in time to use
+
+
+
Returns
data_t
+ +

Definition at line 122 of file monte_carlo.cpp.

+ +
+
+ +

◆ pd_estimate()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void montecarlo::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.

+
Parameters
+ + + + + + +
TThe temperature of the Ising model
LThe size of the lattice
cyclesThe amount of Monte Carlo cycles to do
filenameThe file to write to
burn_in_timeThe burn-in time to use
+
+
+ +

Definition at line 91 of file monte_carlo.cpp.

+ +
+
+ +

◆ phase_transition()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void montecarlo::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.

+
Parameters
+ + + + + + + + +
LThe size of the lattice
start_TThe start temperature
end_TThe end temperature
point_TThe amount of point to measure
monte_carloWhich Monte Carlo implementation to use
outfileThe file to write the data to
burn_in_timeThe burn-in time to use
+
+
+ +

Definition at line 169 of file monte_carlo.cpp.

+ +
+
+ +

◆ progression() [1/2]

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void montecarlo::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.

+
Parameters
+ + + + + + +
TTemperature
LThe size of the lattice
cyclesThe amount of Monte Carlo cycles to do
filenameThe file to write to
burn_in_timeThe burn-in time to use
+
+
+ +

Definition at line 15 of file monte_carlo.cpp.

+ +
+
+ +

◆ progression() [2/2]

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void montecarlo::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.

+
Parameters
+ + + + + + + +
TTemperature
LThe size of the lattice
cyclesThe amount of Monte Carlo cycles to do
valueThe value to set the elements in the lattice
filenameThe file to write to
burn_in_timeThe burn-in time to use
+
+
+ +

Definition at line 53 of file monte_carlo.cpp.

+ +
+
+
+
+ + + + diff --git a/docs/namespaces.html b/docs/namespaces.html new file mode 100644 index 0000000..ea7e425 --- /dev/null +++ b/docs/namespaces.html @@ -0,0 +1,121 @@ + + + + + + + +2 Dimensional Ising Model: Namespace List + + + + + + + + + + + + + + + + +
+
+ + + + + + +
+
2 Dimensional Ising Model +
+
Simulate the change in energy and magnetization in a ferro magnet
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+
Namespace List
+
+
+
Here is a list of all namespaces with brief descriptions:
+ + + + + +
 Ndetails
 Nmontecarlo
 Ntestlib
 Nutils
+
+
+
+ + + + diff --git a/docs/namespaces_dup.js b/docs/namespaces_dup.js new file mode 100644 index 0000000..9846fae --- /dev/null +++ b/docs/namespaces_dup.js @@ -0,0 +1,28 @@ +var namespaces_dup = +[ + [ "details", "namespacedetails.html", [ + [ "m_assert", "namespacedetails.html#a39abb7cba0535176ed62aae136d2fcc7", null ], + [ "methodName", "namespacedetails.html#a178c4922157666a6e9c127c2ffd96346", null ] + ] ], + [ "montecarlo", "namespacemontecarlo.html", [ + [ "mcmc_parallel", "namespacemontecarlo.html#ae1e7f904ecfc3d8f3c4dd1ef155dd771", null ], + [ "mcmc_serial", "namespacemontecarlo.html#ae67483ff00d1b0594d543261c8283ffd", null ], + [ "pd_estimate", "namespacemontecarlo.html#aea2dd1b5fac7c45633bc6f8dc4541226", null ], + [ "phase_transition", "namespacemontecarlo.html#a34e9c3e24f26760693266b8a7b6b3d21", null ], + [ "progression", "namespacemontecarlo.html#a781d946de16211ba18ad6671a5b6838d", null ], + [ "progression", "namespacemontecarlo.html#a1549fc386bd3cdd1cdbe0261b9dd8415", null ] + ] ], + [ "testlib", "namespacetestlib.html", [ + [ "assert_each", "namespacetestlib.html#ab6585c8aa8c276a3442c67a57c8de6fb", null ], + [ "close_to", "namespacetestlib.html#a2cbf3a45367e903de6efbdbea3344cea", null ], + [ "close_to", "namespacetestlib.html#a44f47fa3c8654c09712572d75c0ffa7f", null ], + [ "is_equal", "namespacetestlib.html#a3db67d8721d2f3cd626526b43186bcf3", null ] + ] ], + [ "utils", "namespaceutils.html", [ + [ "concatpath", "namespaceutils.html#ae91fad89394d745d544737e43524bde6", null ], + [ "dirname", "namespaceutils.html#aed026119193a9bbe076671809ff0f430", null ], + [ "mkpath", "namespaceutils.html#a2b45adc86b70f42021582994e83fa00d", null ], + [ "scientific_format", "namespaceutils.html#ab3e89176433ddc9ba721b2eba3d08357", null ], + [ "scientific_format", "namespaceutils.html#a3529a74fd2a25d24de73d9d4e1c90835", null ] + ] ] +]; \ No newline at end of file diff --git a/docs/namespacetestlib.html b/docs/namespacetestlib.html new file mode 100644 index 0000000..03e1860 --- /dev/null +++ b/docs/namespacetestlib.html @@ -0,0 +1,354 @@ + + + + + + + +2 Dimensional Ising Model: testlib Namespace Reference + + + + + + + + + + + + + + + + +
+
+ + + + + + +
+
2 Dimensional Ising Model +
+
Simulate the change in energy and magnetization in a ferro magnet
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
testlib Namespace Reference
+
+
+ + + + + + + + + + + + + + + + + + +

+Functions

template<class T , class = typename std::enable_if<std::is_arithmetic<T>::value>::type>
static bool close_to (arma::Mat< T > &a, arma::Mat< T > &b, double tol=1e-8)
 Test if two armadillo matrices/vectors are close to each other.
 
template<class T , class = typename std::enable_if<std::is_arithmetic<T>::value>::type>
static bool close_to (T a, T b, double tol=1e-8)
 Test if two numbers are close to each other.
 
template<class T , class = typename std::enable_if<std::is_integral<T>::value>::type>
static bool is_equal (arma::Mat< T > &a, arma::Mat< T > &b)
 Test if two armadillo matrices/vectors are equal.
 
template<class T , class = typename std::enable_if<std::is_arithmetic<T>::value>::type>
static bool assert_each (std::function< bool(T)> expr, arma::Mat< T > &M)
 Test that all elements fulfill the condition.
 
+

Function Documentation

+ +

◆ assert_each()

+ +
+
+
+template<class T , class = typename std::enable_if<std::is_arithmetic<T>::value>::type>
+ + + + + +
+ + + + + + + + + + + + + + + + + + +
static bool testlib::assert_each (std::function< bool(T)> expr,
arma::Mat< T > & M 
)
+
+static
+
+ +

Test that all elements fulfill the condition.

+
Parameters
+ + + +
exprThe boolean expression to apply to each element
MThe matrix/vector to iterate over
+
+
+
Returns
bool
+ +

Definition at line 130 of file testlib.hpp.

+ +
+
+ +

◆ close_to() [1/2]

+ +
+
+
+template<class T , class = typename std::enable_if<std::is_arithmetic<T>::value>::type>
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
static bool testlib::close_to (arma::Mat< T > & a,
arma::Mat< T > & b,
double tol = 1e-8 
)
+
+static
+
+ +

Test if two armadillo matrices/vectors are close to each other.

+

This function takes in 2 matrices/vectors and checks if they are approximately equal to each other given a tolerance.

+
Parameters
+ + + + +
aMatrix/vector a
bMatrix/vector b
tolThe tolerance
+
+
+
Returns
bool
+ +

Definition at line 67 of file testlib.hpp.

+ +
+
+ +

◆ close_to() [2/2]

+ +
+
+
+template<class T , class = typename std::enable_if<std::is_arithmetic<T>::value>::type>
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
static bool testlib::close_to (a,
b,
double tol = 1e-8 
)
+
+static
+
+ +

Test if two numbers are close to each other.

+

This function takes in 2 matrices/vectors and checks if they are approximately equal to each other given a tolerance.

+
Parameters
+ + + + +
aMatrix/vector a
bMatrix/vector b
tolThe tolerance
+
+
+
Returns
bool
+ +

Definition at line 94 of file testlib.hpp.

+ +
+
+ +

◆ is_equal()

+ +
+
+
+template<class T , class = typename std::enable_if<std::is_integral<T>::value>::type>
+ + + + + +
+ + + + + + + + + + + + + + + + + + +
static bool testlib::is_equal (arma::Mat< T > & a,
arma::Mat< T > & b 
)
+
+static
+
+ +

Test if two armadillo matrices/vectors are equal.

+

This function takes in 2 matrices/vectors and checks if they are equal to each other. This should only be used for integral types.

+
Parameters
+ + + +
aMatrix/vector a
bMatrix/vector b
+
+
+
Returns
bool
+ +

Definition at line 111 of file testlib.hpp.

+ +
+
+
+
+ + + + diff --git a/docs/namespaceutils.html b/docs/namespaceutils.html new file mode 100644 index 0000000..cd3d9b5 --- /dev/null +++ b/docs/namespaceutils.html @@ -0,0 +1,343 @@ + + + + + + + +2 Dimensional Ising Model: utils Namespace Reference + + + + + + + + + + + + + + + + +
+
+ + + + + + +
+
2 Dimensional Ising Model +
+
Simulate the change in energy and magnetization in a ferro magnet
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
utils Namespace Reference
+
+
+ + + + + + + + + + + + + + + + + +

+Functions

std::string scientific_format (double d, int width=20, int prec=10)
 Turns a double into a string written in scientific format.
 
std::string scientific_format (const std::vector< double > &v, int width=20, int prec=10)
 Turns a vector of doubles into a string written in scientific format.
 
bool mkpath (std::string path, int mode=0777)
 Make path given.
 
std::string dirname (const std::string &path)
 Get the directory name of the path.
 
std::string concatpath (const std::string &left, const std::string &right)
 Take 2 strings and concatenate them and make sure there is a directory separator (/) between them.
 
+

Function Documentation

+ +

◆ concatpath()

+ +
+
+ + + + + + + + + + + + + + + + + + +
std::string utils::concatpath (const std::string & left,
const std::string & right 
)
+
+ +

Take 2 strings and concatenate them and make sure there is a directory separator (/) between them.

+

This function doesn't care whether or not the values given as parameters are valid path strings. It is the responsibility of the user to make sure that the values given are valid path strings. The function only guarantees that the output string is a valid path string.

+
Parameters
+ + + +
leftThe left hand side of the result string
rightThe right hand side of the result string
+
+
+
Returns
string
+ +

Definition at line 63 of file utils.cpp.

+ +
+
+ +

◆ dirname()

+ +
+
+ + + + + + + + +
std::string utils::dirname (const std::string & path)
+
+ +

Get the directory name of the path.

+
Parameters
+ + +
pathThe path to use.
+
+
+
Returns
string
+ +

Definition at line 58 of file utils.cpp.

+ +
+
+ +

◆ mkpath()

+ +
+
+ + + + + + + + + + + + + + + + + + +
bool utils::mkpath (std::string path,
int mode = 0777 
)
+
+ +

Make path given.

+

This tries to be the equivalent to "mkdir -p" and creates a new directory whenever it needs to.

+
Parameters
+ + + +
pathThe path to be created
modeThe mode/permissions for all the new directories
+
+
+
Returns
bool Success/Fail
+ +

Definition at line 32 of file utils.cpp.

+ +
+
+ +

◆ scientific_format() [1/2]

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
std::string utils::scientific_format (const std::vector< double > & v,
int width = 20,
int prec = 10 
)
+
+ +

Turns a vector of doubles into a string written in scientific format.

+

The code is stolen from https://github.com/anderkve/FYS3150.

+
Parameters
+ + + + +
vThe vector to stringify
widthThe reserved width of the string
precThe precision of the stringified number
+
+
+
Returns
std::string
+ +

Definition at line 23 of file utils.cpp.

+ +
+
+ +

◆ scientific_format() [2/2]

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
std::string utils::scientific_format (double d,
int width = 20,
int prec = 10 
)
+
+ +

Turns a double into a string written in scientific format.

+

The code is stolen from https://github.com/anderkve/FYS3150.

+
Parameters
+ + + + +
dThe number to stringify
widthThe reserved width of the string
precThe precision of the stringified number
+
+
+
Returns
std::string
+ +

Definition at line 16 of file utils.cpp.

+ +
+
+
+
+ + + + diff --git a/docs/navtreedata.js b/docs/navtreedata.js index 0bae02f..33166f7 100644 --- a/docs/navtreedata.js +++ b/docs/navtreedata.js @@ -33,7 +33,8 @@ var NAVTREE = [ "Class Members", "functions.html", [ [ "All", "functions.html", null ], [ "Functions", "functions_func.html", null ], - [ "Variables", "functions_vars.html", null ] + [ "Variables", "functions_vars.html", null ], + [ "Related Functions", "functions_rela.html", null ] ] ] ] ], [ "Files", "files.html", [ diff --git a/docs/navtreeindex0.js b/docs/navtreeindex0.js index 28a4183..7f2c662 100644 --- a/docs/navtreeindex0.js +++ b/docs/navtreeindex0.js @@ -1,121 +1,170 @@ var NAVTREEINDEX0 = { -"IsingModel_8cpp.html":[3,0,1,2], -"IsingModel_8cpp_source.html":[3,0,1,2], -"IsingModel_8hpp.html":[3,0,0,2], -"IsingModel_8hpp_source.html":[3,0,0,2], +"IsingModel_8cpp.html":[3,0,1,1], +"IsingModel_8cpp_source.html":[3,0,1,1], +"IsingModel_8hpp.html":[3,0,0,1], +"IsingModel_8hpp.html#a1965eaca47dbf3f87acdafc2208f04eb":[3,0,0,1,5], +"IsingModel_8hpp.html#a3039ac753f46401767c38f867787fae6":[3,0,0,1,2], +"IsingModel_8hpp.html#a4193cd1c8c2e6ebd0e056fa2364a663f":[3,0,0,1,1], +"IsingModel_8hpp.html#a437ef08681e7210d6678427030446a54":[3,0,0,1,3], +"IsingModel_8hpp.html#a80fb826a684cf3f0d306b22aa100ddac":[3,0,0,1,4], +"IsingModel_8hpp_source.html":[3,0,0,1], "annotated.html":[2,0], "bug.html":[1], -"burn__in__time_8py_source.html":[3,0,1,0,0], "classIsingModel.html":[2,0,1], -"classIsingModel.html#a0d373a61baca6b0faa607bb12d82cc47":[2,0,1,15], -"classIsingModel.html#a1a4ceb1bb2593dbd20c51ed04100cbcd":[2,0,1,12], -"classIsingModel.html#a20fc4c0c99d8a119f70a1614784d4e5c":[2,0,1,17], -"classIsingModel.html#a2b8ac43baefeb386186266d5aa4de348":[2,0,1,13], -"classIsingModel.html#a2c3c76c79717c968d7c227c58b46df41":[2,0,1,14], -"classIsingModel.html#a34a4710949b4a70f3e37ca223aefcf8a":[2,0,1,7], +"classIsingModel.html#a1bbe0cb10abee98058e7b45b22b9cd0a":[2,0,1,14], +"classIsingModel.html#a1c8a2a4331c7e60c3e1350c0cf8300b9":[2,0,1,12], +"classIsingModel.html#a20fc4c0c99d8a119f70a1614784d4e5c":[2,0,1,19], +"classIsingModel.html#a2b1cf104e0bda1fce78ed366e1ec7287":[2,0,1,11], +"classIsingModel.html#a2b8ac43baefeb386186266d5aa4de348":[2,0,1,15], +"classIsingModel.html#a2c3c76c79717c968d7c227c58b46df41":[2,0,1,16], +"classIsingModel.html#a34a4710949b4a70f3e37ca223aefcf8a":[2,0,1,6], "classIsingModel.html#a46c9446e94854452f715d307c77c1c15":[2,0,1,2], "classIsingModel.html#a4a39ee7fbfbbf566f75bc28900ca9ea5":[2,0,1,1], "classIsingModel.html#a56559d68dc9aaff1976d84b157f43488":[2,0,1,10], -"classIsingModel.html#a59fced38c695e2fa647f53be81b9d2a1":[2,0,1,5], +"classIsingModel.html#a59fced38c695e2fa647f53be81b9d2a1":[2,0,1,3], "classIsingModel.html#a6776109105051597c275670dabd0054a":[2,0,1,9], +"classIsingModel.html#a7112dd6433b1bb9512150cbdc1a0b77e":[2,0,1,13], "classIsingModel.html#a926cf4964d190d2ce23e5a17201787a4":[2,0,1,8], -"classIsingModel.html#a94093aaf30facca62737f2ac381fdbcd":[2,0,1,16], -"classIsingModel.html#aa5701496e6483bc4668c486d6d3af625":[2,0,1,4], -"classIsingModel.html#aaa0787d964b004a17869811a5e947ff5":[2,0,1,3], +"classIsingModel.html#a94093aaf30facca62737f2ac381fdbcd":[2,0,1,18], +"classIsingModel.html#aaedc25b7284e04849269f31291590bf5":[2,0,1,5], +"classIsingModel.html#acc86effd6889bea199a3d70a9f38dc78":[2,0,1,7], "classIsingModel.html#acf281f6f5ed02911ca6ab07004449864":[2,0,1,0], -"classIsingModel.html#ae9f872ca2054992161d53306119979dd":[2,0,1,11], -"classIsingModel.html#aff9a1201933fd5408845a1447e4895b4":[2,0,1,6], +"classIsingModel.html#aef7232b28df08e064ef58eb5ef32f738":[2,0,1,17], +"classIsingModel.html#aff9a1201933fd5408845a1447e4895b4":[2,0,1,4], "classIsingModelTest.html":[2,0,2], "classIsingModelTest.html#a4ace7013fa2d257ad1747961da6bc4de":[2,0,2,0], "classIsingModelTest.html#a717e5852ca51432a61fb6ed38da37931":[2,0,2,1], "classdata__t.html":[2,0,0], +"classdata__t.html#a13bc1d73eadeb39c507e89f5872d726f":[2,0,0,4], +"classdata__t.html#a3f2d19ab309e696ba91a2000479bcb83":[2,0,0,1], +"classdata__t.html#a429a11c53ee7fe08f6a4e75db524521d":[2,0,0,6], +"classdata__t.html#a586475e0f71322dffda2e75f228ab24b":[2,0,0,12], +"classdata__t.html#a6c1a196d96e177b11ca98c61fae35a2e":[2,0,0,8], +"classdata__t.html#a6cb96b4ff750ab29041038ca53f307cb":[2,0,0,5], +"classdata__t.html#a6ddf3a7372730ef2393aee8bbcb34992":[2,0,0,3], +"classdata__t.html#a71ae3cd4460f2c66239500c11804e70b":[2,0,0,11], +"classdata__t.html#a7954efc97086ea50e10c33113b203085":[2,0,0,2], +"classdata__t.html#a88da5be78439fbdecfa473ec007dffd8":[2,0,0,7], +"classdata__t.html#aa2690d3e5d711b4baf3c8f8b9095faf7":[2,0,0,0], +"classdata__t.html#abb622f9c6cc5ffb9dddb151d2e202f72":[2,0,0,9], +"classdata__t.html#ad08d2488bf913c626157471cf6e8a46a":[2,0,0,10], "classes.html":[2,1], -"constants_8hpp.html":[3,0,0,0], -"constants_8hpp.html#abfa7d6668c777f9516606394bbc9c414":[3,0,0,0,0], -"constants_8hpp_source.html":[3,0,0,0], -"data__type_8cpp.html":[3,0,1,1], -"data__type_8cpp_source.html":[3,0,1,1], -"data__type_8hpp.html":[3,0,0,1], -"data__type_8hpp_source.html":[3,0,0,1], -"dir_634e799a3947388232110823971192a8.html":[3,0,1,0], +"data__type_8cpp.html":[3,0,1,0], +"data__type_8cpp_source.html":[3,0,1,0], +"data__type_8hpp.html":[3,0,0,0], +"data__type_8hpp_source.html":[3,0,0,0], "dir_68267d1309a1af8e8297ef4c3efbcdba.html":[3,0,1], "dir_d44c64559bbebec7f509842c48db8b23.html":[3,0,0], "files.html":[3,0], "functions.html":[2,2,0], "functions_func.html":[2,2,1], +"functions_rela.html":[2,2,3], "functions_vars.html":[2,2,2], "globals.html":[3,1,0], "globals_defs.html":[3,1,2], "globals_func.html":[3,1,1], -"index.html":[0], "index.html":[], +"index.html":[0], "index.html#autotoc_md1":[0,0], -"index.html#autotoc_md10":[0,2,1,1], -"index.html#autotoc_md11":[0,2,2], -"index.html#autotoc_md12":[0,3], -"index.html#autotoc_md13":[0,3,0], -"index.html#autotoc_md14":[0,3,1], -"index.html#autotoc_md15":[0,4], +"index.html#autotoc_md10":[0,2,0], +"index.html#autotoc_md11":[0,2,1], +"index.html#autotoc_md12":[0,2,1,0], +"index.html#autotoc_md13":[0,2,1,1], +"index.html#autotoc_md14":[0,2,2], +"index.html#autotoc_md15":[0,3], +"index.html#autotoc_md16":[0,3,0], +"index.html#autotoc_md17":[0,3,1], +"index.html#autotoc_md18":[0,4], "index.html#autotoc_md2":[0,0,0], "index.html#autotoc_md3":[0,0,1], "index.html#autotoc_md4":[0,0,2], "index.html#autotoc_md5":[0,1], -"index.html#autotoc_md6":[0,2], -"index.html#autotoc_md7":[0,2,0], -"index.html#autotoc_md8":[0,2,1], -"index.html#autotoc_md9":[0,2,1,0], -"main_8cpp.html":[3,0,1,3], -"main_8cpp.html#a3c04138a5bfe5d72780bb7e82a18e627":[3,0,1,3,0], -"main_8cpp_source.html":[3,0,1,3], +"index.html#autotoc_md6":[0,1,0], +"index.html#autotoc_md7":[0,1,1], +"index.html#autotoc_md8":[0,1,2], +"index.html#autotoc_md9":[0,2], +"main_8cpp.html":[3,0,1,2], +"main_8cpp.html#a0dfa85080578dffff23b68e372cece95":[3,0,1,2,5], +"main_8cpp.html#a3c04138a5bfe5d72780bb7e82a18e627":[3,0,1,2,3], +"main_8cpp.html#a4f8ea24364d72024915d3753a572cc5b":[3,0,1,2,1], +"main_8cpp.html#a68406fc2dd8de5849c3984658c171f32":[3,0,1,2,0], +"main_8cpp.html#a746d8dc451b2b2536abbb1ff1acaf861":[3,0,1,2,4], +"main_8cpp.html#a9d62cf1399596f4c5a39abdd3196d76d":[3,0,1,2,2], +"main_8cpp.html#ac907e18135856c90366aaa599a9e10b1":[3,0,1,2,6], +"main_8cpp_source.html":[3,0,1,2], +"mcmc__progression_8cpp.html":[3,0,1,3], +"mcmc__progression_8cpp.html#a3c04138a5bfe5d72780bb7e82a18e627":[3,0,1,3,0], +"mcmc__progression_8cpp.html#ac907e18135856c90366aaa599a9e10b1":[3,0,1,3,1], +"mcmc__progression_8cpp_source.html":[3,0,1,3], "monte__carlo_8cpp.html":[3,0,1,4], -"monte__carlo_8cpp.html#a7df22ace588b4d229d1029ce766d0009":[3,0,1,4,5], -"monte__carlo_8cpp.html#a89ddd777796c65eb2b289af11fc0ce09":[3,0,1,4,2], -"monte__carlo_8cpp.html#a8f8d4c5e032ed8565a3ac518b32c6aed":[3,0,1,4,3], -"monte__carlo_8cpp.html#a962f704ab35208bf6541eb3b707a9559":[3,0,1,4,4], -"monte__carlo_8cpp.html#ac97d0de27f2f0d50fc6ecf3a79f32826":[3,0,1,4,1], -"monte__carlo_8cpp.html#acc34e2049a5030874f6f548f3adab958":[3,0,1,4,0], +"monte__carlo_8cpp.html#a1549fc386bd3cdd1cdbe0261b9dd8415":[3,0,1,4,5], +"monte__carlo_8cpp.html#a34e9c3e24f26760693266b8a7b6b3d21":[3,0,1,4,3], +"monte__carlo_8cpp.html#a781d946de16211ba18ad6671a5b6838d":[3,0,1,4,4], +"monte__carlo_8cpp.html#ae1e7f904ecfc3d8f3c4dd1ef155dd771":[3,0,1,4,0], +"monte__carlo_8cpp.html#ae67483ff00d1b0594d543261c8283ffd":[3,0,1,4,1], +"monte__carlo_8cpp.html#aea2dd1b5fac7c45633bc6f8dc4541226":[3,0,1,4,2], "monte__carlo_8cpp_source.html":[3,0,1,4], -"monte__carlo_8hpp.html":[3,0,0,3], -"monte__carlo_8hpp.html#a2dfe843fbb80e10a763f3260131a148e":[3,0,0,3,5], -"monte__carlo_8hpp.html#a89ddd777796c65eb2b289af11fc0ce09":[3,0,0,3,2], -"monte__carlo_8hpp.html#a8f8d4c5e032ed8565a3ac518b32c6aed":[3,0,0,3,3], -"monte__carlo_8hpp.html#a962f704ab35208bf6541eb3b707a9559":[3,0,0,3,4], -"monte__carlo_8hpp.html#aa8b4fc86b26f0e3e253ba5556d2d14dc":[3,0,0,3,6], -"monte__carlo_8hpp.html#ac97d0de27f2f0d50fc6ecf3a79f32826":[3,0,0,3,1], -"monte__carlo_8hpp.html#acc34e2049a5030874f6f548f3adab958":[3,0,0,3,0], -"monte__carlo_8hpp_source.html":[3,0,0,3], +"monte__carlo_8hpp.html":[3,0,0,2], +"monte__carlo_8hpp.html#a1549fc386bd3cdd1cdbe0261b9dd8415":[3,0,0,2,5], +"monte__carlo_8hpp.html#a34e9c3e24f26760693266b8a7b6b3d21":[3,0,0,2,3], +"monte__carlo_8hpp.html#a781d946de16211ba18ad6671a5b6838d":[3,0,0,2,4], +"monte__carlo_8hpp.html#ae1e7f904ecfc3d8f3c4dd1ef155dd771":[3,0,0,2,0], +"monte__carlo_8hpp.html#ae67483ff00d1b0594d543261c8283ffd":[3,0,0,2,1], +"monte__carlo_8hpp.html#aea2dd1b5fac7c45633bc6f8dc4541226":[3,0,0,2,2], +"monte__carlo_8hpp_source.html":[3,0,0,2], "pages.html":[], -"pd__estimate_8py_source.html":[3,0,1,0,1], -"phase__transition_8py_source.html":[3,0,1,0,2], -"phase__transition__mpi_8cpp.html":[3,0,1,5], -"phase__transition__mpi_8cpp.html#a3c04138a5bfe5d72780bb7e82a18e627":[3,0,1,5,0], -"phase__transition__mpi_8cpp_source.html":[3,0,1,5], -"test__suite_8cpp.html":[3,0,1,6], -"test__suite_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4":[3,0,1,6,1], -"test__suite_8cpp_source.html":[3,0,1,6], -"testlib_8cpp.html":[3,0,1,7], -"testlib_8cpp.html#a39abb7cba0535176ed62aae136d2fcc7":[3,0,1,7,0], -"testlib_8cpp_source.html":[3,0,1,7], -"testlib_8hpp.html":[3,0,0,4], -"testlib_8hpp.html#a39abb7cba0535176ed62aae136d2fcc7":[3,0,0,4,1], -"testlib_8hpp.html#a73d4f21ad937dbc50a0c0538c78fd4f9":[3,0,0,4,0], -"testlib_8hpp_source.html":[3,0,0,4], -"typedefs_8hpp.html":[3,0,0,5], -"typedefs_8hpp_source.html":[3,0,0,5], -"utils_8cpp.html":[3,0,1,8], -"utils_8cpp.html#a2b45adc86b70f42021582994e83fa00d":[3,0,1,8,1], -"utils_8cpp.html#a3529a74fd2a25d24de73d9d4e1c90835":[3,0,1,8,3], -"utils_8cpp.html#ab3e89176433ddc9ba721b2eba3d08357":[3,0,1,8,2], -"utils_8cpp.html#aed026119193a9bbe076671809ff0f430":[3,0,1,8,0], -"utils_8cpp_source.html":[3,0,1,8], -"utils_8hpp.html":[3,0,0,6], -"utils_8hpp.html#a178c4922157666a6e9c127c2ffd96346":[3,0,0,6,3], -"utils_8hpp.html#a2b45adc86b70f42021582994e83fa00d":[3,0,0,6,4], -"utils_8hpp.html#a3529a74fd2a25d24de73d9d4e1c90835":[3,0,0,6,6], -"utils_8hpp.html#a60dca3177fb9cb5256609adc7af55168":[3,0,0,6,0], -"utils_8hpp.html#ab3e89176433ddc9ba721b2eba3d08357":[3,0,0,6,5], -"utils_8hpp.html#aecc1f7a8a2493b9e021e5bff76a00a5b":[3,0,0,6,1], -"utils_8hpp.html#aed026119193a9bbe076671809ff0f430":[3,0,0,6,2], -"utils_8hpp_source.html":[3,0,0,6] +"pd__estimate_8cpp.html":[3,0,1,5], +"pd__estimate_8cpp.html#a3c04138a5bfe5d72780bb7e82a18e627":[3,0,1,5,0], +"pd__estimate_8cpp.html#ac907e18135856c90366aaa599a9e10b1":[3,0,1,5,1], +"pd__estimate_8cpp_source.html":[3,0,1,5], +"phase__transition_8cpp.html":[3,0,1,6], +"phase__transition_8cpp.html#a3c04138a5bfe5d72780bb7e82a18e627":[3,0,1,6,0], +"phase__transition_8cpp.html#ac907e18135856c90366aaa599a9e10b1":[3,0,1,6,1], +"phase__transition_8cpp_source.html":[3,0,1,6], +"phase__transition__mpi_8cpp.html":[3,0,1,7], +"phase__transition__mpi_8cpp.html#a3c04138a5bfe5d72780bb7e82a18e627":[3,0,1,7,0], +"phase__transition__mpi_8cpp.html#ac907e18135856c90366aaa599a9e10b1":[3,0,1,7,1], +"phase__transition__mpi_8cpp_source.html":[3,0,1,7], +"test__suite_8cpp.html":[3,0,1,8], +"test__suite_8cpp.html#a00367775d110a9537bd06bde2e630471":[3,0,1,8,2], +"test__suite_8cpp.html#a9fd092d930430eb4693d93e0c9066605":[3,0,1,8,3], +"test__suite_8cpp.html#ad27c84dda71475ffd365c649b525199e":[3,0,1,8,4], +"test__suite_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4":[3,0,1,8,5], +"test__suite_8cpp.html#af02dd88b4d495baf7af5826d1481634c":[3,0,1,8,1], +"test__suite_8cpp_source.html":[3,0,1,8], +"testlib_8cpp.html":[3,0,1,9], +"testlib_8cpp.html#a39abb7cba0535176ed62aae136d2fcc7":[3,0,1,9,0], +"testlib_8cpp_source.html":[3,0,1,9], +"testlib_8hpp.html":[3,0,0,3], +"testlib_8hpp.html#a2cbf3a45367e903de6efbdbea3344cea":[3,0,0,3,2], +"testlib_8hpp.html#a39abb7cba0535176ed62aae136d2fcc7":[3,0,0,3,5], +"testlib_8hpp.html#a3db67d8721d2f3cd626526b43186bcf3":[3,0,0,3,4], +"testlib_8hpp.html#a44f47fa3c8654c09712572d75c0ffa7f":[3,0,0,3,3], +"testlib_8hpp.html#a73d4f21ad937dbc50a0c0538c78fd4f9":[3,0,0,3,0], +"testlib_8hpp.html#ab6585c8aa8c276a3442c67a57c8de6fb":[3,0,0,3,1], +"testlib_8hpp_source.html":[3,0,0,3], +"time_8cpp.html":[3,0,1,10], +"time_8cpp.html#a3c04138a5bfe5d72780bb7e82a18e627":[3,0,1,10,0], +"time_8cpp.html#aa224066f42c47cae5fbd457c1948e4a5":[3,0,1,10,1], +"time_8cpp.html#ac907e18135856c90366aaa599a9e10b1":[3,0,1,10,3], +"time_8cpp.html#ace9eb0821fe4edf19cf2e7d8ffe6efb4":[3,0,1,10,2], +"time_8cpp_source.html":[3,0,1,10], +"utils_8cpp.html":[3,0,1,11], +"utils_8cpp.html#a2b45adc86b70f42021582994e83fa00d":[3,0,1,11,2], +"utils_8cpp.html#a3529a74fd2a25d24de73d9d4e1c90835":[3,0,1,11,4], +"utils_8cpp.html#ab3e89176433ddc9ba721b2eba3d08357":[3,0,1,11,3], +"utils_8cpp.html#ae91fad89394d745d544737e43524bde6":[3,0,1,11,0], +"utils_8cpp.html#aed026119193a9bbe076671809ff0f430":[3,0,1,11,1], +"utils_8cpp_source.html":[3,0,1,11], +"utils_8hpp.html":[3,0,0,4], +"utils_8hpp.html#a178c4922157666a6e9c127c2ffd96346":[3,0,0,4,4], +"utils_8hpp.html#a2b45adc86b70f42021582994e83fa00d":[3,0,0,4,5], +"utils_8hpp.html#a3529a74fd2a25d24de73d9d4e1c90835":[3,0,0,4,7], +"utils_8hpp.html#a60dca3177fb9cb5256609adc7af55168":[3,0,0,4,0], +"utils_8hpp.html#ab3e89176433ddc9ba721b2eba3d08357":[3,0,0,4,6], +"utils_8hpp.html#ae91fad89394d745d544737e43524bde6":[3,0,0,4,2], +"utils_8hpp.html#aecc1f7a8a2493b9e021e5bff76a00a5b":[3,0,0,4,1], +"utils_8hpp.html#aed026119193a9bbe076671809ff0f430":[3,0,0,4,3], +"utils_8hpp_source.html":[3,0,0,4] }; diff --git a/docs/pd__estimate_8cpp.html b/docs/pd__estimate_8cpp.html new file mode 100644 index 0000000..8d8fc1a --- /dev/null +++ b/docs/pd__estimate_8cpp.html @@ -0,0 +1,201 @@ + + + + + + + +2 Dimensional Ising Model: src/pd_estimate.cpp File Reference + + + + + + + + + + + + + + + + +
+
+ + + + + + +
+
2 Dimensional Ising Model +
+
Simulate the change in energy and magnetization in a ferro magnet
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
pd_estimate.cpp File Reference
+
+
+ +

execute the mcmc algorithm and write data to file after each Monte Carlo cycles. +More...

+
#include "data_type.hpp"
+#include "monte_carlo.hpp"
+#include "utils.hpp"
+#include <getopt.h>
+#include <omp.h>
+#include <string>
+
+

Go to the source code of this file.

+ + + + + + + + +

+Functions

void usage (std::string filename)
 A function that displays how to use the program and quits.
 
int main (int argc, char **argv)
 The main function.
 
+

Detailed Description

+

execute the mcmc algorithm and write data to file after each Monte Carlo cycles.

+
Author
Cory Alexander Balaton (coryab)
+
+Janita Ovidie Sandtrøen Willumsen (janitaws)
+
Version
1.0
+
Bug:
No known bugs
+ +

Definition in file pd_estimate.cpp.

+

Function Documentation

+ +

◆ main()

+ +
+
+ + + + + + + + + + + + + + + + + + +
int main (int argc,
char ** argv 
)
+
+ +

The main function.

+ +

Definition at line 34 of file pd_estimate.cpp.

+ +
+
+ +

◆ usage()

+ +
+
+ + + + + + + + +
void usage (std::string filename)
+
+ +

A function that displays how to use the program and quits.

+ +

Definition at line 22 of file pd_estimate.cpp.

+ +
+
+
+
+ + + + diff --git a/docs/pd__estimate_8cpp.js b/docs/pd__estimate_8cpp.js new file mode 100644 index 0000000..671e358 --- /dev/null +++ b/docs/pd__estimate_8cpp.js @@ -0,0 +1,5 @@ +var pd__estimate_8cpp = +[ + [ "main", "pd__estimate_8cpp.html#a3c04138a5bfe5d72780bb7e82a18e627", null ], + [ "usage", "pd__estimate_8cpp.html#ac907e18135856c90366aaa599a9e10b1", null ] +]; \ No newline at end of file diff --git a/docs/pd__estimate_8cpp_source.html b/docs/pd__estimate_8cpp_source.html new file mode 100644 index 0000000..7885bae --- /dev/null +++ b/docs/pd__estimate_8cpp_source.html @@ -0,0 +1,197 @@ + + + + + + + +2 Dimensional Ising Model: src/pd_estimate.cpp Source File + + + + + + + + + + + + + + + + +
+
+ + + + + + +
+
2 Dimensional Ising Model +
+
Simulate the change in energy and magnetization in a ferro magnet
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+
pd_estimate.cpp
+
+
+Go to the documentation of this file.
1/** @file pd_estimate.cpp
+
2 *
+
3 * @author Cory Alexander Balaton (coryab)
+
4 * @author Janita Ovidie Sandtrøen Willumsen (janitaws)
+
5 *
+
6 * @version 1.0
+
7 *
+
8 * @brief execute the mcmc algorithm and write data to file after each
+
9 * Monte Carlo cycles.
+
10 *
+
11 * @bug No known bugs
+
12 * */
+
13#include "data_type.hpp"
+
14#include "monte_carlo.hpp"
+
15#include "utils.hpp"
+
16
+
17#include <getopt.h>
+
18#include <omp.h>
+
19#include <string>
+
20
+
21/** @brief A function that displays how to use the program and quits.*/
+
22void usage(std::string filename)
+
23{
+
24 std::cout << "Usage: " << filename
+
25 << " <temperature> <lattice size> "
+
26 "<cycles> <burn-in-time> <output file>\n\n"
+
27 << "\t[ -h | --help ]\n";
+
28 exit(-1);
+
29}
+
30
+
31/** @brief The main function
+
32 *
+
33 * */
+
34int main(int argc, char **argv)
+
35{
+
36 // Command options
+
37 struct option long_options[] = {{"help", 0, 0, 0}, {NULL, 0, NULL, 0}};
+
38
+
39 int option_index = -1;
+
40 int c;
+
41
+
42 while (true) {
+
43 c = getopt_long(argc, argv, "h", long_options, &option_index);
+
44
+
45 if (c == -1)
+
46 break;
+
47
+
48 switch (c) {
+
49 case 0:
+
50 switch (option_index) {
+
51 case 0: // Not a mistake. This just goes to the default.
+
52 default:
+
53 usage(argv[0]);
+
54 }
+
55 break;
+
56 case 'h':
+
57 default:
+
58 usage(argv[0]);
+
59 }
+
60 }
+
61 // Check that the number of arguments is at least 8.
+
62 if (argc < 6) {
+
63 usage(argv[0]);
+
64 }
+
65
+
66 // Timing variables
+
67 double t0, t1;
+
68 t0 = omp_get_wtime();
+
69
+
70 // Define/initialize variables
+
71 double temp = atoi(argv[1]);
+
72 int L = atoi(argv[2]), cycles = atoi(argv[3]), burn_in_time = atoi(argv[4]);
+
73 std::string outfile = argv[5];
+
74
+
75 montecarlo::pd_estimate(temp, L, cycles, outfile, burn_in_time);
+
76
+
77 t1 = omp_get_wtime();
+
78
+
79 std::cout << "Time: " << t1 - t0 << " seconds\n";
+
80}
+
int main(int argc, char **argv)
The main function.
Definition: main.cpp:125
+
void usage(std::string filename)
A function that displays how to use the program and quits.
Definition: main.cpp:110
+
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
+
+
+ + + + diff --git a/docs/phase__transition_8cpp.html b/docs/phase__transition_8cpp.html new file mode 100644 index 0000000..bcd1725 --- /dev/null +++ b/docs/phase__transition_8cpp.html @@ -0,0 +1,202 @@ + + + + + + + +2 Dimensional Ising Model: src/phase_transition.cpp File Reference + + + + + + + + + + + + + + + + +
+
+ + + + + + +
+
2 Dimensional Ising Model +
+
Simulate the change in energy and magnetization in a ferro magnet
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
phase_transition.cpp File Reference
+
+
+ +

Sweep over different temperatures and generate data. +More...

+
#include "data_type.hpp"
+#include "monte_carlo.hpp"
+#include "utils.hpp"
+#include <getopt.h>
+#include <omp.h>
+#include <string>
+
+

Go to the source code of this file.

+ + + + + + + + +

+Functions

void usage (std::string filename)
 A function that displays how to use the program and quits.
 
int main (int argc, char **argv)
 The main function.
 
+

Detailed Description

+

Sweep over different temperatures and generate data.

+
Author
Cory Alexander Balaton (coryab)
+
+Janita Ovidie Sandtrøen Willumsen (janitaws)
+
Version
1.0
+

This program takes in 4 arguments: the start temperature, the end temperature, the amount of temperature points to simulate, and the amount of monte carlo samples to collect, in that order.

+
Bug:
No known bugs
+ +

Definition in file phase_transition.cpp.

+

Function Documentation

+ +

◆ main()

+ +
+
+ + + + + + + + + + + + + + + + + + +
int main (int argc,
char ** argv 
)
+
+ +

The main function.

+ +

Definition at line 35 of file phase_transition.cpp.

+ +
+
+ +

◆ usage()

+ +
+
+ + + + + + + + +
void usage (std::string filename)
+
+ +

A function that displays how to use the program and quits.

+ +

Definition at line 25 of file phase_transition.cpp.

+ +
+
+
+
+ + + + diff --git a/docs/phase__transition_8cpp.js b/docs/phase__transition_8cpp.js new file mode 100644 index 0000000..01d6bc9 --- /dev/null +++ b/docs/phase__transition_8cpp.js @@ -0,0 +1,5 @@ +var phase__transition_8cpp = +[ + [ "main", "phase__transition_8cpp.html#a3c04138a5bfe5d72780bb7e82a18e627", null ], + [ "usage", "phase__transition_8cpp.html#ac907e18135856c90366aaa599a9e10b1", null ] +]; \ No newline at end of file diff --git a/docs/phase__transition_8cpp_source.html b/docs/phase__transition_8cpp_source.html new file mode 100644 index 0000000..c233f9f --- /dev/null +++ b/docs/phase__transition_8cpp_source.html @@ -0,0 +1,201 @@ + + + + + + + +2 Dimensional Ising Model: src/phase_transition.cpp Source File + + + + + + + + + + + + + + + + +
+
+ + + + + + +
+
2 Dimensional Ising Model +
+
Simulate the change in energy and magnetization in a ferro magnet
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+
phase_transition.cpp
+
+
+Go to the documentation of this file.
1/** @file phase_transition.cpp
+
2 *
+
3 * @author Cory Alexander Balaton (coryab)
+
4 * @author Janita Ovidie Sandtrøen Willumsen (janitaws)
+
5 *
+
6 * @version 1.0
+
7 *
+
8 * @brief Sweep over different temperatures and generate data.
+
9 *
+
10 * @details This program takes in 4 arguments: the start temperature,
+
11 * the end temperature, the amount of temperature points to simulate, and
+
12 * the amount of monte carlo samples to collect, in that order.
+
13 *
+
14 * @bug No known bugs
+
15 * */
+
16#include "data_type.hpp"
+
17#include "monte_carlo.hpp"
+
18#include "utils.hpp"
+
19
+
20#include <getopt.h>
+
21#include <omp.h>
+
22#include <string>
+
23
+
24/** @brief A function that displays how to use the program and quits.*/
+
25void usage(std::string filename)
+
26{
+
27 std::cout << "Usage: " << filename
+
28 << " <start temperature> <end temperature> <points> "
+
29 "<lattice size> <cycles> <burn-in-time> <output file>\n\n"
+
30 << "\t[ -h | --help ]\n";
+
31 exit(-1);
+
32}
+
33
+
34/** @brief The main function.*/
+
35int main(int argc, char **argv)
+
36{
+
37 // Command options
+
38 struct option long_options[] = {{"help", 0, 0, 0}, {NULL, 0, NULL, 0}};
+
39
+
40 int option_index = -1;
+
41 int c;
+
42
+
43 while (true) {
+
44 c = getopt_long(argc, argv, "h", long_options, &option_index);
+
45
+
46 if (c == -1)
+
47 break;
+
48
+
49 switch (c) {
+
50 case 0:
+
51 switch (option_index) {
+
52 case 0: // Not a mistake. This just goes to the default.
+
53 default:
+
54 usage(argv[0]);
+
55 }
+
56 break;
+
57 case 'h':
+
58 default:
+
59 usage(argv[0]);
+
60 }
+
61 }
+
62 // Check that the number of arguments is at least 8.
+
63 if (argc < 8) {
+
64 usage(argv[0]);
+
65 }
+
66
+
67 // Timing variables
+
68 double t0, t1;
+
69 t0 = omp_get_wtime();
+
70
+
71 // Define/initialize variables
+
72 double start = atof(argv[1]), end = atof(argv[2]);
+
73 int points = atoi(argv[3]), cycles = atoi(argv[5]), L = atoi(argv[4]),
+
74 burn_in_time = atoi(argv[6]), N = L * L;
+
75 std::string outfile = argv[7];
+
76
+
77 montecarlo::phase_transition(L, start, end, points, cycles,
+
78 montecarlo::mcmc_parallel, outfile, burn_in_time);
+
79
+
80 t1 = omp_get_wtime();
+
81
+
82 std::cout << "Time: " << t1 - t0 << " seconds\n";
+
83}
+
int main(int argc, char **argv)
The main function.
Definition: main.cpp:125
+
void usage(std::string filename)
A function that displays how to use the program and quits.
Definition: main.cpp:110
+
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.
+
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.
+
+
+ + + + diff --git a/docs/phase__transition__mpi_8cpp.html b/docs/phase__transition__mpi_8cpp.html index 0e88ed6..8966e3d 100644 --- a/docs/phase__transition__mpi_8cpp.html +++ b/docs/phase__transition__mpi_8cpp.html @@ -109,17 +109,17 @@ $(document).ready(function(){initNavTree('phase__transition__mpi_8cpp.html','');
#include "data_type.hpp"
#include "monte_carlo.hpp"
#include "utils.hpp"
-#include <algorithm>
-#include <fstream>
-#include <iostream>
-#include <iterator>
+#include <getopt.h>
#include <mpi.h>
-#include <sstream>
+#include <string>

Go to the source code of this file.

+ + + @@ -130,6 +130,7 @@ Functions
Janita Ovidie Sandtrøen Willumsen (janitaws)
Version
1.0
+

This program takes in 4 arguments: the start temperature, the end temperature, the amount of temperature points to simulate, and the amount of monte carlo samples to collect, in that order.

Bug:
No known bugs

Definition in file phase_transition_mpi.cpp.

@@ -162,7 +163,29 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)

The main function.

-

Definition at line 24 of file phase_transition_mpi.cpp.

+

Definition at line 38 of file phase_transition_mpi.cpp.

+ + + + +

◆ usage()

+ +
+
+

Functions

void usage (std::string filename)
 A function that displays how to use the program and quits.
 
int main (int argc, char **argv)
 The main function.
 
+ + + + + + + +
void usage (std::string filename)
+
+ +

A function that displays how to use the program and quits.

+ +

Definition at line 25 of file phase_transition_mpi.cpp.

diff --git a/docs/phase__transition__mpi_8cpp.js b/docs/phase__transition__mpi_8cpp.js index 9cad85a..40c7698 100644 --- a/docs/phase__transition__mpi_8cpp.js +++ b/docs/phase__transition__mpi_8cpp.js @@ -1,4 +1,5 @@ var phase__transition__mpi_8cpp = [ - [ "main", "phase__transition__mpi_8cpp.html#a3c04138a5bfe5d72780bb7e82a18e627", null ] + [ "main", "phase__transition__mpi_8cpp.html#a3c04138a5bfe5d72780bb7e82a18e627", null ], + [ "usage", "phase__transition__mpi_8cpp.html#ac907e18135856c90366aaa599a9e10b1", null ] ]; \ No newline at end of file diff --git a/docs/phase__transition__mpi_8cpp_source.html b/docs/phase__transition__mpi_8cpp_source.html index 0be9b13..f608f12 100644 --- a/docs/phase__transition__mpi_8cpp_source.html +++ b/docs/phase__transition__mpi_8cpp_source.html @@ -101,129 +101,188 @@ $(document).ready(function(){initNavTree('phase__transition__mpi_8cpp_source.htm
phase_transition_mpi.cpp
-Go to the documentation of this file.
1
-
12#include "data_type.hpp"
-
13#include "monte_carlo.hpp"
-
14#include "utils.hpp"
-
15
-
16#include <algorithm>
-
17#include <fstream>
-
18#include <iostream>
-
19#include <iterator>
-
20#include <mpi.h>
-
21#include <sstream>
-
22
-
24int main(int argc, char **argv)
-
25{
-
26 if (argc < 5) {
-
27 std::cout << "You need at least 4 arguments" << std::endl;
-
28 abort();
-
29 }
-
30 double t0, t1;
-
31 t0 = MPI_Wtime();
-
32 double start = atof(argv[1]), end = atof(argv[2]);
-
33 int points = atoi(argv[3]), N;
-
34 int lattice_sizes[] = {20, 40, 60, 80, 100};
-
35 double dt = (end - start) / points;
-
36 int cycles = atoi(argv[4]);
-
37 std::ofstream ofile;
-
38
-
39 data_t data[points];
-
40
-
41 // MPI stuff
-
42 int rank, cluster_size;
-
43
-
44 // Initialize MPI
-
45 MPI_Init(&argc, &argv);
-
46
-
47 // Get the cluster size and rank
-
48 MPI_Comm_size(MPI_COMM_WORLD, &cluster_size);
-
49 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
-
50
-
51 int remainder = points % cluster_size;
-
52 double i_start;
-
53 int i_points;
-
54 // Distribute temperature points
-
55 if (rank < remainder) {
-
56 i_points = points / cluster_size + 1;
-
57 i_start = start + dt * i_points * rank;
-
58 }
-
59 else {
-
60 i_points = points / cluster_size;
-
61 i_start = start + dt * (i_points * rank + remainder);
-
62 }
-
63
-
64 data_t i_data[i_points];
-
65 std::cout << "Rank " << rank << ": " << i_points << ',' << i_start << '\n';
-
66
-
67 for (int L : lattice_sizes) {
-
68 N = L * L;
-
69 for (size_t i = 0; i < i_points; i++) {
-
70 i_data[i] = monte_carlo_parallel(L, i_start + dt * i, cycles);
-
71 }
-
72
-
73 if (rank == 0) {
-
74 std::copy_n(i_data, i_points, data);
-
75 for (size_t i = 1; i < cluster_size; i++) {
-
76 if (rank < remainder) {
-
77 MPI_Recv((void *)i_data,
-
78 sizeof(data_t) * (points / cluster_size + 1),
-
79 MPI_CHAR, i, MPI_ANY_TAG, MPI_COMM_WORLD,
-
80 MPI_STATUS_IGNORE);
-
81 std::copy_n(i_data, points / cluster_size + 1,
-
82 data + (points / cluster_size) * i);
-
83 }
-
84 else {
-
85 MPI_Recv((void *)i_data,
-
86 sizeof(data_t) * (points / cluster_size), MPI_CHAR,
-
87 i, MPI_ANY_TAG, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
-
88 std::copy_n(i_data, points / cluster_size,
-
89 data + (points / cluster_size) * i + remainder);
-
90 }
-
91 }
-
92 std::stringstream outfile;
-
93 outfile << "output/phase_transition/size_" << L << ".txt";
-
94 utils::mkpath(utils::dirname(outfile.str()));
-
95 ofile.open(outfile.str());
+Go to the documentation of this file.
1/** @file phase_transition_mpi.cpp
+
2 *
+
3 * @author Cory Alexander Balaton (coryab)
+
4 * @author Janita Ovidie Sandtrøen Willumsen (janitaws)
+
5 *
+
6 * @version 1.0
+
7 *
+
8 * @brief Sweep over different temperatures and generate data.
+
9 *
+
10 * @details This program takes in 4 arguments: the start temperature,
+
11 * the end temperature, the amount of temperature points to simulate, and
+
12 * the amount of monte carlo samples to collect, in that order.
+
13 *
+
14 * @bug No known bugs
+
15 * */
+
16#include "data_type.hpp"
+
17#include "monte_carlo.hpp"
+
18#include "utils.hpp"
+
19
+
20#include <getopt.h>
+
21#include <mpi.h>
+
22#include <string>
+
23
+
24/** @brief A function that displays how to use the program and quits.*/
+
25void usage(std::string filename)
+
26{
+
27 std::cout
+
28 << "Usage: " << filename
+
29 << " <start temperature> <end temperature> <lattice size> "
+
30 "<points> <cycles> <burn-in-time> <output file>\n"
+
31 << "This should be used with mpiexec or mpirun for maximum "
+
32 "performance\n\n"
+
33 << "\t[ -h | --help ]\n";
+
34 exit(-1);
+
35}
+
36
+
37/** @brief The main function.*/
+
38int main(int argc, char **argv)
+
39{
+
40 // Command options
+
41 struct option long_options[] = {{"help", 0, 0, 0}, {NULL, 0, NULL, 0}};
+
42
+
43 int option_index = -1;
+
44 int c;
+
45
+
46 while (true) {
+
47 c = getopt_long(argc, argv, "h", long_options, &option_index);
+
48
+
49 if (c == -1)
+
50 break;
+
51
+
52 switch (c) {
+
53 case 0:
+
54 switch (option_index) {
+
55 case 0: // Not a mistake. This just goes to the default.
+
56 default:
+
57 usage(argv[0]);
+
58 }
+
59 break;
+
60 case 'h':
+
61 default:
+
62 usage(argv[0]);
+
63 }
+
64 }
+
65 // Check that the number of arguments is at least 8.
+
66 if (argc < 8) {
+
67 usage(argv[0]);
+
68 }
+
69
+
70 // Timing variables
+
71 double t0, t1;
+
72 t0 = MPI_Wtime();
+
73
+
74 // Define/initialize variables
+
75 double start = atof(argv[1]), end = atof(argv[2]);
+
76 int points = atoi(argv[3]), cycles = atoi(argv[5]), L = atoi(argv[4]),
+
77 burn_in_time = atoi(argv[6]), N = L * L;
+
78 double dt = (end - start) / points;
+
79 std::ofstream ofile;
+
80 std::string outfile = argv[7];
+
81 data_t data[points];
+
82
+
83 // MPI specific variables
+
84 int rank, cluster_size;
+
85
+
86 // Initialize MPI
+
87 MPI_Init(&argc, &argv);
+
88
+
89 // Get the cluster size and rank
+
90 MPI_Comm_size(MPI_COMM_WORLD, &cluster_size);
+
91 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+
92
+
93 int remainder = points % cluster_size;
+
94 double i_start; // What temperature to start from
+
95 int i_points; // How many points to simulate
96
-
97 double temp, CV, X;
-
98
-
99 using utils::scientific_format;
-
100 for (size_t i = 0; i < points; i++) {
-
101 temp = start + dt * i;
-
102 CV = (data[i].E2 - data[i].E * data[i].E)
-
103 / ((double)N * temp * temp);
-
104 X = (data[i].M2 - data[i].M_abs * data[i].M_abs)
-
105 / ((double)N * temp);
+
97 // Distribute temperature points
+
98 if (rank < remainder) {
+
99 i_points = points / cluster_size + 1;
+
100 i_start = start + dt * i_points * rank;
+
101 }
+
102 else {
+
103 i_points = points / cluster_size;
+
104 i_start = start + dt * (i_points * rank + remainder);
+
105 }
106
-
107 ofile << scientific_format(temp) << ','
-
108 << scientific_format(data[i].E / N) << ','
-
109 << scientific_format(data[i].M_abs / N) << ','
-
110 << scientific_format(CV) << ',' << scientific_format(X)
-
111 << '\n';
-
112 }
-
113 ofile.close();
-
114 }
-
115 else {
-
116 MPI_Send(i_data, i_points * sizeof(data_t), MPI_CHAR, 0, rank,
-
117 MPI_COMM_WORLD);
-
118 }
-
119 }
-
120
-
121 t1 = MPI_Wtime();
-
122
-
123 if (rank == 0) {
-
124 std::cout << "Time: " << t1 - t0 << " seconds\n";
-
125 }
-
126
-
127 MPI_Finalize();
-
128}
- -
Header for the data_t type.
-
Functions for monte carlo simulations.
-
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.
Definition: test_suite.cpp:148
-
Function prototypes and macros that are useful.
+
107 // Initialize array to contains data for each temperature point
+
108 data_t i_data[i_points];
+
109
+
110 // Simulate and save data to array
+
111 for (size_t i = 0; i < i_points; i++) {
+
112 i_data[i] = montecarlo::mcmc_parallel(L, i_start + dt * i, cycles,
+
113 burn_in_time);
+
114 }
+
115
+
116 // Rank 0 collects all the data and copies it to the "master"
+
117 // data array.
+
118 if (rank == 0) {
+
119 // Copy its own i_data to the data array
+
120 std::copy_n(i_data, i_points, data);
+
121
+
122 // Collect i_data from other ranks in order and copy to data.
+
123 for (size_t i = 1; i < cluster_size; i++) {
+
124 if (rank < remainder) {
+
125 MPI_Recv((void *)i_data,
+
126 sizeof(data_t) * (points / cluster_size + 1), MPI_CHAR,
+
127 i, MPI_ANY_TAG, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
+
128 std::copy_n(i_data, points / cluster_size + 1,
+
129 data + (points / cluster_size) * i);
+
130 }
+
131 else {
+
132 MPI_Recv((void *)i_data,
+
133 sizeof(data_t) * (points / cluster_size), MPI_CHAR, i,
+
134 MPI_ANY_TAG, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
+
135 std::copy_n(i_data, points / cluster_size,
+
136 data + (points / cluster_size) * i + remainder);
+
137 }
+
138 }
+
139
+
140 // Write everything from data to file
+
141 utils::mkpath(utils::dirname(outfile));
+
142 ofile.open(outfile);
+
143
+
144 double temp, CV, X;
+
145
+
146 using utils::scientific_format;
+
147 for (size_t i = 0; i < points; i++) {
+
148 temp = start + dt * i;
+
149 CV = (data[i].E2 - data[i].E * data[i].E)
+
150 / ((double)N * temp * temp);
+
151 X = (data[i].M2 - data[i].M_abs * data[i].M_abs)
+
152 / ((double)N * temp);
+
153
+
154 ofile << scientific_format(temp) << ','
+
155 << scientific_format(data[i].E / N) << ','
+
156 << scientific_format(data[i].M_abs / N) << ','
+ +
158 << '\n';
+
159 }
+
160 ofile.close();
+
161 }
+
162 // For all other ranks, send the data to rank 0
+
163 else {
+
164 MPI_Send(i_data, i_points * sizeof(data_t), MPI_CHAR, 0, rank,
+
165 MPI_COMM_WORLD);
+
166 }
+
167
+
168 t1 = MPI_Wtime();
+
169
+
170 if (rank == 0) {
+
171 std::cout << "Time: " << t1 - t0 << " seconds\n";
+
172 }
+
173
+
174 MPI_Finalize();
+
175}
+
Type to use with the IsingModel class and montecarlo module.
Definition: data_type.hpp:19
+
int main(int argc, char **argv)
The main function.
Definition: main.cpp:125
+
void usage(std::string filename)
A function that displays how to use the program and quits.
Definition: main.cpp:110
+
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.
+
bool mkpath(std::string path, int mode=0777)
Make path given.
Definition: utils.cpp:32
+
std::string scientific_format(double d, int width=20, int prec=10)
Turns a double into a string written in scientific format.
Definition: utils.cpp:16
+
std::string dirname(const std::string &path)
Get the directory name of the path.
Definition: utils.cpp:58
diff --git a/docs/search/all_1.js b/docs/search/all_1.js index e35967d..0af0d30 100644 --- a/docs/search/all_1.js +++ b/docs/search/all_1.js @@ -1,4 +1,5 @@ var searchData= [ - ['assert_0',['ASSERT',['../testlib_8hpp.html#a73d4f21ad937dbc50a0c0538c78fd4f9',1,'testlib.hpp']]] + ['assert_0',['ASSERT',['../testlib_8hpp.html#a73d4f21ad937dbc50a0c0538c78fd4f9',1,'testlib.hpp']]], + ['assert_5feach_1',['assert_each',['../testlib_8hpp.html#ab6585c8aa8c276a3442c67a57c8de6fb',1,'testlib']]] ]; diff --git a/docs/search/all_10.js b/docs/search/all_10.js index cd921db..18553b5 100644 --- a/docs/search/all_10.js +++ b/docs/search/all_10.js @@ -1,5 +1,4 @@ var searchData= [ - ['utils_2ecpp_0',['utils.cpp',['../utils_8cpp.html',1,'']]], - ['utils_2ehpp_1',['utils.hpp',['../utils_8hpp.html',1,'']]] + ['x_5f2_0',['X_2',['../test__suite_8cpp.html#ad27c84dda71475ffd365c649b525199e',1,'test_suite.cpp']]] ]; diff --git a/docs/search/all_3.js b/docs/search/all_3.js index 0648f09..729601d 100644 --- a/docs/search/all_3.js +++ b/docs/search/all_3.js @@ -1,4 +1,9 @@ var searchData= [ - ['constants_2ehpp_0',['constants.hpp',['../constants_8hpp.html',1,'']]] + ['close_5fto_0',['close_to',['../testlib_8hpp.html#a2cbf3a45367e903de6efbdbea3344cea',1,'testlib::close_to(arma::Mat< T > &a, arma::Mat< T > &b, double tol=1e-8)'],['../testlib_8hpp.html#a44f47fa3c8654c09712572d75c0ffa7f',1,'testlib::close_to(T a, T b, double tol=1e-8)']]], + ['concatpath_1',['concatpath',['../utils_8hpp.html#ae91fad89394d745d544737e43524bde6',1,'utils']]], + ['create_5fburn_5fin_5ftime_5fdata_2',['create_burn_in_time_data',['../main_8cpp.html#a68406fc2dd8de5849c3984658c171f32',1,'main.cpp']]], + ['create_5fpd_5festimate_5fdata_3',['create_pd_estimate_data',['../main_8cpp.html#a4f8ea24364d72024915d3753a572cc5b',1,'main.cpp']]], + ['create_5fphase_5ftransition_5fdata_4',['create_phase_transition_data',['../main_8cpp.html#a9d62cf1399596f4c5a39abdd3196d76d',1,'main.cpp']]], + ['cv_5f2_5',['CV_2',['../test__suite_8cpp.html#af02dd88b4d495baf7af5826d1481634c',1,'test_suite.cpp']]] ]; diff --git a/docs/search/all_4.js b/docs/search/all_4.js index 43c3415..76376d5 100644 --- a/docs/search/all_4.js +++ b/docs/search/all_4.js @@ -1,8 +1,9 @@ var searchData= [ - ['data_5ft_0',['data_t',['../classdata__t.html',1,'']]], + ['data_5ft_0',['data_t',['../classdata__t.html',1,'data_t'],['../classdata__t.html#aa2690d3e5d711b4baf3c8f8b9095faf7',1,'data_t::data_t()'],['../classdata__t.html#a3f2d19ab309e696ba91a2000479bcb83',1,'data_t::data_t(double E, double E2, double M, double M2, double M_abs)']]], ['data_5ftype_2ecpp_1',['data_type.cpp',['../data__type_8cpp.html',1,'']]], ['data_5ftype_2ehpp_2',['data_type.hpp',['../data__type_8hpp.html',1,'']]], ['debug_3',['DEBUG',['../utils_8hpp.html#aecc1f7a8a2493b9e021e5bff76a00a5b',1,'utils.hpp']]], - ['dirname_4',['dirname',['../utils_8hpp.html#aed026119193a9bbe076671809ff0f430',1,'utils']]] + ['dirname_4',['dirname',['../utils_8hpp.html#aed026119193a9bbe076671809ff0f430',1,'utils']]], + ['down_5',['DOWN',['../IsingModel_8hpp.html#a4193cd1c8c2e6ebd0e056fa2364a663f',1,'IsingModel.hpp']]] ]; diff --git a/docs/search/all_5.js b/docs/search/all_5.js index 3834eab..1e777af 100644 --- a/docs/search/all_5.js +++ b/docs/search/all_5.js @@ -1,5 +1,8 @@ var searchData= [ - ['e_0',['E',['../classIsingModel.html#ae9f872ca2054992161d53306119979dd',1,'IsingModel']]], - ['energy_5fdiff_1',['energy_diff',['../classIsingModel.html#a1a4ceb1bb2593dbd20c51ed04100cbcd',1,'IsingModel']]] + ['e_0',['E',['../classdata__t.html#a6c1a196d96e177b11ca98c61fae35a2e',1,'data_t::E()'],['../classIsingModel.html#a1c8a2a4331c7e60c3e1350c0cf8300b9',1,'IsingModel::E()']]], + ['e2_1',['E2',['../classdata__t.html#abb622f9c6cc5ffb9dddb151d2e202f72',1,'data_t']]], + ['energy_5fdiff_2',['energy_diff',['../classIsingModel.html#a7112dd6433b1bb9512150cbdc1a0b77e',1,'IsingModel']]], + ['engine_3',['engine',['../classIsingModel.html#a1bbe0cb10abee98058e7b45b22b9cd0a',1,'IsingModel']]], + ['eps_5f2_4',['EPS_2',['../test__suite_8cpp.html#a00367775d110a9537bd06bde2e630471',1,'test_suite.cpp']]] ]; diff --git a/docs/search/all_6.js b/docs/search/all_6.js index 45fb121..db297e3 100644 --- a/docs/search/all_6.js +++ b/docs/search/all_6.js @@ -1,5 +1,16 @@ var searchData= [ - ['get_5fe_0',['get_E',['../classIsingModel.html#aaa0787d964b004a17869811a5e947ff5',1,'IsingModel']]], - ['get_5fm_1',['get_M',['../classIsingModel.html#aa5701496e6483bc4668c486d6d3af625',1,'IsingModel']]] + ['index_0',['INDEX',['../IsingModel_8hpp.html#a3039ac753f46401767c38f867787fae6',1,'IsingModel.hpp']]], + ['initialize_5fenergy_1',['initialize_energy',['../classIsingModel.html#a59fced38c695e2fa647f53be81b9d2a1',1,'IsingModel']]], + ['initialize_5fenergy_5fdiff_2',['initialize_energy_diff',['../classIsingModel.html#aff9a1201933fd5408845a1447e4895b4',1,'IsingModel']]], + ['initialize_5fengine_3',['initialize_engine',['../classIsingModel.html#aaedc25b7284e04849269f31291590bf5',1,'IsingModel']]], + ['initialize_5flattice_4',['initialize_lattice',['../classIsingModel.html#a34a4710949b4a70f3e37ca223aefcf8a',1,'IsingModel::initialize_lattice()'],['../classIsingModel.html#acc86effd6889bea199a3d70a9f38dc78',1,'IsingModel::initialize_lattice(int val)']]], + ['initialize_5fmagnetization_5',['initialize_magnetization',['../classIsingModel.html#a926cf4964d190d2ce23e5a17201787a4',1,'IsingModel']]], + ['initialize_5fneighbors_6',['initialize_neighbors',['../classIsingModel.html#a6776109105051597c275670dabd0054a',1,'IsingModel']]], + ['is_5fequal_7',['is_equal',['../testlib_8hpp.html#a3db67d8721d2f3cd626526b43186bcf3',1,'testlib']]], + ['ising_20model_8',['Ising Model',['../index.html',1,'']]], + ['isingmodel_9',['IsingModel',['../classIsingModel.html#acf281f6f5ed02911ca6ab07004449864',1,'IsingModel::IsingModel()'],['../classIsingModel.html#a4a39ee7fbfbbf566f75bc28900ca9ea5',1,'IsingModel::IsingModel(int L, double T)'],['../classIsingModel.html#a46c9446e94854452f715d307c77c1c15',1,'IsingModel::IsingModel(int L, double T, int val)'],['../classIsingModel.html',1,'IsingModel']]], + ['isingmodel_2ecpp_10',['IsingModel.cpp',['../IsingModel_8cpp.html',1,'']]], + ['isingmodel_2ehpp_11',['IsingModel.hpp',['../IsingModel_8hpp.html',1,'']]], + ['isingmodeltest_12',['IsingModelTest',['../classIsingModel.html#a2b1cf104e0bda1fce78ed366e1ec7287',1,'IsingModel::IsingModelTest()'],['../classIsingModelTest.html',1,'IsingModelTest']]] ]; diff --git a/docs/search/all_7.js b/docs/search/all_7.js index a2ea4bf..a00b603 100644 --- a/docs/search/all_7.js +++ b/docs/search/all_7.js @@ -1,13 +1,6 @@ var searchData= [ - ['initialize_5fenergy_0',['initialize_energy',['../classIsingModel.html#a59fced38c695e2fa647f53be81b9d2a1',1,'IsingModel']]], - ['initialize_5fenergy_5fdiff_1',['initialize_energy_diff',['../classIsingModel.html#aff9a1201933fd5408845a1447e4895b4',1,'IsingModel']]], - ['initialize_5flattice_2',['initialize_lattice',['../classIsingModel.html#a34a4710949b4a70f3e37ca223aefcf8a',1,'IsingModel']]], - ['initialize_5fmagnetization_3',['initialize_magnetization',['../classIsingModel.html#a926cf4964d190d2ce23e5a17201787a4',1,'IsingModel']]], - ['initialize_5fneighbors_4',['initialize_neighbors',['../classIsingModel.html#a6776109105051597c275670dabd0054a',1,'IsingModel']]], - ['ising_20model_5',['Ising Model',['../index.html',1,'']]], - ['isingmodel_6',['IsingModel',['../classIsingModel.html',1,'IsingModel'],['../classIsingModel.html#acf281f6f5ed02911ca6ab07004449864',1,'IsingModel::IsingModel()'],['../classIsingModel.html#a4a39ee7fbfbbf566f75bc28900ca9ea5',1,'IsingModel::IsingModel(int L, double T)'],['../classIsingModel.html#a46c9446e94854452f715d307c77c1c15',1,'IsingModel::IsingModel(int L, double T, int val)']]], - ['isingmodel_2ecpp_7',['IsingModel.cpp',['../IsingModel_8cpp.html',1,'']]], - ['isingmodel_2ehpp_8',['IsingModel.hpp',['../IsingModel_8hpp.html',1,'']]], - ['isingmodeltest_9',['IsingModelTest',['../classIsingModelTest.html',1,'']]] + ['l_0',['L',['../classIsingModel.html#a2b8ac43baefeb386186266d5aa4de348',1,'IsingModel']]], + ['lattice_1',['lattice',['../classIsingModel.html#a2c3c76c79717c968d7c227c58b46df41',1,'IsingModel']]], + ['left_2',['LEFT',['../IsingModel_8hpp.html#a437ef08681e7210d6678427030446a54',1,'IsingModel.hpp']]] ]; diff --git a/docs/search/all_8.js b/docs/search/all_8.js index 9d163ac..1324740 100644 --- a/docs/search/all_8.js +++ b/docs/search/all_8.js @@ -1,4 +1,18 @@ var searchData= [ - ['k_5fb_0',['k_B',['../constants_8hpp.html#abfa7d6668c777f9516606394bbc9c414',1,'constants.hpp']]] + ['m_0',['M',['../classdata__t.html#ad08d2488bf913c626157471cf6e8a46a',1,'data_t::M()'],['../classIsingModel.html#aef7232b28df08e064ef58eb5ef32f738',1,'IsingModel::M()']]], + ['m2_1',['M2',['../classdata__t.html#a71ae3cd4460f2c66239500c11804e70b',1,'data_t']]], + ['m_5fabs_2',['M_abs',['../classdata__t.html#a586475e0f71322dffda2e75f228ab24b',1,'data_t']]], + ['m_5fassert_3',['m_assert',['../testlib_8hpp.html#a39abb7cba0535176ed62aae136d2fcc7',1,'details']]], + ['mag_5f2_4',['MAG_2',['../test__suite_8cpp.html#a9fd092d930430eb4693d93e0c9066605',1,'test_suite.cpp']]], + ['main_5',['main',['../time_8cpp.html#a3c04138a5bfe5d72780bb7e82a18e627',1,'main(int argc, char **argv): time.cpp'],['../test__suite_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4',1,'main(): test_suite.cpp'],['../phase__transition__mpi_8cpp.html#a3c04138a5bfe5d72780bb7e82a18e627',1,'main(int argc, char **argv): phase_transition_mpi.cpp'],['../phase__transition_8cpp.html#a3c04138a5bfe5d72780bb7e82a18e627',1,'main(int argc, char **argv): phase_transition.cpp'],['../main_8cpp.html#a3c04138a5bfe5d72780bb7e82a18e627',1,'main(int argc, char **argv): main.cpp'],['../mcmc__progression_8cpp.html#a3c04138a5bfe5d72780bb7e82a18e627',1,'main(int argc, char **argv): mcmc_progression.cpp'],['../pd__estimate_8cpp.html#a3c04138a5bfe5d72780bb7e82a18e627',1,'main(int argc, char **argv): pd_estimate.cpp']]], + ['main_2ecpp_6',['main.cpp',['../main_8cpp.html',1,'']]], + ['mcmc_5fparallel_7',['mcmc_parallel',['../monte__carlo_8hpp.html#ae1e7f904ecfc3d8f3c4dd1ef155dd771',1,'montecarlo']]], + ['mcmc_5fprogression_2ecpp_8',['mcmc_progression.cpp',['../mcmc__progression_8cpp.html',1,'']]], + ['mcmc_5fserial_9',['mcmc_serial',['../monte__carlo_8hpp.html#ae67483ff00d1b0594d543261c8283ffd',1,'montecarlo']]], + ['methodname_10',['methodName',['../utils_8hpp.html#a178c4922157666a6e9c127c2ffd96346',1,'details']]], + ['metropolis_11',['Metropolis',['../classIsingModel.html#a56559d68dc9aaff1976d84b157f43488',1,'IsingModel']]], + ['mkpath_12',['mkpath',['../utils_8hpp.html#a2b45adc86b70f42021582994e83fa00d',1,'utils']]], + ['monte_5fcarlo_2ecpp_13',['monte_carlo.cpp',['../monte__carlo_8cpp.html',1,'']]], + ['monte_5fcarlo_2ehpp_14',['monte_carlo.hpp',['../monte__carlo_8hpp.html',1,'']]] ]; diff --git a/docs/search/all_9.js b/docs/search/all_9.js index d4681d4..9fae6f7 100644 --- a/docs/search/all_9.js +++ b/docs/search/all_9.js @@ -1,5 +1,4 @@ var searchData= [ - ['l_0',['L',['../classIsingModel.html#a2b8ac43baefeb386186266d5aa4de348',1,'IsingModel']]], - ['lattice_1',['lattice',['../classIsingModel.html#a2c3c76c79717c968d7c227c58b46df41',1,'IsingModel']]] + ['neighbors_0',['neighbors',['../classIsingModel.html#a94093aaf30facca62737f2ac381fdbcd',1,'IsingModel']]] ]; diff --git a/docs/search/all_a.js b/docs/search/all_a.js index 670bfbb..e5e6e9e 100644 --- a/docs/search/all_a.js +++ b/docs/search/all_a.js @@ -1,15 +1,9 @@ var searchData= [ - ['m_0',['M',['../classIsingModel.html#a0d373a61baca6b0faa607bb12d82cc47',1,'IsingModel']]], - ['m_5fassert_1',['m_assert',['../testlib_8hpp.html#a39abb7cba0535176ed62aae136d2fcc7',1,'details']]], - ['main_2',['main',['../test__suite_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4',1,'main(): test_suite.cpp'],['../phase__transition__mpi_8cpp.html#a3c04138a5bfe5d72780bb7e82a18e627',1,'main(int argc, char **argv): phase_transition_mpi.cpp'],['../main_8cpp.html#a3c04138a5bfe5d72780bb7e82a18e627',1,'main(int argc, char **argv): main.cpp']]], - ['main_2ecpp_3',['main.cpp',['../main_8cpp.html',1,'']]], - ['methodname_4',['methodName',['../utils_8hpp.html#a178c4922157666a6e9c127c2ffd96346',1,'details']]], - ['metropolis_5',['Metropolis',['../classIsingModel.html#a56559d68dc9aaff1976d84b157f43488',1,'IsingModel']]], - ['mkpath_6',['mkpath',['../utils_8hpp.html#a2b45adc86b70f42021582994e83fa00d',1,'utils']]], - ['monte_5fcarlo_2ecpp_7',['monte_carlo.cpp',['../monte__carlo_8cpp.html',1,'']]], - ['monte_5fcarlo_2ehpp_8',['monte_carlo.hpp',['../monte__carlo_8hpp.html',1,'']]], - ['monte_5fcarlo_5fparallel_9',['monte_carlo_parallel',['../monte__carlo_8hpp.html#acc34e2049a5030874f6f548f3adab958',1,'monte_carlo_parallel(int L, double T, int cycles): monte_carlo.cpp'],['../monte__carlo_8cpp.html#acc34e2049a5030874f6f548f3adab958',1,'monte_carlo_parallel(int L, double T, int cycles): monte_carlo.cpp']]], - ['monte_5fcarlo_5fprogression_10',['monte_carlo_progression',['../monte__carlo_8hpp.html#ac97d0de27f2f0d50fc6ecf3a79f32826',1,'monte_carlo_progression(double T, int L, int cycles, const std::string filename): monte_carlo.cpp'],['../monte__carlo_8hpp.html#a89ddd777796c65eb2b289af11fc0ce09',1,'monte_carlo_progression(double T, int L, int cycles, int value, const std::string filename): monte_carlo.cpp'],['../monte__carlo_8cpp.html#ac97d0de27f2f0d50fc6ecf3a79f32826',1,'monte_carlo_progression(double T, int L, int cycles, const std::string filename): monte_carlo.cpp'],['../monte__carlo_8cpp.html#a89ddd777796c65eb2b289af11fc0ce09',1,'monte_carlo_progression(double T, int L, int cycles, int value, const std::string filename): monte_carlo.cpp']]], - ['monte_5fcarlo_5fserial_11',['monte_carlo_serial',['../monte__carlo_8hpp.html#a8f8d4c5e032ed8565a3ac518b32c6aed',1,'monte_carlo_serial(int L, double T, int cycles): monte_carlo.cpp'],['../monte__carlo_8cpp.html#a8f8d4c5e032ed8565a3ac518b32c6aed',1,'monte_carlo_serial(int L, double T, int cycles): monte_carlo.cpp']]] + ['operator_2a_0',['operator*',['../classdata__t.html#a7954efc97086ea50e10c33113b203085',1,'data_t']]], + ['operator_2a_3d_1',['operator*=',['../classdata__t.html#a6ddf3a7372730ef2393aee8bbcb34992',1,'data_t']]], + ['operator_2b_2',['operator+',['../classdata__t.html#a13bc1d73eadeb39c507e89f5872d726f',1,'data_t']]], + ['operator_2b_3d_3',['operator+=',['../classdata__t.html#a6cb96b4ff750ab29041038ca53f307cb',1,'data_t']]], + ['operator_2f_4',['operator/',['../classdata__t.html#a429a11c53ee7fe08f6a4e75db524521d',1,'data_t']]], + ['operator_2f_3d_5',['operator/=',['../classdata__t.html#a88da5be78439fbdecfa473ec007dffd8',1,'data_t']]] ]; diff --git a/docs/search/all_b.js b/docs/search/all_b.js index 9fae6f7..e40c691 100644 --- a/docs/search/all_b.js +++ b/docs/search/all_b.js @@ -1,4 +1,9 @@ var searchData= [ - ['neighbors_0',['neighbors',['../classIsingModel.html#a94093aaf30facca62737f2ac381fdbcd',1,'IsingModel']]] + ['pd_5festimate_0',['pd_estimate',['../monte__carlo_8hpp.html#aea2dd1b5fac7c45633bc6f8dc4541226',1,'montecarlo']]], + ['pd_5festimate_2ecpp_1',['pd_estimate.cpp',['../pd__estimate_8cpp.html',1,'']]], + ['phase_5ftransition_2',['phase_transition',['../monte__carlo_8hpp.html#a34e9c3e24f26760693266b8a7b6b3d21',1,'montecarlo']]], + ['phase_5ftransition_2ecpp_3',['phase_transition.cpp',['../phase__transition_8cpp.html',1,'']]], + ['phase_5ftransition_5fmpi_2ecpp_4',['phase_transition_mpi.cpp',['../phase__transition__mpi_8cpp.html',1,'']]], + ['progression_5',['progression',['../monte__carlo_8hpp.html#a781d946de16211ba18ad6671a5b6838d',1,'montecarlo::progression(double T, int L, int cycles, const std::string filename, int burn_in_time=BURN_IN_TIME)'],['../monte__carlo_8hpp.html#a1549fc386bd3cdd1cdbe0261b9dd8415',1,'montecarlo::progression(double T, int L, int cycles, int value, const std::string filename, int burn_in_time=BURN_IN_TIME)']]] ]; diff --git a/docs/search/all_c.js b/docs/search/all_c.js index fef9e21..1196503 100644 --- a/docs/search/all_c.js +++ b/docs/search/all_c.js @@ -1,6 +1,4 @@ var searchData= [ - ['pd_5festimate_0',['pd_estimate',['../monte__carlo_8hpp.html#a962f704ab35208bf6541eb3b707a9559',1,'pd_estimate(double T, int L, int cycles, const std::string filename): monte_carlo.cpp'],['../monte__carlo_8cpp.html#a962f704ab35208bf6541eb3b707a9559',1,'pd_estimate(double T, int L, int cycles, const std::string filename): monte_carlo.cpp']]], - ['phase_5ftransition_1',['phase_transition',['../monte__carlo_8hpp.html#a2dfe843fbb80e10a763f3260131a148e',1,'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): monte_carlo.cpp'],['../monte__carlo_8cpp.html#a7df22ace588b4d229d1029ce766d0009',1,'phase_transition(int L, double start, double end, int points, std::function< data_t(int, double, int)> monte_carlo, std::string outfile): monte_carlo.cpp']]], - ['phase_5ftransition_5fmpi_2ecpp_2',['phase_transition_mpi.cpp',['../phase__transition__mpi_8cpp.html',1,'']]] + ['right_0',['RIGHT',['../IsingModel_8hpp.html#a80fb826a684cf3f0d306b22aa100ddac',1,'IsingModel.hpp']]] ]; diff --git a/docs/search/all_e.js b/docs/search/all_e.js index b656b4b..609c264 100644 --- a/docs/search/all_e.js +++ b/docs/search/all_e.js @@ -1,10 +1,14 @@ var searchData= [ ['t_0',['T',['../classIsingModel.html#a20fc4c0c99d8a119f70a1614784d4e5c',1,'IsingModel']]], - ['test_5f2x2_5flattice_1',['test_2x2_lattice',['../classIsingModelTest.html#a4ace7013fa2d257ad1747961da6bc4de',1,'IsingModelTest::test_2x2_lattice()'],['../monte__carlo_8hpp.html#aa8b4fc86b26f0e3e253ba5556d2d14dc',1,'test_2x2_lattice(): monte_carlo.hpp']]], - ['test_5finit_5ffunctions_2',['test_init_functions',['../classIsingModelTest.html#a717e5852ca51432a61fb6ed38da37931',1,'IsingModelTest']]], - ['test_5fsuite_2ecpp_3',['test_suite.cpp',['../test__suite_8cpp.html',1,'']]], - ['testlib_2ecpp_4',['testlib.cpp',['../testlib_8cpp.html',1,'']]], - ['testlib_2ehpp_5',['testlib.hpp',['../testlib_8hpp.html',1,'']]], - ['typedefs_2ehpp_6',['typedefs.hpp',['../typedefs_8hpp.html',1,'']]] + ['test_5f2x2_5flattice_1',['test_2x2_lattice',['../classIsingModelTest.html#a4ace7013fa2d257ad1747961da6bc4de',1,'IsingModelTest']]], + ['test_5fburn_5fin_5ftime_2',['test_burn_in_time',['../main_8cpp.html#a746d8dc451b2b2536abbb1ff1acaf861',1,'main.cpp']]], + ['test_5finit_5ffunctions_3',['test_init_functions',['../classIsingModelTest.html#a717e5852ca51432a61fb6ed38da37931',1,'IsingModelTest']]], + ['test_5fparallel_5fspeedup_4',['test_parallel_speedup',['../main_8cpp.html#a0dfa85080578dffff23b68e372cece95',1,'main.cpp']]], + ['test_5fsuite_2ecpp_5',['test_suite.cpp',['../test__suite_8cpp.html',1,'']]], + ['testlib_2ecpp_6',['testlib.cpp',['../testlib_8cpp.html',1,'']]], + ['testlib_2ehpp_7',['testlib.hpp',['../testlib_8hpp.html',1,'']]], + ['time_2ecpp_8',['time.cpp',['../time_8cpp.html',1,'']]], + ['time_5flattice_5fsizes_9',['time_lattice_sizes',['../time_8cpp.html#aa224066f42c47cae5fbd457c1948e4a5',1,'time.cpp']]], + ['time_5fsample_5fsizes_10',['time_sample_sizes',['../time_8cpp.html#ace9eb0821fe4edf19cf2e7d8ffe6efb4',1,'time.cpp']]] ]; diff --git a/docs/search/all_f.js b/docs/search/all_f.js index cd921db..256f9d4 100644 --- a/docs/search/all_f.js +++ b/docs/search/all_f.js @@ -1,5 +1,7 @@ var searchData= [ - ['utils_2ecpp_0',['utils.cpp',['../utils_8cpp.html',1,'']]], - ['utils_2ehpp_1',['utils.hpp',['../utils_8hpp.html',1,'']]] + ['up_0',['UP',['../IsingModel_8hpp.html#a1965eaca47dbf3f87acdafc2208f04eb',1,'IsingModel.hpp']]], + ['usage_1',['usage',['../main_8cpp.html#ac907e18135856c90366aaa599a9e10b1',1,'usage(std::string filename): main.cpp'],['../mcmc__progression_8cpp.html#ac907e18135856c90366aaa599a9e10b1',1,'usage(std::string filename): mcmc_progression.cpp'],['../pd__estimate_8cpp.html#ac907e18135856c90366aaa599a9e10b1',1,'usage(std::string filename): pd_estimate.cpp'],['../phase__transition_8cpp.html#ac907e18135856c90366aaa599a9e10b1',1,'usage(std::string filename): phase_transition.cpp'],['../phase__transition__mpi_8cpp.html#ac907e18135856c90366aaa599a9e10b1',1,'usage(std::string filename): phase_transition_mpi.cpp'],['../time_8cpp.html#ac907e18135856c90366aaa599a9e10b1',1,'usage(std::string filename): time.cpp']]], + ['utils_2ecpp_2',['utils.cpp',['../utils_8cpp.html',1,'']]], + ['utils_2ehpp_3',['utils.hpp',['../utils_8hpp.html',1,'']]] ]; diff --git a/docs/search/defines_2.js b/docs/search/defines_2.js index c6466cb..fb20ef6 100644 --- a/docs/search/defines_2.js +++ b/docs/search/defines_2.js @@ -1,4 +1,4 @@ var searchData= [ - ['debug_0',['DEBUG',['../utils_8hpp.html#aecc1f7a8a2493b9e021e5bff76a00a5b',1,'utils.hpp']]] + ['cv_5f2_0',['CV_2',['../test__suite_8cpp.html#af02dd88b4d495baf7af5826d1481634c',1,'test_suite.cpp']]] ]; diff --git a/docs/search/defines_3.js b/docs/search/defines_3.js index 9d163ac..f00a465 100644 --- a/docs/search/defines_3.js +++ b/docs/search/defines_3.js @@ -1,4 +1,5 @@ var searchData= [ - ['k_5fb_0',['k_B',['../constants_8hpp.html#abfa7d6668c777f9516606394bbc9c414',1,'constants.hpp']]] + ['debug_0',['DEBUG',['../utils_8hpp.html#aecc1f7a8a2493b9e021e5bff76a00a5b',1,'utils.hpp']]], + ['down_1',['DOWN',['../IsingModel_8hpp.html#a4193cd1c8c2e6ebd0e056fa2364a663f',1,'IsingModel.hpp']]] ]; diff --git a/docs/search/defines_4.js b/docs/search/defines_4.js new file mode 100644 index 0000000..782ca6c --- /dev/null +++ b/docs/search/defines_4.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['eps_5f2_0',['EPS_2',['../test__suite_8cpp.html#a00367775d110a9537bd06bde2e630471',1,'test_suite.cpp']]] +]; diff --git a/docs/search/defines_5.js b/docs/search/defines_5.js new file mode 100644 index 0000000..d53c4a7 --- /dev/null +++ b/docs/search/defines_5.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['index_0',['INDEX',['../IsingModel_8hpp.html#a3039ac753f46401767c38f867787fae6',1,'IsingModel.hpp']]] +]; diff --git a/docs/search/defines_6.js b/docs/search/defines_6.js new file mode 100644 index 0000000..9f2f559 --- /dev/null +++ b/docs/search/defines_6.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['left_0',['LEFT',['../IsingModel_8hpp.html#a437ef08681e7210d6678427030446a54',1,'IsingModel.hpp']]] +]; diff --git a/docs/search/defines_7.js b/docs/search/defines_7.js new file mode 100644 index 0000000..e3d3aa7 --- /dev/null +++ b/docs/search/defines_7.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['mag_5f2_0',['MAG_2',['../test__suite_8cpp.html#a9fd092d930430eb4693d93e0c9066605',1,'test_suite.cpp']]] +]; diff --git a/docs/search/defines_8.js b/docs/search/defines_8.js new file mode 100644 index 0000000..1196503 --- /dev/null +++ b/docs/search/defines_8.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['right_0',['RIGHT',['../IsingModel_8hpp.html#a80fb826a684cf3f0d306b22aa100ddac',1,'IsingModel.hpp']]] +]; diff --git a/docs/search/defines_9.js b/docs/search/defines_9.js new file mode 100644 index 0000000..c7887aa --- /dev/null +++ b/docs/search/defines_9.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['up_0',['UP',['../IsingModel_8hpp.html#a1965eaca47dbf3f87acdafc2208f04eb',1,'IsingModel.hpp']]] +]; diff --git a/docs/search/defines_a.js b/docs/search/defines_a.js new file mode 100644 index 0000000..18553b5 --- /dev/null +++ b/docs/search/defines_a.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['x_5f2_0',['X_2',['../test__suite_8cpp.html#ad27c84dda71475ffd365c649b525199e',1,'test_suite.cpp']]] +]; diff --git a/docs/search/defines_b.js b/docs/search/defines_b.js new file mode 100644 index 0000000..18553b5 --- /dev/null +++ b/docs/search/defines_b.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['x_5f2_0',['X_2',['../test__suite_8cpp.html#ad27c84dda71475ffd365c649b525199e',1,'test_suite.cpp']]] +]; diff --git a/docs/search/files_0.js b/docs/search/files_0.js index 0648f09..99d33f4 100644 --- a/docs/search/files_0.js +++ b/docs/search/files_0.js @@ -1,4 +1,5 @@ var searchData= [ - ['constants_2ehpp_0',['constants.hpp',['../constants_8hpp.html',1,'']]] + ['data_5ftype_2ecpp_0',['data_type.cpp',['../data__type_8cpp.html',1,'']]], + ['data_5ftype_2ehpp_1',['data_type.hpp',['../data__type_8hpp.html',1,'']]] ]; diff --git a/docs/search/files_1.js b/docs/search/files_1.js index 99d33f4..172e9fd 100644 --- a/docs/search/files_1.js +++ b/docs/search/files_1.js @@ -1,5 +1,5 @@ var searchData= [ - ['data_5ftype_2ecpp_0',['data_type.cpp',['../data__type_8cpp.html',1,'']]], - ['data_5ftype_2ehpp_1',['data_type.hpp',['../data__type_8hpp.html',1,'']]] + ['isingmodel_2ecpp_0',['IsingModel.cpp',['../IsingModel_8cpp.html',1,'']]], + ['isingmodel_2ehpp_1',['IsingModel.hpp',['../IsingModel_8hpp.html',1,'']]] ]; diff --git a/docs/search/files_2.js b/docs/search/files_2.js index 172e9fd..5bfde32 100644 --- a/docs/search/files_2.js +++ b/docs/search/files_2.js @@ -1,5 +1,7 @@ var searchData= [ - ['isingmodel_2ecpp_0',['IsingModel.cpp',['../IsingModel_8cpp.html',1,'']]], - ['isingmodel_2ehpp_1',['IsingModel.hpp',['../IsingModel_8hpp.html',1,'']]] + ['main_2ecpp_0',['main.cpp',['../main_8cpp.html',1,'']]], + ['mcmc_5fprogression_2ecpp_1',['mcmc_progression.cpp',['../mcmc__progression_8cpp.html',1,'']]], + ['monte_5fcarlo_2ecpp_2',['monte_carlo.cpp',['../monte__carlo_8cpp.html',1,'']]], + ['monte_5fcarlo_2ehpp_3',['monte_carlo.hpp',['../monte__carlo_8hpp.html',1,'']]] ]; diff --git a/docs/search/files_3.js b/docs/search/files_3.js index 4878898..42fa72d 100644 --- a/docs/search/files_3.js +++ b/docs/search/files_3.js @@ -1,6 +1,6 @@ var searchData= [ - ['main_2ecpp_0',['main.cpp',['../main_8cpp.html',1,'']]], - ['monte_5fcarlo_2ecpp_1',['monte_carlo.cpp',['../monte__carlo_8cpp.html',1,'']]], - ['monte_5fcarlo_2ehpp_2',['monte_carlo.hpp',['../monte__carlo_8hpp.html',1,'']]] + ['pd_5festimate_2ecpp_0',['pd_estimate.cpp',['../pd__estimate_8cpp.html',1,'']]], + ['phase_5ftransition_2ecpp_1',['phase_transition.cpp',['../phase__transition_8cpp.html',1,'']]], + ['phase_5ftransition_5fmpi_2ecpp_2',['phase_transition_mpi.cpp',['../phase__transition__mpi_8cpp.html',1,'']]] ]; diff --git a/docs/search/files_4.js b/docs/search/files_4.js index 44579d3..70f4074 100644 --- a/docs/search/files_4.js +++ b/docs/search/files_4.js @@ -1,4 +1,7 @@ var searchData= [ - ['phase_5ftransition_5fmpi_2ecpp_0',['phase_transition_mpi.cpp',['../phase__transition__mpi_8cpp.html',1,'']]] + ['test_5fsuite_2ecpp_0',['test_suite.cpp',['../test__suite_8cpp.html',1,'']]], + ['testlib_2ecpp_1',['testlib.cpp',['../testlib_8cpp.html',1,'']]], + ['testlib_2ehpp_2',['testlib.hpp',['../testlib_8hpp.html',1,'']]], + ['time_2ecpp_3',['time.cpp',['../time_8cpp.html',1,'']]] ]; diff --git a/docs/search/files_5.js b/docs/search/files_5.js index f687ddb..cd921db 100644 --- a/docs/search/files_5.js +++ b/docs/search/files_5.js @@ -1,7 +1,5 @@ var searchData= [ - ['test_5fsuite_2ecpp_0',['test_suite.cpp',['../test__suite_8cpp.html',1,'']]], - ['testlib_2ecpp_1',['testlib.cpp',['../testlib_8cpp.html',1,'']]], - ['testlib_2ehpp_2',['testlib.hpp',['../testlib_8hpp.html',1,'']]], - ['typedefs_2ehpp_3',['typedefs.hpp',['../typedefs_8hpp.html',1,'']]] + ['utils_2ecpp_0',['utils.cpp',['../utils_8cpp.html',1,'']]], + ['utils_2ehpp_1',['utils.hpp',['../utils_8hpp.html',1,'']]] ]; diff --git a/docs/search/functions_0.js b/docs/search/functions_0.js index 4199254..9bf63f1 100644 --- a/docs/search/functions_0.js +++ b/docs/search/functions_0.js @@ -1,4 +1,4 @@ var searchData= [ - ['dirname_0',['dirname',['../utils_8hpp.html#aed026119193a9bbe076671809ff0f430',1,'utils']]] + ['assert_5feach_0',['assert_each',['../testlib_8hpp.html#ab6585c8aa8c276a3442c67a57c8de6fb',1,'testlib']]] ]; diff --git a/docs/search/functions_1.js b/docs/search/functions_1.js index 45fb121..6750ee2 100644 --- a/docs/search/functions_1.js +++ b/docs/search/functions_1.js @@ -1,5 +1,8 @@ var searchData= [ - ['get_5fe_0',['get_E',['../classIsingModel.html#aaa0787d964b004a17869811a5e947ff5',1,'IsingModel']]], - ['get_5fm_1',['get_M',['../classIsingModel.html#aa5701496e6483bc4668c486d6d3af625',1,'IsingModel']]] + ['close_5fto_0',['close_to',['../testlib_8hpp.html#a2cbf3a45367e903de6efbdbea3344cea',1,'testlib::close_to(arma::Mat< T > &a, arma::Mat< T > &b, double tol=1e-8)'],['../testlib_8hpp.html#a44f47fa3c8654c09712572d75c0ffa7f',1,'testlib::close_to(T a, T b, double tol=1e-8)']]], + ['concatpath_1',['concatpath',['../utils_8hpp.html#ae91fad89394d745d544737e43524bde6',1,'utils']]], + ['create_5fburn_5fin_5ftime_5fdata_2',['create_burn_in_time_data',['../main_8cpp.html#a68406fc2dd8de5849c3984658c171f32',1,'main.cpp']]], + ['create_5fpd_5festimate_5fdata_3',['create_pd_estimate_data',['../main_8cpp.html#a4f8ea24364d72024915d3753a572cc5b',1,'main.cpp']]], + ['create_5fphase_5ftransition_5fdata_4',['create_phase_transition_data',['../main_8cpp.html#a9d62cf1399596f4c5a39abdd3196d76d',1,'main.cpp']]] ]; diff --git a/docs/search/functions_2.js b/docs/search/functions_2.js index 7bbfb9b..a993caf 100644 --- a/docs/search/functions_2.js +++ b/docs/search/functions_2.js @@ -1,9 +1,5 @@ var searchData= [ - ['initialize_5fenergy_0',['initialize_energy',['../classIsingModel.html#a59fced38c695e2fa647f53be81b9d2a1',1,'IsingModel']]], - ['initialize_5fenergy_5fdiff_1',['initialize_energy_diff',['../classIsingModel.html#aff9a1201933fd5408845a1447e4895b4',1,'IsingModel']]], - ['initialize_5flattice_2',['initialize_lattice',['../classIsingModel.html#a34a4710949b4a70f3e37ca223aefcf8a',1,'IsingModel']]], - ['initialize_5fmagnetization_3',['initialize_magnetization',['../classIsingModel.html#a926cf4964d190d2ce23e5a17201787a4',1,'IsingModel']]], - ['initialize_5fneighbors_4',['initialize_neighbors',['../classIsingModel.html#a6776109105051597c275670dabd0054a',1,'IsingModel']]], - ['isingmodel_5',['IsingModel',['../classIsingModel.html#acf281f6f5ed02911ca6ab07004449864',1,'IsingModel::IsingModel()'],['../classIsingModel.html#a4a39ee7fbfbbf566f75bc28900ca9ea5',1,'IsingModel::IsingModel(int L, double T)'],['../classIsingModel.html#a46c9446e94854452f715d307c77c1c15',1,'IsingModel::IsingModel(int L, double T, int val)']]] + ['data_5ft_0',['data_t',['../classdata__t.html#aa2690d3e5d711b4baf3c8f8b9095faf7',1,'data_t::data_t()'],['../classdata__t.html#a3f2d19ab309e696ba91a2000479bcb83',1,'data_t::data_t(double E, double E2, double M, double M2, double M_abs)']]], + ['dirname_1',['dirname',['../utils_8hpp.html#aed026119193a9bbe076671809ff0f430',1,'utils']]] ]; diff --git a/docs/search/functions_3.js b/docs/search/functions_3.js index de0435f..3677807 100644 --- a/docs/search/functions_3.js +++ b/docs/search/functions_3.js @@ -1,11 +1,11 @@ var searchData= [ - ['m_5fassert_0',['m_assert',['../testlib_8hpp.html#a39abb7cba0535176ed62aae136d2fcc7',1,'details']]], - ['main_1',['main',['../main_8cpp.html#a3c04138a5bfe5d72780bb7e82a18e627',1,'main(int argc, char **argv): main.cpp'],['../phase__transition__mpi_8cpp.html#a3c04138a5bfe5d72780bb7e82a18e627',1,'main(int argc, char **argv): phase_transition_mpi.cpp'],['../test__suite_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4',1,'main(): test_suite.cpp']]], - ['methodname_2',['methodName',['../utils_8hpp.html#a178c4922157666a6e9c127c2ffd96346',1,'details']]], - ['metropolis_3',['Metropolis',['../classIsingModel.html#a56559d68dc9aaff1976d84b157f43488',1,'IsingModel']]], - ['mkpath_4',['mkpath',['../utils_8hpp.html#a2b45adc86b70f42021582994e83fa00d',1,'utils']]], - ['monte_5fcarlo_5fparallel_5',['monte_carlo_parallel',['../monte__carlo_8hpp.html#acc34e2049a5030874f6f548f3adab958',1,'monte_carlo_parallel(int L, double T, int cycles): monte_carlo.cpp'],['../monte__carlo_8cpp.html#acc34e2049a5030874f6f548f3adab958',1,'monte_carlo_parallel(int L, double T, int cycles): monte_carlo.cpp']]], - ['monte_5fcarlo_5fprogression_6',['monte_carlo_progression',['../monte__carlo_8hpp.html#ac97d0de27f2f0d50fc6ecf3a79f32826',1,'monte_carlo_progression(double T, int L, int cycles, const std::string filename): monte_carlo.cpp'],['../monte__carlo_8hpp.html#a89ddd777796c65eb2b289af11fc0ce09',1,'monte_carlo_progression(double T, int L, int cycles, int value, const std::string filename): monte_carlo.cpp'],['../monte__carlo_8cpp.html#ac97d0de27f2f0d50fc6ecf3a79f32826',1,'monte_carlo_progression(double T, int L, int cycles, const std::string filename): monte_carlo.cpp'],['../monte__carlo_8cpp.html#a89ddd777796c65eb2b289af11fc0ce09',1,'monte_carlo_progression(double T, int L, int cycles, int value, const std::string filename): monte_carlo.cpp']]], - ['monte_5fcarlo_5fserial_7',['monte_carlo_serial',['../monte__carlo_8hpp.html#a8f8d4c5e032ed8565a3ac518b32c6aed',1,'monte_carlo_serial(int L, double T, int cycles): monte_carlo.cpp'],['../monte__carlo_8cpp.html#a8f8d4c5e032ed8565a3ac518b32c6aed',1,'monte_carlo_serial(int L, double T, int cycles): monte_carlo.cpp']]] + ['initialize_5fenergy_0',['initialize_energy',['../classIsingModel.html#a59fced38c695e2fa647f53be81b9d2a1',1,'IsingModel']]], + ['initialize_5fenergy_5fdiff_1',['initialize_energy_diff',['../classIsingModel.html#aff9a1201933fd5408845a1447e4895b4',1,'IsingModel']]], + ['initialize_5fengine_2',['initialize_engine',['../classIsingModel.html#aaedc25b7284e04849269f31291590bf5',1,'IsingModel']]], + ['initialize_5flattice_3',['initialize_lattice',['../classIsingModel.html#a34a4710949b4a70f3e37ca223aefcf8a',1,'IsingModel::initialize_lattice()'],['../classIsingModel.html#acc86effd6889bea199a3d70a9f38dc78',1,'IsingModel::initialize_lattice(int val)']]], + ['initialize_5fmagnetization_4',['initialize_magnetization',['../classIsingModel.html#a926cf4964d190d2ce23e5a17201787a4',1,'IsingModel']]], + ['initialize_5fneighbors_5',['initialize_neighbors',['../classIsingModel.html#a6776109105051597c275670dabd0054a',1,'IsingModel']]], + ['is_5fequal_6',['is_equal',['../testlib_8hpp.html#a3db67d8721d2f3cd626526b43186bcf3',1,'testlib']]], + ['isingmodel_7',['IsingModel',['../classIsingModel.html#acf281f6f5ed02911ca6ab07004449864',1,'IsingModel::IsingModel()'],['../classIsingModel.html#a4a39ee7fbfbbf566f75bc28900ca9ea5',1,'IsingModel::IsingModel(int L, double T)'],['../classIsingModel.html#a46c9446e94854452f715d307c77c1c15',1,'IsingModel::IsingModel(int L, double T, int val)']]] ]; diff --git a/docs/search/functions_4.js b/docs/search/functions_4.js index 4577437..e2c1ec3 100644 --- a/docs/search/functions_4.js +++ b/docs/search/functions_4.js @@ -1,5 +1,10 @@ var searchData= [ - ['pd_5festimate_0',['pd_estimate',['../monte__carlo_8hpp.html#a962f704ab35208bf6541eb3b707a9559',1,'pd_estimate(double T, int L, int cycles, const std::string filename): monte_carlo.cpp'],['../monte__carlo_8cpp.html#a962f704ab35208bf6541eb3b707a9559',1,'pd_estimate(double T, int L, int cycles, const std::string filename): monte_carlo.cpp']]], - ['phase_5ftransition_1',['phase_transition',['../monte__carlo_8hpp.html#a2dfe843fbb80e10a763f3260131a148e',1,'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): monte_carlo.cpp'],['../monte__carlo_8cpp.html#a7df22ace588b4d229d1029ce766d0009',1,'phase_transition(int L, double start, double end, int points, std::function< data_t(int, double, int)> monte_carlo, std::string outfile): monte_carlo.cpp']]] + ['m_5fassert_0',['m_assert',['../testlib_8hpp.html#a39abb7cba0535176ed62aae136d2fcc7',1,'details']]], + ['main_1',['main',['../main_8cpp.html#a3c04138a5bfe5d72780bb7e82a18e627',1,'main(int argc, char **argv): main.cpp'],['../mcmc__progression_8cpp.html#a3c04138a5bfe5d72780bb7e82a18e627',1,'main(int argc, char **argv): mcmc_progression.cpp'],['../pd__estimate_8cpp.html#a3c04138a5bfe5d72780bb7e82a18e627',1,'main(int argc, char **argv): pd_estimate.cpp'],['../phase__transition_8cpp.html#a3c04138a5bfe5d72780bb7e82a18e627',1,'main(int argc, char **argv): phase_transition.cpp'],['../phase__transition__mpi_8cpp.html#a3c04138a5bfe5d72780bb7e82a18e627',1,'main(int argc, char **argv): phase_transition_mpi.cpp'],['../test__suite_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4',1,'main(): test_suite.cpp'],['../time_8cpp.html#a3c04138a5bfe5d72780bb7e82a18e627',1,'main(int argc, char **argv): time.cpp']]], + ['mcmc_5fparallel_2',['mcmc_parallel',['../monte__carlo_8hpp.html#ae1e7f904ecfc3d8f3c4dd1ef155dd771',1,'montecarlo']]], + ['mcmc_5fserial_3',['mcmc_serial',['../monte__carlo_8hpp.html#ae67483ff00d1b0594d543261c8283ffd',1,'montecarlo']]], + ['methodname_4',['methodName',['../utils_8hpp.html#a178c4922157666a6e9c127c2ffd96346',1,'details']]], + ['metropolis_5',['Metropolis',['../classIsingModel.html#a56559d68dc9aaff1976d84b157f43488',1,'IsingModel']]], + ['mkpath_6',['mkpath',['../utils_8hpp.html#a2b45adc86b70f42021582994e83fa00d',1,'utils']]] ]; diff --git a/docs/search/functions_5.js b/docs/search/functions_5.js index 83e74c2..e5e6e9e 100644 --- a/docs/search/functions_5.js +++ b/docs/search/functions_5.js @@ -1,4 +1,9 @@ var searchData= [ - ['scientific_5fformat_0',['scientific_format',['../utils_8hpp.html#a3529a74fd2a25d24de73d9d4e1c90835',1,'utils::scientific_format(double d, int width=20, int prec=10)'],['../utils_8hpp.html#ab3e89176433ddc9ba721b2eba3d08357',1,'utils::scientific_format(const std::vector< double > &v, int width=20, int prec=10)']]] + ['operator_2a_0',['operator*',['../classdata__t.html#a7954efc97086ea50e10c33113b203085',1,'data_t']]], + ['operator_2a_3d_1',['operator*=',['../classdata__t.html#a6ddf3a7372730ef2393aee8bbcb34992',1,'data_t']]], + ['operator_2b_2',['operator+',['../classdata__t.html#a13bc1d73eadeb39c507e89f5872d726f',1,'data_t']]], + ['operator_2b_3d_3',['operator+=',['../classdata__t.html#a6cb96b4ff750ab29041038ca53f307cb',1,'data_t']]], + ['operator_2f_4',['operator/',['../classdata__t.html#a429a11c53ee7fe08f6a4e75db524521d',1,'data_t']]], + ['operator_2f_3d_5',['operator/=',['../classdata__t.html#a88da5be78439fbdecfa473ec007dffd8',1,'data_t']]] ]; diff --git a/docs/search/functions_6.js b/docs/search/functions_6.js index 23c5afa..c061015 100644 --- a/docs/search/functions_6.js +++ b/docs/search/functions_6.js @@ -1,5 +1,6 @@ var searchData= [ - ['test_5f2x2_5flattice_0',['test_2x2_lattice',['../classIsingModelTest.html#a4ace7013fa2d257ad1747961da6bc4de',1,'IsingModelTest::test_2x2_lattice()'],['../monte__carlo_8hpp.html#aa8b4fc86b26f0e3e253ba5556d2d14dc',1,'test_2x2_lattice(): monte_carlo.hpp']]], - ['test_5finit_5ffunctions_1',['test_init_functions',['../classIsingModelTest.html#a717e5852ca51432a61fb6ed38da37931',1,'IsingModelTest']]] + ['pd_5festimate_0',['pd_estimate',['../monte__carlo_8hpp.html#aea2dd1b5fac7c45633bc6f8dc4541226',1,'montecarlo']]], + ['phase_5ftransition_1',['phase_transition',['../monte__carlo_8hpp.html#a34e9c3e24f26760693266b8a7b6b3d21',1,'montecarlo']]], + ['progression_2',['progression',['../monte__carlo_8hpp.html#a781d946de16211ba18ad6671a5b6838d',1,'montecarlo::progression(double T, int L, int cycles, const std::string filename, int burn_in_time=BURN_IN_TIME)'],['../monte__carlo_8hpp.html#a1549fc386bd3cdd1cdbe0261b9dd8415',1,'montecarlo::progression(double T, int L, int cycles, int value, const std::string filename, int burn_in_time=BURN_IN_TIME)']]] ]; diff --git a/docs/search/functions_7.js b/docs/search/functions_7.js index c18dff8..83e74c2 100644 --- a/docs/search/functions_7.js +++ b/docs/search/functions_7.js @@ -1,5 +1,4 @@ var searchData= [ - ['test_5f2x2_5flattice_0',['test_2x2_lattice',['../monte__carlo_8hpp.html#a64fd72aa1f6ff03e36c35f6265d0f874',1,'test_2x2_lattice(double tol, uint max_cycles): monte_carlo.cpp'],['../monte__carlo_8cpp.html#a64fd72aa1f6ff03e36c35f6265d0f874',1,'test_2x2_lattice(double tol, uint max_cycles): monte_carlo.cpp']]], - ['test_5finit_5ffunctions_1',['test_init_functions',['../classIsingModelTest.html#a717e5852ca51432a61fb6ed38da37931',1,'IsingModelTest']]] + ['scientific_5fformat_0',['scientific_format',['../utils_8hpp.html#a3529a74fd2a25d24de73d9d4e1c90835',1,'utils::scientific_format(double d, int width=20, int prec=10)'],['../utils_8hpp.html#ab3e89176433ddc9ba721b2eba3d08357',1,'utils::scientific_format(const std::vector< double > &v, int width=20, int prec=10)']]] ]; diff --git a/docs/search/functions_8.js b/docs/search/functions_8.js new file mode 100644 index 0000000..40534f4 --- /dev/null +++ b/docs/search/functions_8.js @@ -0,0 +1,9 @@ +var searchData= +[ + ['test_5f2x2_5flattice_0',['test_2x2_lattice',['../classIsingModelTest.html#a4ace7013fa2d257ad1747961da6bc4de',1,'IsingModelTest']]], + ['test_5fburn_5fin_5ftime_1',['test_burn_in_time',['../main_8cpp.html#a746d8dc451b2b2536abbb1ff1acaf861',1,'main.cpp']]], + ['test_5finit_5ffunctions_2',['test_init_functions',['../classIsingModelTest.html#a717e5852ca51432a61fb6ed38da37931',1,'IsingModelTest']]], + ['test_5fparallel_5fspeedup_3',['test_parallel_speedup',['../main_8cpp.html#a0dfa85080578dffff23b68e372cece95',1,'main.cpp']]], + ['time_5flattice_5fsizes_4',['time_lattice_sizes',['../time_8cpp.html#aa224066f42c47cae5fbd457c1948e4a5',1,'time.cpp']]], + ['time_5fsample_5fsizes_5',['time_sample_sizes',['../time_8cpp.html#ace9eb0821fe4edf19cf2e7d8ffe6efb4',1,'time.cpp']]] +]; diff --git a/docs/search/functions_9.js b/docs/search/functions_9.js new file mode 100644 index 0000000..788434a --- /dev/null +++ b/docs/search/functions_9.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['usage_0',['usage',['../main_8cpp.html#ac907e18135856c90366aaa599a9e10b1',1,'usage(std::string filename): main.cpp'],['../mcmc__progression_8cpp.html#ac907e18135856c90366aaa599a9e10b1',1,'usage(std::string filename): mcmc_progression.cpp'],['../pd__estimate_8cpp.html#ac907e18135856c90366aaa599a9e10b1',1,'usage(std::string filename): pd_estimate.cpp'],['../phase__transition_8cpp.html#ac907e18135856c90366aaa599a9e10b1',1,'usage(std::string filename): phase_transition.cpp'],['../phase__transition__mpi_8cpp.html#ac907e18135856c90366aaa599a9e10b1',1,'usage(std::string filename): phase_transition_mpi.cpp'],['../time_8cpp.html#ac907e18135856c90366aaa599a9e10b1',1,'usage(std::string filename): time.cpp']]] +]; diff --git a/docs/search/namespaces_0.js b/docs/search/namespaces_0.js new file mode 100644 index 0000000..7a6d15c --- /dev/null +++ b/docs/search/namespaces_0.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['details_0',['details',['../namespacedetails.html',1,'']]] +]; diff --git a/docs/search/namespaces_1.js b/docs/search/namespaces_1.js new file mode 100644 index 0000000..9cc45b2 --- /dev/null +++ b/docs/search/namespaces_1.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['montecarlo_0',['montecarlo',['../namespacemontecarlo.html',1,'']]] +]; diff --git a/docs/search/namespaces_2.js b/docs/search/namespaces_2.js new file mode 100644 index 0000000..14ee089 --- /dev/null +++ b/docs/search/namespaces_2.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['testlib_0',['testlib',['../namespacetestlib.html',1,'']]] +]; diff --git a/docs/search/namespaces_3.js b/docs/search/namespaces_3.js new file mode 100644 index 0000000..c76a02d --- /dev/null +++ b/docs/search/namespaces_3.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['utils_0',['utils',['../namespaceutils.html',1,'']]] +]; diff --git a/docs/search/related_0.js b/docs/search/related_0.js new file mode 100644 index 0000000..d32ef0d --- /dev/null +++ b/docs/search/related_0.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['isingmodeltest_0',['IsingModelTest',['../classIsingModel.html#a2b1cf104e0bda1fce78ed366e1ec7287',1,'IsingModel']]] +]; diff --git a/docs/search/searchdata.js b/docs/search/searchdata.js index 2a8f22a..817754f 100644 --- a/docs/search/searchdata.js +++ b/docs/search/searchdata.js @@ -1,12 +1,13 @@ var indexSectionsWithContent = { - 0: "_abcdegiklmnpstu", + 0: "_abcdeilmnoprstux", 1: "di", - 2: "cdimptu", - 3: "dgimpst", + 2: "dimptu", + 3: "acdimopstu", 4: "elmnt", - 5: "_adk", - 6: "bi" + 5: "i", + 6: "_acdeilmrux", + 7: "bi" }; var indexSectionNames = @@ -16,8 +17,9 @@ var indexSectionNames = 2: "files", 3: "functions", 4: "variables", - 5: "defines", - 6: "pages" + 5: "related", + 6: "defines", + 7: "pages" }; var indexSectionLabels = @@ -27,7 +29,8 @@ var indexSectionLabels = 2: "Files", 3: "Functions", 4: "Variables", - 5: "Macros", - 6: "Pages" + 5: "Friends", + 6: "Macros", + 7: "Pages" }; diff --git a/docs/search/variables_0.js b/docs/search/variables_0.js index 3834eab..248709d 100644 --- a/docs/search/variables_0.js +++ b/docs/search/variables_0.js @@ -1,5 +1,7 @@ var searchData= [ - ['e_0',['E',['../classIsingModel.html#ae9f872ca2054992161d53306119979dd',1,'IsingModel']]], - ['energy_5fdiff_1',['energy_diff',['../classIsingModel.html#a1a4ceb1bb2593dbd20c51ed04100cbcd',1,'IsingModel']]] + ['e_0',['E',['../classdata__t.html#a6c1a196d96e177b11ca98c61fae35a2e',1,'data_t::E()'],['../classIsingModel.html#a1c8a2a4331c7e60c3e1350c0cf8300b9',1,'IsingModel::E()']]], + ['e2_1',['E2',['../classdata__t.html#abb622f9c6cc5ffb9dddb151d2e202f72',1,'data_t']]], + ['energy_5fdiff_2',['energy_diff',['../classIsingModel.html#a7112dd6433b1bb9512150cbdc1a0b77e',1,'IsingModel']]], + ['engine_3',['engine',['../classIsingModel.html#a1bbe0cb10abee98058e7b45b22b9cd0a',1,'IsingModel']]] ]; diff --git a/docs/search/variables_2.js b/docs/search/variables_2.js index c556415..4b62716 100644 --- a/docs/search/variables_2.js +++ b/docs/search/variables_2.js @@ -1,4 +1,6 @@ var searchData= [ - ['m_0',['M',['../classIsingModel.html#a0d373a61baca6b0faa607bb12d82cc47',1,'IsingModel']]] + ['m_0',['M',['../classdata__t.html#ad08d2488bf913c626157471cf6e8a46a',1,'data_t::M()'],['../classIsingModel.html#aef7232b28df08e064ef58eb5ef32f738',1,'IsingModel::M()']]], + ['m2_1',['M2',['../classdata__t.html#a71ae3cd4460f2c66239500c11804e70b',1,'data_t']]], + ['m_5fabs_2',['M_abs',['../classdata__t.html#a586475e0f71322dffda2e75f228ab24b',1,'data_t']]] ]; diff --git a/docs/test__suite_8cpp.html b/docs/test__suite_8cpp.html index ff4138e..dd47d54 100644 --- a/docs/test__suite_8cpp.html +++ b/docs/test__suite_8cpp.html @@ -110,7 +110,6 @@ $(document).ready(function(){initNavTree('test__suite_8cpp.html',''); initResiza More...

#include "IsingModel.hpp"
#include "testlib.hpp"
-#include <fstream>

Go to the source code of this file.

@@ -123,12 +122,16 @@ Classes + + + +

Macros

#define EPS_2   (-2 * std::sinh(8.)) / (std::cosh(8.) + 3)
 The analytic expected energy for a \( 2 \times 2 \) lattice.
 
#define MAG_2   (std::exp(8.) + 1) / (2 * (cosh(8.) + 3))
 The analytic expected magnetization for a \( 2 \times 2 \) lattice.
 
#define CV_2    16 * (3 * std::cosh(8.) + 1) / ((std::cosh(8.) + 3) * (std::cosh(8.) + 3))
 The analytic heat capacity for a \( 2 \times 2 \) lattice.
 
#define X_2
 The analytic susceptibility for a \( 2 \times 2 \) lattice.
 

@@ -159,7 +162,9 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)

-

Definition at line 21 of file test_suite.cpp.

+

The analytic heat capacity for a \( 2 \times 2 \) lattice.

+ +

Definition at line 26 of file test_suite.cpp.

@@ -175,6 +180,8 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
+

The analytic expected energy for a \( 2 \times 2 \) lattice.

+

Definition at line 17 of file test_suite.cpp.

@@ -191,7 +198,9 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)
-

Definition at line 19 of file test_suite.cpp.

+

The analytic expected magnetization for a \( 2 \times 2 \) lattice.

+ +

Definition at line 22 of file test_suite.cpp.

@@ -209,7 +218,9 @@ Janita Ovidie Sandtrøen Willumsen (janitaws) Value:
(3 * std::exp(8.) + std::exp(-8.) + 3) \
/ ((std::cosh(8.) + 3) * (std::cosh(8.) + 3))
-

Definition at line 24 of file test_suite.cpp.

+

The analytic susceptibility for a \( 2 \times 2 \) lattice.

+ +

Definition at line 30 of file test_suite.cpp.

@@ -231,7 +242,7 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)

The main function.

-

Definition at line 148 of file test_suite.cpp.

+

Definition at line 110 of file test_suite.cpp.

diff --git a/docs/test__suite_8cpp.js b/docs/test__suite_8cpp.js index f9b584a..2b1212f 100644 --- a/docs/test__suite_8cpp.js +++ b/docs/test__suite_8cpp.js @@ -1,5 +1,9 @@ var test__suite_8cpp = [ [ "IsingModelTest", "classIsingModelTest.html", "classIsingModelTest" ], + [ "CV_2", "test__suite_8cpp.html#af02dd88b4d495baf7af5826d1481634c", null ], + [ "EPS_2", "test__suite_8cpp.html#a00367775d110a9537bd06bde2e630471", null ], + [ "MAG_2", "test__suite_8cpp.html#a9fd092d930430eb4693d93e0c9066605", null ], + [ "X_2", "test__suite_8cpp.html#ad27c84dda71475ffd365c649b525199e", null ], [ "main", "test__suite_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4", null ] ]; \ No newline at end of file diff --git a/docs/test__suite_8cpp_source.html b/docs/test__suite_8cpp_source.html index 7ab3051..ef0f705 100644 --- a/docs/test__suite_8cpp_source.html +++ b/docs/test__suite_8cpp_source.html @@ -101,170 +101,164 @@ $(document).ready(function(){initNavTree('test__suite_8cpp_source.html',''); ini
test_suite.cpp
-Go to the documentation of this file.
1
-
12#include "IsingModel.hpp"
-
13#include "testlib.hpp"
+Go to the documentation of this file.
1/** @file test_suite.cpp
+
2 *
+
3 * @author Cory Alexander Balaton (coryab)
+
4 * @author Janita Ovidie Sandtrøen Willumsen (janitaws)
+
5 *
+
6 * @version 1.0
+
7 *
+
8 * @brief Sweep over different temperatures and generate data.
+
9 *
+
10 * @bug No known bugs
+
11 * */
+
12#include "IsingModel.hpp"
+
13#include "testlib.hpp"
14
-
15#include <fstream>
-
16
-
17#define EPS_2 (-2 * std::sinh(8.)) / (std::cosh(8.) + 3)
+
15/** @brief The analytic expected energy for a \f$ 2 \times 2 \f$ lattice.
+
16 * */
+
17#define EPS_2 (-2 * std::sinh(8.)) / (std::cosh(8.) + 3)
18
-
19#define MAG_2 (std::exp(8.) + 1) / (2 * (cosh(8.) + 3))
-
20
-
21#define CV_2 \
-
22 16 * (3 * std::cosh(8.) + 1) / ((std::cosh(8.) + 3) * (std::cosh(8.) + 3))
+
19/** @brief The analytic expected magnetization for a \f$ 2 \times 2 \f$
+
20 * lattice.
+
21 * */
+
22#define MAG_2 (std::exp(8.) + 1) / (2 * (cosh(8.) + 3))
23
-
24#define X_2 \
-
25 (3 * std::exp(8.) + std::exp(-8.) + 3) \
-
26 / ((std::cosh(8.) + 3) * (std::cosh(8.) + 3))
-
27
- -
31public:
- -
35 {
-
36 IsingModel test;
-
37 test.L = 3;
-
38 test.T = 1.;
-
39
-
40 // Test that initializing the lattice only yields 1s and -1s.
-
41 test.initialize_lattice();
-
42 std::function<bool(int)> f = [](int x) { return x == 1 || x == -1; };
-
43 ASSERT(testlib::assert_each(f, test.lattice),
-
44 "Test lattice initialization.");
+
24/** @brief The analytic heat capacity for a \f$ 2 \times 2 \f$ lattice.
+
25 * */
+
26#define CV_2
+
27 16 * (3 * std::cosh(8.) + 1) / ((std::cosh(8.) + 3) * (std::cosh(8.) + 3))
+
28
+
29/** @brief The analytic susceptibility for a \f$ 2 \times 2 \f$ lattice.*/
+
30#define X_2
+
31 (3 * std::exp(8.) + std::exp(-8.) + 3)
+
32 / ((std::cosh(8.) + 3) * (std::cosh(8.) + 3))
+
33
+
34/** @brief Test class for the Ising model
+
35 * */
+ +
37public:
+
38 /** @brief Test that initializing works as intended.
+
39 * */
+ +
41 {
+
42 IsingModel test;
+
43 test.L = 3;
+
44 test.T = 1.;
45
- -
47 arma::Mat<int> neighbor_matrix("2, 1 ; 0, 2 ; 1, 0");
-
48 ASSERT(testlib::is_equal(neighbor_matrix, test.neighbors),
-
49 "Test neighbor matrix.");
-
50
-
51 // Fill the lattice with 1s to be able to test the next functions.
-
52 test.lattice.fill(1);
-
53
-
54 // Test the initial magnetization.
- -
56 ASSERT(std::fabs(test.M - 9.) < 1e-8, "Test intial magnetization");
-
57
-
58 // Test that the initial energy is correct
-
59 test.initialize_energy();
-
60 ASSERT(std::fabs(test.E - (-18)) < 1e-8, "Test initial energy.");
-
61 }
-
62
-
70 int test_2x2_lattice(double tol, int max_cycles)
-
71 {
-
72 data_t data, tmp;
-
73 size_t L = 2;
-
74 size_t n_spins = L * L;
-
75 double T = 1.;
-
76 size_t cycles = 0;
-
77
-
78 // Create random engine using the mersenne twister
-
79 std::random_device rd;
-
80 std::mt19937 engine(rd());
-
81
-
82 IsingModel test(L, T);
+
46 // Test that initializing the lattice only yields 1s and -1s.
+ +
48 std::function<bool(int)> f = [](int x) { return x == 1 || x == -1; };
+
49 ASSERT(testlib::assert_each(f, test.lattice),
+
50 "Test lattice initialization.");
+
51
+ +
53 arma::Mat<int> neighbor_matrix("2, 1 ; 0, 2 ; 1, 0");
+
54 ASSERT(testlib::is_equal(neighbor_matrix, test.neighbors),
+
55 "Test neighbor matrix.");
+
56
+
57 // Fill the lattice with 1s to be able to test the next functions.
+
58 test.lattice.fill(1);
+
59
+
60 // Test the initial magnetization.
+ +
62 ASSERT(std::fabs(test.M - 9.) < 1e-8, "Test intial magnetization");
+
63
+
64 // Test that the initial energy is correct
+ +
66 ASSERT(std::fabs(test.E - (-18)) < 1e-8, "Test initial energy.");
+
67 }
+
68
+
69 /** @brief Test numerical data with analytical data.
+
70 *
+
71 * @param tol The tolerance between the analytical and numerical solution.
+
72 * @param max_cycles The max number of Monte Carlo cycles.
+
73 *
+
74 * return int
+
75 * */
+
76 int test_2x2_lattice(double tol, int max_cycles)
+
77 {
+
78 data_t data, tmp;
+
79 size_t L = 2;
+
80 size_t n_spins = L * L;
+
81 double T = 1.;
+
82 size_t cycles = 0;
83
-
84 int arr[]{0, 0, 0, 0};
-
85
-
86 // Loop through cycles
-
87 //std::ofstream ofile;
-
88 //ofile.open("output/test_2x2.txt");
-
89 while (cycles++ < max_cycles) {
-
90 data += test.Metropolis();
-
91 tmp = data / cycles;
-
92 //ofile << cycles << ',' << tmp.E / n_spins << ','
-
93 //<< tmp.M_abs / n_spins << ','
-
94 //<< (tmp.E2 - tmp.E * tmp.E) / (T * T) / n_spins << ','
-
95 //<< (tmp.M2 - tmp.M_abs * tmp.M_abs) / T / n_spins << '\n';
-
96 if (testlib::close_to(EPS_2, tmp.E / n_spins, tol)
-
97 && testlib::close_to(MAG_2, tmp.M_abs / n_spins, tol)
-
98 && testlib::close_to(CV_2, (tmp.E2 - tmp.E * tmp.E) / (T * T)
-
99 / n_spins, tol)
-
100 && testlib::close_to(X_2, (tmp.M2 - tmp.M_abs * tmp.M_abs) / T
-
101 / n_spins, tol)) {
+
84 // Create random engine using the mersenne twister
+
85 std::random_device rd;
+
86 std::mt19937 engine(rd());
+
87
+
88 IsingModel test(L, T);
+
89
+
90 int arr[]{0, 0, 0, 0};
+
91
+
92 // Loop through cycles
+
93 while (cycles++ < max_cycles) {
+
94 data += test.Metropolis();
+
95 tmp = data / cycles;
+
96 if (testlib::close_to(EPS_2, tmp.E / n_spins, tol)
+
97 && testlib::close_to(MAG_2, tmp.M_abs / n_spins, tol)
+
98 && testlib::close_to(
+
99 CV_2, (tmp.E2 - tmp.E * tmp.E) / (T * T) / n_spins, tol)
+
100 && testlib::close_to(
+
101 X_2, (tmp.M2 - tmp.M_abs * tmp.M_abs) / T / n_spins, tol)) {
102 return cycles;
103 }
104 }
-
105 //std::cout << EPS_2 << ',' << MAG_2 << ',' << CV_2 << ',' << X_2
-
106 //<< std::endl;
-
107 //ofile.close();
-
108 // cycles = 0;
-
109 // data = 0;
-
110 // IsingModel test_mag(L, T);
-
111 // while (cycles++ < max_cycles) {
-
112 // data += test.Metropolis();
-
113 // tmp = data / (cycles * n_spins);
-
114 // if (testlib::close_to(MAG_2, tmp.M, tol)) {
-
115 // arr[1] = cycles;
-
116 // break;
-
117 //}
-
118 //}
-
119 // cycles = 0;
-
120 // data = 0;
-
121 // IsingModel test_CV(L, T);
-
122 // while (cycles++ < max_cycles) {
-
123 // data += test.Metropolis();
-
124 // tmp = data / (cycles * n_spins);
-
125 // if (testlib::close_to(CV_2, (tmp.E2 - tmp.E * tmp.E) / (T * T),
-
126 // tol)) {
-
127 // arr[2] = cycles;
-
128 // break;
-
129 //}
-
130 //}
-
131 // cycles = 0;
-
132 // data = 0;
-
133 // IsingModel test_X(L, T);
-
134 // while (cycles++ < max_cycles) {
-
135 // data += test.Metropolis();
-
136 // tmp = data / (cycles * n_spins);
-
137 // if (testlib::close_to(X_2, (tmp.M2 - tmp.M_abs * tmp.M_abs) / T,
-
138 // tol)) {
-
139 // arr[3] = cycles;
-
140 // break;
-
141 //}
-
142 //}
-
143 return 0;
-
144 }
-
145};
-
146
-
148int main()
-
149{
-
150 IsingModelTest test;
-
151
-
152 test.test_init_functions();
-
153 int res = 0;
-
154 int tmp;
-
155 for (size_t i=0; i < 1000; i++) {
-
156 tmp = test.test_2x2_lattice(1e-2, 1e5);
-
157 if (tmp == 0) {
-
158 std::cout << "not enough cycles\n";
-
159 break;
-
160 }
-
161 res += tmp;
-
162 }
-
163
-
164 std::cout << "Res: " << res / 1000 << std::endl;
-
165
-
166 return 0;
-
167}
-
The definition of the Ising model.
-
Test class for the Ising model.
Definition: test_suite.cpp:30
-
int test_2x2_lattice(double tol, int max_cycles)
Test numerical data with analytical data.
Definition: test_suite.cpp:70
-
void test_init_functions()
Test That initializing works as intended.
Definition: test_suite.cpp:34
-
The Ising model in 2 dimensions.
Definition: IsingModel.hpp:37
-
int M
The current magnetic strength. unit: Unitless.
Definition: IsingModel.hpp:72
-
double T
The temperature of the model.
Definition: IsingModel.hpp:60
-
int L
Size of the lattice.
Definition: IsingModel.hpp:64
-
arma::Mat< int > lattice
matrix where element .
Definition: IsingModel.hpp:42
-
void initialize_lattice()
Initialize the lattice with a random distribution of 1s and -1s.
Definition: IsingModel.cpp:44
-
data_t Metropolis()
The Metropolis algorithm.
Definition: IsingModel.cpp:96
-
void initialize_energy()
Initialize the energy.
Definition: IsingModel.cpp:82
-
void initialize_neighbors()
initialize the neighbors matrix.
Definition: IsingModel.cpp:56
-
void initialize_magnetization()
Initialize the magnetization.
Definition: IsingModel.cpp:74
-
arma::Mat< int > neighbors
matrix with the neighbors of each element .
Definition: IsingModel.hpp:52
-
int E
The current energy state. unit: .
Definition: IsingModel.hpp:68
- -
int main()
The main function.
Definition: test_suite.cpp:148
-
A small test library.
+
105 return 0;
+
106 }
+
107};
+
108
+
109/** @brief The main function.*/
+
110int main()
+
111{
+
112 IsingModelTest test;
+
113
+ +
115
+
116 int res = 0;
+
117 int tmp;
+
118 int iterations = 10000;
+
119 int accepted_values = 0;
+
120
+
121 // Run through the test multiple times to get a better estimate.
+
122 for (size_t i = 0; i < iterations; i++) {
+
123 tmp = test.test_2x2_lattice(1e-2, 1e5);
+
124 if (tmp == 0) {
+
125 continue;
+
126 }
+
127 accepted_values++;
+
128 res += tmp;
+
129 }
+
130
+
131 std::cout << "Res: " << res / accepted_values << std::endl;
+
132
+
133 return 0;
+
134}
+
Test class for the Ising model.
Definition: test_suite.cpp:36
+
int test_2x2_lattice(double tol, int max_cycles)
Test numerical data with analytical data.
Definition: test_suite.cpp:76
+
void test_init_functions()
Test that initializing works as intended.
Definition: test_suite.cpp:40
+
The Ising model in 2 dimensions.
Definition: IsingModel.hpp:36
+
int64_t E
The current energy state. unit: .
Definition: IsingModel.hpp:70
+
double T
The temperature of the model.
Definition: IsingModel.hpp:62
+
int L
Size of the lattice.
Definition: IsingModel.hpp:66
+
void initialize_lattice()
Initialize the lattice with a random distribution of 1s and -1s.
Definition: IsingModel.cpp:49
+
data_t Metropolis()
The Metropolis algorithm.
Definition: IsingModel.cpp:110
+
void initialize_energy()
Initialize the energy of the system.
Definition: IsingModel.cpp:96
+
void initialize_neighbors()
initialize the neighbors matrix.
Definition: IsingModel.cpp:70
+
void initialize_magnetization()
Initialize the magnetization of the system.
Definition: IsingModel.cpp:88
+
int64_t M
The current magnetic strength. unit: Unitless.
Definition: IsingModel.hpp:74
+
Type to use with the IsingModel class and montecarlo module.
Definition: data_type.hpp:19
+
double M_abs
Absolute Magnetization.
Definition: data_type.hpp:25
+
double E
Energy.
Definition: data_type.hpp:21
+
data_t & operator+=(const data_t &b)
Overload of the addition equals operator.
Definition: data_type.hpp:150
+
double M2
Magnetization squared.
Definition: data_type.hpp:24
+
double E2
Energy squared.
Definition: data_type.hpp:23
+
#define EPS_2
The analytic expected energy for a lattice.
Definition: test_suite.cpp:17
+
#define MAG_2
The analytic expected magnetization for a lattice.
Definition: test_suite.cpp:22
+
#define X_2
The analytic susceptibility for a lattice.
Definition: test_suite.cpp:30
+
int main()
The main function.
Definition: test_suite.cpp:110
+
#define CV_2
The analytic heat capacity for a lattice.
Definition: test_suite.cpp:26
#define ASSERT(expr, msg)
A prettier assertion function.
Definition: testlib.hpp:31
diff --git a/docs/testlib_8cpp.html b/docs/testlib_8cpp.html index 759935c..644d4c2 100644 --- a/docs/testlib_8cpp.html +++ b/docs/testlib_8cpp.html @@ -122,7 +122,7 @@ Functions
Janita Ovidie Sandtrøen Willumsen (janitaws)
Version
1.0
-
Bug:
No known bugs
+
Bug:
No known bugs

Definition in file testlib.cpp.

Function Documentation

diff --git a/docs/testlib_8cpp_source.html b/docs/testlib_8cpp_source.html index 1b8d3f7..3e93441 100644 --- a/docs/testlib_8cpp_source.html +++ b/docs/testlib_8cpp_source.html @@ -101,14 +101,24 @@ $(document).ready(function(){initNavTree('testlib_8cpp_source.html',''); initRes
testlib.cpp
-Go to the documentation of this file.
1
-
12#include "testlib.hpp"
+Go to the documentation of this file.
1/** @file testlib.cpp
+
2 *
+
3 * @author Cory Alexander Balaton (coryab)
+
4 * @author Janita Ovidie Sandtrøen Willumsen (janitaws)
+
5 *
+
6 * @version 1.0
+
7 *
+
8 * @brief Implementation of the testing library
+
9 *
+
10 * @bug No known bugs
+
11 * */
+
12#include "testlib.hpp"
13
-
14namespace details {
+
14namespace details {
15void m_assert(bool expr, std::string expr_str, std::string f, std::string file,
16 int line, std::string msg)
17{
-
18 std::function<void(const std::string &)> print_message =
+
18 std::function<void(const std::string &)> print_message =
19 [](const std::string &msg) {
20 if (msg.size() > 0) {
21 std::cout << "message: " << msg << "\n\n";
@@ -117,7 +127,7 @@ $(document).ready(function(){initNavTree('testlib_8cpp_source.html',''); initRes
24 std::cout << "\n";
25 }
26 };
-
27 std::string new_assert(f.size() + (expr ? 4 : 6), '-');
+
27 std::string new_assert(f.size() + (expr ? 4 : 6), '-');
28 std::cout << "\x1B[36m" << new_assert << "\033[0m\n";
29 std::cout << f << ": ";
30 if (expr) {
@@ -133,7 +143,6 @@ $(document).ready(function(){initNavTree('testlib_8cpp_source.html',''); initRes
40 }
41}
42} // namespace details
-
A small test library.
void m_assert(bool expr, std::string expr_str, std::string func, std::string file, int line, std::string msg)
Test an expression, confirm that test is ok, or abort execution.
Definition: testlib.cpp:15
diff --git a/docs/testlib_8hpp.html b/docs/testlib_8hpp.html index 60ec200..99eafb6 100644 --- a/docs/testlib_8hpp.html +++ b/docs/testlib_8hpp.html @@ -125,6 +125,22 @@ Functions void details::m_assert (bool expr, std::string expr_str, std::string func, std::string file, int line, std::string msg)  Test an expression, confirm that test is ok, or abort execution.
  +template<class T , class = typename std::enable_if<std::is_arithmetic<T>::value>::type> +static bool testlib::close_to (arma::Mat< T > &a, arma::Mat< T > &b, double tol=1e-8) + Test if two armadillo matrices/vectors are close to each other.
+  +template<class T , class = typename std::enable_if<std::is_arithmetic<T>::value>::type> +static bool testlib::close_to (T a, T b, double tol=1e-8) + Test if two numbers are close to each other.
+  +template<class T , class = typename std::enable_if<std::is_integral<T>::value>::type> +static bool testlib::is_equal (arma::Mat< T > &a, arma::Mat< T > &b) + Test if two armadillo matrices/vectors are equal.
+  +template<class T , class = typename std::enable_if<std::is_arithmetic<T>::value>::type> +static bool testlib::assert_each (std::function< bool(T)> expr, arma::Mat< T > &M) + Test that all elements fulfill the condition.

Detailed Description

A small test library.

@@ -133,7 +149,7 @@ Functions Janita Ovidie Sandtrøen Willumsen (janitaws)
Version
1.0

This a small testing library that is tailored for the needs of the project. Anything that is in the details namespace should not be used directly, or else it might cause undefined behavior if not used correctly.

-
Bug:
No known bugs
+
Bug:
No known bugs

Definition in file testlib.hpp.

Macro Definition Documentation

@@ -171,6 +187,223 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)

Function Documentation

+ +

◆ assert_each()

+ +
+
+
+template<class T , class = typename std::enable_if<std::is_arithmetic<T>::value>::type>
+ + + + + +
+ + + + + + + + + + + + + + + + + + +
static bool testlib::assert_each (std::function< bool(T)> expr,
arma::Mat< T > & M 
)
+
+static
+
+ +

Test that all elements fulfill the condition.

+
Parameters
+ + + +
exprThe boolean expression to apply to each element
MThe matrix/vector to iterate over
+
+
+
Returns
bool
+ +

Definition at line 130 of file testlib.hpp.

+ +
+
+ +

◆ close_to() [1/2]

+ +
+
+
+template<class T , class = typename std::enable_if<std::is_arithmetic<T>::value>::type>
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
static bool testlib::close_to (arma::Mat< T > & a,
arma::Mat< T > & b,
double tol = 1e-8 
)
+
+static
+
+ +

Test if two armadillo matrices/vectors are close to each other.

+

This function takes in 2 matrices/vectors and checks if they are approximately equal to each other given a tolerance.

+
Parameters
+ + + + +
aMatrix/vector a
bMatrix/vector b
tolThe tolerance
+
+
+
Returns
bool
+ +

Definition at line 67 of file testlib.hpp.

+ +
+
+ +

◆ close_to() [2/2]

+ +
+
+
+template<class T , class = typename std::enable_if<std::is_arithmetic<T>::value>::type>
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
static bool testlib::close_to (a,
b,
double tol = 1e-8 
)
+
+static
+
+ +

Test if two numbers are close to each other.

+

This function takes in 2 matrices/vectors and checks if they are approximately equal to each other given a tolerance.

+
Parameters
+ + + + +
aMatrix/vector a
bMatrix/vector b
tolThe tolerance
+
+
+
Returns
bool
+ +

Definition at line 94 of file testlib.hpp.

+ +
+
+ +

◆ is_equal()

+ +
+
+
+template<class T , class = typename std::enable_if<std::is_integral<T>::value>::type>
+ + + + + +
+ + + + + + + + + + + + + + + + + + +
static bool testlib::is_equal (arma::Mat< T > & a,
arma::Mat< T > & b 
)
+
+static
+
+ +

Test if two armadillo matrices/vectors are equal.

+

This function takes in 2 matrices/vectors and checks if they are equal to each other. This should only be used for integral types.

+
Parameters
+ + + +
aMatrix/vector a
bMatrix/vector b
+
+
+
Returns
bool
+ +

Definition at line 111 of file testlib.hpp.

+ +
+

◆ m_assert()

diff --git a/docs/testlib_8hpp.js b/docs/testlib_8hpp.js index 9b491a8..09a5613 100644 --- a/docs/testlib_8hpp.js +++ b/docs/testlib_8hpp.js @@ -1,5 +1,9 @@ var testlib_8hpp = [ [ "ASSERT", "testlib_8hpp.html#a73d4f21ad937dbc50a0c0538c78fd4f9", null ], + [ "assert_each", "testlib_8hpp.html#ab6585c8aa8c276a3442c67a57c8de6fb", null ], + [ "close_to", "testlib_8hpp.html#a2cbf3a45367e903de6efbdbea3344cea", null ], + [ "close_to", "testlib_8hpp.html#a44f47fa3c8654c09712572d75c0ffa7f", null ], + [ "is_equal", "testlib_8hpp.html#a3db67d8721d2f3cd626526b43186bcf3", null ], [ "m_assert", "testlib_8hpp.html#a39abb7cba0535176ed62aae136d2fcc7", null ] ]; \ No newline at end of file diff --git a/docs/testlib_8hpp_source.html b/docs/testlib_8hpp_source.html index bfd14a2..8c92105 100644 --- a/docs/testlib_8hpp_source.html +++ b/docs/testlib_8hpp_source.html @@ -101,74 +101,177 @@ $(document).ready(function(){initNavTree('testlib_8hpp_source.html',''); initRes
testlib.hpp
-Go to the documentation of this file.
1
-
16#ifndef __TESTLIB__
-
17#define __TESTLIB__
+Go to the documentation of this file.
1/** @file testlib.hpp
+
2 *
+
3 * @author Cory Alexander Balaton (coryab)
+
4 * @author Janita Ovidie Sandtrøen Willumsen (janitaws)
+
5 *
+
6 * @version 1.0
+
7 *
+
8 * @brief A small test library.
+
9 *
+
10 * @details This a small testing library that is tailored for the needs of the
+
11 * project. Anything that is in the details namespace should not be used
+
12 * directly, or else it might cause undefined behavior if not used correctly.
+
13 *
+
14 * @bug No known bugs
+
15 * */
+
16#ifndef __TESTLIB__
+
17#define __TESTLIB__
18
-
19#include "utils.hpp"
+
19#include "utils.hpp"
20
-
21#include <armadillo>
-
22#include <string>
-
23#include <type_traits>
+
21#include <armadillo>
+
22#include <string>
+
23#include <type_traits>
24
-
31#define ASSERT(expr, msg) \
-
32 details::m_assert(expr, #expr, __METHOD_NAME__, __FILE__, __LINE__, msg)
+
25/** @def ASSERT(expr)
+
26 * @brief A prettier assertion function.
+
27 *
+
28 * This macro calls the m_assert function which is a more informative
+
29 * assertion function than the regular assert function from cassert.
+
30 * */
+
31#define ASSERT(expr, msg)
+
32 details::m_assert(expr, #expr, __METHOD_NAME__, __FILE__, __LINE__, msg)
33
-
34namespace details {
-
47void m_assert(bool expr, std::string expr_str, std::string func,
-
48 std::string file, int line, std::string msg);
-
49} // namespace details
-
50
-
51namespace testlib {
-
63template <class T,
-
64 class = typename std::enable_if<std::is_arithmetic<T>::value>::type>
-
65static bool close_to(arma::Mat<T> &a, arma::Mat<T> &b, double tol = 1e-8)
-
66{
-
67 if (a.n_elem != b.n_elem) {
-
68 return false;
-
69 }
-
70
-
71 for (size_t i = 0; i < a.n_elem; i++) {
-
72 if (!close_to(a(i), b(i))) {
-
73 return false;
-
74 }
-
75 }
-
76 return true;
-
77}
-
78
-
90template <class T,
-
91 class = typename std::enable_if<std::is_arithmetic<T>::value>::type>
-
92static bool close_to(T a, T b, double tol = 1e-8)
-
93{
-
94 return std::fabs(a - b) < tol;
-
95}
-
96
-
107template <class T,
-
108 class = typename std::enable_if<std::is_integral<T>::value>::type>
-
109static bool is_equal(arma::Mat<T> &a, arma::Mat<T> &b)
-
110{
-
111 for (size_t i = 0; i < a.n_elem; i++) {
-
112 if (!(a(i) == b(i))) {
-
113 return false;
-
114 }
-
115 }
-
116 return true;
-
117}
-
118
-
126template <class T,
-
127 class = typename std::enable_if<std::is_arithmetic<T>::value>::type>
-
128static bool assert_each(std::function<bool(T)> expr, arma::Mat<T> &M)
-
129{
-
130 for (size_t i = 0; i < M.n_elem; i++) {
-
131 if (!expr(M(i))) {
-
132 return false;
-
133 }
-
134 }
-
135 return true;
-
136}
-
137} // namespace testlib
-
138#endif
-
Function prototypes and macros that are useful.
+
34namespace details {
+
35
+
36/** @brief Test an expression, confirm that test is ok, or abort execution.
+
37 *
+
38 * @details This function takes in an expression and prints an OK message if
+
39 * it's true, or it prints a fail message and aborts execution if it fails.
+
40 *
+
41 * @param expr The expression to be evaluated
+
42 * @param expr_str The stringified version of the expression
+
43 * @param func The function name of the caller
+
44 * @param file The file of the caller
+
45 * @param line The line number where this function is called from
+
46 * @param msg The message to be displayed
+
47 * */
+
48void m_assert(bool expr, std::string expr_str, std::string func,
+
49 std::string file, int line, std::string msg);
+
50} // namespace details
+
51
+
52namespace testlib {
+
53
+
54/** @brief Test if two armadillo matrices/vectors are close to each other.
+
55 *
+
56 * @details This function takes in 2 matrices/vectors and checks if they are
+
57 * approximately equal to each other given a tolerance.
+
58 *
+
59 * @param a Matrix/vector a
+
60 * @param b Matrix/vector b
+
61 * @param tol The tolerance
+
62 *
+
63 * @return bool
+
64 * */
+
65template <class T,
+
66 class = typename std::enable_if<std::is_arithmetic<T>::value>::type>
+
67static bool close_to(arma::Mat<T> &a, arma::Mat<T> &b, double tol = 1e-8)
+
68{
+
69 if (a.n_elem != b.n_elem) {
+
70 return false;
+
71 }
+
72
+
73 for (size_t i = 0; i < a.n_elem; i++) {
+
74 if (!close_to(a(i), b(i))) {
+
75 return false;
+
76 }
+
77 }
+
78 return true;
+
79}
+
80
+
81/** @brief Test if two numbers are close to each other.
+
82 *
+
83 * @details This function takes in 2 matrices/vectors and checks if they are
+
84 * approximately equal to each other given a tolerance.
+
85 *
+
86 * @param a Matrix/vector a
+
87 * @param b Matrix/vector b
+
88 * @param tol The tolerance
+
89 *
+
90 * @return bool
+
91 * */
+
92template <class T,
+
93 class = typename std::enable_if<std::is_arithmetic<T>::value>::type>
+
94static bool close_to(T a, T b, double tol = 1e-8)
+
95{
+
96 return std::fabs(a - b) < tol;
+
97}
+
98
+
99/** @brief Test if two armadillo matrices/vectors are equal.
+
100 *
+
101 * @details This function takes in 2 matrices/vectors and checks if they are
+
102 * equal to each other. This should only be used for integral types.
+
103 *
+
104 * @param a Matrix/vector a
+
105 * @param b Matrix/vector b
+
106 *
+
107 * @return bool
+
108 * */
+
109template <class T,
+
110 class = typename std::enable_if<std::is_integral<T>::value>::type>
+
111static bool is_equal(arma::Mat<T> &a, arma::Mat<T> &b)
+
112{
+
113 for (size_t i = 0; i < a.n_elem; i++) {
+
114 if (!(a(i) == b(i))) {
+
115 return false;
+
116 }
+
117 }
+
118 return true;
+
119}
+
120
+
121/** @brief Test that all elements fulfill the condition.
+
122 *
+
123 * @param expr The boolean expression to apply to each element
+
124 * @param M The matrix/vector to iterate over
+
125 *
+
126 * @return bool
+
127 * */
+
128template <class T,
+
129 class = typename std::enable_if<std::is_arithmetic<T>::value>::type>
+
130static bool assert_each(std::function<bool(T)> expr, arma::Mat<T> &M)
+
131{
+
132 for (size_t i = 0; i < M.n_elem; i++) {
+
133 if (!expr(M(i))) {
+
134 return false;
+
135 }
+
136 }
+
137 return true;
+
138}
+
139} // namespace testlib
+
140#endif
+
Test class for the Ising model.
Definition: test_suite.cpp:36
+
int test_2x2_lattice(double tol, int max_cycles)
Test numerical data with analytical data.
Definition: test_suite.cpp:76
+
void test_init_functions()
Test that initializing works as intended.
Definition: test_suite.cpp:40
+
The Ising model in 2 dimensions.
Definition: IsingModel.hpp:36
+
int64_t E
The current energy state. unit: .
Definition: IsingModel.hpp:70
+
double T
The temperature of the model.
Definition: IsingModel.hpp:62
+
int L
Size of the lattice.
Definition: IsingModel.hpp:66
+
void initialize_lattice()
Initialize the lattice with a random distribution of 1s and -1s.
Definition: IsingModel.cpp:49
+
data_t Metropolis()
The Metropolis algorithm.
Definition: IsingModel.cpp:110
+
void initialize_energy()
Initialize the energy of the system.
Definition: IsingModel.cpp:96
+
void initialize_neighbors()
initialize the neighbors matrix.
Definition: IsingModel.cpp:70
+
void initialize_magnetization()
Initialize the magnetization of the system.
Definition: IsingModel.cpp:88
+
int64_t M
The current magnetic strength. unit: Unitless.
Definition: IsingModel.hpp:74
+
Type to use with the IsingModel class and montecarlo module.
Definition: data_type.hpp:19
+
double M_abs
Absolute Magnetization.
Definition: data_type.hpp:25
+
double E
Energy.
Definition: data_type.hpp:21
+
data_t & operator+=(const data_t &b)
Overload of the addition equals operator.
Definition: data_type.hpp:150
+
double M2
Magnetization squared.
Definition: data_type.hpp:24
+
double E2
Energy squared.
Definition: data_type.hpp:23
+
#define EPS_2
The analytic expected energy for a lattice.
Definition: test_suite.cpp:17
+
#define MAG_2
The analytic expected magnetization for a lattice.
Definition: test_suite.cpp:22
+
#define X_2
The analytic susceptibility for a lattice.
Definition: test_suite.cpp:30
+
int main()
The main function.
Definition: test_suite.cpp:110
+
#define CV_2
The analytic heat capacity for a lattice.
Definition: test_suite.cpp:26
+
static bool close_to(arma::Mat< T > &a, arma::Mat< T > &b, double tol=1e-8)
Test if two armadillo matrices/vectors are close to each other.
Definition: testlib.hpp:67
+
void m_assert(bool expr, std::string expr_str, std::string func, std::string file, int line, std::string msg)
Test an expression, confirm that test is ok, or abort execution.
Definition: testlib.cpp:15
+
static bool is_equal(arma::Mat< T > &a, arma::Mat< T > &b)
Test if two armadillo matrices/vectors are equal.
Definition: testlib.hpp:111
+
static bool close_to(T a, T b, double tol=1e-8)
Test if two numbers are close to each other.
Definition: testlib.hpp:94
+
#define ASSERT(expr, msg)
A prettier assertion function.
Definition: testlib.hpp:31
+
static bool assert_each(std::function< bool(T)> expr, arma::Mat< T > &M)
Test that all elements fulfill the condition.
Definition: testlib.hpp:130
+
#define __METHOD_NAME__
Get the name of the current method/function without the return type.
Definition: utils.hpp:45
diff --git a/docs/time_8cpp.html b/docs/time_8cpp.html new file mode 100644 index 0000000..809c11e --- /dev/null +++ b/docs/time_8cpp.html @@ -0,0 +1,249 @@ + + + + + + + +2 Dimensional Ising Model: src/time.cpp File Reference + + + + + + + + + + + + + + + + +
+
+ + + + + + +
+
2 Dimensional Ising Model +
+
Simulate the change in energy and magnetization in a ferro magnet
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
time.cpp File Reference
+
+
+ +

Timing various things. +More...

+
#include "data_type.hpp"
+#include "monte_carlo.hpp"
+#include "utils.hpp"
+#include <getopt.h>
+#include <omp.h>
+#include <ostream>
+
+

Go to the source code of this file.

+ + + + + + + + + + + + + + +

+Functions

void time_lattice_sizes ()
 Time phase transition using different lattice sizes.
 
void time_sample_sizes ()
 Time phase transition using different sample sizes.
 
void usage (std::string filename)
 A function that displays how to use the program and quits.
 
int main (int argc, char **argv)
 The main function.
 
+

Detailed Description

+

Timing various things.

+
Author
Cory Alexander Balaton (coryab)
+
+Janita Ovidie Sandtrøen Willumsen (janitaws)
+
Version
0.1
+
Bug:
No known bugs
+ +

Definition in file time.cpp.

+

Function Documentation

+ +

◆ main()

+ +
+
+ + + + + + + + + + + + + + + + + + +
int main (int argc,
char ** argv 
)
+
+ +

The main function.

+ +

Definition at line 79 of file time.cpp.

+ +
+
+ +

◆ time_lattice_sizes()

+ +
+
+ + + + + + + +
void time_lattice_sizes ()
+
+ +

Time phase transition using different lattice sizes.

+ +

Definition at line 22 of file time.cpp.

+ +
+
+ +

◆ time_sample_sizes()

+ +
+
+ + + + + + + +
void time_sample_sizes ()
+
+ +

Time phase transition using different sample sizes.

+ +

Definition at line 45 of file time.cpp.

+ +
+
+ +

◆ usage()

+ +
+
+ + + + + + + + +
void usage (std::string filename)
+
+ +

A function that displays how to use the program and quits.

+ +

Definition at line 67 of file time.cpp.

+ +
+
+
+
+ + + + diff --git a/docs/time_8cpp.js b/docs/time_8cpp.js new file mode 100644 index 0000000..d8d555c --- /dev/null +++ b/docs/time_8cpp.js @@ -0,0 +1,7 @@ +var time_8cpp = +[ + [ "main", "time_8cpp.html#a3c04138a5bfe5d72780bb7e82a18e627", null ], + [ "time_lattice_sizes", "time_8cpp.html#aa224066f42c47cae5fbd457c1948e4a5", null ], + [ "time_sample_sizes", "time_8cpp.html#ace9eb0821fe4edf19cf2e7d8ffe6efb4", null ], + [ "usage", "time_8cpp.html#ac907e18135856c90366aaa599a9e10b1", null ] +]; \ No newline at end of file diff --git a/docs/time_8cpp_source.html b/docs/time_8cpp_source.html new file mode 100644 index 0000000..b4559b7 --- /dev/null +++ b/docs/time_8cpp_source.html @@ -0,0 +1,244 @@ + + + + + + + +2 Dimensional Ising Model: src/time.cpp Source File + + + + + + + + + + + + + + + + +
+
+ + + + + + +
+
2 Dimensional Ising Model +
+
Simulate the change in energy and magnetization in a ferro magnet
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+
time.cpp
+
+
+Go to the documentation of this file.
1/** @file time.cpp
+
2 *
+
3 * @author Cory Alexander Balaton (coryab)
+
4 * @author Janita Ovidie Sandtrøen Willumsen (janitaws)
+
5 *
+
6 * @version 0.1
+
7 *
+
8 * @brief Timing various things.
+
9 *
+
10 * @bug No known bugs
+
11 * */
+
12#include "data_type.hpp"
+
13#include "monte_carlo.hpp"
+
14#include "utils.hpp"
+
15
+
16#include <getopt.h>
+
17#include <omp.h>
+
18#include <ostream>
+
19
+
20/** @brief Time phase transition using different lattice sizes.
+
21 * */
+ +
23{
+
24 std::string outfile = "data/timing/lattice_sizes.txt";
+
25 std::ofstream ofile;
+
26
+
27 int lattice_sizes[] = {20, 40, 60, 80, 100};
+
28
+
29 utils::mkpath(utils::dirname(outfile));
+
30 ofile.open(outfile);
+
31 double t0, t1;
+
32 for (int L : lattice_sizes) {
+
33 t0 = omp_get_wtime();
+
34 montecarlo::phase_transition(L, 2.1, 2.4, 40, 100000,
+
35 montecarlo::mcmc_parallel, "/dev/null");
+
36 t1 = omp_get_wtime();
+
37 ofile << utils::scientific_format(L) << ','
+
38 << utils::scientific_format(t1 - t0) << '\n';
+
39 }
+
40 ofile.close();
+
41}
+
42
+
43/** @brief Time phase transition using different sample sizes.
+
44 * */
+ +
46{
+
47 std::string outfile = "data/timing/sample_sizes.txt";
+
48 std::ofstream ofile;
+
49
+
50 int sample_sizes[] = {1000, 10000, 100000};
+
51
+
52 utils::mkpath(utils::dirname(outfile));
+
53 ofile.open(outfile);
+
54 double t0, t1;
+
55 for (int samples : sample_sizes) {
+
56 t0 = omp_get_wtime();
+
57 montecarlo::phase_transition(20, 2.1, 2.4, 40, samples,
+
58 montecarlo::mcmc_parallel, "/dev/null");
+
59 t1 = omp_get_wtime();
+
60 ofile << utils::scientific_format(samples) << ','
+
61 << utils::scientific_format(t1 - t0) << '\n';
+
62 }
+
63 ofile.close();
+
64}
+
65
+
66/** @brief A function that displays how to use the program and quits.*/
+
67void usage(std::string filename)
+
68{
+
69 std::cout << "Usage: " << filename << " OPTION ...\n"
+
70 << "At least one option should be used.\n\n"
+
71 << "\t[ -h | --help ]\n"
+
72 << "\t[ --all ]\n"
+
73 << "\t[ --time-lattice-sizes ]\n"
+
74 << "\t[ --time-sample-sizes ]\n";
+
75 exit(-1);
+
76}
+
77
+
78/** @brief The main function.*/
+
79int main(int argc, char **argv)
+
80{
+
81 struct option long_options[] = {{"all", 0, 0, 0},
+
82 {"time-lattice-sizes", 0, 0, 0},
+
83 {"time-sample-sizes", 0, 0, 0},
+
84 {"help", 0, 0, 0},
+
85 {NULL, 0, NULL, 0}};
+
86
+
87 int option_index = -1;
+
88 int c;
+
89
+
90 while (true) {
+
91 c = getopt_long(argc, argv, "h", long_options, &option_index);
+
92
+
93 if (c == -1)
+
94 break;
+
95
+
96 switch (c) {
+
97 case 0:
+
98 switch (option_index) {
+
99 case 0:
+ + +
102 break;
+
103 case 1:
+ +
105 break;
+
106 case 2:
+ +
108 break;
+
109 case 3: // Not a mistake. This just goes to the default.
+
110 default:
+
111 usage(argv[0]);
+
112 }
+
113 break;
+
114 case 'h':
+
115 default:
+
116 usage(argv[0]);
+
117 }
+
118 }
+
119
+
120 return 0;
+
121}
+
int main(int argc, char **argv)
The main function.
Definition: main.cpp:125
+
void usage(std::string filename)
A function that displays how to use the program and quits.
Definition: main.cpp:110
+
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.
+
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.
+
void time_lattice_sizes()
Time phase transition using different lattice sizes.
Definition: time.cpp:22
+
void time_sample_sizes()
Time phase transition using different sample sizes.
Definition: time.cpp:45
+
bool mkpath(std::string path, int mode=0777)
Make path given.
Definition: utils.cpp:32
+
std::string scientific_format(double d, int width=20, int prec=10)
Turns a double into a string written in scientific format.
Definition: utils.cpp:16
+
std::string dirname(const std::string &path)
Get the directory name of the path.
Definition: utils.cpp:58
+
+
+ + + + diff --git a/docs/typedefs_8hpp.html b/docs/typedefs_8hpp.html index 1f2efc5..4362ecf 100644 --- a/docs/typedefs_8hpp.html +++ b/docs/typedefs_8hpp.html @@ -113,7 +113,7 @@ $(document).ready(function(){initNavTree('typedefs_8hpp.html',''); initResizable Janita Ovidie Sandtrøen Willumsen (janitaws)
Version
1.0

These typedefs make the code more readable and easy to follow along.

-
Bug:
No known bugs
+
Bug:
No known bugs

Definition in file typedefs.hpp.

diff --git a/docs/utils_8cpp.html b/docs/utils_8cpp.html index fdff28a..bde3745 100644 --- a/docs/utils_8cpp.html +++ b/docs/utils_8cpp.html @@ -124,6 +124,9 @@ Functions std::string utils::dirname (const std::string &path)  Get the directory name of the path.
  +std::string utils::concatpath (const std::string &left, const std::string &right) + Take 2 strings and concatenate them and make sure there is a directory separator (/) between them.

Detailed Description

Implementation of the utils.

@@ -131,10 +134,51 @@ Functions
Janita Ovidie Sandtrøen Willumsen (janitaws)
Version
1.0
-
Bug:
No known bugs
+
Bug:
No known bugs

Definition in file utils.cpp.

Function Documentation

+ +

◆ concatpath()

+ +
+
+ + + + + + + + + + + + + + + + + + +
std::string utils::concatpath (const std::string & left,
const std::string & right 
)
+
+ +

Take 2 strings and concatenate them and make sure there is a directory separator (/) between them.

+

This function doesn't care whether or not the values given as parameters are valid path strings. It is the responsibility of the user to make sure that the values given are valid path strings. The function only guarantees that the output string is a valid path string.

+
Parameters
+ + + +
leftThe left hand side of the result string
rightThe right hand side of the result string
+
+
+
Returns
string
+ +

Definition at line 63 of file utils.cpp.

+ +
+

◆ dirname()

diff --git a/docs/utils_8cpp.js b/docs/utils_8cpp.js index edb7fe6..8450d12 100644 --- a/docs/utils_8cpp.js +++ b/docs/utils_8cpp.js @@ -1,5 +1,6 @@ var utils_8cpp = [ + [ "concatpath", "utils_8cpp.html#ae91fad89394d745d544737e43524bde6", null ], [ "dirname", "utils_8cpp.html#aed026119193a9bbe076671809ff0f430", null ], [ "mkpath", "utils_8cpp.html#a2b45adc86b70f42021582994e83fa00d", null ], [ "scientific_format", "utils_8cpp.html#ab3e89176433ddc9ba721b2eba3d08357", null ], diff --git a/docs/utils_8cpp_source.html b/docs/utils_8cpp_source.html index ab3a676..74ed3fb 100644 --- a/docs/utils_8cpp_source.html +++ b/docs/utils_8cpp_source.html @@ -101,10 +101,20 @@ $(document).ready(function(){initNavTree('utils_8cpp_source.html',''); initResiz
utils.cpp
-Go to the documentation of this file.
1
-
12#include "utils.hpp"
+Go to the documentation of this file.
1/** @file utils.cpp
+
2 *
+
3 * @author Cory Alexander Balaton (coryab)
+
4 * @author Janita Ovidie Sandtrøen Willumsen (janitaws)
+
5 *
+
6 * @version 1.0
+
7 *
+
8 * @brief Implementation of the utils
+
9 *
+
10 * @bug No known bugs
+
11 * */
+
12#include "utils.hpp"
13
-
14namespace utils {
+
14namespace utils {
15
16std::string scientific_format(double d, int width, int prec)
17{
@@ -113,11 +123,11 @@ $(document).ready(function(){initNavTree('utils_8cpp_source.html',''); initResiz
20 return ss.str();
21}
22
-
23std::string scientific_format(const std::vector<double> &v, int width, int prec)
+
23std::string scientific_format(const std::vector<double> &v, int width, int prec)
24{
25 std::stringstream ss;
26 for (double elem : v) {
-
27 ss << scientific_format(elem, width, prec);
+
27 ss << scientific_format(elem, width, prec);
28 }
29 return ss.str();
30}
@@ -126,14 +136,14 @@ $(document).ready(function(){initNavTree('utils_8cpp_source.html',''); initResiz
33{
34 std::string cur_dir;
35 std::string::size_type pos = -1;
-
36 struct stat buf;
+
36 struct stat buf;
37
-
38 if (path.back() != '/') {
-
39 path += '/';
+
38 if (path.back() != '/') {
+
39 path += '/';
40 }
41 while (true) {
42 pos++;
-
43 pos = path.find('/', pos);
+
43 pos = path.find('/', pos);
44 if (pos != std::string::npos) {
45 cur_dir = path.substr(0, pos);
46 if (mkdir(cur_dir.c_str(), mode) != 0
@@ -153,10 +163,21 @@ $(document).ready(function(){initNavTree('utils_8cpp_source.html',''); initResiz
60 return path.substr(0, path.find_last_of("/"));
61}
62
-
63} // namespace utils
-
Function prototypes and macros that are useful.
+
63std::string concatpath(const std::string &left, const std::string &right)
+
64{
+
65 if (left.back() != '/' and right.front() != '/') {
+
66 return left + '/' + right;
+
67 }
+
68 else {
+
69 return left + right;
+
70 }
+
71}
+
72
+
73} // namespace utils
bool mkpath(std::string path, int mode=0777)
Make path given.
Definition: utils.cpp:32
std::string scientific_format(double d, int width=20, int prec=10)
Turns a double into a string written in scientific format.
Definition: utils.cpp:16
+
std::string scientific_format(const std::vector< double > &v, int width=20, int prec=10)
Turns a vector of doubles into a string written in scientific format.
Definition: utils.cpp:23
+
std::string concatpath(const std::string &left, const std::string &right)
Take 2 strings and concatenate them and make sure there is a directory separator (/) between them.
Definition: utils.cpp:63
std::string dirname(const std::string &path)
Get the directory name of the path.
Definition: utils.cpp:58
diff --git a/docs/utils_8hpp.html b/docs/utils_8hpp.html index 44140c6..ee2413b 100644 --- a/docs/utils_8hpp.html +++ b/docs/utils_8hpp.html @@ -142,6 +142,9 @@ Functions std::string utils::dirname (const std::string &path)  Get the directory name of the path.
  +std::string utils::concatpath (const std::string &left, const std::string &right) + Take 2 strings and concatenate them and make sure there is a directory separator (/) between them.

Detailed Description

Function prototypes and macros that are useful.

@@ -196,6 +199,47 @@ Janita Ovidie Sandtrøen Willumsen (janitaws)

Function Documentation

+ +

◆ concatpath()

+ +
+
+ + + + + + + + + + + + + + + + + + +
std::string utils::concatpath (const std::string & left,
const std::string & right 
)
+
+ +

Take 2 strings and concatenate them and make sure there is a directory separator (/) between them.

+

This function doesn't care whether or not the values given as parameters are valid path strings. It is the responsibility of the user to make sure that the values given are valid path strings. The function only guarantees that the output string is a valid path string.

+
Parameters
+ + + +
leftThe left hand side of the result string
rightThe right hand side of the result string
+
+
+
Returns
string
+ +

Definition at line 63 of file utils.cpp.

+ +
+

◆ dirname()

diff --git a/docs/utils_8hpp.js b/docs/utils_8hpp.js index 9c9e4b4..e68e7de 100644 --- a/docs/utils_8hpp.js +++ b/docs/utils_8hpp.js @@ -2,6 +2,7 @@ var utils_8hpp = [ [ "__METHOD_NAME__", "utils_8hpp.html#a60dca3177fb9cb5256609adc7af55168", null ], [ "DEBUG", "utils_8hpp.html#aecc1f7a8a2493b9e021e5bff76a00a5b", null ], + [ "concatpath", "utils_8hpp.html#ae91fad89394d745d544737e43524bde6", null ], [ "dirname", "utils_8hpp.html#aed026119193a9bbe076671809ff0f430", null ], [ "methodName", "utils_8hpp.html#a178c4922157666a6e9c127c2ffd96346", null ], [ "mkpath", "utils_8hpp.html#a2b45adc86b70f42021582994e83fa00d", null ], diff --git a/docs/utils_8hpp_source.html b/docs/utils_8hpp_source.html index 2d2a1bd..84ff5bc 100644 --- a/docs/utils_8hpp_source.html +++ b/docs/utils_8hpp_source.html @@ -101,55 +101,173 @@ $(document).ready(function(){initNavTree('utils_8hpp_source.html',''); initResiz
utils.hpp
-Go to the documentation of this file.
1
-
17#ifndef __UTILS__
-
18#define __UTILS__
+Go to the documentation of this file.
1/** @file utils.hpp
+
2 *
+
3 * @author Cory Alexander Balaton (coryab)
+
4 * @author Janita Ovidie Sandtrøen Willumsen (janitaws)
+
5 *
+
6 * @version 1.0
+
7 *
+
8 * @brief Function prototypes and macros that are useful.
+
9 *
+
10 * These utility function are mainly for convenience and aren't directly
+
11 * related to the project. Anything that is in the details namespace should
+
12 * not be used directly, or else it might cause undefined behavior if not used
+
13 * correctly.
+
14 *
+
15 * @bug No known bugs
+
16 * */
+
17#ifndef __UTILS__
+
18#define __UTILS__
19
-
20#include <armadillo>
-
21#include <iomanip>
-
22#include <sstream>
-
23#include <string>
-
24#include <sys/stat.h>
-
25#include <vector>
+
20#include <armadillo>
+
21#include <iomanip>
+
22#include <sstream>
+
23#include <string>
+
24#include <sys/stat.h>
+
25#include <vector>
26
-
35#ifdef DBG
-
36#define DEBUG(msg) \
-
37 std::cout << __FILE__ << " " << __LINE__ << ": " << msg << std::endl
-
38#else
-
39#define DEBUG(msg)
-
40#endif
+
27/** @def DEBUG(msg)
+
28 * @brief Writes a debug message
+
29 *
+
30 * This macro writes a debug message that includes the filename,
+
31 * line number, and a custom message. The function is wrapped in an ifdef
+
32 * that checks if DBG is defined, so one can choose to display the debug
+
33 * messages by adding the -DDBG flag when compiling.
+
34 * */
+
35#ifdef DBG
+
36#define DEBUG(msg)
+
37 std::cout << __FILE__ << " " << __LINE__ << ": " << msg << std::endl
+
38#else
+
39#define DEBUG(msg)
+
40#endif
41
-
45#define __METHOD_NAME__ details::methodName(__PRETTY_FUNCTION__)
+
42/** @def __METHOD_NAME__
+
43 * @brief Get the name of the current method/function without the return type.
+
44 * */
+
45#define __METHOD_NAME__ details::methodName(__PRETTY_FUNCTION__)
46
-
47namespace details {
+
47namespace details {
+
48/** @brief Takes in the __PRETTY_FUNCTION__ string and removes the return type.
+
49 *
+
50 * @details This function should only be used for the __METHOD_NAME__ macro,
+
51 * since it takes the output from __PRETTY_FUNCTION__ and strips the return
+
52 * type.
+
53 *
+
54 * @param pretty_function The string from __PRETTY_FUNCTION__
+
55 *
+
56 * @return std::string
+
57 * */
58inline std::string methodName(const std::string &pretty_function)
59{
-
60 size_t colons = pretty_function.find("::");
-
61 size_t begin = pretty_function.substr(0, colons).rfind(" ") + 1;
-
62 size_t end = pretty_function.rfind("(") - begin;
+
60 size_t colons = pretty_function.find("::");
+
61 size_t begin = pretty_function.substr(0, colons).rfind(" ") + 1;
+
62 size_t end = pretty_function.rfind("(") - begin;
63
64 return pretty_function.substr(begin, end) + "()";
65}
66
67} // namespace details
68
-
69namespace utils {
+
69namespace utils {
70
+
71/** @brief Turns a double into a string written in scientific format.
+
72 *
+
73 * @details The code is stolen from https://github.com/anderkve/FYS3150.
+
74 *
+
75 * @param d The number to stringify
+
76 * @param width The reserved width of the string
+
77 * @param prec The precision of the stringified number
+
78 *
+
79 * @return std::string
+
80 * */
81std::string scientific_format(double d, int width = 20, int prec = 10);
82
-
94std::string scientific_format(const std::vector<double> &v, int width = 20,
+
83/** @brief Turns a vector of doubles into a string written in scientific
+
84 * format.
+
85 *
+
86 * @details The code is stolen from https://github.com/anderkve/FYS3150.
+
87 *
+
88 * @param v The vector to stringify
+
89 * @param width The reserved width of the string
+
90 * @param prec The precision of the stringified number
+
91 *
+
92 * @return std::string
+
93 * */
+
94std::string scientific_format(const std::vector<double> &v, int width = 20,
95 int prec = 10);
96
+
97/** @brief Make path given.
+
98 *
+
99 * @details This tries to be the equivalent to "mkdir -p" and creates a new
+
100 * directory whenever it needs to.
+
101 *
+
102 * @param path The path to be created
+
103 * @param mode The mode/permissions for all the new directories
+
104 *
+
105 * @return bool Success/Fail
+
106 * */
107bool mkpath(std::string path, int mode = 0777);
108
+
109/** @brief Get the directory name of the path
+
110 *
+
111 * @param path The path to use.
+
112 *
+
113 * @return string
+
114 * */
115std::string dirname(const std::string &path);
116
-
117} // namespace utils
-
118
-
119#endif
+
117/** @brief Take 2 strings and concatenate them and make sure there is a
+
118 * directory separator (/) between them.
+
119 *
+
120 * @details This function doesn't care whether or not the values given as
+
121 * parameters are valid path strings. It is the responsibility of the user to make
+
122 * sure that the values given are valid path strings.
+
123 * The function only guarantees that the output string is a valid path string.
+
124 *
+
125 * @param left The left hand side of the result string
+
126 * @param right The right hand side of the result string
+
127 *
+
128 * @return string
+
129 * */
+
130std::string concatpath(const std::string &left, const std::string &right);
+
131
+
132} // namespace utils
+
133
+
134#endif
+
#define UP
Used for the neighbor matrix in the class.
Definition: IsingModel.hpp:26
+
#define INDEX(I, N)
I modulo N.
Definition: IsingModel.hpp:23
+
#define DOWN
Used for the neighbor matrix in the class.
Definition: IsingModel.hpp:28
+
#define LEFT
Used for the neighbor matrix in the class.
Definition: IsingModel.hpp:27
+
#define RIGHT
Used for the neighbor matrix in the class.
Definition: IsingModel.hpp:29
+
Test class for the Ising model.
Definition: test_suite.cpp:36
+
The Ising model in 2 dimensions.
Definition: IsingModel.hpp:36
+
std::mt19937 engine
The RNG that is used for the Metropolis algorithm.
Definition: IsingModel.hpp:78
+
int64_t E
The current energy state. unit: .
Definition: IsingModel.hpp:70
+
double T
The temperature of the model.
Definition: IsingModel.hpp:62
+
int L
Size of the lattice.
Definition: IsingModel.hpp:66
+
arma::Mat< int > lattice
matrix where element .
Definition: IsingModel.hpp:44
+
void initialize_lattice()
Initialize the lattice with a random distribution of 1s and -1s.
Definition: IsingModel.cpp:49
+
IsingModel(int L, double T, int val)
Constructor for the Ising model.
Definition: IsingModel.cpp:31
+
IsingModel(int L, double T)
Constructor for the Ising model.
Definition: IsingModel.cpp:19
+
data_t Metropolis()
The Metropolis algorithm.
Definition: IsingModel.cpp:110
+
void initialize_energy()
Initialize the energy of the system.
Definition: IsingModel.cpp:96
+
void initialize_neighbors()
initialize the neighbors matrix.
Definition: IsingModel.cpp:70
+
double energy_diff[17]
An array containing all possible energy differences.
Definition: IsingModel.hpp:58
+
void initialize_magnetization()
Initialize the magnetization of the system.
Definition: IsingModel.cpp:88
+
arma::Mat< int > neighbors
matrix with the neighbors of each element .
Definition: IsingModel.hpp:54
+
void initialize_engine()
Initialize the RNG.
Definition: IsingModel.cpp:43
+
void initialize_lattice(int val)
Initialize the lattice with a specific value.
Definition: IsingModel.cpp:59
+
IsingModel()
Constructor used for testing.
Definition: IsingModel.cpp:14
+
int64_t M
The current magnetic strength. unit: Unitless.
Definition: IsingModel.hpp:74
+
void initialize_energy_diff()
Initialize the energy_diff array with the correct values.
Definition: IsingModel.cpp:81
+
Type to use with the IsingModel class and montecarlo module.
Definition: data_type.hpp:19
+
data_t(double E, double E2, double M, double M2, double M_abs)
Constructor with parameters.
Definition: data_type.hpp:45
std::string methodName(const std::string &pretty_function)
Takes in the PRETTY_FUNCTION string and removes the return type.
Definition: utils.hpp:58
bool mkpath(std::string path, int mode=0777)
Make path given.
Definition: utils.cpp:32
std::string scientific_format(double d, int width=20, int prec=10)
Turns a double into a string written in scientific format.
Definition: utils.cpp:16
+
std::string scientific_format(const std::vector< double > &v, int width=20, int prec=10)
Turns a vector of doubles into a string written in scientific format.
Definition: utils.cpp:23
+
std::string concatpath(const std::string &left, const std::string &right)
Take 2 strings and concatenate them and make sure there is a directory separator (/) between them.
Definition: utils.cpp:63
std::string dirname(const std::string &path)
Get the directory name of the path.
Definition: utils.cpp:58