Skip to content

Commit

Permalink
Clean up work_data
Browse files Browse the repository at this point in the history
  • Loading branch information
nkavokine committed Jun 24, 2024
1 parent 0a49338 commit 60fd877
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
27 changes: 17 additions & 10 deletions c++/triqs_ctseg/work_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,6 @@ work_data_t::work_data_t(params_t const &p, inputs_t const &inputs, mpi::communi
gf_struct = p.gf_struct;
n_color = count_colors(gf_struct);

// Compute gf_block_size_partial_sum
{ // to make acc local
long acc = 0;
for (auto const &[s, l] : gf_struct) {
if (l > 1) offdiag_delta = true;
gf_block_size_partial_sum.push_back(acc);
acc += l;
}
}

// Compute color/block conversion tables
for (auto const &color : range(n_color)) {
block_number.push_back(find_block_number(color));
Expand All @@ -57,6 +47,8 @@ work_data_t::work_data_t(params_t const &p, inputs_t const &inputs, mpi::communi
spdlog::info("Orbital energies: mu - eps = {}", mu);
}

// FIXME: Convert here Block2Gf to matrix Gf.

// Do we have D(tau) and J_perp(tau)? Yes, unless the data is 0
has_Dt = max_element(abs(inputs.d0t.data())) > 1.e-13;
has_jperp = max_element(abs(inputs.jperpt.data())) > 1.e-13;
Expand Down Expand Up @@ -156,6 +148,11 @@ work_data_t::work_data_t(params_t const &p, inputs_t const &inputs, mpi::communi
if (c.rank() == 0) { spdlog::info("Delta(tau) is 0, running only spin moves."); }
}

// Does gf_struct allow for off-diagonal Delta?
for (auto const &[s, l] : gf_struct) {
if (l > 1) offdiag_delta = true;
}

// Take the real part of Delta(tau)
delta = map([](gf_const_view<imtime> d) { return real(d); }, inputs.delta);
for (auto const &bl : range(delta.size())) {
Expand All @@ -169,6 +166,16 @@ work_data_t::work_data_t(params_t const &p, inputs_t const &inputs, mpi::communi
}
} // work_data constructor

int work_data_t::block_to_color(int block, int idx) const {
std::vector<long> gf_block_size_partial_sum;
long acc = 0;
for (auto const &[s, l] : gf_struct) {
gf_block_size_partial_sum.push_back(acc);
acc += l;
}
return gf_block_size_partial_sum[block] + idx;
}

long work_data_t::find_block_number(int color) const {
long bl = 0;
long colors_so_far = 0;
Expand Down
7 changes: 3 additions & 4 deletions c++/triqs_ctseg/work_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,13 @@ struct work_data_t {
std::vector<long> block_number; // block numbers corresponding to colors
std::vector<long> index_in_block; // index in block of a given color

// Map (block, idx) of gf to a color
std::vector<long> gf_block_size_partial_sum; // data for block_to_color method
int block_to_color(int block, int idx) const { return gf_block_size_partial_sum[block] + idx; }
// Find color corresponding to (block, idx)
int block_to_color(int block, int idx) const;

// Find block of color
long find_block_number(int color) const;

// Find index of color in block
// Find index of color in its block
long find_index_in_block(int color) const;
};

Expand Down

0 comments on commit 60fd877

Please sign in to comment.