Unverified Commit 233bdb30 authored by Peter Doak's avatar Peter Doak Committed by GitHub
Browse files

Kagome branch (#282)

* suppressing warnings from unimplemented Kagome methods

* attempt at hdf_reader fix

* fast tests pass

* remove uneeded header
parent 7b3a533a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@
#include <string>
#include <vector>

#include "H5Cpp.h"
#include <H5Cpp.h>

#include "dca/function/domains.hpp"
#include "dca/io/buffer.hpp"
+6 −0
Original line number Diff line number Diff line
@@ -82,6 +82,8 @@ public:
  }
#endif

  bool isOpen() { return is_open_; }
  
  void begin_step() {
    std::visit([&](auto& var) { var.begin_step(); }, writer_);
  }
@@ -92,10 +94,12 @@ public:

  void open_file(const std::string& file_name, bool overwrite = true) {
    std::visit([&](auto& var) { var.open_file(file_name, overwrite); }, writer_);
    is_open_ = true;
  }

  void close_file() {
    std::visit([&](auto& var) { var.close_file(); }, writer_);
    is_open_ = false;
  }

  /** For writing open_group is expected to always return true
@@ -150,6 +154,7 @@ public:
    std::visit([&](auto& var) { var.set_verbose(verbose); }, writer_);
  }

  dca::parallel::thread_traits::mutex_type& get_mutex() { return mutex_; }
private:
  dca::parallel::thread_traits::mutex_type mutex_;
  DCAWriterVariant writer_;
@@ -157,6 +162,7 @@ private:
  adios2::ADIOS& adios_;
#endif
  Concurrency& concurrency_;
  bool is_open_;
};

}  // namespace dca::io
+24 −19
Original line number Diff line number Diff line
@@ -81,38 +81,44 @@ public:
};

template <typename PointGroupType>
int KagomeHubbard<PointGroupType>::transformationSignOfR(int b1, int b2, int s) {
int KagomeHubbard<PointGroupType>::transformationSignOfR(int b1 [[maybe_unused]],
                                                         int b2 [[maybe_unused]],
                                                         int s [[maybe_unused]]) {
  return 1;  // TODO: FIXME
}

template <typename PointGroupType>
int KagomeHubbard<PointGroupType>::transformationSignOfK(int b1, int b2, int s) {
int KagomeHubbard<PointGroupType>::transformationSignOfK(int b1 [[maybe_unused]],
                                                         int b2 [[maybe_unused]],
                                                         int s [[maybe_unused]]) {
  return 1;  // TODO: FIXME
}

template <typename PointGroupType>
double* KagomeHubbard<PointGroupType>::initializeRDCABasis() {
  static std::array<double, 4> basis{std::cos(M_PI / 3.), std::sin(M_PI / 3.), std::cos(M_PI / 3.), std::sin(-M_PI / 3.)};
  static std::array<double, 4> basis{std::cos(M_PI / 3.), std::sin(M_PI / 3.), std::cos(M_PI / 3.),
                                     std::sin(-M_PI / 3.)};
  // static std::array<double, 4> basis{1, 0, 0.5, std::sin(M_PI / 3.)};
  return basis.data();
}
// template <typename PointGroupType>
// double* KagomeHubbard<PointGroupType>::initializeKDCABasis() {
//   static std::array<double, 4> basis{2 * M_PI, -M_PI/std::sin(M_PI/3.), 0, 2. * M_PI/std::sin(M_PI/3.)};
//   return basis.data();
//   static std::array<double, 4> basis{2 * M_PI, -M_PI/std::sin(M_PI/3.), 0, 2. *
//   M_PI/std::sin(M_PI/3.)}; return basis.data();
// }

template <typename PointGroupType>
double* KagomeHubbard<PointGroupType>::initializeRLDABasis() {
  static std::array<double, 4> basis{std::cos(M_PI / 3.), std::sin(M_PI / 3.), std::cos(M_PI / 3.), std::sin(-M_PI / 3.)};
  static std::array<double, 4> basis{std::cos(M_PI / 3.), std::sin(M_PI / 3.), std::cos(M_PI / 3.),
                                     std::sin(-M_PI / 3.)};
  // static std::array<double, 4> basis{1, 0, 0, std::sin(M_PI / 3.)};
  return basis.data();
}

// template <typename PointGroupType>
// double* KagomeHubbard<PointGroupType>::initializeKLDABasis() {
//   static std::array<double, 4> basis{2 * M_PI, -M_PI/std::sin(M_PI/3.), 0, 2. * M_PI/std::sin(M_PI/3.)};
//   return basis.data();
//   static std::array<double, 4> basis{2 * M_PI, -M_PI/std::sin(M_PI/3.), 0, 2. *
//   M_PI/std::sin(M_PI/3.)}; return basis.data();
// }

template <typename PointGroupType>
@@ -197,7 +203,6 @@ void KagomeHubbard<PointGroupType>::initializeH0(
      H_0(1, s, 0, s, k_ind) = -2. * t * std::cos(0.5 * k[0]);
      H_0(2, s, 0, s, k_ind) = -2. * t * std::cos(0.25 * k[0] + 0.25 * sqrt(3.) * k[1]);
      H_0(2, s, 1, s, k_ind) = -2. * t * std::cos(0.25 * k[0] - 0.25 * sqrt(3.) * k[1]);

    }
  }
}
+10 −3
Original line number Diff line number Diff line
@@ -12,7 +12,6 @@

#include "dca/io/hdf5/hdf5_reader.hpp"
#include "hdf5.h"

#include <fstream>
#include <stdexcept>

@@ -59,7 +58,11 @@ std::string HDF5Reader::get_path() {
}

bool HDF5Reader::execute(const std::string& name, std::string& value) {
  std::string full_name = get_path() + "/" + name;
  std::string full_name = get_path();
  if (full_name.size() < 1)
    full_name += name;
  else
    full_name += "/" + name;
  if (!exists(full_name)) {
    return false;
  }
@@ -80,7 +83,11 @@ bool HDF5Reader::execute(const std::string& name, std::string& value) {
}

bool HDF5Reader::execute(const std::string& name, std::vector<std::string>& value) {
  std::string full_name = get_path() + "/" + name;
  std::string full_name = get_path();
  if (full_name.size() < 1)
    full_name += name;
  else
    full_name += "/" + name;
  if (!exists(full_name)) {
    return false;
  }
+4 −2
Original line number Diff line number Diff line
@@ -64,13 +64,15 @@ TEST(HDF5ReaderTest, Vector) {
  // Simple 3D vector
  std::vector<float> vec_1;
  std::vector<float> vec_1_check{1., 2., 3.};
  reader.execute("simple-vector", vec_1);
  bool result = reader.execute("simple-vector", vec_1);
  EXPECT_TRUE(result);
  EXPECT_EQ(vec_1_check, vec_1);

  // Vector of 3 vectors variable length
  std::vector<std::vector<float>> vec_2;
  std::vector<std::vector<float>> vec_2_check{{1.2, 3.4}, {5.6, 7.8, 4.4}, {1.0}};
  reader.execute("vector-of-vectors", vec_2);
  result = reader.execute("vector-of-vectors", vec_2);
  EXPECT_TRUE(result);
  EXPECT_EQ(vec_2_check, vec_2);

  reader.close_file();
Loading