feat: integrate PhreeqcKnobs into PhreeqcMatrix; add getKnobs method and update Engine initialization

This commit is contained in:
Max Lübke 2024-12-03 08:07:15 +00:00
parent 863fb146c8
commit d19d0bc695
3 changed files with 21 additions and 0 deletions

View File

@ -7,6 +7,7 @@
#include <vector> #include <vector>
#include "IPhreeqc.hpp" #include "IPhreeqc.hpp"
#include "PhreeqcKnobs.hpp"
/** /**
* @brief Class for storing information from Phreeqc * @brief Class for storing information from Phreeqc
@ -273,6 +274,16 @@ public:
*/ */
bool checkIfExists(int cell_id) const; 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: private:
std::map<int, std::vector<element>> _m_map; std::map<int, std::vector<element>> _m_map;
std::map<int, std::vector<base_names>> _m_internal_names; std::map<int, std::vector<base_names>> _m_internal_names;
@ -284,5 +295,7 @@ private:
void remove_NaNs(); void remove_NaNs();
std::shared_ptr<IPhreeqc> _m_pqc; std::shared_ptr<IPhreeqc> _m_pqc;
std::shared_ptr<PhreeqcKnobs> _m_knobs;
std::string _m_database; std::string _m_database;
}; };

View File

@ -10,6 +10,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "PhreeqcKnobs.hpp"
#include "PhreeqcMatrix.hpp" #include "PhreeqcMatrix.hpp"
#include "Wrapper/EquilibriumWrapper.hpp" #include "Wrapper/EquilibriumWrapper.hpp"
#include "Wrapper/ExchangeWrapper.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()); this->LoadDatabaseString(pqc_mat.getDatabase().c_str());
pqc_mat.getKnobs().writeKnobs(this->PhreeqcPtr);
const std::string pqc_string = const std::string pqc_string =
replaceRawKeywordID(pqc_mat.getDumpStringsPQI(cell_id)); replaceRawKeywordID(pqc_mat.getDumpStringsPQI(cell_id));

View File

@ -1,9 +1,11 @@
#include "IPhreeqc.hpp" #include "IPhreeqc.hpp"
#include "PhreeqcKnobs.hpp"
#include "PhreeqcMatrix.hpp" #include "PhreeqcMatrix.hpp"
#include <Phreeqc.h> #include <Phreeqc.h>
#include <Solution.h> #include <Solution.h>
#include <cmath> #include <cmath>
#include <memory>
#include <string> #include <string>
PhreeqcMatrix::PhreeqcMatrix(const std::string &database, 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->LoadDatabaseString(database.c_str());
this->_m_pqc->RunString(input_script.c_str()); this->_m_pqc->RunString(input_script.c_str());
this->_m_knobs =
std::make_shared<PhreeqcKnobs>(this->_m_pqc.get()->GetPhreeqcPtr());
this->initialize(); this->initialize();
} }