Commit e0b30bf9 authored by gbalduzz's avatar gbalduzz
Browse files

small cleanup of g0 initialization.

parent a9203ea3
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -32,6 +32,8 @@
#include "dca/parallel/util/get_workload.hpp"
#include "dca/phys/dca_step/cluster_solver/ctaux/ctaux_accumulator.hpp"
#include "dca/phys/dca_step/cluster_solver/ctaux/ctaux_walker.hpp"
#include "dca/phys/dca_step/cluster_solver/shared_tools/interpolation/g0_interpolation.hpp"
#include "dca/phys/dca_step/cluster_solver/shared_tools/accumulation/time_correlator.hpp"
#include "dca/phys/dca_step/symmetrization/symmetrize.hpp"
#include "dca/phys/domains/cluster/cluster_domain.hpp"
#include "dca/phys/domains/quantum/electron_band_domain.hpp"
@@ -149,6 +151,8 @@ private:
  func::function<std::complex<double>, NuNuKClusterWDmn> Sigma_old_;
  func::function<std::complex<double>, NuNuKClusterWDmn> Sigma_new_;

  G0Interpolation<device, double> g0_;

  double accumulated_sign_;
  func::function<std::complex<double>, NuNuRClusterWDmn> M_r_w_;
  func::function<std::complex<double>, NuNuRClusterWDmn> M_r_w_squared_;
@@ -183,6 +187,8 @@ CtauxClusterSolver<device_t, Parameters, Data>::CtauxClusterSolver(Parameters& p
      M_r_w_squared_("M_r_w_squared"),

      averaged_(false) {
  TimeCorrelator<Parameters, double, device>::setG0(g0_);

  if (concurrency_.id() == concurrency_.first())
    std::cout << "\n\n\t CT-AUX Integrator is born \n" << std::endl;
}
@@ -204,6 +210,8 @@ template <dca::linalg::DeviceType device_t, class Parameters, class Data>
void CtauxClusterSolver<device_t, Parameters, Data>::initialize(int dca_iteration) {
  dca_iteration_ = dca_iteration;

  g0_.initializeShrinked(data_.G0_r_t_cluster_excluded);

  Sigma_old_ = data_.Sigma;

  accumulator_.initialize(dca_iteration_);
+4 −3
Original line number Diff line number Diff line
@@ -30,7 +30,8 @@
#include "dca/phys/dca_step/cluster_solver/ctint/details/solver_methods.hpp"
#include "dca/phys/dca_step/cluster_solver/ctint/domains/common_domains.hpp"
#include "dca/phys/dca_step/cluster_solver/ctint/walker/ctint_walker_choice.hpp"
//#include "dca/phys/dca_step/cluster_solver/shared_tools/accumulation/time_correlator.hpp"
#include "dca/phys/dca_step/cluster_solver/shared_tools/interpolation/g0_interpolation.hpp"
#include "dca/phys/dca_step/cluster_solver/shared_tools/accumulation/time_correlator.hpp"
#include "dca/phys/dca_data/dca_data.hpp"
#include "dca/phys/dca_loop/dca_loop_data.hpp"
#include "dca/phys/dca_step/symmetrization/symmetrize.hpp"
@@ -156,7 +157,7 @@ CtintClusterSolver<device_t, Parameters, use_submatrix>::CtintClusterSolver(Para

      rng_(concurrency_.id(), concurrency_.number_of_processors(), parameters_.get_seed()) {
  Walker::setDMatrixBuilder(g0_);
  //  TimeCorrelator<Parameters, Real, device_t>::setG0(g0_);
  TimeCorrelator<Parameters, Real, device_t>::setG0(g0_);
  Walker::setInteractionVertices(data_, parameters_);

  if (concurrency_.id() == concurrency_.first())
@@ -173,7 +174,7 @@ template <dca::linalg::DeviceType device_t, class Parameters, bool use_submatrix
void CtintClusterSolver<device_t, Parameters, use_submatrix>::initialize(int dca_iteration) {
  dca_iteration_ = dca_iteration;

  g0_.initialize(ctint::details::shrinkG0(data_.G0_r_t_cluster_excluded));
  g0_.initializeShrinked(data_.G0_r_t_cluster_excluded);

  Walker::setDMatrixAlpha(parameters_.getAlphas(), parameters_.adjustAlphaDd());

+1 −0
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ public:
  void compute_G_r_t(const std::array<dca::linalg::Matrix<RealInp, device>, 2>& M,
                     const std::array<WalkerConfig, 2>& configs, int sign);

  // TODO: use a shared pointer.
  static void setG0(const G0Interpolation<device, Real>& g0) {
    g0_ = &g0;
  }
+5 −101
Original line number Diff line number Diff line
@@ -7,110 +7,14 @@
//
// Authors: Giovanni Balduzzi (gbalduzz@itp.phys.ethz.ch)
//
// This class organizes the interpolation G0(tau) for tau in [0, beta]
// specialization for CPU.
// Include file.

#ifndef DCA_PHYS_DCA_STEP_CLUSTER_SOLVER_SHARED_TOOLS_INTERPOLATION_G0_INTERPOLATION_HPP
#define DCA_PHYS_DCA_STEP_CLUSTER_SOLVER_SHARED_TOOLS_INTERPOLATION_G0_INTERPOLATION_HPP

#include <assert.h>
#include <vector>

#include "dca/function/domains/dmn.hpp"
#include "dca/function/domains/dmn_0.hpp"
#include "dca/function/domains/dmn_variadic.hpp"
#include "dca/function/function.hpp"
#include "dca/linalg/device_type.hpp"
#include "dca/math/interpolation/akima_interpolation.hpp"
#include "dca/phys/dca_step/cluster_solver/shared_tools/interpolation/interpolation_domains.hpp"
#include "dca/phys/dca_step/cluster_solver/shared_tools/interpolation/function_proxy.hpp"
#include "dca/phys/dca_step/cluster_solver/shared_tools/interpolation/shrink_G0.hpp"
#include "dca/phys/domains/time_and_frequency/time_domain.hpp"

namespace dca {
namespace phys {
namespace solver {
// dca::phys::solver::

// void template
template <linalg::DeviceType device_t, typename Real>
class G0Interpolation {};

// ParametersDomain is a collection of discrete labels not involving the time.
template <typename Real>
class G0Interpolation<linalg::CPU, Real> {
private:
  using Pdmn = G0ParametersDomain;
  using Pdmn0 = func::dmn_0<G0ParametersDomain>;
  using Tdmn = func::dmn_0<domains::time_domain>;
  using PTdmn = func::dmn_variadic<Pdmn0, Tdmn>;

public:
  G0Interpolation() = default;
  // See this->initialize(G0_pars_t).
  template <class InputDmn>
  G0Interpolation(const func::function<double, InputDmn>& G0_pars_t);

  virtual ~G0Interpolation() {}

  // In: G0_pars_t. Assumed to be a function of discrete labels and time (in this order) and to
  //             be antiperiodic in time.
  template <class InputDmn>
  void initialize(const func::function<double, InputDmn>& G0_pars_t);

  // Initialize with only one spin sector.
  template <int dim>
  void initializeShrinked(const details::SpGreensFunction<dim>& g0_r_t) {
    initialize(details::shrinkG0(g0_r_t));
  }

  // Returns cubic interpolation of G0(tau) in the spin-band-position defined by lindex.
  Real operator()(Real tau, int lindex) const;

  // Number of value if g0 stored per parameter value.
  int getTimeSlices() const {
    return G0_coeff_[1];
  }
  int getStride() const {
    return getTimeSlices() * COEFF_SIZE;
  }

  friend class G0Interpolation<linalg::GPU, Real>;

  static constexpr int COEFF_SIZE = 4;

private:
  virtual void initialize(const FunctionProxy<double, PTdmn>& G0_pars_t);

private:
  using CoeffDmn = func::dmn_0<func::dmn<COEFF_SIZE>>;
  using PTime0 = func::dmn_0<PositiveTimeDomain>;
  using InterpolationDmn = func::dmn_variadic<CoeffDmn, PTime0, Pdmn0>;

  func::function<Real, InterpolationDmn> G0_coeff_;
  Real beta_ = 0;
  // value at tau = 0
  std::vector<Real> g0_minus_;
  // Spacing between time bins.
  double n_div_beta_;
};

template <typename Real>
template <class InputDmn>
G0Interpolation<linalg::CPU, Real>::G0Interpolation(const func::function<double, InputDmn>& G0_pars_t) {
  initialize(G0_pars_t);
}

template <typename Real>
template <class InputDmn>
void G0Interpolation<linalg::CPU, Real>::initialize(const func::function<double, InputDmn>& G0_pars_t) {
  PositiveTimeDomain::initialize();
  Pdmn::initialize(InputDmn::dmn_size() / Tdmn::dmn_size());
  initialize(FunctionProxy<double, PTdmn>(G0_pars_t));
}

}  // namespace solver
}  // namespace phys
}  // namespace dca
#include "dca/phys/dca_step/cluster_solver/shared_tools/interpolation/g0_interpolation_cpu.hpp"
#ifdef DCA_HAVE_CUDA
#include "dca/phys/dca_step/cluster_solver/shared_tools/interpolation/g0_interpolation_gpu.hpp"
#endif

#endif  // DCA_PHYS_DCA_STEP_CLUSTER_SOLVER_SHARED_TOOLS_INTERPOLATION_G0_INTERPOLATION_HPP
+112 −0
Original line number Diff line number Diff line
// Copyright (C) 2018 ETH Zurich
// Copyright (C) 2018 UT-Battelle, LLC
// All rights reserved.
//
// See LICENSE.txt for terms of usage.
// See CITATION.md for citation guidelines, if DCA++ is used for scientific publications.
//
// Authors: Giovanni Balduzzi (gbalduzz@itp.phys.ethz.ch)
//
// This class organizes the interpolation G0(tau) for tau in [0, beta]
// specialization for CPU.

#ifndef DCA_PHYS_DCA_STEP_CLUSTER_SOLVER_SHARED_TOOLS_INTERPOLATION_G0_INTERPOLATION_CPU_HPP
#define DCA_PHYS_DCA_STEP_CLUSTER_SOLVER_SHARED_TOOLS_INTERPOLATION_G0_INTERPOLATION_CPU_HPP

#include <assert.h>
#include <vector>

#include "dca/function/domains/dmn.hpp"
#include "dca/function/domains/dmn_0.hpp"
#include "dca/function/domains/dmn_variadic.hpp"
#include "dca/function/function.hpp"
#include "dca/linalg/device_type.hpp"
#include "dca/math/interpolation/akima_interpolation.hpp"
#include "dca/phys/dca_step/cluster_solver/shared_tools/interpolation/interpolation_domains.hpp"
#include "dca/phys/dca_step/cluster_solver/shared_tools/interpolation/function_proxy.hpp"
#include "dca/phys/dca_step/cluster_solver/shared_tools/interpolation/shrink_G0.hpp"
#include "dca/phys/domains/time_and_frequency/time_domain.hpp"

namespace dca {
namespace phys {
namespace solver {
// dca::phys::solver::

// void template
template <linalg::DeviceType device_t, typename Real>
class G0Interpolation {};

// ParametersDomain is a collection of discrete labels not involving the time.
template <typename Real>
class G0Interpolation<linalg::CPU, Real> {
protected:
  using Pdmn = G0ParametersDomain;
  using Pdmn0 = func::dmn_0<G0ParametersDomain>;
  using Tdmn = func::dmn_0<domains::time_domain>;
  using PTdmn = func::dmn_variadic<Pdmn0, Tdmn>;

public:
  G0Interpolation() = default;

  template <class InputDmn>
  G0Interpolation(const func::function<double, InputDmn>& G0_func) {
    initialize(G0_func);
  }

  virtual ~G0Interpolation() = default;

  // In: G0_pars_t. Assumed to be a function of discrete labels and time (in this order) and to
  //             be antiperiodic in time.
  template <class InputDmn>
  void initialize(const func::function<double, InputDmn>& G0_func);

  // Initialize with only one spin sector.
  template <int dim>
  void initializeShrinked(const details::SpGreensFunction<dim>& g0_r_t) {
    initialize(details::shrinkG0(g0_r_t));
  }

  // Returns cubic interpolation of G0(tau) in the spin-band-position defined by lindex.
  Real operator()(Real tau, int lindex) const;

  // Number of value if g0 stored per parameter value.
  int getTimeSlices() const {
    return G0_coeff_[1];
  }
  int getStride() const {
    return getTimeSlices() * COEFF_SIZE;
  }

  friend class G0Interpolation<linalg::GPU, Real>;

  static constexpr int COEFF_SIZE = 4;

private:
  virtual void initialize(const FunctionProxy<double, PTdmn>& G0_pars_t);

private:
  using CoeffDmn = func::dmn_0<func::dmn<COEFF_SIZE>>;
  using PTime0 = func::dmn_0<PositiveTimeDomain>;
  using InterpolationDmn = func::dmn_variadic<CoeffDmn, PTime0, Pdmn0>;

  func::function<Real, InterpolationDmn> G0_coeff_;
  Real beta_ = 0;
  // value at tau = 0
  std::vector<Real> g0_minus_;
  // Spacing between time bins.
  double n_div_beta_;
};

template <typename Real>
template <class InputDmn>
void G0Interpolation<linalg::CPU, Real>::initialize(const func::function<double, InputDmn>& G0_func) {
  PositiveTimeDomain::initialize();
  Pdmn::initialize(InputDmn::dmn_size() / Tdmn::dmn_size());
  initialize(FunctionProxy<double, PTdmn>(G0_func));
}

}  // namespace solver
}  // namespace phys
}  // namespace dca

#endif  // DCA_PHYS_DCA_STEP_CLUSTER_SOLVER_SHARED_TOOLS_INTERPOLATION_G0_INTERPOLATION_CPU_HPP
Loading