diff --git a/config.yaml b/config.yaml index e76f23a..5e66aed 100644 --- a/config.yaml +++ b/config.yaml @@ -1,3 +1,6 @@ +n_k_points: 0 +n_occupied_total: 3 +n_unoccupied_total: 9 n_isdf_vexc: 3 n_isdf_wscr_occupied: 4 n_isdf_wscr_unoccupied: 5 diff --git a/dev/app/src/main.cpp b/dev/app/src/main.cpp index a8ce4ee..b491572 100644 --- a/dev/app/src/main.cpp +++ b/dev/app/src/main.cpp @@ -10,12 +10,11 @@ using namespace flash; int main() { + try { - Config config("config.yaml"); - } catch (InvalidKeyException ike) { - std::cout << "Caught InvalidKeyException: " << ike.what() << std::endl; - } catch (MissingKeyException mke) { - std::cout << "Caught MissingKeyExceptionr " << mke.what() << std::endl; + Config params("config.yaml"); + std::cout< } try { + n_k_points = nodeToValue(configYamlNode["n_k_points"], "n_k_points is wrongly initialized."); + n_occupied_total = nodeToValue(configYamlNode["n_occupied_total"], "n_occupied_total is wrongly initialized."); + n_unoccupied_total = nodeToValue(configYamlNode["n_unoccupied_total"], "n_unoccupied_total is wrongly initialized."); n_isdf_vexc = nodeToValue(configYamlNode["n_isdf_vexc"], "n_isdf_vexc is wrongly initialized."); n_isdf_wscr_occupied = nodeToValue(configYamlNode["n_isdf_wscr_occupied"], "n_isdf_wscr_occupied is wrongly initialized."); @@ -104,57 +107,66 @@ Config::Config(const YAML::Node &configYamlNode, const std::vector Config::Config(const std::string &configYamlFile, const std::vector &allowedKeys, const std::vector &mandatoryKeys, const DefaultConfig &defaults) { - YAML::Node configYamlNode = YAML::LoadFile("config.yaml"); - Config(configYamlNode, allowedKeys, mandatoryKeys, defaults); + try{ + YAML::Node configYamlNode = YAML::LoadFile("config.yaml"); + Config(configYamlNode, allowedKeys, mandatoryKeys, defaults); + } catch(...) { + throw; + } }; -void Config::sanityChecks() { +void Config::validate() { + // Rule for n_k_points - if (!n_k_points > 0) { + if (n_k_points == 0) { throw InvalidConfigurationException("n_k_points must be > 0."); } // Rule for n_occupied_total - if (!n_occpied_total > 0) { - throw InvalidConfigurationException("n_occpied_total must be > 0."); + if (n_occupied_total == 0) { + throw InvalidConfigurationException("n_occupied_total must be > 0."); } // Rule for n_unoccupied_total - if (!n_unoccupied_total > 0) { + if (n_unoccupied_total == 0) { throw InvalidConfigurationException("n_unoccupied_total must be > 0."); } // Rule for n_occupied_total + n_unoccupied_total - if (!(n_unoccupied_total + n_occpied_total) % n_k_points == 0) { - throw InvalidConfigurationException("n_occpied_total + n_unoccupied_total must be divisable by n_k_points."); + if ((n_unoccupied_total + n_occupied_total) % n_k_points != 0) { + throw InvalidConfigurationException("n_occupied_total + n_unoccupied_total must be divisable by n_k_points."); } // Rules for n_isdf_vexc if (!n_isdf_vexc > 0) { throw InvalidConfigurationException("n_isdf_vexc must be > 0."); } - if (!n_isdf_vexc <= n_occpied_total * n_unoccupied_total / n_k_points) { + if (!n_isdf_vexc <= n_occupied_total * n_unoccupied_total / n_k_points) { throw InvalidConfigurationException( - "n_isdf_vexc must be <= n_occpied_total * n_unoccupied_total / n_k_points (" + - std::to_string(n_occpied_total * n_unoccupied_total / n_k_points) + ")."); + "n_isdf_vexc must be <= n_occupied_total * n_unoccupied_total / n_k_points (" + + std::to_string(n_occupied_total * n_unoccupied_total / n_k_points) + ")."); } // Rules for n_isdf_wscr_occupied if (!n_isdf_wscr_occupied > 0) { throw InvalidConfigurationException("n_isdf_wscr_occupied must be > 0."); } - if (!n_isdf_wscr_occupied <= n_occpied_total * *2) { - throw InvalidConfigurationException("n_isdf_wscr_occupied must be <= n_occpied_total ** 2 (" + - std::to_string(n_occpied_total * *2) + ")."); + if (!n_isdf_wscr_occupied <= std::pow(n_occupied_total, 2)) { + throw InvalidConfigurationException("n_isdf_wscr_occupied must be <= n_occupied_total^2 (" + + std::to_string(std::pow(n_occupied_total, 2)) + ")."); } // Rules for n_isdf_wscr_unoccupied if (!n_isdf_wscr_unoccupied > 0) { throw InvalidConfigurationException("n_isdf_wscr_unoccupied must be > 0."); } - if (!n_isdf_wscr_unoccupied <= n_unoccupied_total * *2) { - throw InvalidConfigurationException("n_isdf_wscr_unoccupied must be <= n_occpied_total ** 2 (" + - std::to_string(n_unoccupied_total * *2) + ")."); + if (!n_isdf_wscr_unoccupied <= std::pow(n_occupied_total, 2)) { + throw InvalidConfigurationException("n_isdf_wscr_unoccupied must be <= n_occupied_total^2 (" + + std::to_string(std::pow(n_occupied_total, 2)) + ")."); } // Rule for max_lanczos_iterations if (!max_lanczos_iterations > 0) { throw InvalidConfigurationException("max_lanczos_iterations must be > 0."); } // Rule for omega_range + if (!sizeof(omega_range) == 2) { + throw InvalidConfigurationException( + "omega_range must contain exactly 2 values."); + } if (!omega_range[0] < omega_range[1]) { throw InvalidConfigurationException( "Lower limit of omega_range (left value) must be smaller then the upper limit (right value)."); diff --git a/dev/tests/data_processing/src/config_test.cpp b/dev/tests/data_processing/src/config_test.cpp index 661b3cf..6352f21 100644 --- a/dev/tests/data_processing/src/config_test.cpp +++ b/dev/tests/data_processing/src/config_test.cpp @@ -24,6 +24,9 @@ TEST_CASE("Test Config construction from a valid YAML::node that defines all par validNode["cvt_convergence_criterium"] = 1e-6; validNode["seed_source"] = "fixed"; const Config params(validNode); + REQUIRE(params.n_k_points == 50); + REQUIRE(params.n_occupied_total == 13); + REQUIRE(params.n_unoccupied_total == 37); REQUIRE(params.n_isdf_vexc == 2); REQUIRE(params.n_isdf_wscr_occupied == 3); REQUIRE(params.n_isdf_wscr_unoccupied == 4); @@ -50,6 +53,9 @@ TEST_CASE("Test Config construction from a valid YAML::node that defines not all validNodeDefaults["omega_range"].push_back(2.0); validNodeDefaults["n_omega"] = 1000; const Config params(validNodeDefaults); + REQUIRE(params.n_k_points == 50); + REQUIRE(params.n_occupied_total == 13); + REQUIRE(params.n_unoccupied_total == 37); REQUIRE(params.n_isdf_vexc == 2); REQUIRE(params.n_isdf_wscr_occupied == 3); REQUIRE(params.n_isdf_wscr_unoccupied == 4); @@ -80,6 +86,7 @@ TEST_CASE("Test Config construction from an invalid YAML::node that uses a forbi TEST_CASE("Test Config construction from an invalid YAML::node that does not define all mandatory parameters.", "[invalid-config-missing-param]") { + // n_k_points missing YAML::Node invalidNodeMissingKey; invalidNodeMissingKey["n_occupied_total"] = 13; invalidNodeMissingKey["n_unoccupied_total"] = 37; @@ -92,6 +99,7 @@ TEST_CASE("Test Config construction from an invalid YAML::node that does not def invalidNodeMissingKey["n_omega"] = 1000; REQUIRE_THROWS_AS(Config(invalidNodeMissingKey), MissingKeyException); + // n_k_points n_occupied_total invalidNodeMissingKey.reset(); invalidNodeMissingKey["n_k_points"] = 50; invalidNodeMissingKey["n_unoccupied_total"] = 37; @@ -103,6 +111,7 @@ TEST_CASE("Test Config construction from an invalid YAML::node that does not def invalidNodeMissingKey["n_omega"] = 1000; REQUIRE_THROWS_AS(Config(invalidNodeMissingKey), MissingKeyException); + // n_k_points n_unoccupied_total invalidNodeMissingKey.reset(); invalidNodeMissingKey["n_k_points"] = 50; invalidNodeMissingKey["n_occupied_total"] = 13; @@ -114,6 +123,7 @@ TEST_CASE("Test Config construction from an invalid YAML::node that does not def invalidNodeMissingKey["n_omega"] = 1000; REQUIRE_THROWS_AS(Config(invalidNodeMissingKey), MissingKeyException); + // n_k_points n_isdf_vexc invalidNodeMissingKey.reset(); invalidNodeMissingKey["n_k_points"] = 50; invalidNodeMissingKey["n_occupied_total"] = 13; @@ -126,6 +136,7 @@ TEST_CASE("Test Config construction from an invalid YAML::node that does not def invalidNodeMissingKey["n_omega"] = 1000; REQUIRE_THROWS_AS(Config(invalidNodeMissingKey), MissingKeyException); + // n_isdf_wscr_occupied missing invalidNodeMissingKey.reset(); invalidNodeMissingKey["n_k_points"] = 50; invalidNodeMissingKey["n_occupied_total"] = 13; @@ -138,6 +149,7 @@ TEST_CASE("Test Config construction from an invalid YAML::node that does not def invalidNodeMissingKey["n_omega"] = 1000; REQUIRE_THROWS_AS(Config(invalidNodeMissingKey), MissingKeyException); + // n_isdf_wscr_unoccupied missing invalidNodeMissingKey.reset(); invalidNodeMissingKey["n_k_points"] = 50; invalidNodeMissingKey["n_occupied_total"] = 13; @@ -150,6 +162,7 @@ TEST_CASE("Test Config construction from an invalid YAML::node that does not def invalidNodeMissingKey["n_omega"] = 1000; REQUIRE_THROWS_AS(Config(invalidNodeMissingKey), MissingKeyException); + // max_lanczos_iterations missing invalidNodeMissingKey.reset(); invalidNodeMissingKey["n_k_points"] = 50; invalidNodeMissingKey["n_occupied_total"] = 13; @@ -162,6 +175,7 @@ TEST_CASE("Test Config construction from an invalid YAML::node that does not def invalidNodeMissingKey["n_omega"] = 1000; REQUIRE_THROWS_AS(Config(invalidNodeMissingKey), MissingKeyException); + // omega_range missing invalidNodeMissingKey.reset(); invalidNodeMissingKey["n_k_points"] = 50; invalidNodeMissingKey["n_occupied_total"] = 13; @@ -173,6 +187,7 @@ TEST_CASE("Test Config construction from an invalid YAML::node that does not def invalidNodeMissingKey["n_omega"] = 1000; REQUIRE_THROWS_AS(Config(invalidNodeMissingKey), MissingKeyException); + // n_omega missing invalidNodeMissingKey.reset(); invalidNodeMissingKey["n_k_points"] = 50; invalidNodeMissingKey["n_occupied_total"] = 13; @@ -186,8 +201,12 @@ TEST_CASE("Test Config construction from an invalid YAML::node that does not def REQUIRE_THROWS_AS(Config(invalidNodeMissingKey), MissingKeyException); } -TEST_CASE("Test Config construction from an invalid YAML::node that defines a parameter wrongly.", "[invalid-config]") { +TEST_CASE("Test Config construction from an invalid YAML::node that defines a parameter illegally.", "[invalid-config]") { + // Assign character string to integer parameter YAML::Node invalidNodeInvalidConfiguration; + invalidNodeInvalidConfiguration["n_k_points"] = 50; + invalidNodeInvalidConfiguration["n_occupied_total"] = 13; + invalidNodeInvalidConfiguration["n_unoccupied_total"] = 37; invalidNodeInvalidConfiguration["n_isdf_vexc"] = "asf"; invalidNodeInvalidConfiguration["n_isdf_wscr_occupied"] = 3; invalidNodeInvalidConfiguration["n_isdf_wscr_unoccupied"] = 4; @@ -197,13 +216,321 @@ TEST_CASE("Test Config construction from an invalid YAML::node that defines a pa invalidNodeInvalidConfiguration["n_omega"] = 1000; REQUIRE_THROWS_AS(Config(invalidNodeInvalidConfiguration), InvalidConfigurationException); + // Assign character string to real parameter invalidNodeInvalidConfiguration.reset(); + invalidNodeInvalidConfiguration["n_k_points"] = 50; + invalidNodeInvalidConfiguration["n_occupied_total"] = 13; + invalidNodeInvalidConfiguration["n_unoccupied_total"] = 37; invalidNodeInvalidConfiguration["n_isdf_vexc"] = 1; - invalidNodeInvalidConfiguration["n_isdf_wscr_occupied"] = 3; + invalidNodeInvalidConfiguration["n_isdf_wscr_occupied"] = "3"; invalidNodeInvalidConfiguration["n_isdf_wscr_unoccupied"] = 4; - invalidNodeInvalidConfiguration["max_lanczos_iterations"] = "asd"; + invalidNodeInvalidConfiguration["max_lanczos_iterations"] = 12; invalidNodeInvalidConfiguration["omega_range"].push_back(1.0); invalidNodeInvalidConfiguration["omega_range"].push_back("2.0"); invalidNodeInvalidConfiguration["n_omega"] = 1000; + invalidNodeInvalidConfiguration["cvt_convergence_criterium"] = "abc"; + REQUIRE_THROWS_AS(Config(invalidNodeInvalidConfiguration), InvalidConfigurationException); + + // Assign invalid string for seed + invalidNodeInvalidConfiguration.reset(); + invalidNodeInvalidConfiguration["n_k_points"] = 50; + invalidNodeInvalidConfiguration["n_occupied_total"] = 13; + invalidNodeInvalidConfiguration["n_unoccupied_total"] = 37; + invalidNodeInvalidConfiguration["n_isdf_vexc"] = 1; + invalidNodeInvalidConfiguration["n_isdf_wscr_occupied"] = 3; + invalidNodeInvalidConfiguration["n_isdf_wscr_unoccupied"] = 4; + invalidNodeInvalidConfiguration["max_lanczos_iterations"] = 20; + invalidNodeInvalidConfiguration["omega_range"].push_back(1.0); + invalidNodeInvalidConfiguration["omega_range"].push_back(2.0); + invalidNodeInvalidConfiguration["n_omega"] = 1000; + invalidNodeInvalidConfiguration["seed_source"] = "nope"; + REQUIRE_THROWS_AS(Config(invalidNodeInvalidConfiguration), InvalidConfigurationException); + + + // Assign only one value to omega_range + invalidNodeInvalidConfiguration.reset(); + invalidNodeInvalidConfiguration["n_k_points"] = 50; + invalidNodeInvalidConfiguration["n_occupied_total"] = 13; + invalidNodeInvalidConfiguration["n_unoccupied_total"] = 37; + invalidNodeInvalidConfiguration["n_isdf_vexc"] = 1; + invalidNodeInvalidConfiguration["n_isdf_wscr_occupied"] = 3; + invalidNodeInvalidConfiguration["n_isdf_wscr_unoccupied"] = 4; + invalidNodeInvalidConfiguration["max_lanczos_iterations"] = 20; + invalidNodeInvalidConfiguration["omega_range"] = 1.0; + invalidNodeInvalidConfiguration["n_omega"] = 1000; + invalidNodeInvalidConfiguration["seed_source"] = "fixed"; REQUIRE_THROWS_AS(Config(invalidNodeInvalidConfiguration), InvalidConfigurationException); } + +TEST_CASE("Test Config construction from an invalid YAML::node that defines a parameter wrongly.", "[invalid-config]") { + + // Check n_k_points rule + YAML::Node invalidNodeInvalidConfiguration; + invalidNodeInvalidConfiguration["n_k_points"] = 0; + invalidNodeInvalidConfiguration["n_occupied_total"] = 13; + invalidNodeInvalidConfiguration["n_unoccupied_total"] = 37; + invalidNodeInvalidConfiguration["n_isdf_vexc"] = 1; + invalidNodeInvalidConfiguration["n_isdf_wscr_occupied"] = 3; + invalidNodeInvalidConfiguration["n_isdf_wscr_unoccupied"] = 4; + invalidNodeInvalidConfiguration["max_lanczos_iterations"] = 20; + invalidNodeInvalidConfiguration["omega_range"].push_back(1.0); + invalidNodeInvalidConfiguration["omega_range"].push_back(2.0); + invalidNodeInvalidConfiguration["n_omega"] = 1000; + invalidNodeInvalidConfiguration["max_cvt_iterations"] = 333; + invalidNodeInvalidConfiguration["cvt_convergence_criterium"] = 1e-6; + invalidNodeInvalidConfiguration["seed_source"] = "fixed"; + REQUIRE_THROWS_AS(Config(invalidNodeInvalidConfiguration).validate(), InvalidConfigurationException); + + // Check n_occupied_total rule + invalidNodeInvalidConfiguration.reset(); + invalidNodeInvalidConfiguration["n_k_points"] = 50; + invalidNodeInvalidConfiguration["n_occupied_total"] = 0; + invalidNodeInvalidConfiguration["n_unoccupied_total"] = 37; + invalidNodeInvalidConfiguration["n_isdf_vexc"] = 1; + invalidNodeInvalidConfiguration["n_isdf_wscr_occupied"] = 3; + invalidNodeInvalidConfiguration["n_isdf_wscr_unoccupied"] = 4; + invalidNodeInvalidConfiguration["max_lanczos_iterations"] = 20; + invalidNodeInvalidConfiguration["omega_range"].push_back(1.0); + invalidNodeInvalidConfiguration["omega_range"].push_back(2.0); + invalidNodeInvalidConfiguration["n_omega"] = 1000; + invalidNodeInvalidConfiguration["max_cvt_iterations"] = 333; + invalidNodeInvalidConfiguration["cvt_convergence_criterium"] = 1e-6; + invalidNodeInvalidConfiguration["seed_source"] = "fixed"; + REQUIRE_THROWS_AS(Config(invalidNodeInvalidConfiguration).validate(), InvalidConfigurationException); + + // Check n_unoccupied_total rule + invalidNodeInvalidConfiguration.reset(); + invalidNodeInvalidConfiguration["n_k_points"] = 50; + invalidNodeInvalidConfiguration["n_occupied_total"] = 13; + invalidNodeInvalidConfiguration["n_unoccupied_total"] = 0; + invalidNodeInvalidConfiguration["n_isdf_vexc"] = 1; + invalidNodeInvalidConfiguration["n_isdf_wscr_occupied"] = 3; + invalidNodeInvalidConfiguration["n_isdf_wscr_unoccupied"] = 4; + invalidNodeInvalidConfiguration["max_lanczos_iterations"] = 20; + invalidNodeInvalidConfiguration["omega_range"].push_back(1.0); + invalidNodeInvalidConfiguration["omega_range"].push_back(2.0); + invalidNodeInvalidConfiguration["n_omega"] = 1000; + invalidNodeInvalidConfiguration["max_cvt_iterations"] = 333; + invalidNodeInvalidConfiguration["cvt_convergence_criterium"] = 1e-6; + invalidNodeInvalidConfiguration["seed_source"] = "fixed"; + REQUIRE_THROWS_AS(Config(invalidNodeInvalidConfiguration).validate(), InvalidConfigurationException); + + // Check n_occupied_total + n_unoccupied_total rule + invalidNodeInvalidConfiguration.reset(); + invalidNodeInvalidConfiguration["n_k_points"] = 50; + invalidNodeInvalidConfiguration["n_occupied_total"] = 13; + invalidNodeInvalidConfiguration["n_unoccupied_total"] = 38; + invalidNodeInvalidConfiguration["n_isdf_vexc"] = 1; + invalidNodeInvalidConfiguration["n_isdf_wscr_occupied"] = 3; + invalidNodeInvalidConfiguration["n_isdf_wscr_unoccupied"] = 4; + invalidNodeInvalidConfiguration["max_lanczos_iterations"] = 20; + invalidNodeInvalidConfiguration["omega_range"].push_back(1.0); + invalidNodeInvalidConfiguration["omega_range"].push_back(2.0); + invalidNodeInvalidConfiguration["n_omega"] = 1000; + invalidNodeInvalidConfiguration["max_cvt_iterations"] = 333; + invalidNodeInvalidConfiguration["cvt_convergence_criterium"] = 1e-6; + invalidNodeInvalidConfiguration["seed_source"] = "fixed"; + REQUIRE_THROWS_AS(Config(invalidNodeInvalidConfiguration).validate(), InvalidConfigurationException); + + // Checkn_isdf_vexc rules + invalidNodeInvalidConfiguration.reset(); + invalidNodeInvalidConfiguration["n_k_points"] = 50; + invalidNodeInvalidConfiguration["n_occupied_total"] = 13; + invalidNodeInvalidConfiguration["n_unoccupied_total"] = 37; + invalidNodeInvalidConfiguration["n_isdf_vexc"] = 0; + invalidNodeInvalidConfiguration["n_isdf_wscr_occupied"] = 3; + invalidNodeInvalidConfiguration["n_isdf_wscr_unoccupied"] = 4; + invalidNodeInvalidConfiguration["max_lanczos_iterations"] = 20; + invalidNodeInvalidConfiguration["omega_range"].push_back(1.0); + invalidNodeInvalidConfiguration["omega_range"].push_back(2.0); + invalidNodeInvalidConfiguration["n_omega"] = 1000; + invalidNodeInvalidConfiguration["max_cvt_iterations"] = 333; + invalidNodeInvalidConfiguration["cvt_convergence_criterium"] = 1e-6; + invalidNodeInvalidConfiguration["seed_source"] = "fixed"; + REQUIRE_THROWS_AS(Config(invalidNodeInvalidConfiguration).validate(), InvalidConfigurationException); + + invalidNodeInvalidConfiguration.reset(); + invalidNodeInvalidConfiguration["n_k_points"] = 50; + invalidNodeInvalidConfiguration["n_occupied_total"] = 13; + invalidNodeInvalidConfiguration["n_unoccupied_total"] = 37; + invalidNodeInvalidConfiguration["n_isdf_vexc"] = 10; + invalidNodeInvalidConfiguration["n_isdf_wscr_occupied"] = 3; + invalidNodeInvalidConfiguration["n_isdf_wscr_unoccupied"] = 4; + invalidNodeInvalidConfiguration["max_lanczos_iterations"] = 20; + invalidNodeInvalidConfiguration["omega_range"].push_back(1.0); + invalidNodeInvalidConfiguration["omega_range"].push_back(2.0); + invalidNodeInvalidConfiguration["n_omega"] = 1000; + invalidNodeInvalidConfiguration["max_cvt_iterations"] = 333; + invalidNodeInvalidConfiguration["cvt_convergence_criterium"] = 1e-6; + invalidNodeInvalidConfiguration["seed_source"] = "fixed"; + REQUIRE_THROWS_AS(Config(invalidNodeInvalidConfiguration).validate(), InvalidConfigurationException); + + // n_isdf_wscr_occupied rules + invalidNodeInvalidConfiguration.reset(); + invalidNodeInvalidConfiguration["n_k_points"] = 50; + invalidNodeInvalidConfiguration["n_occupied_total"] = 13; + invalidNodeInvalidConfiguration["n_unoccupied_total"] = 37; + invalidNodeInvalidConfiguration["n_isdf_vexc"] = 2; + invalidNodeInvalidConfiguration["n_isdf_wscr_occupied"] = 0; + invalidNodeInvalidConfiguration["n_isdf_wscr_unoccupied"] = 4; + invalidNodeInvalidConfiguration["max_lanczos_iterations"] = 20; + invalidNodeInvalidConfiguration["omega_range"].push_back(1.0); + invalidNodeInvalidConfiguration["omega_range"].push_back(2.0); + invalidNodeInvalidConfiguration["n_omega"] = 1000; + invalidNodeInvalidConfiguration["max_cvt_iterations"] = 333; + invalidNodeInvalidConfiguration["cvt_convergence_criterium"] = 1e-6; + invalidNodeInvalidConfiguration["seed_source"] = "fixed"; + REQUIRE_THROWS_AS(Config(invalidNodeInvalidConfiguration).validate(), InvalidConfigurationException); + + + invalidNodeInvalidConfiguration.reset(); + invalidNodeInvalidConfiguration["n_k_points"] = 50; + invalidNodeInvalidConfiguration["n_occupied_total"] = 13; + invalidNodeInvalidConfiguration["n_unoccupied_total"] = 37; + invalidNodeInvalidConfiguration["n_isdf_vexc"] = 2; + invalidNodeInvalidConfiguration["n_isdf_wscr_occupied"] = 170; + invalidNodeInvalidConfiguration["n_isdf_wscr_unoccupied"] = 0; + invalidNodeInvalidConfiguration["max_lanczos_iterations"] = 20; + invalidNodeInvalidConfiguration["omega_range"].push_back(1.0); + invalidNodeInvalidConfiguration["omega_range"].push_back(2.0); + invalidNodeInvalidConfiguration["n_omega"] = 1000; + invalidNodeInvalidConfiguration["max_cvt_iterations"] = 333; + invalidNodeInvalidConfiguration["cvt_convergence_criterium"] = 1e-6; + invalidNodeInvalidConfiguration["seed_source"] = "fixed"; + REQUIRE_THROWS_AS(Config(invalidNodeInvalidConfiguration).validate(), InvalidConfigurationException); + + // n_isdf_wscr_unoccupied rules + invalidNodeInvalidConfiguration.reset(); + invalidNodeInvalidConfiguration["n_k_points"] = 50; + invalidNodeInvalidConfiguration["n_occupied_total"] = 13; + invalidNodeInvalidConfiguration["n_unoccupied_total"] = 37; + invalidNodeInvalidConfiguration["n_isdf_vexc"] = 2; + invalidNodeInvalidConfiguration["n_isdf_wscr_occupied"] = 3; + invalidNodeInvalidConfiguration["n_isdf_wscr_unoccupied"] = 0; + invalidNodeInvalidConfiguration["max_lanczos_iterations"] = 20; + invalidNodeInvalidConfiguration["omega_range"].push_back(1.0); + invalidNodeInvalidConfiguration["omega_range"].push_back(2.0); + invalidNodeInvalidConfiguration["n_omega"] = 1000; + invalidNodeInvalidConfiguration["max_cvt_iterations"] = 333; + invalidNodeInvalidConfiguration["cvt_convergence_criterium"] = 1e-6; + invalidNodeInvalidConfiguration["seed_source"] = "fixed"; + REQUIRE_THROWS_AS(Config(invalidNodeInvalidConfiguration).validate(), InvalidConfigurationException); + + // max_lanczos_iterations rule + invalidNodeInvalidConfiguration.reset(); + invalidNodeInvalidConfiguration["n_k_points"] = 50; + invalidNodeInvalidConfiguration["n_occupied_total"] = 13; + invalidNodeInvalidConfiguration["n_unoccupied_total"] = 37; + invalidNodeInvalidConfiguration["n_isdf_vexc"] = 10; + invalidNodeInvalidConfiguration["n_isdf_wscr_occupied"] = 3; + invalidNodeInvalidConfiguration["n_isdf_wscr_unoccupied"] = 1407; + invalidNodeInvalidConfiguration["max_lanczos_iterations"] = 20; + invalidNodeInvalidConfiguration["omega_range"].push_back(1.0); + invalidNodeInvalidConfiguration["omega_range"].push_back(2.0); + invalidNodeInvalidConfiguration["n_omega"] = 1000; + invalidNodeInvalidConfiguration["max_cvt_iterations"] = 333; + invalidNodeInvalidConfiguration["cvt_convergence_criterium"] = 1e-6; + invalidNodeInvalidConfiguration["seed_source"] = "fixed"; + REQUIRE_THROWS_AS(Config(invalidNodeInvalidConfiguration).validate(), InvalidConfigurationException); + + invalidNodeInvalidConfiguration.reset(); + invalidNodeInvalidConfiguration["n_k_points"] = 50; + invalidNodeInvalidConfiguration["n_occupied_total"] = 13; + invalidNodeInvalidConfiguration["n_unoccupied_total"] = 37; + invalidNodeInvalidConfiguration["n_isdf_vexc"] = 10; + invalidNodeInvalidConfiguration["n_isdf_wscr_occupied"] = 3; + invalidNodeInvalidConfiguration["n_isdf_wscr_unoccupied"] = 4; + invalidNodeInvalidConfiguration["max_lanczos_iterations"] = 0; + invalidNodeInvalidConfiguration["omega_range"].push_back(1.0); + invalidNodeInvalidConfiguration["omega_range"].push_back(2.0); + invalidNodeInvalidConfiguration["n_omega"] = 1000; + invalidNodeInvalidConfiguration["max_cvt_iterations"] = 333; + invalidNodeInvalidConfiguration["cvt_convergence_criterium"] = 1e-6; + invalidNodeInvalidConfiguration["seed_source"] = "fixed"; + REQUIRE_THROWS_AS(Config(invalidNodeInvalidConfiguration).validate(), InvalidConfigurationException); + + // omega_range rules + invalidNodeInvalidConfiguration.reset(); + invalidNodeInvalidConfiguration["n_k_points"] = 50; + invalidNodeInvalidConfiguration["n_occupied_total"] = 13; + invalidNodeInvalidConfiguration["n_unoccupied_total"] = 37; + invalidNodeInvalidConfiguration["n_isdf_vexc"] = 10; + invalidNodeInvalidConfiguration["n_isdf_wscr_occupied"] = 3; + invalidNodeInvalidConfiguration["n_isdf_wscr_unoccupied"] = 4; + invalidNodeInvalidConfiguration["max_lanczos_iterations"] = 20; + invalidNodeInvalidConfiguration["omega_range"].push_back(2.0); + invalidNodeInvalidConfiguration["omega_range"].push_back(1.0); + invalidNodeInvalidConfiguration["n_omega"] = 1000; + invalidNodeInvalidConfiguration["max_cvt_iterations"] = 333; + invalidNodeInvalidConfiguration["cvt_convergence_criterium"] = 1e-6; + invalidNodeInvalidConfiguration["seed_source"] = "fixed"; + REQUIRE_THROWS_AS(Config(invalidNodeInvalidConfiguration).validate(), InvalidConfigurationException); + + invalidNodeInvalidConfiguration.reset(); + invalidNodeInvalidConfiguration["n_k_points"] = 50; + invalidNodeInvalidConfiguration["n_occupied_total"] = 13; + invalidNodeInvalidConfiguration["n_unoccupied_total"] = 37; + invalidNodeInvalidConfiguration["n_isdf_vexc"] = 10; + invalidNodeInvalidConfiguration["n_isdf_wscr_occupied"] = 3; + invalidNodeInvalidConfiguration["n_isdf_wscr_unoccupied"] = 4; + invalidNodeInvalidConfiguration["max_lanczos_iterations"] = 20; + invalidNodeInvalidConfiguration["omega_range"].push_back(2.0); + invalidNodeInvalidConfiguration["omega_range"].push_back(1.0); + invalidNodeInvalidConfiguration["omega_range"].push_back(3.0); + invalidNodeInvalidConfiguration["n_omega"] = 1000; + invalidNodeInvalidConfiguration["max_cvt_iterations"] = 333; + invalidNodeInvalidConfiguration["cvt_convergence_criterium"] = 1e-6; + invalidNodeInvalidConfiguration["seed_source"] = "fixed"; + REQUIRE_THROWS_AS(Config(invalidNodeInvalidConfiguration).validate(), InvalidConfigurationException); + + // n_omega rule + invalidNodeInvalidConfiguration.reset(); + invalidNodeInvalidConfiguration["n_k_points"] = 50; + invalidNodeInvalidConfiguration["n_occupied_total"] = 13; + invalidNodeInvalidConfiguration["n_unoccupied_total"] = 37; + invalidNodeInvalidConfiguration["n_isdf_vexc"] = 10; + invalidNodeInvalidConfiguration["n_isdf_wscr_occupied"] = 3; + invalidNodeInvalidConfiguration["n_isdf_wscr_unoccupied"] = 4; + invalidNodeInvalidConfiguration["max_lanczos_iterations"] = 20; + invalidNodeInvalidConfiguration["omega_range"].push_back(1.0); + invalidNodeInvalidConfiguration["omega_range"].push_back(2.0); + invalidNodeInvalidConfiguration["n_omega"] = 0; + invalidNodeInvalidConfiguration["max_cvt_iterations"] = 333; + invalidNodeInvalidConfiguration["cvt_convergence_criterium"] = 1e-6; + invalidNodeInvalidConfiguration["seed_source"] = "fixed"; + REQUIRE_THROWS_AS(Config(invalidNodeInvalidConfiguration).validate(), InvalidConfigurationException); + + // max_cvt_iterations rule + invalidNodeInvalidConfiguration.reset(); + invalidNodeInvalidConfiguration["n_k_points"] = 50; + invalidNodeInvalidConfiguration["n_occupied_total"] = 13; + invalidNodeInvalidConfiguration["n_unoccupied_total"] = 37; + invalidNodeInvalidConfiguration["n_isdf_vexc"] = 10; + invalidNodeInvalidConfiguration["n_isdf_wscr_occupied"] = 3; + invalidNodeInvalidConfiguration["n_isdf_wscr_unoccupied"] = 4; + invalidNodeInvalidConfiguration["max_lanczos_iterations"] = 20; + invalidNodeInvalidConfiguration["omega_range"].push_back(1.0); + invalidNodeInvalidConfiguration["omega_range"].push_back(2.0); + invalidNodeInvalidConfiguration["n_omega"] = 1000; + invalidNodeInvalidConfiguration["max_cvt_iterations"] = 0; + invalidNodeInvalidConfiguration["cvt_convergence_criterium"] = 1e-6; + invalidNodeInvalidConfiguration["seed_source"] = "fixed"; + REQUIRE_THROWS_AS(Config(invalidNodeInvalidConfiguration).validate(), InvalidConfigurationException); + + // cvt_convergence_criterium rule + invalidNodeInvalidConfiguration.reset(); + invalidNodeInvalidConfiguration["n_k_points"] = 50; + invalidNodeInvalidConfiguration["n_occupied_total"] = 13; + invalidNodeInvalidConfiguration["n_unoccupied_total"] = 37; + invalidNodeInvalidConfiguration["n_isdf_vexc"] = 10; + invalidNodeInvalidConfiguration["n_isdf_wscr_occupied"] = 3; + invalidNodeInvalidConfiguration["n_isdf_wscr_unoccupied"] = 4; + invalidNodeInvalidConfiguration["max_lanczos_iterations"] = 20; + invalidNodeInvalidConfiguration["omega_range"].push_back(1.0); + invalidNodeInvalidConfiguration["omega_range"].push_back(2.0); + invalidNodeInvalidConfiguration["n_omega"] = 1000; + invalidNodeInvalidConfiguration["max_cvt_iterations"] = 333; + invalidNodeInvalidConfiguration["cvt_convergence_criterium"] = 0; + invalidNodeInvalidConfiguration["seed_source"] = "fixed"; + REQUIRE_THROWS_AS(Config(invalidNodeInvalidConfiguration).validate(), InvalidConfigurationException); +}