Commit 8983ea65 authored by gbalduzz's avatar gbalduzz
Browse files

Added documentation and using inline static variables.

parent cccfeb63
Loading
Loading
Loading
Loading
+3 −10
Original line number Diff line number Diff line
@@ -164,8 +164,8 @@ protected:
  void updateSweepAverages();

protected:  // Members.
  static std::unique_ptr<DMatrixBuilder<linalg::CPU, Real>> d_builder_ptr_;
  static InteractionVertices vertices_;
  static inline std::unique_ptr<DMatrixBuilder<linalg::CPU, Real>> d_builder_ptr_;
  static inline InteractionVertices vertices_;

  const Parameters& parameters_;
  const Concurrency& concurrency_;
@@ -179,7 +179,7 @@ protected: // Members.
  MatrixPair M_;

  const Real beta_;
  static constexpr int n_bands_ = Parameters::bands;
  static inline constexpr int n_bands_ = Parameters::bands;
  const int possible_partners_;

  const Real total_interaction_;  // Space integrated interaction Hamiltonian.
@@ -204,13 +204,6 @@ private:
  linalg::Vector<int, linalg::CPU> ipiv_;
  linalg::Vector<Real, linalg::CPU> work_;
};
template <class Parameters, typename Real>
constexpr int CtintWalkerBase<Parameters, Real>::n_bands_;

template <class Parameters, typename Real>
InteractionVertices CtintWalkerBase<Parameters, Real>::vertices_;
template <class Parameters, typename Real>
std::unique_ptr<DMatrixBuilder<linalg::CPU, Real>> CtintWalkerBase<Parameters, Real>::d_builder_ptr_;

template <class Parameters, typename Real>
CtintWalkerBase<Parameters, Real>::CtintWalkerBase(const Parameters& parameters_ref, Rng& rng_ref,
+4 −4
Original line number Diff line number Diff line
@@ -42,6 +42,10 @@ public:
  using typename BaseClass::Rng;
  using typename BaseClass::Data;

  using Matrix = typename BaseClass::Matrix;
  using MatrixPair = typename BaseClass::MatrixPair;
  using MatrixView = typename linalg::MatrixView<Real, linalg::CPU>;

public:
  CtintWalker(const Parameters& pars_ref, const Data& /*data*/, Rng& rng_ref, int id = 0);

@@ -67,10 +71,6 @@ protected:
private:
  Real insertionProbability(int delta_vertices);

  using Matrix = typename BaseClass::Matrix;
  using MatrixPair = typename BaseClass::MatrixPair;
  using MatrixView = typename linalg::MatrixView<Real, linalg::CPU>;

  void applyInsertion(const MatrixPair& S, const MatrixPair& Q, const MatrixPair& R);

  Real removalProbability();
+19 −4
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@
// Authors: Giovanni Balduzzi (gbalduzz@itp.phys.ethz.ch)
//          Jérémie Bouquet (bouquetj@gmail.com)
//
// Class to compute matrices made by different combinations of G0 and auxiliary fields.
// Class to compute new entries of the D matrix.

#ifndef DCA_PHYS_DCA_STEP_CLUSTER_SOLVER_CTINT_WALKER_TOOLS_D_MATRIX_BUILDER_HPP
#define DCA_PHYS_DCA_STEP_CLUSTER_SOLVER_CTINT_WALKER_TOOLS_D_MATRIX_BUILDER_HPP
@@ -51,19 +51,32 @@ public:

  virtual ~DMatrixBuilder() {}

  // Set the parameters of the alpha field (see next function).
  void setAlphas(const std::array<double, 3>& alphas_base, bool adjust_dd);

  // Computes the right (Q), bottom(R), and right-bottom (S) blocks of the D matrix (M^-1) with elements
  // D_i,j = G0(v_i, v_j) + delta(i, j) alpha_field(v_i), where v_i is an interaction vertex.
  void buildSQR(MatrixPair& S, MatrixPair& Q, MatrixPair& R, const SolverConfiguration& config) const;

  const G0Interpolation<linalg::CPU, Real>& getG0() const {
    return g0_ref_;
  }

  // Computes the i, j entry of the D matrix.
  Real computeD(const int i, const int j, const Sector& config) const;

  // Computes the alpha field given auxiliary spin and band.
  Real computeAlpha(const int aux_spin_type, const int b) const;

  // Computes the quantity f = alpha_field / (1 - alpha_field). Used by the submatrix solver.
  Real computeF(const Real alpha) const;
  Real computeF(const int aux_spin_type, int b) const;

  // computes the gamma factor: gamma = (f(new_spin) - f(old_spin)) / f(old_spin)
  Real computeGamma(int aux_spin_type, int new_aux_spin_type, int b) const;

  // Computes a sector of the G0 matrix.
  // If which_section == 0, computes the bottom sector. If which_sector == 1 computes the right sector.
  void computeG0(Matrix& G0, const Sector& configuration, const int n_init, const int n_max,
                 const int which_section) const;

@@ -80,9 +93,11 @@ private:

protected:
  const G0Interpolation<linalg::CPU, Real>& g0_ref_;
  std::vector<Real> alpha_dd_;
  Real alpha_dd_neg_ = 0;
  Real alpha_ndd_ = 0;

  std::vector<Real> alpha_dd_;  // alpha parameters for density-density interactions. One for each band.
  Real alpha_dd_neg_ = 0;  // parameter for density-density interactions with negative coupling.
  Real alpha_ndd_ = 0;     // parameter for non-density-density interactions.

  const int n_bands_ = -1;
  std::array<int, 2> sbdm_step_;
  // Note: site_diff is a matrix where site_diff(i,j) = r_j - r_i.
+2 −0
Original line number Diff line number Diff line
@@ -47,6 +47,8 @@ public:
    return g0_ref_;
  }

  // See DMatrixBuilder<linalg::CPU, Real>::computeG0.
  // Out: G0. Device matrix
  void computeG0(Matrix& G0, const details::DeviceConfiguration& configuration, int n_init,
                 bool right_section, cudaStream_t stream) const override;

+1 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ DMatrixBuilder<linalg::GPU, Real>::DMatrixBuilder(const G0Interpolation<GPU, Rea
                   site_diff.leadingDimension(), nb, site_add.nrRows(), r0);
}


template <typename Real>
void DMatrixBuilder<GPU, Real>::computeG0(Matrix& G0,
                                          const details::DeviceConfiguration& configuration,