TRIQS/triqs_ctint 4.0.0
A TRIQS application
Loading...
Searching...
No Matches
lazy_det_operation.hpp
1// Copyright (c) 2017--present, The Simons Foundation
2// This file is part of TRIQS/ctint and is licensed under the terms of GPLv3 or later.
3// SPDX-License-Identifier: GPL-3.0-or-later
4// See LICENSE in the root of this distribution for details.
5
6#pragma once
7#include "vertex.hpp"
8#include "dets.hpp"
9
10namespace triqs_ctint {
11
21 class lazy_det_operation_t {
22
23 private:
24 // Vector of all determinants
25 std::vector<det_t> *dets;
26
27 // This type keeps track of lazy inserts for single determinant
28 struct one_block {
29 // Vector of $c$ (x) and $c^\dagger$ (y) operators
30 std::vector<c_t> c_lst = {};
31 std::vector<cdag_t> cdag_lst = {};
32
33 // Lazy-add a $c$ operator
34 void lazy_add_c(c_t const &c_) { c_lst.emplace_back(c_); }
35
36 // Lazy-add a $c^\dagger$ operator
37 void lazy_add_cdag(cdag_t const &cdag_) { cdag_lst.emplace_back(cdag_); }
38
39 // Tries to perform all insertions into the det, returning the det ratio
40 g_tau_scalar_t execute_try_insert(det_t *d);
41
42 // Tries to perform all removals from the det, returning the det ratio
43 g_tau_scalar_t execute_try_remove(det_t *d);
44
45 // Tries to perform all spinflips from the det, returning the det ratio
46 g_tau_scalar_t execute_try_change_col_row(det_t *d);
47 };
48
49 // The list of lazy operations, one for each determinant
50 std::vector<one_block> lazy_op_lst;
51
52 public:
53 lazy_det_operation_t(std::vector<det_t> *dets) : dets(dets), lazy_op_lst(dets->size()) {}
54
56 void reset() {
57 for (auto &l : lazy_op_lst) {
58 l.c_lst.clear();
59 l.cdag_lst.clear();
60 }
61 }
62
64 lazy_det_operation_t &operator<<(vertex_t const &v) {
65 // Separately lazy-add all four operators associated with this vertex
66 lazy_op_lst[v.idx.b1].lazy_add_cdag(cdag_t{v.tau1, v.idx.u1, v.vertex_label, 0, v.s}); //c^\dagger
67 lazy_op_lst[v.idx.b2].lazy_add_c(c_t{v.tau2, v.idx.u2, v.vertex_label, 0, v.s}); //c
68 lazy_op_lst[v.idx.b3].lazy_add_cdag(cdag_t{v.tau3, v.idx.u3, v.vertex_label, 1, v.s}); //c^\dagger
69 lazy_op_lst[v.idx.b4].lazy_add_c(c_t{v.tau4, v.idx.u4, v.vertex_label, 1, v.s}); //c
70 return *this;
71 }
72
74 g_tau_scalar_t execute_try_insert() {
75 g_tau_scalar_t det_ratio = 1.0;
76 for (auto i : range(dets->size())) det_ratio *= lazy_op_lst[i].execute_try_insert(&(*dets)[i]);
77 reset();
78 return det_ratio;
79 }
80
82 g_tau_scalar_t execute_try_remove() {
83 g_tau_scalar_t det_ratio = 1.0;
84 for (auto i : range(dets->size())) det_ratio *= lazy_op_lst[i].execute_try_remove(&(*dets)[i]);
85 reset();
86 return det_ratio;
87 }
88
90 g_tau_scalar_t execute_try_change_col_row() {
91 g_tau_scalar_t det_ratio = 1.0;
92 for (auto i : range(dets->size())) det_ratio *= lazy_op_lst[i].execute_try_change_col_row(&(*dets)[i]);
93 reset();
94 return det_ratio;
95 }
96 };
97} // namespace triqs_ctint
g_tau_scalar_t execute_try_insert()
Tries to perform the insertions into all dets, returning the det ratio.
g_tau_scalar_t execute_try_change_col_row()
Tries to perform the removal from all dets, returning the det ratio.
lazy_det_operation_t & operator<<(vertex_t const &v)
Register a vertex for insertion/removal into the configuration.
g_tau_scalar_t execute_try_remove()
Tries to perform the removal from all dets, returning the det ratio.
void reset()
Clean all registered moves.
int b2
Second operator of the vertex (ingoing, c): block index, non-block.
Definition vertex.hpp:85
int b4
Fourth operator of the vertex (ingoing, c): block index, non-block.
Definition vertex.hpp:91
int b1
First operator of the vertex (outgoing, c^\dagger): block index, non-block.
Definition vertex.hpp:82
int b3
Third operator of the vertex (outgoing, c^\dagger): block index, non-block.
Definition vertex.hpp:88
vertex_idx_t idx
Object containing discrete quantum numbers for external legs, i.e. block and non-block index.
Definition vertex.hpp:103
int s
Value of auxiliary spin.
Definition vertex.hpp:118
int vertex_label
The label of the vertex (position in h_int).
Definition vertex.hpp:115
tau_t tau1
Imaginary times for all four external legs (c^\dagger, c, c^\dagger, c).
Definition vertex.hpp:106