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

little cleanup of dca_data reading

parent 9121a1e2
Loading
Loading
Loading
Loading
+84 −44
Original line number Diff line number Diff line
@@ -76,6 +76,45 @@ private:
template <typename PARAMETERS>
void compute_band_structure<PARAMETERS>::execute(const Parameters& parameters,
                                                 func::function<Real, nu_k_cut>& band_structure) {
  if constexpr (std::is_same_v<double, Real>) {
    std::vector<std::vector<double>> collection_k_vecs;

    std::string coordinate_type;
    std::vector<std::vector<double>> brillouin_zone_vecs;

    // Construct the path in the Brilluoin zone.
    high_symmetry_line<Parameters::lattice_dimension>(coordinate_type, brillouin_zone_vecs);
    construct_path<Parameters::lattice_dimension>(coordinate_type, brillouin_zone_vecs,
                                                      collection_k_vecs);

    brillouin_zone_cut_domain_type::get_size() = collection_k_vecs.size();
    brillouin_zone_cut_domain_type::get_elements() = collection_k_vecs;

    band_structure.reset();

    // Compute H(k).
    func::function<std::complex<double>, func::dmn_variadic<nu, nu, k_domain_cut_dmn_type>> H_k(
        "H_k");
    Parameters::lattice_type::initializeH0(parameters, H_k);

    // Compute the bands.
    dca::linalg::Vector<double, dca::linalg::CPU> L_vec(nu::dmn_size());
    dca::linalg::Matrix<std::complex<double>, dca::linalg::CPU> H_mat(nu::dmn_size());
    dca::linalg::Matrix<std::complex<double>, dca::linalg::CPU> V_mat(nu::dmn_size());

    for (int l = 0; l < int(collection_k_vecs.size()); l++) {
      for (int i = 0; i < nu::dmn_size(); i++)
        for (int j = 0; j < nu::dmn_size(); j++)
          H_mat(i, j) = H_k(i, j, l);

      dca::linalg::matrixop::eigensolverHermitian('N', 'U', H_mat, L_vec, V_mat);

      for (int i = 0; i < b::dmn_size(); i++)
        for (int j = 0; j < s::dmn_size(); j++)
          band_structure(i, j, l) = L_vec[2 * i + j];
    }
  }
  else {
    std::vector<std::vector<Real>> collection_k_vecs;

    std::string coordinate_type;
@@ -130,6 +169,7 @@ void compute_band_structure<PARAMETERS>::execute(const Parameters& parameters,
          band_structure(i, j, l) = L_vec[2 * i + j];
    }
  }
}

template <class PARAMETERS>
template <int lattice_dimension>
+18 −16
Original line number Diff line number Diff line
@@ -113,12 +113,15 @@ public:

  DcaData(Parameters& parameters_ref);

  /** These reads are used by analysis programs only for now.
   */
  void read(const std::string& filename);
#ifdef DCA_HAVE_ADIOS2
  void read(adios2::ADIOS& adios, std::string filename);
#endif

  /** prefer this as it allows for more sensible handling of appendable files like bp4.
   *  currently this is used by chi_q_omega only.
   */
  void read(dca::io::Reader<Concurrency>& reader);

@@ -345,14 +348,14 @@ DcaData<Parameters, DT>::DcaData(/*const*/ Parameters& parameters_ref)

template <class Parameters, DistType DT>
void DcaData<Parameters, DT>::read(const std::string& filename) {
  if (concurrency_.id() == concurrency_.first())
  if (concurrency_.id() == concurrency_.first()) {
    std::cout << "\n\n\t starts reading \n\n";
    dca::io::Reader<typename Parameters::concurrency_type> reader(concurrency_,
                                                                  parameters_.get_output_format());
    reader.open_file(filename);
    read(reader);
    reader.close_file();

  }
  concurrency_.broadcast(parameters_.get_chemical_potential());
  concurrency_.broadcast_object(Sigma);

@@ -367,7 +370,7 @@ void DcaData<Parameters, DT>::read(const std::string& filename) {
#ifdef DCA_HAVE_ADIOS2
template <class Parameters, DistType DT>
void DcaData<Parameters, DT>::read(adios2::ADIOS& adios, std::string filename) {
  if (concurrency_.id() == concurrency_.first())
  if (concurrency_.id() == concurrency_.first()) {
    std::cout << "\n\n\t starts reading \n\n";

    dca::io::Reader<typename Parameters::concurrency_type> reader(adios, concurrency_,
@@ -375,7 +378,8 @@ void DcaData<Parameters, DT>::read(adios2::ADIOS& adios, std::string filename) {
    reader.open_file(filename);
    read(reader);
    reader.close_file();

  }
  // realize that if you need anyting else from the prior data that you need to add its broadcast here.
  concurrency_.broadcast(parameters_.get_chemical_potential());
  concurrency_.broadcast_object(Sigma);

@@ -406,8 +410,6 @@ void DcaData<Parameters, DT>::read(dca::io::Reader<typename Parameters::concurre
  reader.open_group("functions");

  reader.execute(Sigma);
  reader.execute(Sigma_lattice);
  reader.execute(Sigma_lattice_interpolated);

  if (parameters_.isAccumulatingG4()) {
    std::cout << "Trying to read Gkw since we are accumulating G4\n";
+0 −1
Original line number Diff line number Diff line
@@ -241,7 +241,6 @@ void DcaLoop<ParametersType, DDT, MCIntegratorType, DIST>::initialize() {
    else
#endif
      MOMS.initializeSigma(parameters.get_initial_self_energy());

    perform_lattice_mapping();
  }