5
5
// Copyright (c) 2019 Kun Chen. All rights reserved.
6
6
//
7
7
#include " markov.h"
8
+ #include " utility/tinyformat.h"
8
9
#include < stdio.h>
9
10
10
11
extern parameter Para;
@@ -21,55 +22,6 @@ using namespace std;
21
22
22
23
int markov::DynamicTest () { return Weight.DynamicTest (); }
23
24
24
- void markov::Hop (int Sweep) {
25
- for (int i = 0 ; i < Sweep; i++) {
26
- Para.Counter ++;
27
- // if (Para.Counter == 9) {
28
- // cout << "Before: " << Para.Counter << endl;
29
- // PrintDeBugMCInfo();
30
- // }
31
-
32
- double x = Random.urn ();
33
- if (x < 1.0 / MCUpdates)
34
- IncreaseOrder ();
35
- else if (x < 2.0 / MCUpdates)
36
- DecreaseOrder ();
37
- else if (x < 3.0 / MCUpdates)
38
- ChangeGroup ();
39
- else if (x < 4.0 / MCUpdates)
40
- ChangeMomentum ();
41
- // ;
42
- else if (x < 5.0 / MCUpdates)
43
- ChangeTau ();
44
- // ;
45
- // if (x < 0.5)
46
- // ChangeMomentum();
47
- // // ;
48
- // else
49
- // ChangeTau();
50
- // // ;
51
-
52
- // if (Para.Counter == 8831001) {
53
- // cout << "After: " << Para.Counter << endl;
54
- // PrintDeBugMCInfo();
55
- // }
56
-
57
- // double Tau = Var.Tau[1] - Var.Tau[0];
58
- // momentum G1, G2;
59
- // for (int i = 0; i < D; i++) {
60
- // G1[i] = Var.LoopMom[0][i] + Var.LoopMom[1][i];
61
- // G2[i] = Var.LoopMom[1][i];
62
- // }
63
- // ASSERT_ALLWAYS(Equal(Green(Tau, G1, UP, 0),
64
- // Var.CurrGroup->Diag[0].G[0]->Weight, 1.0e-8),
65
- // Weight._DebugInfo());
66
-
67
- // ASSERT_ALLWAYS(Equal(Green(-Tau, G2, UP, 0),
68
- // Var.CurrGroup->Diag[0].G[1]->Weight, 1.0e-8),
69
- // Weight._DebugInfo());
70
- }
71
- }
72
-
73
25
void markov::PrintDeBugMCInfo () {
74
26
string msg;
75
27
msg = string (80 , ' =' ) + " \n " ;
@@ -159,30 +111,33 @@ void markov::Measure() {
159
111
void markov::SaveToFile () {
160
112
for (int i = 0 ; i < Polar.size (); i++) {
161
113
ofstream PolarFile;
162
- string FileName = + " Group " + ToString (Weight. Groups [i]. ID ) + " _ " +
163
- ToString ( Para.PID ) + " .dat " ;
114
+ string FileName =
115
+ tfm::format ( " group%d_pid%d.dat " , Weight. Groups [i]. ID , Para.PID );
164
116
PolarFile.open (FileName, ios::out | ios::trunc);
165
117
if (PolarFile.is_open ()) {
166
- PolarFile << " #PID: " << Para.PID << " , rs: " << Para.Rs
167
- << " , Beta: " << Para.Beta << " , Group: " << i << endl;
118
+ PolarFile << tfm::format (
119
+ " #PID: %d, rs:%.3f, Beta: %.3f, Group: %d, Step: %d\n " , Para.PID ,
120
+ Para.Rs , Para.Beta , Weight.Groups [i].ID , Para.Counter );
121
+
168
122
for (int j = 0 ; j < Polar[i].size (); j++)
169
- PolarFile << Var.ExtMomTable [j][0 ] << " " << Polar[i][j] << endl;
170
- PolarFile << endl ;
123
+ PolarFile << tfm::format ( " %13.6f \t %13.6f \n " , Var.ExtMomTable [j][0 ],
124
+ Polar[i][j]) ;
171
125
PolarFile.close ();
172
126
} else {
173
127
LOG_WARNING (" Polarization for PID " << Para.PID << " fails to save!" );
174
128
}
175
129
}
176
130
177
131
ofstream StaticPolarFile;
178
- string FileName = " output.dat" ;
179
- StaticPolarFile.open (FileName, ios::out | ios::app );
132
+ string FileName = tfm::format ( " output%d .dat" , Para. PID ) ;
133
+ StaticPolarFile.open (FileName, ios::out | ios::trunc );
180
134
if (StaticPolarFile.is_open ()) {
181
135
for (int i = 0 ; i < PolarStatic.size (); i++) {
182
- StaticPolarFile << " #PID: " << Para.PID << " , rs: " << Para.Rs
183
- << " , Beta: " << Para.Beta << endl;
184
- StaticPolarFile << i << " " << PolarStatic[i] << endl;
185
- StaticPolarFile << endl;
136
+ StaticPolarFile << tfm::format (
137
+ " PID:%-4d Group:%-4d rs:%-.3f "
138
+ " Beta:%-.3f Lambda:%-.3f Polar: % 13.6f\n " ,
139
+ Para.PID , Weight.Groups [i].ID , Para.Rs , Para.Beta , Para.Mass2 ,
140
+ PolarStatic[i]);
186
141
}
187
142
StaticPolarFile.close ();
188
143
} else {
0 commit comments