Loading include/dca/io/hdf5/hdf5_writer.hpp +1 −1 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ #include <string> #include <vector> #include "H5Cpp.h" #include <H5Cpp.h> #include "dca/function/domains.hpp" #include "dca/io/buffer.hpp" Loading include/dca/io/writer.hpp +6 −0 Original line number Diff line number Diff line Loading @@ -82,6 +82,8 @@ public: } #endif bool isOpen() { return is_open_; } void begin_step() { std::visit([&](auto& var) { var.begin_step(); }, writer_); } Loading @@ -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 Loading Loading @@ -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_; Loading @@ -157,6 +162,7 @@ private: adios2::ADIOS& adios_; #endif Concurrency& concurrency_; bool is_open_; }; } // namespace dca::io Loading include/dca/phys/models/analytic_hamiltonians/Kagome_hubbard.hpp +24 −19 Original line number Diff line number Diff line Loading @@ -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> Loading Loading @@ -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]); } } } Loading src/io/hdf5/hdf5_reader.cpp +10 −3 Original line number Diff line number Diff line Loading @@ -12,7 +12,6 @@ #include "dca/io/hdf5/hdf5_reader.hpp" #include "hdf5.h" #include <fstream> #include <stdexcept> Loading Loading @@ -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; } Loading @@ -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; } Loading test/unit/io/reader_test.cpp +4 −2 Original line number Diff line number Diff line Loading @@ -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 Loading
include/dca/io/hdf5/hdf5_writer.hpp +1 −1 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ #include <string> #include <vector> #include "H5Cpp.h" #include <H5Cpp.h> #include "dca/function/domains.hpp" #include "dca/io/buffer.hpp" Loading
include/dca/io/writer.hpp +6 −0 Original line number Diff line number Diff line Loading @@ -82,6 +82,8 @@ public: } #endif bool isOpen() { return is_open_; } void begin_step() { std::visit([&](auto& var) { var.begin_step(); }, writer_); } Loading @@ -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 Loading Loading @@ -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_; Loading @@ -157,6 +162,7 @@ private: adios2::ADIOS& adios_; #endif Concurrency& concurrency_; bool is_open_; }; } // namespace dca::io Loading
include/dca/phys/models/analytic_hamiltonians/Kagome_hubbard.hpp +24 −19 Original line number Diff line number Diff line Loading @@ -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> Loading Loading @@ -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]); } } } Loading
src/io/hdf5/hdf5_reader.cpp +10 −3 Original line number Diff line number Diff line Loading @@ -12,7 +12,6 @@ #include "dca/io/hdf5/hdf5_reader.hpp" #include "hdf5.h" #include <fstream> #include <stdexcept> Loading Loading @@ -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; } Loading @@ -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; } Loading
test/unit/io/reader_test.cpp +4 −2 Original line number Diff line number Diff line Loading @@ -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