@@ -130,14 +130,14 @@ int main(int argc, char *argv[])
130
130
}
131
131
132
132
C.ConstructIdentity (); // Construct the density matrix corresponding to infinite temperature
133
-
133
+ const double cut_off_rho = param. val ( " cut_off_rho " );
134
134
// Note on the option below: if we "Normalize=true" (default for fitapplyMPO)
135
135
// we would normalize rho such that Tr[rho^2]=1, (norm of the MPS)
136
136
// which is of course not appropriate for a density matrix.
137
137
auto argsRho = Args ();
138
138
argsRho.add (" Normalize" , false );
139
139
argsRho.add (" MaxDim" , param.longval (" max_dim_rho" ));
140
- argsRho.add (" Cutoff" , param. val ( " cut_off_rho" ) );
140
+ argsRho.add (" Cutoff" , cut_off_rho);
141
141
142
142
vector<long > init_graph_state = param.longvec (" init_graph_state" );
143
143
vector<long > init_cz_gates = param.longvec (" init_cz_gates" );
@@ -680,7 +680,7 @@ int main(int argc, char *argv[])
680
680
681
681
cout2 << " C.rho.orthogonalize..." ;
682
682
cout2.flush ();
683
- C.rho .orthogonalize (Args (" Cutoff" , param. val ( " cut_off_rho" ) , " MaxDim" , param.longval (" max_dim_rho" )));
683
+ C.rho .orthogonalize (Args (" Cutoff" , cut_off_rho, " MaxDim" , param.longval (" max_dim_rho" )));
684
684
cout2 << " done.\n " ;
685
685
cout2 << " New max bond dimension of rho:" << maxLinkDim (C.rho ) << " \n " ;
686
686
cout2.flush ();
@@ -912,7 +912,7 @@ int main(int argc, char *argv[])
912
912
if (std::abs (z) < _2_N)
913
913
cout2 << " \t\t Note: " << " Tr{rho} = " << z << " encountered during collapse projectors, "
914
914
<< " this is smaller than 2^(-N)!" ;
915
- // C.rho /= z;
915
+ C.rho /= z;
916
916
}
917
917
if (i_coll == 0 )
918
918
rho_c = MPS (C.rho );
@@ -928,16 +928,17 @@ int main(int argc, char *argv[])
928
928
cout2 << " \t\t Note: this is smaller than 2^(-N)!"
929
929
<< " \n " ;
930
930
// TODO: This is a somewhat arbitrary threshold for the warning.
931
- // C.rho /= z;
931
+ C.rho /= z;
932
932
auto t_collapse_end = steady_clock::now ();
933
933
duration_ms = duration_cast<milliseconds>(t_collapse_end - t_collapse_start);
934
934
cout2 << " Collapse evaluation terminated. Duration: " << duration_ms.count () / 1000 . << " s\n " ;
935
935
}
936
936
937
937
char buf[100 ];
938
+ const bool b_quiet = param.boolval (" b_quiet" );
939
+ const double cut_off_observable = param.val (" cut_off_observable" );
938
940
const long force_rho_hermitian_step = param.longval (" force_rho_hermitian_step" );
939
941
const long force_rho_hermitian_gates = param.longval (" force_rho_hermitian_gates" );
940
- const bool b_quiet = param.boolval (" b_quiet" );
941
942
cout2.quiet (b_quiet);
942
943
double t = t_0;
943
944
for (int n = 0 ; n <= n_steps; n++)
@@ -1093,6 +1094,8 @@ int main(int argc, char *argv[])
1093
1094
cout2 << " \t Warning: <S^" << s << " (" << i << " )> = " << expectation_value
1094
1095
<< " ; it should be real, but has an imaginary part > " << IMAGINARY_THRESHOLD
1095
1096
<< " .\n " ;
1097
+ if (cut_off_observable && (abs (expectation_value) < cut_off_observable))
1098
+ expectation_value = .0 ;
1096
1099
file_1q << t << " \t " << char (toupper (s[0 ])) << " \t " << i << " \t " << expectation_value.real ()
1097
1100
<< endl;
1098
1101
count++;
@@ -1129,6 +1132,8 @@ int main(int argc, char *argv[])
1129
1132
<< " )> = " << expectation_value
1130
1133
<< " ; it should be real, but has an imaginary part > " << IMAGINARY_THRESHOLD
1131
1134
<< " .\n " ;
1135
+ if (cut_off_observable && (abs (expectation_value) < cut_off_observable))
1136
+ expectation_value = .0 ;
1132
1137
file_2q << t << " \t " << char (toupper (s[0 ])) << char (toupper (s[1 ])) << " \t " << i << " \t " << j
1133
1138
<< " \t " << expectation_value.real () << endl;
1134
1139
count++;
@@ -1165,6 +1170,8 @@ int main(int argc, char *argv[])
1165
1170
<< k << " )" << expectation_value
1166
1171
<< " ; it should be real, but has an imaginary part > " << IMAGINARY_THRESHOLD
1167
1172
<< " .\n " ;
1173
+ if (cut_off_observable && (abs (expectation_value) < cut_off_observable))
1174
+ expectation_value = .0 ;
1168
1175
file_3q << t << " \t " << char (toupper (s[0 ])) << char (toupper (s[1 ])) << char (toupper (s[2 ]))
1169
1176
<< " \t " << i << " \t " << j << " \t " << k << " \t " << expectation_value.real () << endl;
1170
1177
count++;
@@ -1192,6 +1199,8 @@ int main(int argc, char *argv[])
1192
1199
for (MPS &proj : ProjectorList)
1193
1200
{
1194
1201
Cplx op_val = innerC (proj, C.rho );
1202
+ if (cut_off_observable && (abs (op_val) < cut_off_observable))
1203
+ op_val = .0 ;
1195
1204
file_custom << t << " \t " << ProjectorNames[c] << " \t " << op_val.real () << endl;
1196
1205
c++;
1197
1206
}
@@ -1203,6 +1212,8 @@ int main(int argc, char *argv[])
1203
1212
for (string &s_op_obs : OperatorObsNames)
1204
1213
{
1205
1214
Cplx op_val = C.Expect (OperatorObs[c], OperatorObsQubits[c]);
1215
+ if (cut_off_observable && (abs (op_val) < cut_off_observable))
1216
+ op_val = .0 ;
1206
1217
// cout2 << "\nCalculating: " << OperatorObs[c] << " " << OperatorObsQubits[c];
1207
1218
file_custom << t << " \t " << s_op_obs << " \t " << op_val.real () << endl;
1208
1219
c++;
0 commit comments