Skip to content

Commit 38f4ab4

Browse files
committed
finalize and unify variable names with ctseg_old
1 parent 82389c9 commit 38f4ab4

File tree

5 files changed

+58
-29
lines changed

5 files changed

+58
-29
lines changed

c++/triqs_ctseg/measures/four_point.cpp

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ namespace triqs_ctseg::measures {
3232
for (auto const &[bl1_name, bl1_size] : wdata.gf_struct)
3333
for (auto const &[bl2_name, bl2_size] : wdata.gf_struct)
3434
green_v.emplace_back(gf<prod<imfreq, imfreq, imfreq>, tensor_valued<4>>(
35-
{{beta, Fermion, p.n_iw_chi4_f, imfreq::option::all_frequencies},
36-
{beta, Fermion, p.n_iw_chi4_f, imfreq::option::all_frequencies},
37-
{beta, Boson, p.n_iw_chi4_b, imfreq::option::positive_frequencies_only}},
35+
{{beta, Fermion, p.n_w_f_vertex, imfreq::option::all_frequencies},
36+
{beta, Fermion, p.n_w_f_vertex, imfreq::option::all_frequencies},
37+
{beta, Boson, p.n_w_b_vertex, imfreq::option::positive_frequencies_only}},
3838
make_shape(bl1_size, bl1_size, bl2_size, bl2_size)));
3939
return green_v;
4040
};
@@ -48,18 +48,15 @@ namespace triqs_ctseg::measures {
4848

4949
g3w = make_block_gf<prod<imfreq, imfreq, imfreq>, tensor_valued<4>>(bosonic_block_names, g3w_vec());
5050
f3w = make_block_gf<prod<imfreq, imfreq, imfreq>, tensor_valued<4>>(bosonic_block_names, g3w_vec());
51-
52-
LOG("\n ====================== COMPUTING M-MATRIX ====================== \n");
51+
g3w() = 0;
52+
f3w() = 0;
5353

5454
n_w_fermionic = std::get<0>(g3w[0].mesh().components()).last_index() + 1;
5555
n_w_bosonic = std::get<2>(g3w[0].mesh().components()).last_index() + 1;
5656

5757
w_ini = (2 * (-n_w_fermionic) + 1) * M_PI / beta;
5858
w_inc = 2 * M_PI / beta;
5959

60-
Mw_vector = compute_Mw(false);
61-
if (measure_f3w) nMw_vector = compute_Mw(true);
62-
6360
}
6461

6562
// -------------------------------------
@@ -89,6 +86,11 @@ namespace triqs_ctseg::measures {
8986

9087
Z += s;
9188

89+
auto const mesh_fermionic = std::get<0>(g3w[0].mesh());
90+
auto const mesh_bosonic = std::get<2>(g3w[0].mesh());
91+
92+
Mw_vector = compute_Mw(false);
93+
9294
if (measure_g3w) {
9395
for (long bl = 0; bl < g3w.size(); bl++) { // bl : 'upup', 'updn', ...
9496
long b1 = bl / wdata.gf_struct.size();
@@ -102,9 +104,13 @@ namespace triqs_ctseg::measures {
102104
for (int m = 0; m < n_w_bosonic; m++) {
103105
int n2 = n1 + m;
104106
int n3 = n4 + m;
105-
g3w[bl](n1, n4, m)(a, b, c, d) = s * Mw(b1, a, b, n1, n2) * Mw(b2, c, d, n3, n4);
107+
// This structure is ugly. Need someone who familiar with TRIQS to prune this part.
108+
auto freq_1 = mesh_fermionic[n1 + n_w_fermionic];
109+
auto freq_2 = mesh_fermionic[n4 + n_w_fermionic];
110+
auto freq_3 = mesh_bosonic[m];
111+
g3w[bl][freq_1, freq_2, freq_3](a, b, c, d) += s * Mw(b1, a, b, n1, n2) * Mw(b2, c, d, n3, n4);
106112
if (b1 == b2)
107-
g3w[bl](n1, n4, m)(a, b, c, d) -= s * Mw(b1, a, d, n1, n4) * Mw(b2, c, b, n3, n2);
113+
g3w[bl][freq_1, freq_2, freq_3](a, b, c, d) -= s * Mw(b1, a, d, n1, n4) * Mw(b2, c, b, n3, n2);
108114
} // m
109115
} // n4
110116
} // n1
@@ -116,6 +122,7 @@ namespace triqs_ctseg::measures {
116122
} // measure_g3w
117123

118124
if (measure_f3w) {
125+
nMw_vector = compute_Mw(true);
119126
for (long bl = 0; bl < f3w.size(); bl++) { // bl : 'upup', 'updn', ...
120127
long b1 = bl / wdata.gf_struct.size();
121128
long b2 = bl % wdata.gf_struct.size();
@@ -128,9 +135,13 @@ namespace triqs_ctseg::measures {
128135
for (int m = 0; m < n_w_bosonic; m++) {
129136
int n2 = n1 + m;
130137
int n3 = n4 + m;
131-
f3w[bl](n1, n4, m)(a, b, c, d) = s * nMw(b1, a, b, n1, n2) * Mw(b2, c, d, n3, n4);
138+
// Please prune this
139+
auto freq_1 = mesh_fermionic[n1 + n_w_fermionic];
140+
auto freq_2 = mesh_fermionic[n4 + n_w_fermionic];
141+
auto freq_3 = mesh_bosonic[m];
142+
f3w[bl][freq_1, freq_2, freq_3](a, b, c, d) += s * nMw(b1, a, b, n1, n2) * Mw(b2, c, d, n3, n4);
132143
if (b1 == b2)
133-
f3w[bl](n1, n4, m)(a, b, c, d) -= s * nMw(b1, a, d, n1, n4) * Mw(b2, c, b, n3, n2);
144+
f3w[bl][freq_1, freq_2, freq_3](a, b, c, d) -= s * nMw(b1, a, d, n1, n4) * Mw(b2, c, b, n3, n2);
134145
} // m
135146
} // n4
136147
} // n1
@@ -196,8 +207,10 @@ namespace triqs_ctseg::measures {
196207
auto const &[bl_name, bl_size] = bl_pair;
197208
result[bl].resize(make_shape(bl_size, bl_size, n_w_aux, n_w_aux));
198209
result[bl]() = 0;
210+
}
199211

200-
long N = wdata.dets[bl].size();
212+
for (auto const &[bl, det] : itertools::enumerate(wdata.dets)) {
213+
long N = det.size();
201214
y_exp_ini.resize(N);
202215
y_exp_inc.resize(N);
203216
x_exp_ini.resize(N);
@@ -206,8 +219,8 @@ namespace triqs_ctseg::measures {
206219
x_inner_index.resize(N);
207220

208221
for (long id : range(N)) {
209-
auto y = wdata.dets[bl].get_y(id);
210-
auto x = wdata.dets[bl].get_x(id);
222+
auto y = det.get_y(id);
223+
auto x = det.get_x(id);
211224
y_exp_ini(id) = std::exp(dcomplex(0, w_ini * double(std::get<0>(y))));
212225
y_exp_inc(id) = std::exp(dcomplex(0, w_inc * double(std::get<0>(y))));
213226
x_exp_ini(id) = std::exp(dcomplex(0, -w_ini * double(std::get<0>(x))));
@@ -217,15 +230,15 @@ namespace triqs_ctseg::measures {
217230
}
218231

219232
for (long id_y : range(N)) {
220-
auto y = wdata.dets[bl].get_y(id_y);
233+
auto y = det.get_y(id_y);
221234
int yj = y_inner_index(id_y);
222235
double f_fact = is_nMw ? fprefactor(bl, y) : 1.0;
223236

224237
for (long id_x : range(N)) {
225238
int xi = x_inner_index(id_x);
226239
dcomplex y_exp = y_exp_ini(id_y);
227240
dcomplex x_exp = x_exp_ini(id_x);
228-
auto Minv = wdata.dets[bl].inverse_matrix(id_y, id_x);
241+
auto Minv = det.inverse_matrix(id_y, id_x);
229242

230243
for (int n_1 : range(n_w_aux)) {
231244
for (int n_2 : range(n_w_aux)) {

c++/triqs_ctseg/params.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ namespace triqs_ctseg {
5151
h5_write(grp, "h_loc0", c.h_loc0);
5252
h5_write(grp, "n_tau_G", c.n_tau_G);
5353
h5_write(grp, "n_tau_chi2", c.n_tau_chi2);
54-
h5_write(grp, "n_iw_chi4_b", c.n_iw_chi4_b);
55-
h5_write(grp, "n_iw_chi4_f", c.n_iw_chi4_f);
54+
h5_write(grp, "n_w_b_vertex", c.n_w_b_vertex);
55+
h5_write(grp, "n_w_f_vertex", c.n_w_f_vertex);
5656
h5_write(grp, "n_cycles", c.n_cycles);
5757
h5_write(grp, "length_cycle", c.length_cycle);
5858
h5_write(grp, "n_warmup_cycles", c.n_warmup_cycles);

c++/triqs_ctseg/params.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ namespace triqs_ctseg {
5757
/// Number of points on which to measure 2-point functions (defaults to n_tau_bosonic)
5858
int n_tau_chi2 = 0;
5959

60-
/// Number of bosonic M-frequency points on which to measure 4-point functions
61-
int n_iw_chi4_b = 1001;
60+
/// Number of bosonic M-frequency points on which to measure vertex functions
61+
int n_w_b_vertex = 10;
6262

63-
/// Number of fermionic M-frequency points on which to measure 4-point functions
64-
int n_iw_chi4_f = 1000;
63+
/// Number of fermionic M-frequency points on which to measure vertex functions
64+
int n_w_f_vertex = 10;
6565

6666
/// Number of QMC cycles
6767
int n_cycles;

python/triqs_ctseg/parameters_solve_params_t.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
+-------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+
1010
| n_tau_chi2 | int | 0 | Number of points on which to measure 2-point functions (defaults to n_tau_bosonic) |
1111
+-------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+
12+
| n_w_b_vertex | int | 10 | Number of bosonic M-frequency points on which to measure vertex functions |
13+
+-------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+
14+
| n_w_f_vertex | int | 10 | Number of fermionic M-frequency points on which to measure vertex functions |
15+
+-------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+
1216
| n_cycles | int | -- | Number of QMC cycles |
1317
+-------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+
1418
| length_cycle | int | 50 | Length of a single QMC cycle |
@@ -61,6 +65,10 @@
6165
+-------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+
6266
| measure_state_hist | bool | false | Whether to measure state histograms (see measures/state_hist) |
6367
+-------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+
68+
| measure_g3w | bool | false | Whether to measure four-point correlation function (see measures/four_point) |
69+
+-------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+
70+
| measure_f3w | bool | false | Whether to measure four-point correlation function improved estimator (see measures/four_point) |
71+
+-------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+
6472
| det_init_size | int | 100 | The maximum size of the determinant matrix before a resize |
6573
+-------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+
6674
| det_n_operations_before_check | int | 100 | Max number of ops before the test of deviation of the det, M^-1 is performed. |

python/triqs_ctseg/solver_core_desc.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@
168168
+-------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+
169169
| n_tau_chi2 | int | 0 | Number of points on which to measure 2-point functions (defaults to n_tau_bosonic) |
170170
+-------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+
171+
| n_w_b_vertex | int | 10 | Number of bosonic M-frequency points on which to measure vertex functions |
172+
+-------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+
173+
| n_w_f_vertex | int | 10 | Number of fermionic M-frequency points on which to measure vertex functions |
174+
+-------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+
171175
| n_cycles | int | -- | Number of QMC cycles |
172176
+-------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+
173177
| length_cycle | int | 50 | Length of a single QMC cycle |
@@ -220,6 +224,10 @@
220224
+-------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+
221225
| measure_state_hist | bool | false | Whether to measure state histograms (see measures/state_hist) |
222226
+-------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+
227+
| measure_g3w | bool | false | Whether to measure four-point correlation function (see measures/four_point) |
228+
+-------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+
229+
| measure_f3w | bool | false | Whether to measure four-point correlation function improved estimator (see measures/four_point) |
230+
+-------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+
223231
| det_init_size | int | 100 | The maximum size of the determinant matrix before a resize |
224232
+-------------------------------+--------------------------------------+-----------------------------------------+-------------------------------------------------------------------------------------------------------------------+
225233
| det_n_operations_before_check | int | 100 | Max number of ops before the test of deviation of the det, M^-1 is performed. |
@@ -274,15 +282,15 @@
274282
initializer = """ 0 """,
275283
doc = r"""Number of points on which to measure 2-point functions (defaults to n_tau_bosonic)""")
276284

277-
c.add_member(c_name = "n_iw_chi4_b",
285+
c.add_member(c_name = "n_w_b_vertex",
278286
c_type = "int",
279-
initializer = """ 1001 """,
280-
doc = r"""Number of bosonic M-frequency points on which to measure 4-point functions""")
287+
initializer = """ 10 """,
288+
doc = r"""Number of bosonic M-frequency points on which to measure vertex functions""")
281289

282-
c.add_member(c_name = "n_iw_chi4_f",
290+
c.add_member(c_name = "n_w_f_vertex",
283291
c_type = "int",
284-
initializer = """ 1000 """,
285-
doc = r"""Number of fermionic M-frequency points on which to measure 4-point functions""")
292+
initializer = """ 10 """,
293+
doc = r"""Number of fermionic M-frequency points on which to measure vertex functions""")
286294

287295
c.add_member(c_name = "n_cycles",
288296
c_type = "int",

0 commit comments

Comments
 (0)