Unverified Commit 23f3c2a7 authored by gbalduzz's avatar gbalduzz Committed by GitHub
Browse files

Merge pull request #183 from CompFUSE/fix_182

Fix 182.
parents 51d00850 1ee94cf0
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -29,14 +29,14 @@ namespace ctint {
// Expansion term.
struct Vertex {
  Vertex() = default;
  Vertex(bool _aux_spin, ushort _interaction_id, std::uint64_t _tag, double _tau)
  Vertex(bool _aux_spin, unsigned short _interaction_id, std::uint64_t _tag, double _tau)
      : aux_spin(_aux_spin), interaction_id(_interaction_id), tag(_tag), tau(_tau) {
    spins.fill(-1);
    matrix_config_indices.fill(-1);
  }

  bool aux_spin;
  ushort interaction_id;
  unsigned short interaction_id;
  std::uint64_t tag;
  double tau;

@@ -97,7 +97,7 @@ protected:
  // Out: config_refs. References from matrix configuration to solver configuration to be updated.
  void addVertex(Vertex& v, unsigned config_id, std::array<std::vector<ConfigRef>, 2>& config_refs);

  //  inline void pop(ushort idx_up, ushort idx_down);
  //  inline void pop(unsigned short idx_up, unsigned short idx_down);

  const auto& getEntries(const int s) const {
    return sectors_[s].entries_;
+7 −9
Original line number Diff line number Diff line
@@ -26,8 +26,6 @@ namespace solver {
namespace ctint {
// dca::phys::solver::ctint::



class Sector {
public:
  Sector() : entries_(){};
@@ -36,7 +34,7 @@ public:
  friend class MatrixConfiguration;
  friend class DeviceConfigurationManager;

  ushort size() const {
  unsigned short size() const {
    return entries_.size();
  }

@@ -49,19 +47,19 @@ public:
    return entries_[idx];
  }

  inline ushort getLeftB(const int i) const {
  inline unsigned short getLeftB(const int i) const {
    return entries_[i].b_left_;
  }

  inline ushort getRightB(const int i) const {
  inline unsigned short getRightB(const int i) const {
    return entries_[i].b_right_;
  }

  inline ushort getLeftR(const int i) const {
  inline unsigned short getLeftR(const int i) const {
    return entries_[i].r_left_;
  }

  inline ushort getRightR(const int i) const {
  inline unsigned short getRightR(const int i) const {
    return entries_[i].r_right_;
  }

+13 −13
Original line number Diff line number Diff line
@@ -26,13 +26,13 @@ namespace details {
struct DeviceConfiguration {
  const SectorEntry* data;

  __DEVICE__ inline ushort getLeftB(const int matrix_index) const;
  __DEVICE__ inline unsigned short getLeftB(const int matrix_index) const;

  __DEVICE__ inline ushort getRightB(const int matrix_index) const;
  __DEVICE__ inline unsigned short getRightB(const int matrix_index) const;

  __DEVICE__ inline ushort getLeftR(const int matrix_index) const;
  __DEVICE__ inline unsigned short getLeftR(const int matrix_index) const;

  __DEVICE__ inline ushort getRightR(const int matrix_index) const;
  __DEVICE__ inline unsigned short getRightR(const int matrix_index) const;

  __DEVICE__ inline double getTau(const int matrix_index) const;

@@ -40,22 +40,22 @@ struct DeviceConfiguration {
};

__DEVICE__
ushort DeviceConfiguration::getLeftB(const int matrix_index) const {
unsigned short DeviceConfiguration::getLeftB(const int matrix_index) const {
  return data[matrix_index].b_left_;
}

__DEVICE__
ushort DeviceConfiguration::getRightB(const int matrix_index) const {
unsigned short DeviceConfiguration::getRightB(const int matrix_index) const {
  return data[matrix_index].b_right_;
}

__DEVICE__
ushort DeviceConfiguration::getLeftR(const int matrix_index) const {
unsigned short DeviceConfiguration::getLeftR(const int matrix_index) const {
  return data[matrix_index].r_left_;
}

__DEVICE__
ushort DeviceConfiguration::getRightR(const int matrix_index) const {
unsigned short DeviceConfiguration::getRightR(const int matrix_index) const {
  return data[matrix_index].r_right_;
}

@@ -69,11 +69,11 @@ short DeviceConfiguration::getAuxFieldType(int matrix_index) const {
  return data[matrix_index].aux_field_type_;
}

}  // details
}  // ctint
}  // solver
}  // phys
}  // dca
}  // namespace details
}  // namespace ctint
}  // namespace solver
}  // namespace phys
}  // namespace dca

#endif  // DCA_HAVE_CUDA
#endif  // DCA_PHYS_DCA_STEP_CLUSTER_SOLVER_CTINT_STRUCTS_DEVICE_CONFIGURATION_HPP
+25 −22
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@
#define DCA_PHYS_DCA_STEP_CLUSTER_SOLVER_CTINT_STRUCTS_INTERACTION_VERTICES_HPP

#include <algorithm>
#include <array>
#include <cmath>
#include <stdexcept>
#include <vector>
@@ -28,11 +29,11 @@ namespace ctint {
// Represent a matrix element W(i,j,k,l) of the interaction hamiltonian.
// Each index represent a cluster position and a spin-band index.
struct InteractionElement {
  std::array<ushort, 4> r;
  std::array<ushort, 4> nu;
  std::array<unsigned short, 4> r;
  std::array<unsigned short, 4> nu;
  double w;
  // TODO: write proper constructor.
  std::vector<ushort> partners_id = std::vector<ushort>();
  std::vector<unsigned short> partners_id = std::vector<unsigned short>();
  // Returns true if r and nu members are equal.
  bool operator==(const InteractionElement& other) const;
};
@@ -126,14 +127,14 @@ void InteractionVertices::initializeFromHamiltonian(
    const func::function<double, func::dmn_variadic<Nu, Nu, Rdmn>>& H_int) {
  // Note: Use this version of the code if double counting in the interaction hamiltonian is removed.
  //
  //  for (ushort nu1 = 0; nu1 < Nu::dmn_size(); nu1++) {
  //    for (ushort nu2 = 0; nu2 < Nu::dmn_size(); nu2++)
  //      for (ushort delta_r = 0; delta_r < Rdmn::dmn_size(); delta_r++) {
  //  for (unsigned short nu1 = 0; nu1 < Nu::dmn_size(); nu1++) {
  //    for (unsigned short nu2 = 0; nu2 < Nu::dmn_size(); nu2++)
  //      for (unsigned short delta_r = 0; delta_r < Rdmn::dmn_size(); delta_r++) {
  //        const double value = H_int(nu1, nu2, delta_r);
  //        if (std::abs(value) < 1e-8)
  //          continue;
  //        for (ushort r1 = 0; r1 < Rdmn::dmn_size(); r1++) {
  //          const ushort r2 = Rdmn::parameter_type::subtract(delta_r, r1); // delta_r = r1 - r2
  //        for (unsigned short r1 = 0; r1 < Rdmn::dmn_size(); r1++) {
  //          const unsigned short r2 = Rdmn::parameter_type::subtract(delta_r, r1); // delta_r = r1 - r2
  //          insertElement(InteractionElement{{r1, r1, r2, r2}, {nu1, nu1, nu2, nu2}, value, short(-1)});
  //        }
  //      }
@@ -144,9 +145,9 @@ void InteractionVertices::initializeFromHamiltonian(
  // physical Hamiltonian.
  func::function<bool, func::dmn_variadic<Nu, Nu, Rdmn>> already_inserted;
  const int r0 = Rdmn::parameter_type::origin_index();
  for (ushort nu1 = 0; nu1 < Nu::dmn_size(); nu1++) {
    for (ushort nu2 = 0; nu2 < Nu::dmn_size(); nu2++)
      for (ushort delta_r = 0; delta_r < Rdmn::dmn_size(); delta_r++) {
  for (unsigned short nu1 = 0; nu1 < Nu::dmn_size(); nu1++) {
    for (unsigned short nu2 = 0; nu2 < Nu::dmn_size(); nu2++)
      for (unsigned short delta_r = 0; delta_r < Rdmn::dmn_size(); delta_r++) {
        const double value = H_int(nu1, nu2, delta_r);
        if (std::abs(value) < 1e-8)
          continue;
@@ -160,8 +161,9 @@ void InteractionVertices::initializeFromHamiltonian(

        // Insert
        already_inserted(nu1, nu2, delta_r) = true;
        for (ushort r1 = 0; r1 < Rdmn::dmn_size(); r1++) {
          const ushort r2 = Rdmn::parameter_type::subtract(delta_r, r1);  // delta_r = r1 - r2
        for (unsigned short r1 = 0; r1 < Rdmn::dmn_size(); r1++) {
          const unsigned short r2 =
              Rdmn::parameter_type::subtract(delta_r, r1);  // delta_r = r1 - r2
          insertElement(InteractionElement{{r1, r1, r2, r2}, {nu1, nu1, nu2, nu2}, value});
        }
      }
@@ -171,16 +173,17 @@ void InteractionVertices::initializeFromHamiltonian(
template <class Nu, class Rdmn>
void InteractionVertices::initializeFromNonDensityHamiltonian(
    const func::function<double, func::dmn_variadic<Nu, Nu, Nu, Nu, Rdmn>>& H_int) {
  auto spin = [](ushort nu) { return nu >= Nu::dmn_size() / 2; };
  auto check_spins = [&](ushort nu1, ushort nu2, ushort nu3, ushort nu4) -> bool {
  auto spin = [](unsigned short nu) { return nu >= Nu::dmn_size() / 2; };
  auto check_spins = [&](unsigned short nu1, unsigned short nu2, unsigned short nu3,
                         unsigned short nu4) -> bool {
    return spin(nu1) == spin(nu2) && spin(nu3) == spin(nu4);
  };

  for (ushort nu1 = 0; nu1 < Nu::dmn_size(); nu1++)
    for (ushort nu2 = 0; nu2 < Nu::dmn_size(); nu2++)
      for (ushort nu3 = 0; nu3 < Nu::dmn_size(); nu3++)
        for (ushort nu4 = 0; nu4 < Nu::dmn_size(); nu4++)
          for (ushort delta_r = 0; delta_r < Rdmn::dmn_size(); delta_r++) {
  for (unsigned short nu1 = 0; nu1 < Nu::dmn_size(); nu1++)
    for (unsigned short nu2 = 0; nu2 < Nu::dmn_size(); nu2++)
      for (unsigned short nu3 = 0; nu3 < Nu::dmn_size(); nu3++)
        for (unsigned short nu4 = 0; nu4 < Nu::dmn_size(); nu4++)
          for (unsigned short delta_r = 0; delta_r < Rdmn::dmn_size(); delta_r++) {
            const double value = H_int(nu1, nu2, nu3, nu4, delta_r);
            if (std::abs(value) < 1e-8)
              continue;
@@ -188,8 +191,8 @@ void InteractionVertices::initializeFromNonDensityHamiltonian(
              throw(std::logic_error(
                  "Format input hamiltonian s.t. pair of creation and annihilation "
                  "operators have same spin."));
            for (ushort r1 = 0; r1 < Rdmn::dmn_size(); r1++) {
              const ushort r2 = Rdmn::parameter_type::subtract(delta_r, r1);
            for (unsigned short r1 = 0; r1 < Rdmn::dmn_size(); r1++) {
              const unsigned short r2 = Rdmn::parameter_type::subtract(delta_r, r1);
              insertElement(InteractionElement{{r1, r1, r2, r2}, {nu1, nu2, nu3, nu4}, value});
            }
          }
+4 −4
Original line number Diff line number Diff line
@@ -45,10 +45,10 @@ struct SectorEntry {
           r_left_ == rhs.r_left_ && tau_ == rhs.tau_ && aux_field_type_ == rhs.aux_field_type_;
  }

  ushort b_left_;
  ushort r_left_;
  ushort b_right_;
  ushort r_right_;
  unsigned short b_left_;
  unsigned short r_left_;
  unsigned short b_right_;
  unsigned short r_right_;
  double tau_;
  short aux_field_type_;
};
Loading