From ee8ede20a3df0c2488c86d5ab6dfea4feca81a44 Mon Sep 17 00:00:00 2001 From: Anton Kozhevnikov Date: Wed, 10 Jan 2024 08:32:15 +0100 Subject: [PATCH] [feature] control muffin-tin lapw radii from the main input file (#953) * [feature] control muffin-tin lapw radii from the main input file * apply format --- src/context/config.hpp | 6 ++++++ src/context/input_schema.json | 11 +++++++++++ src/context/simulation_parameters.cpp | 11 ++++++----- src/unit_cell/atom_type.cpp | 18 +++++++++++------- 4 files changed, 34 insertions(+), 12 deletions(-) diff --git a/src/context/config.hpp b/src/context/config.hpp index a3a45608c..9b8175579 100644 --- a/src/context/config.hpp +++ b/src/context/config.hpp @@ -399,6 +399,12 @@ class config_t nlohmann::json::json_pointer p("/unit_cell/atom_files"); return dict_.at(p / label__).get(); } + /// Mapping between atom type labels and muffin-tin radii (LAPW only) + inline auto atom_type_rmt(std::string label__) const + { + nlohmann::json::json_pointer p("/unit_cell/atom_type_rmt"); + return dict_.at(p / label__).get(); + } /// Atomic coordinates inline auto atoms(std::string label__) const { diff --git a/src/context/input_schema.json b/src/context/input_schema.json index b670199ac..5b583588e 100644 --- a/src/context/input_schema.json +++ b/src/context/input_schema.json @@ -224,6 +224,17 @@ }, "additionalProperties": false }, + "atom_type_rmt": { + "type": "object", + "title": "Mapping between atom type labels and muffin-tin radii (LAPW only)", + "default": {}, + "patternProperties": { + ".*": { + "type": "number" + } + }, + "additionalProperties": false + }, "atoms": { "type": "object", "title": "Atomic coordinates", diff --git a/src/context/simulation_parameters.cpp b/src/context/simulation_parameters.cpp index 4d06f5a38..b03178051 100644 --- a/src/context/simulation_parameters.cpp +++ b/src/context/simulation_parameters.cpp @@ -60,7 +60,7 @@ compose_default_json(nlohmann::json const& schema__, nlohmann::json& output__) if (it.value().contains("default")) { output__[key] = it.value()["default"]; } - } else { /* otherwise continue to traverse the shcema */ + } else { /* otherwise continue to traverse the schema */ if (!output__.contains(key)) { output__[key] = nlohmann::json{}; } @@ -98,12 +98,13 @@ compose_json(nlohmann::json const& schema__, nlohmann::json const& in__, nlohman /* copy the new input */ inout__[key] = in__[key]; } - } else { /* otherwise continue to traverse the shcema */ + } else { /* otherwise continue to traverse the schema */ + /* not simple data type : a section with parameter, a dictionary map, etc.*/ if (it.value().contains("properties")) { compose_json(it.value()["properties"], in__.contains(key) ? in__[key] : nlohmann::json{}, inout__[key]); } else if (in__.contains(key)) { inout__[key] = in__[key]; - } else { + } else if (!inout__.contains(key)) { inout__[key] = nlohmann::json(); } } @@ -136,7 +137,7 @@ nlohmann::json const& get_options_dictionary() { if (input_schema.size() == 0) { - throw std::runtime_error("Dictionary not initialized\n"); + RTE_THROW("Dictionary not initialized"); } return input_schema; } @@ -146,7 +147,7 @@ nlohmann::json const& get_section_options(std::string const& section__) { if (input_schema.size() == 0) { - throw std::runtime_error("Dictionary not initialized\n"); + RTE_THROW("Dictionary not initialized"); } return input_schema["properties"][section__]["properties"]; } diff --git a/src/unit_cell/atom_type.cpp b/src/unit_cell/atom_type.cpp index 5388ce606..f3288f575 100644 --- a/src/unit_cell/atom_type.cpp +++ b/src/unit_cell/atom_type.cpp @@ -143,7 +143,6 @@ Atom_type::init() if (!parameters_.full_potential()) { RTE_ASSERT(mt_radial_basis_size() == num_beta_radial_functions()); - // RTE_ASSERT(lmax_beta() == indexr1().lmax()); } /* get number of valence electrons */ @@ -719,12 +718,17 @@ Atom_type::read_input(std::string const& str__) } if (parameters_.full_potential()) { - name_ = parser["name"].get(); - symbol_ = parser["symbol"].get(); - mass_ = parser["mass"].get(); - zn_ = parser["number"].get(); - double r0 = parser["rmin"].get(); - double R = parser["rmt"].get(); + name_ = parser["name"].get(); + symbol_ = parser["symbol"].get(); + mass_ = parser["mass"].get(); + zn_ = parser["number"].get(); + double r0 = parser["rmin"].get(); + double R = parser["rmt"].get(); + try { /* overwrite the muffin-tin radius with the value from the inpupt */ + R = parameters_.cfg().unit_cell().atom_type_rmt(label_); + } catch (...) { + } + int nmtp = parser["nrmt"].get(); this->lmax_apw_ = parser.value("lmax_apw", this->lmax_apw_);