From 1adcfb90ea1b87cbd831296d1991b9181a42d851 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20L=C3=BCbke?= Date: Tue, 3 Dec 2024 08:07:15 +0000 Subject: [PATCH] feat: integrate PhreeqcKnobs into PhreeqcMatrix; add getKnobs method and update Engine initialization --- poet/include/PhreeqcMatrix.hpp | 13 +++++++++++++ poet/src/Engine.cpp | 3 +++ poet/src/PhreeqcMatrix/Ctor.cpp | 5 +++++ 3 files changed, 21 insertions(+) diff --git a/poet/include/PhreeqcMatrix.hpp b/poet/include/PhreeqcMatrix.hpp index f87a138f..5b22b58c 100644 --- a/poet/include/PhreeqcMatrix.hpp +++ b/poet/include/PhreeqcMatrix.hpp @@ -7,6 +7,7 @@ #include #include "IPhreeqc.hpp" +#include "PhreeqcKnobs.hpp" /** * @brief Class for storing information from Phreeqc @@ -273,6 +274,16 @@ public: */ bool checkIfExists(int cell_id) const; + /** + * @brief Retrieves the current PhreeqcKnobs settings. + * + * This function returns a copy of the PhreeqcKnobs object that contains + * the current configuration settings for the Phreeqc instance. + * + * @return PhreeqcKnobs The current configuration settings. + */ + PhreeqcKnobs getKnobs() const { return *_m_knobs; } + private: std::map> _m_map; std::map> _m_internal_names; @@ -284,5 +295,7 @@ private: void remove_NaNs(); std::shared_ptr _m_pqc; + std::shared_ptr _m_knobs; + std::string _m_database; }; \ No newline at end of file diff --git a/poet/src/Engine.cpp b/poet/src/Engine.cpp index 22df7a0a..7ae88e1e 100644 --- a/poet/src/Engine.cpp +++ b/poet/src/Engine.cpp @@ -10,6 +10,7 @@ #include #include +#include "PhreeqcKnobs.hpp" #include "PhreeqcMatrix.hpp" #include "Wrapper/EquilibriumWrapper.hpp" #include "Wrapper/ExchangeWrapper.hpp" @@ -87,6 +88,8 @@ PhreeqcEngine::Impl::Impl(const PhreeqcMatrix &pqc_mat, const int cell_id) { this->LoadDatabaseString(pqc_mat.getDatabase().c_str()); + pqc_mat.getKnobs().writeKnobs(this->PhreeqcPtr); + const std::string pqc_string = replaceRawKeywordID(pqc_mat.getDumpStringsPQI(cell_id)); diff --git a/poet/src/PhreeqcMatrix/Ctor.cpp b/poet/src/PhreeqcMatrix/Ctor.cpp index efdec903..add2aed9 100644 --- a/poet/src/PhreeqcMatrix/Ctor.cpp +++ b/poet/src/PhreeqcMatrix/Ctor.cpp @@ -1,9 +1,11 @@ #include "IPhreeqc.hpp" +#include "PhreeqcKnobs.hpp" #include "PhreeqcMatrix.hpp" #include #include #include +#include #include PhreeqcMatrix::PhreeqcMatrix(const std::string &database, @@ -14,6 +16,9 @@ PhreeqcMatrix::PhreeqcMatrix(const std::string &database, this->_m_pqc->LoadDatabaseString(database.c_str()); this->_m_pqc->RunString(input_script.c_str()); + this->_m_knobs = + std::make_shared(this->_m_pqc.get()->GetPhreeqcPtr()); + this->initialize(); }