Commit ac20f113 authored by Doak, Peter W.'s avatar Doak, Peter W.
Browse files

clean up the autocorrelation architecture a bit

parent 3797433c
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
// Copyright (C) 2018 ETH Zurich
// Copyright (C) 2018 UT-Battelle, LLC
// Copyright (C) 2021 ETH Zurich
// Copyright (C) 2021 UT-Battelle, LLC
// All rights reserved.
//
// See LICENSE for terms of usage.
@@ -7,6 +7,7 @@
//
// Author: Peter Staar (taa@zurich.ibm.com)
//         Giovanni Balduzzi (gbalduzz@itp.phys.ethz.ch)
//         Peter Doak (doakpw@ornl.gov)
//
// Cluster Monte Carlo integrator based on a continuous-time auxilary field (CT-AUX) expansion.
//
@@ -68,9 +69,6 @@ public:

  static constexpr linalg::DeviceType device = device_t;

protected:
  std::shared_ptr<io::Writer<Concurrency>> writer_;

private:
  using w = func::dmn_0<domains::frequency_domain>;
  using b = func::dmn_0<domains::electron_band_domain>;
@@ -86,7 +84,7 @@ private:

public:
  CtauxClusterSolver(Parameters& parameters_ref, Data& MOMS_ref,
                     const std::shared_ptr<io::Writer<Concurrency>>& writer = nullptr);
                     const std::shared_ptr<io::Writer<Concurrency>>& writer);

  template <typename Writer>
  void write(Writer& writer);
@@ -148,6 +146,8 @@ protected:

  int dca_iteration_;

  G0Interpolation<device, typename Walker::Scalar> g0_;

private:
  Rng rng_;

@@ -157,14 +157,15 @@ private:
  func::function<std::complex<double>, NuNuKClusterWDmn> Sigma_old_;
  func::function<std::complex<double>, NuNuKClusterWDmn> Sigma_new_;

  G0Interpolation<device, typename Walker::Scalar> g0_;

  double accumulated_sign_;
  func::function<std::complex<double>, NuNuRClusterWDmn> M_r_w_;
  func::function<std::complex<double>, NuNuRClusterWDmn> M_r_w_squared_;

  bool averaged_;
  bool compute_jack_knife_;

protected:
  std::shared_ptr<io::Writer<Concurrency>> writer_;
};

template <dca::linalg::DeviceType device_t, class Parameters, class Data, dca::DistType DIST>
@@ -190,7 +191,6 @@ CtauxClusterSolver<device_t, Parameters, Data, DIST>::CtauxClusterSolver(

      M_r_w_("M_r_w"),
      M_r_w_squared_("M_r_w_squared"),

      averaged_(false),
      writer_(writer) {
  if (concurrency_.id() == concurrency_.first())
+5 −3
Original line number Diff line number Diff line
// Copyright (C) 2018 ETH Zurich
// Copyright (C) 2018 UT-Battelle, LLC
// Copyright (C) 2021 ETH Zurich
// Copyright (C) 2021 UT-Battelle, LLC
// All rights reserved.
//
// See LICENSE for terms of usage.
@@ -50,6 +50,7 @@ public:
              uint64_t id);

  this_type& operator=(const this_type& other_vertex_pair);
  vertex_pair(const this_type& other_vertex_pair) = default;
  
  uint64_t get_id() const {
    return id_;
@@ -188,6 +189,7 @@ vertex_pair<parameters_type>::vertex_pair(parameters_type& parameters_ref, rng_t
      Bennett(false),
      shuffled(false) {}

// \todo replace this sematic changing operator overload 
template <class parameters_type>
vertex_pair<parameters_type>& vertex_pair<parameters_type>::operator=(
    const vertex_pair<parameters_type>& other_vertex_pair)  // --> necessary for push_back
+4 −3
Original line number Diff line number Diff line
// Copyright (C) 2018 ETH Zurich
// Copyright (C) 2018 UT-Battelle, LLC
// Copyright (C) 2021 ETH Zurich
// Copyright (C) 2021 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.
//
// Author: Giovanni Balduzzi(gbalduzz@itp.phys.ethz.ch)
//         Peter Doak(doakpw@ornl.gov)
//
// Cluster Monte Carlo integrator based on a CT-INT algorithm.

@@ -142,12 +143,12 @@ protected:
  int dca_iteration_ = 0;
  std::shared_ptr<io::Writer<Concurrency>> writer_;

  G0Interpolation<device_t, typename Walker::Scalar> g0_;
private:
  bool perform_tp_accumulation_;
  const LabelDomain label_dmn_;
  std::unique_ptr<Walker> walker_;
  // Walker input.
  G0Interpolation<device_t, Real> g0_;
  Rng rng_;
};

+9 −19
Original line number Diff line number Diff line
// Copyright (C) 2018 ETH Zurich
// Copyright (C) 2018 UT-Battelle, LLC
// Copyright (C) 2021 ETH Zurich
// Copyright (C) 2021 UT-Battelle, LLC
// All rights reserved.
//
// See LICENSE for terms of usage.
// See CITATION.md for citation guidelines, if DCA++ is used for scientific publications.
//
// Author: Giovanni Balduzzi (gbalduzz@itp.phys.ethz.ch)
//         Peter Doak (doakpw@ornl.gov)
//
// This class measures the correlation of G(r = 0, t = 0).

@@ -53,19 +54,12 @@ public:
  template <DeviceType conf_device>
  using Config = linalg::MultiVector<conf_device, Real, int, int>;

  TimeCorrelator(const Parameters& parameters_, int id);
  TimeCorrelator(const Parameters& parameters_, int id, G0Interpolation<device, Real>& g0);

  template <class WalkerConfig, typename RealInp>
  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) {
    if constexpr (device == linalg::GPU)
      details::SolverHelper::set<RDmn, BDmn>();
    g0_ = &g0;
  }

  auto& getCorrelators() {
    return autocorrelations_;
  }
@@ -100,7 +94,7 @@ private:
  constexpr static int n_correlators_ =
      n_bands_ * (n_bands_ + 1) / 2;  // Number of independent entries in a band-band matrix.

  static const inline G0Interpolation<device, Real>* g0_ = nullptr;
  G0Interpolation<device, Real>& g0_;

  const linalg::util::GpuStream& stream_;

@@ -121,11 +115,11 @@ private:
};

template <class Parameters, typename Real, DeviceType device>
TimeCorrelator<Parameters, Real, device>::TimeCorrelator(const Parameters& parameters_ref, int id)
TimeCorrelator<Parameters, Real, device>::TimeCorrelator(const Parameters& parameters_ref, int id, G0Interpolation<device, Real>& g0)
    : parameters_(parameters_ref),
      concurrency_(parameters_.get_concurrency()),

      thread_id_(id),
      g0_(g0),
      stream_(linalg::util::getStream(thread_id_, 0)) {
  // We're going to make one of these per walker
  // @gbalduzz solution of making this static creates a race with cuda driver shutting down.
@@ -160,10 +154,6 @@ template <class WalkerConfig, typename RealInp>
void TimeCorrelator<Parameters, Real, device>::compute_G_r_t(
    const std::array<dca::linalg::Matrix<RealInp, device>, 2>& M,
    const std::array<WalkerConfig, 2>& configs, int sign) {
  if (!g0_) {
    throw(std::runtime_error("G0 is not set."));
  }

  // Upload state
  constexpr int n_electron_spins = 1;  // Compute only on up-up sector.

@@ -270,7 +260,7 @@ void TimeCorrelator<Parameters, Real, device>::computeG0(linalg::Matrix<Real, GP
  G0_mat.resizeNoCopy(std::make_pair(config_l.size(), config_r.size()));

  linalg::MatrixView<Real, device> G0_view(G0_mat);
  details::computeG0(G0_view, *g0_, config_l.template get<0>(), config_l.template get<1>(),
  details::computeG0(G0_view, g0_, config_l.template get<0>(), config_l.template get<1>(),
                     config_l.template get<2>(), config_r.template get<0>(),
                     config_r.template get<1>(), config_r.template get<2>(), stream_);
}
@@ -299,7 +289,7 @@ void TimeCorrelator<Parameters, Real, device>::computeG0(linalg::Matrix<Real, CP
      const int r = RDmn::parameter_type::subtract(r_r[j], r_l[i]);
      const int label = labels(b_l[i], b_r[j], r);

      G0_mat(i, j) = (*g0_)(tau, label);
      G0_mat(i, j) = g0_(tau, label);
    }
}

+15 −8
Original line number Diff line number Diff line
// Copyright (C) 2010 Philipp Werner
// Copyright (C) 2021 ETH Zurich
// Copyright (C) 2021 UT-Battelle, LLC
// All rights reserved.
//
// See LICENSE for terms of usage.
// See CITATION.md for citation guidelines, if DCA++ is used for scientific publications.
//
// Integrated into DCA++ by Peter Staar (taa@zurich.ibm.com) and Bart Ydens.
// Modified by Peter Doak (doakpw@ornl.gov)
//
// Single-site Monte Carlo integrator based on a hybridization expansion.

@@ -52,7 +59,6 @@ public:
  using RClusterDmn = typename CDA::RClusterDmn;
  using KClusterDmn = typename CDA::KClusterDmn;
  using Concurrency = typename parameters_type::concurrency_type;

  using Lattice = typename parameters_type::lattice_type;

  using nu_nu_k_DCA_w = func::dmn_variadic<nu, nu, KClusterDmn, w>;
@@ -129,8 +135,6 @@ protected: // Interface to the thread jacket.
  Accumulator accumulator_;
  double total_time_;
  int dca_iteration_;

  std::shared_ptr<io::Writer<Concurrency>> writer_;
private:
  Rng rng;

@@ -143,12 +147,15 @@ private:
  func::function<double, nu> mu_DC;

  bool averaged_;

protected:
  std::shared_ptr<io::Writer<Concurrency>> writer_;
  G0Interpolation<device_t, typename Walker::Scalar> g0_;
};

template <dca::linalg::DeviceType DEV, class PARAM, class Data>
SsCtHybClusterSolver<DEV, PARAM, Data>::SsCtHybClusterSolver(
    PARAM& parameters_ref, Data& data_ref,
    const std::shared_ptr<io::Writer<Concurrency>>& writer)
    PARAM& parameters_ref, Data& data_ref, const std::shared_ptr<io::Writer<Concurrency>>& writer)
    : cthyb::ss_hybridization_solver_routines<PARAM, Data>(parameters_ref, data_ref),

      parameters_(parameters_ref),
@@ -160,15 +167,15 @@ SsCtHybClusterSolver<DEV, PARAM, Data>::SsCtHybClusterSolver(
      dca_iteration_(-1),

      rng(concurrency_.id(), concurrency_.number_of_processors(), parameters_.get_seed()),

      writer_(writer),
      thermalization_time(0),
      MC_integration_time(0),

      Sigma_old("Self-Energy-n-1-iteration"),
      Sigma_new("Self-Energy-n-0-iteration"),

      averaged_(false) {
      averaged_(false),
      writer_(writer)
{
  if (concurrency_.id() == concurrency_.first())
    std::cout << "\n\n\t SS CT-HYB Integrator is born \n" << std::endl;
}
Loading