Implementing mass_h2o into ESSENTIALS

This commit is contained in:
Marco De Lucia 2025-11-13 15:17:25 +01:00
parent 115fe2f272
commit 51162a4c1d
7 changed files with 13 additions and 10 deletions

View File

@ -41,7 +41,7 @@ endif()
# compile Var.c as c++
set_source_files_properties(src/Var.c PROPERTIES LANGUAGE CXX)
add_library(IPhreeqc STATIC src/IPhreeqc.cpp)
add_library(IPhreeqc src/IPhreeqc.cpp)
target_sources(IPhreeqc
PRIVATE

View File

@ -21,7 +21,8 @@ set(LPQC_SOURCE_FILES
src/PhreeqcMatrix/Misc.cpp
)
add_library(litephreeqc STATIC ${LPQC_SOURCE_FILES})
# add_library(litephreeqc STATIC ${LPQC_SOURCE_FILES})
add_library(litephreeqc ${LPQC_SOURCE_FILES})
target_link_libraries(litephreeqc PUBLIC IPhreeqc)
target_include_directories(litephreeqc PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>

View File

@ -304,7 +304,7 @@ std::vector<std::string> PhreeqcMatrix::getMatrixTransported() const {
std::vector<std::string> names;
const std::vector<std::string> to_remove = {
"tc", "patm", "SolVol", "pH", "pe"
"tc", "patm", "SolVol", "pH", "pe", "MassH2O"
};
// sols contains all solutes; we must remove { tc, patm, SolVol, pH, pe }
@ -322,7 +322,7 @@ std::vector<std::string> PhreeqcMatrix::getMatrixTransported() const {
std::vector<std::string> PhreeqcMatrix::getMatrixOutOnly() const {
// MDL we must append here selected_output / user_punch
std::vector<std::string> defaultnames = {
"tc", "patm", "SolVol", "pH", "pe"
"tc", "patm", "SolVol", "pH", "pe", "MassH2O"
};
std::vector<std::string> ret;
for (auto nm : defaultnames) {

View File

@ -36,6 +36,7 @@ void SolutionWrapper::get(std::span<LDBLE> &data) const {
data[5] = solution->Get_soln_vol();
data[6] = solution->Get_ph();
data[7] = solution->Get_pe();
data[8] = solution->Get_mass_water();
const cxxNameDouble &totals =
(_with_redox ? solution->Get_totals()
@ -61,6 +62,7 @@ void SolutionWrapper::set(const std::span<LDBLE> &data) {
const double &cb = data[2];
const double &tc = data[3];
const double &patm = data[4];
const double &massh2o = data[5];
for (const auto &tot_name : solution_order) {
const double value = data[i++];
@ -71,7 +73,7 @@ void SolutionWrapper::set(const std::span<LDBLE> &data) {
new_totals[tot_name] = value;
}
this->solution->Update(total_h, total_o, cb, tc, patm,
this->solution->Update(total_h, total_o, cb, tc, patm, massh2o,
_with_redox ? new_totals
: new_totals.Simplify_redox());
}

View File

@ -40,10 +40,10 @@ private:
cxxSolution *solution;
const std::vector<std::string> solution_order;
static constexpr std::array<const char *, 8> ESSENTIALS = {
static constexpr std::array<const char *, 9> ESSENTIALS = {
"H", "O", "Charge", "tc", "patm",
"SolVol", "pH", "pe"}; // MDL; ML: only output
"SolVol", "pH", "pe", "MassH2O"}; // MDL; ML: only output
static constexpr std::size_t NUM_ESSENTIALS = ESSENTIALS.size();

View File

@ -1070,7 +1070,7 @@ void cxxSolution::read_raw(CParser &parser, bool check) {
}
void cxxSolution::Update(LDBLE h_tot, LDBLE o_tot, LDBLE charge, LDBLE tc,
LDBLE patm, const cxxNameDouble &const_nd) {
LDBLE patm, LDBLE massh2o, const cxxNameDouble &const_nd) {
this->new_def = false;
this->patm = patm;
// this->potV = 0.0;
@ -1083,7 +1083,7 @@ void cxxSolution::Update(LDBLE h_tot, LDBLE o_tot, LDBLE charge, LDBLE tc,
this->total_h = h_tot;
this->total_o = o_tot;
this->cb = charge;
this->mass_water = o_tot / 55.55;
this->mass_water = massh2o; // o_tot / 55.55; MDL
// this->density = 1.0;
// this->viscosity = 1.0;

View File

@ -123,7 +123,7 @@ public:
// void modify_activities(const cxxSolution & original);
// void Simplify_totals();
void Update(const cxxNameDouble &nd);
void Update(LDBLE h_tot, LDBLE o_tot, LDBLE charge, LDBLE tc, LDBLE patm, const cxxNameDouble &nd);
void Update(LDBLE h_tot, LDBLE o_tot, LDBLE charge, LDBLE tc, LDBLE patm, LDBLE massh2o, const cxxNameDouble &nd);
void Update_activities(const cxxNameDouble &original_tot);
void Serialize(Dictionary &dictionary, std::vector<int> &ints,
std::vector<double> &doubles);