Skip to content

Commit 04ea49b

Browse files
committed
[test] add block-sparse Green's functions tests using all symmetries
1 parent a58ed6b commit 04ea49b

5 files changed

Lines changed: 291 additions & 22 deletions

c++/triqs_xca/block_sparse_backbone.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -501,21 +501,20 @@ void DiagramEvaluator::find_path_correlator(CorrelatorBackbone &backbone, std::v
501501
}
502502
++w;
503503
}
504-
if (f_ix == 3 && kap == 2 && b_ix == 1) {}
505504
int ip_vct0 = ip;
506505

507506
// now consider mu_ops[mu]
508507
if (path_all_nonzero) {
509508
for (int mu = 0; mu < mu_ops.size(); ++mu) {
509+
path_all_nonzero = true; // reset for each mu
510510
const auto &mu_op = mu_ops[mu];
511511
ip_old = ip_vct0;
512512
ip = mu_op.get_block_index(ip_vct0);
513513
if (ip == -1 || Gt.get_zero_block_index(ip) == -1) { // only continue if mu_ops[mu] and Gt have nonzero blocks in right place
514514
path_all_nonzero = false;
515515
} else {
516516
block_dims(vct0 + 1) = mu_op.get_block_size(ip_old, 0);
517-
// replace m!!!!
518-
ind_path(vct0) = ip;
517+
ind_path(vct0) = ip;
519518

520519
// traverse factors on left-hand side of diagram
521520
w = vct0 + 1; // reset w to the vertex connected to vertex 0
@@ -532,10 +531,9 @@ void DiagramEvaluator::find_path_correlator(CorrelatorBackbone &backbone, std::v
532531
}
533532
++w;
534533
}
535-
if (path_all_nonzero) {
534+
if (path_all_nonzero && b_ix == ind_path(2 * m - 1)) {
536535
// evaluate the diagram with these directions, poles, and orbital indices
537536
// b_ix is the block index for the first edge
538-
// DOUBLE-CHECK ALL INDEXING
539537
eval_correlator_fixed_indices(backbone, ind_path, block_dims);
540538
for (int t = 0; t < r; ++t) {
541539
Tmuop(t, range(0, block_dims(2 * m)), range(0, block_dims(1))) =

examples/block_sparse_backbone_third_order.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
#include <triqs_xca/block_sparse.hpp>
66
#include <triqs_xca/block_sparse_manual.hpp>
77
#include <triqs_xca/block_sparse_backbone.hpp>
8-
// temporary include
9-
#include <triqs_xca/dense_backbone.hpp>
108

119
using namespace nda;
1210
using namespace cppdlr;
@@ -267,10 +265,6 @@ int main() {
267265

268266
auto D = DiagramEvaluator(beta, Lambda, eps, Deltat, nda::make_regular(dlr_rf / beta), Gt, Fq); // create DiagramEvaluator object
269267

270-
// temporary dense calculation
271-
auto Fset = DenseFSet(Fs_dense, F_dags_dense, hyb_coeffs);
272-
auto DD = DenseDiagramEvaluator(beta, itops, Deltat, Deltat, dlr_rf, Gt_dense, Fset);
273-
274268
auto Deltadlr = itops.vals2coefs(Deltat); //obtain dlr coefficient of Delta(t)
275269
nda::vector<double> dlr_rf_reflect = -dlr_rf;
276270
nda::array<dcomplex, 3> Deltadlr_reflect = Deltadlr * 1.0;
@@ -293,12 +287,6 @@ int main() {
293287
third_order_result = BlockDiagOpFun(Sigma_third_gf);
294288
D.reset(); // reset the DiagramEvaluator for the next topology
295289

296-
// temp for verification
297-
auto BB = Backbone(topologies(i, _, _), n);
298-
DD.eval_self_energy(BB);
299-
auto dense_result = DD.Sigma;
300-
DD.reset();
301-
302290
// Compute third-order contribution using old code
303291
nda::array<dcomplex, 3> TCA_old(r, N, N);
304292
TCA_old = 0;
@@ -318,9 +306,6 @@ int main() {
318306

319307
std::cout << "max error in block 0: " << nda::max_element(nda::abs(TCA_old(_, range(0, 4), range(0, 4)) - third_order_result.get_block(0)))
320308
<< std::endl;
321-
std::cout << "TCA_old block 0:\n" << TCA_old(5, range(0, 4), range(0, 4)) << std::endl;
322-
std::cout << "third_order_result block 0:\n" << third_order_result.get_block(0)(5, range(0, 4), range(0, 4)) << std::endl;
323-
std::cout << "dense result block 0:\n" << dense_result(5, range(0, 4), range(0, 4)) << std::endl;
324309
std::cout << "max error in block 1: " << nda::max_element(nda::abs(TCA_old(_, range(4, 10), range(4, 10)) - third_order_result.get_block(1)))
325310
<< std::endl;
326311
std::cout << "max error in block 2: " << nda::max_element(nda::abs(TCA_old(_, range(10, 11), range(10, 11)) - third_order_result.get_block(2)))

test/c++/test_block_sparse_OCA_gf_manual.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ TEST(DenseOCAGF, two_band_discrete_bath_dense) {
213213
hyb_F Delta_F(16, r, dim), Delta_F_reflect(16, r, dim);
214214
Delta_F.update_inplace(Delta_decomp, dlr_it, Fs_dense, F_dags_dense); // Compression of Delta(t) and F, F_dag matrices
215215
Delta_F_reflect.update_inplace(Delta_decomp_reflect, dlr_it, F_dags_dense, Fs_dense);
216-
nda::vector<int> fb = {1, 0};
217216
nda::array<int, 2> D_OCA = {{0, 2}, {1, 3}};
218217
auto OCA_gf_old = G_Diagram_calc_sum_all(Delta_F, Delta_F_reflect, D_OCA, Gt_dense, itops, beta, Fs_dense, F_dags_dense);
219218
auto OCA_gf_old_eq = eval_eq(itops, OCA_gf_old, n_quad);

test/c++/test_block_sparse_backbone_eval.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,6 @@ TEST(Backbone, OCA_semicircle_bath_aaa) {
380380
auto OCA_result_gf = D.compute_self_energy(topology);
381381
auto OCA_result = BlockDiagOpFun(OCA_result_gf);
382382

383-
// Use slightly relaxed tolerance to account for accumulated truncation errors from SVD in hyb_decomp
384383
ASSERT_LE(nda::max_element(nda::abs(OCA_result.get_block(0) - OCA_old(_, range(0, 4), range(0, 4)))), eps);
385384
ASSERT_LE(nda::max_element(nda::abs(OCA_result.get_block(1) - OCA_old(_, range(4, 10), range(4, 10)))), eps);
386385
ASSERT_LE(nda::max_element(nda::abs(OCA_result.get_block(2) - OCA_old(_, range(10, 11), range(10, 11)))), eps);

0 commit comments

Comments
 (0)