-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlattice_membrane_main.cpp
148 lines (120 loc) · 4.18 KB
/
lattice_membrane_main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/*============================================================================
Name : Basic_Ising_Kawasaki.cpp
Author : Moritz Hoferer
Date : 20.09.2016
Version : 2.0
Copyright :
Description :Basic Ising model with conserved dynamics
local Kawasaki algorithm
during the burn - in phase (with only type A and B particles) of the simulation a nonlocal Kawasaki algorithm
is used to get faster into the equilibrium state. Type O particles (obstacles) are added later (2nd burn in)
NEW way of counting simulation steps, that sim. steps are comparable to a real time
(1 steps is defined as size_i*size_j sim. steps)
New in 2.0:
no more screen shots of the whole system
new recorded quantities: cluster sizes with and without obstacle, obstacles position in the system with periodic and with infinite boundary conditions
Note :External field function is missing (until now not needed),
also open boundary conditions
recording density can be used to record snapshot with some exposure time
============================================================================*/
#include <iostream>
#include <string>
#include <iomanip>
#include "lattice_membrane_core.h"
#include "timer.h"
using namespace std;
int main(int argc, char *argv[]) {
double Parameters[25];
// initialization of the timer
timer control;
// start the timer
control.start();
// Initialization of the output files
ofstream file0, file1, file2, file3, file4, file5, file6;
string str, identifier, out0, out1, out2, out3, out4, out5, out6;
// define name of input file
str = "Parameters";
str.append(argv[1]);
str.append(".txt");
// read in the control parameter for lattice configuration and particle properties
read_in_parameters(str, Parameters);
// construct an identifier
identifier = "_T_";
identifier.append( do_to_str(Parameters[5]));
if(Parameters[6] != 0 && Parameters[7] != 0 && Parameters[8] != 0){
identifier.append("_E_AA_");
identifier.append( do_to_str(Parameters[9]));
identifier.append("_E_BB_");
identifier.append(do_to_str(Parameters[10]));
identifier.append("_E_OO_");
identifier.append(do_to_str(Parameters[11]));
}
if(Parameters[6] != 0 && Parameters[7] != 0){
identifier.append("_E_AB_");
identifier.append( do_to_str(Parameters[12]));
}
if(Parameters[6] != 0 && Parameters[8] != 0){
identifier.append("_E_AO_");
identifier.append(do_to_str(Parameters[13]));
}
if(Parameters[7] != 0 && Parameters[8] != 0){
identifier.append("_E_BO_");
identifier.append(do_to_str(Parameters[14]));
}
// initialization of the test system
Lattice sys(Parameters);
// print_parameters
sys.print_parameters();
// simulate the system w/o record || BRUN IN
// non local Kawasaki algorithm with A and B
sys.burn_in_sim();
// local Kawaski algorithm with A, B and O
sys.simulate();
// simulate the system w/ record || SIMULATION
sys.simulate_rec(identifier);
// cluster sizes | obstacle position | total energy | bounds || output
// construction of the names of the output files
// open the output file
// write the lattice parameters and particle properties into the output files
// close the output files
out0 = "cluster_size" + identifier + ".txt";
file0.open(out0.c_str());
sys.write_cluster_size(file0);
file0.close();
out3 = "density" + identifier + ".txt";
file3.open(out3.c_str());
sys.write_density(file3);
file3.close();
if( sys.recording_obs_pos()){
out4 = "obs_pos" + identifier + ".txt";
file4.open(out4.c_str());
sys.write_obs_pos(file4);
file4.close();
out5 = "abs_obs_pos" + identifier + ".txt";
file5.open(out5.c_str());
sys.write_abs_obs_pos(file5);
file5.close();
}
if( sys.recording_energy() ){
out1 = "energy" + identifier + ".txt";
file1.open(out1.c_str());
sys.write_energy(file1);
file1.close();
out2 = "bounds" + identifier + ".txt";
file2.open(out2.c_str());
sys.write_bounds(file2);
file2.close();
}
if( sys.recording_density() ){
out6 = "nn" + identifier + ".txt";
file6.open(out6.c_str());
sys.write_nn(file6);
file6.close();
}
// output in the console after finishing the simulation
// stop the time measurement
control.stop();
sys.print_final_info();
control.check();
return 0;
}