Loading include/dca/phys/domains/quantum/electron_spin_domain.hpp +1 −18 Original line number Diff line number Diff line Loading @@ -37,7 +37,7 @@ public: static std::vector<e_spin_states_type>& get_elements() { static std::vector<e_spin_states_type> v = initialize_elements(); return elements_; return v; } template <typename Writer> Loading @@ -45,13 +45,8 @@ public: static int to_coordinate(element_type spin); template <typename Parameters> static void initialize(const Parameters& parameters); private: static std::vector<e_spin_states_type> initialize_elements(); static void initialize_elements(std::vector<e_spin_states_type>& elements); static inline std::vector<element_type> elements_; }; template <typename Writer> Loading @@ -61,18 +56,6 @@ void electron_spin_domain::write(Writer& writer) { writer.close_group(); } template <typename Parameters> void electron_spin_domain::initialize(const Parameters& /*parameters*/) { using Lattice = typename Parameters::lattice_type; int spins = 2; if constexpr(Parameters::template HasCustomSpin<Parameters::Model::lattice_type::SPINS>::value) { spins = Parameters::Model::lattice_type::SPINS; } elements_.resize(spins); initialize_elements(elements_); } } // domains } // phys } // dca Loading src/phys/domains/quantum/electron_spin_domain.cpp +9 −15 Original line number Diff line number Diff line Loading @@ -11,7 +11,6 @@ #include "dca/phys/domains/quantum/electron_spin_domain.hpp" #include <stdexcept> #include <cassert> namespace dca { namespace phys { Loading @@ -33,20 +32,15 @@ int electron_spin_domain::to_coordinate(element_type spin) { } } void electron_spin_domain::initialize_elements(std::vector<e_spin_states_type>& elements) { assert(elements.size() > 0 && elements.size() < 3); for (int i_spin = 0; i_spin < elements.size(); ++i_spin) { elements.push_back(i_spin ? e_DN : e_UP); } } std::vector<e_spin_states_type> electron_spin_domain::initialize_elements() { if (elements_.empty()) { elements_.push_back(e_DN); elements_.push_back(e_UP); } static std::vector<e_spin_states_type> v(0); v.push_back(e_DN); v.push_back(e_UP); return v; } } // namespace domains } // namespace phys } // namespace dca } // domains } // phys } // dca test/unit/phys/parameters/model_parameters/CMakeLists.txt +4 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,10 @@ dca_add_gtest(model_parameters_material_test GTEST_MAIN LIBS function_transform json models) dca_add_gtest(model_parameters_rashba_hubbard_test GTEST_MAIN LIBS function_transform json) dca_add_gtest(model_parameters_single_band_hubbard_test GTEST_MAIN LIBS function_transform json) test/unit/phys/parameters/model_parameters/input_read_all_rashba_hubbard.json 0 → 100644 +8 −0 Original line number Diff line number Diff line { "Rashba-Hubbard-model": { "t": 1., "h": 0.5, "lambda": 0.2, "U": 8. } } test/unit/phys/parameters/model_parameters/model_parameters_rashba_hubbard_test.cpp 0 → 100644 +46 −0 Original line number Diff line number Diff line // Copyright (C) 2023 ETH Zurich // Copyright (C) 2023 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: Urs R. Haehner (haehneru@itp.phys.ethz.ch) // Peter W. Doak (doakpw@ornl.gov) // // This file tests the Rashba-Hubbard model specialization of the ModelParameters class. // // TODO: Add tests for get_buffer_size, pack, unpack and writing. #include "dca/platform/dca_gpu.h" #include "dca/phys/parameters/model_parameters.hpp" #include "dca/testing/gtest_h_w_warning_blocking.h" #include "dca/io/json/json_reader.hpp" #include "dca/phys/domains/cluster/symmetries/point_groups/2d/2d_square.hpp" #include "dca/phys/models/analytic_hamiltonians/rashba_hubbard.hpp" using Lattice = dca::phys::models::RashbaHubbard<dca::phys::domains::no_symmetry<2>>; TEST(ModelParametersRanshbaHubbardTest, DefaultValues) { dca::phys::params::ModelParameters<dca::phys::models::TightBindingModel<Lattice>> pars; EXPECT_EQ(1., pars.get_t()); EXPECT_EQ(0., pars.get_h()); EXPECT_EQ(0., pars.get_lambda()); EXPECT_EQ(0., pars.get_U()); } TEST(ModelParametersSingleBandHubbardTest, ReadAll) { dca::io::JSONReader reader; dca::phys::params::ModelParameters<dca::phys::models::TightBindingModel<Lattice>> pars; reader.open_file( DCA_SOURCE_DIR "/test/unit/phys/parameters/model_parameters/input_read_all_rashba_hubbard.json"); pars.readWrite(reader); reader.close_file(); EXPECT_EQ(1., pars.get_t()); EXPECT_EQ(0.5, pars.get_h()); EXPECT_EQ(0.2, pars.get_lambda()); EXPECT_EQ(8.0, pars.get_U()); } Loading
include/dca/phys/domains/quantum/electron_spin_domain.hpp +1 −18 Original line number Diff line number Diff line Loading @@ -37,7 +37,7 @@ public: static std::vector<e_spin_states_type>& get_elements() { static std::vector<e_spin_states_type> v = initialize_elements(); return elements_; return v; } template <typename Writer> Loading @@ -45,13 +45,8 @@ public: static int to_coordinate(element_type spin); template <typename Parameters> static void initialize(const Parameters& parameters); private: static std::vector<e_spin_states_type> initialize_elements(); static void initialize_elements(std::vector<e_spin_states_type>& elements); static inline std::vector<element_type> elements_; }; template <typename Writer> Loading @@ -61,18 +56,6 @@ void electron_spin_domain::write(Writer& writer) { writer.close_group(); } template <typename Parameters> void electron_spin_domain::initialize(const Parameters& /*parameters*/) { using Lattice = typename Parameters::lattice_type; int spins = 2; if constexpr(Parameters::template HasCustomSpin<Parameters::Model::lattice_type::SPINS>::value) { spins = Parameters::Model::lattice_type::SPINS; } elements_.resize(spins); initialize_elements(elements_); } } // domains } // phys } // dca Loading
src/phys/domains/quantum/electron_spin_domain.cpp +9 −15 Original line number Diff line number Diff line Loading @@ -11,7 +11,6 @@ #include "dca/phys/domains/quantum/electron_spin_domain.hpp" #include <stdexcept> #include <cassert> namespace dca { namespace phys { Loading @@ -33,20 +32,15 @@ int electron_spin_domain::to_coordinate(element_type spin) { } } void electron_spin_domain::initialize_elements(std::vector<e_spin_states_type>& elements) { assert(elements.size() > 0 && elements.size() < 3); for (int i_spin = 0; i_spin < elements.size(); ++i_spin) { elements.push_back(i_spin ? e_DN : e_UP); } } std::vector<e_spin_states_type> electron_spin_domain::initialize_elements() { if (elements_.empty()) { elements_.push_back(e_DN); elements_.push_back(e_UP); } static std::vector<e_spin_states_type> v(0); v.push_back(e_DN); v.push_back(e_UP); return v; } } // namespace domains } // namespace phys } // namespace dca } // domains } // phys } // dca
test/unit/phys/parameters/model_parameters/CMakeLists.txt +4 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,10 @@ dca_add_gtest(model_parameters_material_test GTEST_MAIN LIBS function_transform json models) dca_add_gtest(model_parameters_rashba_hubbard_test GTEST_MAIN LIBS function_transform json) dca_add_gtest(model_parameters_single_band_hubbard_test GTEST_MAIN LIBS function_transform json)
test/unit/phys/parameters/model_parameters/input_read_all_rashba_hubbard.json 0 → 100644 +8 −0 Original line number Diff line number Diff line { "Rashba-Hubbard-model": { "t": 1., "h": 0.5, "lambda": 0.2, "U": 8. } }
test/unit/phys/parameters/model_parameters/model_parameters_rashba_hubbard_test.cpp 0 → 100644 +46 −0 Original line number Diff line number Diff line // Copyright (C) 2023 ETH Zurich // Copyright (C) 2023 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: Urs R. Haehner (haehneru@itp.phys.ethz.ch) // Peter W. Doak (doakpw@ornl.gov) // // This file tests the Rashba-Hubbard model specialization of the ModelParameters class. // // TODO: Add tests for get_buffer_size, pack, unpack and writing. #include "dca/platform/dca_gpu.h" #include "dca/phys/parameters/model_parameters.hpp" #include "dca/testing/gtest_h_w_warning_blocking.h" #include "dca/io/json/json_reader.hpp" #include "dca/phys/domains/cluster/symmetries/point_groups/2d/2d_square.hpp" #include "dca/phys/models/analytic_hamiltonians/rashba_hubbard.hpp" using Lattice = dca::phys::models::RashbaHubbard<dca::phys::domains::no_symmetry<2>>; TEST(ModelParametersRanshbaHubbardTest, DefaultValues) { dca::phys::params::ModelParameters<dca::phys::models::TightBindingModel<Lattice>> pars; EXPECT_EQ(1., pars.get_t()); EXPECT_EQ(0., pars.get_h()); EXPECT_EQ(0., pars.get_lambda()); EXPECT_EQ(0., pars.get_U()); } TEST(ModelParametersSingleBandHubbardTest, ReadAll) { dca::io::JSONReader reader; dca::phys::params::ModelParameters<dca::phys::models::TightBindingModel<Lattice>> pars; reader.open_file( DCA_SOURCE_DIR "/test/unit/phys/parameters/model_parameters/input_read_all_rashba_hubbard.json"); pars.readWrite(reader); reader.close_file(); EXPECT_EQ(1., pars.get_t()); EXPECT_EQ(0.5, pars.get_h()); EXPECT_EQ(0.2, pars.get_lambda()); EXPECT_EQ(8.0, pars.get_U()); }