chore: Add LICENSE.txt for poet directory

refactor: Rename 'poet' directory to 'litephreeqc'
This commit is contained in:
Max Lübke 2025-03-03 13:37:26 +01:00
parent 953c752431
commit 85762ad3f3
50 changed files with 647 additions and 192 deletions

View File

@ -220,7 +220,7 @@ target_sources(IPhreeqc
src/phreeqcpp/UserPunch.cpp src/phreeqcpp/UserPunch.cpp
src/phreeqcpp/UserPunch.h src/phreeqcpp/UserPunch.h
src/phreeqcpp/utilities.cpp src/phreeqcpp/utilities.cpp
src/phreeqcpp/GFZ.cpp src/phreeqcpp/litephreeqc_funcs.cpp
src/thread.h src/thread.h
src/Var.c src/Var.c
src/Var.h src/Var.h
@ -470,7 +470,7 @@ if (STANDALONE_BUILD)
endif() endif()
endif() endif()
add_subdirectory(poet) add_subdirectory(litephreeqc)
# get_cmake_property(_variableNames VARIABLES) # get_cmake_property(_variableNames VARIABLES)
# list (SORT _variableNames) # list (SORT _variableNames)

10
litephreeqc/LICENSE.txt Normal file
View File

@ -0,0 +1,10 @@
This project is subject to the original PHREEQC license. `litephreeqc` is a
version of the PHREEQC code that has been modified to be used as a library.
It adds a C++ interface on top of the original PHREEQC code, with small changes
to the original code base.
Authors of Modifications:
- Max Luebke (mluebke@uni-potsdam.de) - University of Potsdam
- Marco De Lucia (delucia@gfz.de) - GFZ Helmholz Centre for Geosciences

View File

@ -1,3 +1,16 @@
/*
* This project is subject to the original PHREEQC license. `litephreeqc` is a
* version of the PHREEQC code that has been modified to be used as a library.
*
* It adds a C++ interface on top of the original PHREEQC code, with small
* changes to the original code base.
*
* Authors of Modifications:
* - Max Luebke (mluebke@uni-potsdam.de) - University of Potsdam
* - Marco De Lucia (delucia@gfz.de) - GFZ Helmholz Centre for Geosciences
*
*/
#pragma once #pragma once
#include "PhreeqcMatrix.hpp" #include "PhreeqcMatrix.hpp"

View File

@ -1,3 +1,16 @@
/*
* This project is subject to the original PHREEQC license. `litephreeqc` is a
* version of the PHREEQC code that has been modified to be used as a library.
*
* It adds a C++ interface on top of the original PHREEQC code, with small
* changes to the original code base.
*
* Authors of Modifications:
* - Max Luebke (mluebke@uni-potsdam.de) - University of Potsdam
* - Marco De Lucia (delucia@gfz.de) - GFZ Helmholz Centre for Geosciences
*
*/
#pragma once #pragma once
#include <cstdint> #include <cstdint>

View File

@ -1,3 +1,16 @@
/*
* This project is subject to the original PHREEQC license. `litephreeqc` is a
* version of the PHREEQC code that has been modified to be used as a library.
*
* It adds a C++ interface on top of the original PHREEQC code, with small
* changes to the original code base.
*
* Authors of Modifications:
* - Max Luebke (mluebke@uni-potsdam.de) - University of Potsdam
* - Marco De Lucia (delucia@gfz.de) - GFZ Helmholz Centre for Geosciences
*
*/
#pragma once #pragma once
#include <map> #include <map>

View File

@ -1,3 +1,16 @@
/*
* This project is subject to the original PHREEQC license. `litephreeqc` is a
* version of the PHREEQC code that has been modified to be used as a library.
*
* It adds a C++ interface on top of the original PHREEQC code, with small
* changes to the original code base.
*
* Authors of Modifications:
* - Max Luebke (mluebke@uni-potsdam.de) - University of Potsdam
* - Marco De Lucia (delucia@gfz.de) - GFZ Helmholz Centre for Geosciences
*
*/
#pragma once #pragma once
#include "PhreeqcEngine.hpp" #include "PhreeqcEngine.hpp"

View File

@ -1,3 +1,16 @@
/*
* This project is subject to the original PHREEQC license. `litephreeqc` is a
* version of the PHREEQC code that has been modified to be used as a library.
*
* It adds a C++ interface on top of the original PHREEQC code, with small
* changes to the original code base.
*
* Authors of Modifications:
* - Max Luebke (mluebke@uni-potsdam.de) - University of Potsdam
* - Marco De Lucia (delucia@gfz.de) - GFZ Helmholz Centre for Geosciences
*
*/
#include "PhreeqcEngine.hpp" #include "PhreeqcEngine.hpp"
#include <cstddef> #include <cstddef>
#include <iomanip> #include <iomanip>

View File

@ -1,3 +1,16 @@
/*
* This project is subject to the original PHREEQC license. `litephreeqc` is a
* version of the PHREEQC code that has been modified to be used as a library.
*
* It adds a C++ interface on top of the original PHREEQC code, with small
* changes to the original code base.
*
* Authors of Modifications:
* - Max Luebke (mluebke@uni-potsdam.de) - University of Potsdam
* - Marco De Lucia (delucia@gfz.de) - GFZ Helmholz Centre for Geosciences
*
*/
#include "PhreeqcKnobs.hpp" #include "PhreeqcKnobs.hpp"
#include <Phreeqc.h> #include <Phreeqc.h>

View File

@ -1,3 +1,16 @@
/*
* This project is subject to the original PHREEQC license. `litephreeqc` is a
* version of the PHREEQC code that has been modified to be used as a library.
*
* It adds a C++ interface on top of the original PHREEQC code, with small
* changes to the original code base.
*
* Authors of Modifications:
* - Max Luebke (mluebke@uni-potsdam.de) - University of Potsdam
* - Marco De Lucia (delucia@gfz.de) - GFZ Helmholz Centre for Geosciences
*
*/
#include <PhreeqcMatrix.hpp> #include <PhreeqcMatrix.hpp>
#include <algorithm> #include <algorithm>
#include <cstddef> #include <cstddef>

View File

@ -1,3 +1,16 @@
/*
* This project is subject to the original PHREEQC license. `litephreeqc` is a
* version of the PHREEQC code that has been modified to be used as a library.
*
* It adds a C++ interface on top of the original PHREEQC code, with small
* changes to the original code base.
*
* Authors of Modifications:
* - Max Luebke (mluebke@uni-potsdam.de) - University of Potsdam
* - Marco De Lucia (delucia@gfz.de) - GFZ Helmholz Centre for Geosciences
*
*/
#include "IPhreeqc.hpp" #include "IPhreeqc.hpp"
#include "PhreeqcKnobs.hpp" #include "PhreeqcKnobs.hpp"
#include "PhreeqcMatrix.hpp" #include "PhreeqcMatrix.hpp"

View File

@ -1,3 +1,16 @@
/*
* This project is subject to the original PHREEQC license. `litephreeqc` is a
* version of the PHREEQC code that has been modified to be used as a library.
*
* It adds a C++ interface on top of the original PHREEQC code, with small
* changes to the original code base.
*
* Authors of Modifications:
* - Max Luebke (mluebke@uni-potsdam.de) - University of Potsdam
* - Marco De Lucia (delucia@gfz.de) - GFZ Helmholz Centre for Geosciences
*
*/
#include "PhreeqcMatrix.hpp" #include "PhreeqcMatrix.hpp"
#include "../Wrapper/EquilibriumWrapper.hpp" #include "../Wrapper/EquilibriumWrapper.hpp"

View File

@ -1,3 +1,16 @@
/*
* This project is subject to the original PHREEQC license. `litephreeqc` is a
* version of the PHREEQC code that has been modified to be used as a library.
*
* It adds a C++ interface on top of the original PHREEQC code, with small
* changes to the original code base.
*
* Authors of Modifications:
* - Max Luebke (mluebke@uni-potsdam.de) - University of Potsdam
* - Marco De Lucia (delucia@gfz.de) - GFZ Helmholz Centre for Geosciences
*
*/
#include "PhreeqcMatrix.hpp" #include "PhreeqcMatrix.hpp"
#include <IPhreeqc.hpp> #include <IPhreeqc.hpp>

View File

@ -1,3 +1,16 @@
/*
* This project is subject to the original PHREEQC license. `litephreeqc` is a
* version of the PHREEQC code that has been modified to be used as a library.
*
* It adds a C++ interface on top of the original PHREEQC code, with small
* changes to the original code base.
*
* Authors of Modifications:
* - Max Luebke (mluebke@uni-potsdam.de) - University of Potsdam
* - Marco De Lucia (delucia@gfz.de) - GFZ Helmholz Centre for Geosciences
*
*/
#include "PhreeqcEngine.hpp" #include "PhreeqcEngine.hpp"
#include "PhreeqcMatrix.hpp" #include "PhreeqcMatrix.hpp"
#include "PhreeqcRunner.hpp" #include "PhreeqcRunner.hpp"

View File

@ -1,3 +1,16 @@
/*
* This project is subject to the original PHREEQC license. `litephreeqc` is a
* version of the PHREEQC code that has been modified to be used as a library.
*
* It adds a C++ interface on top of the original PHREEQC code, with small
* changes to the original code base.
*
* Authors of Modifications:
* - Max Luebke (mluebke@uni-potsdam.de) - University of Potsdam
* - Marco De Lucia (delucia@gfz.de) - GFZ Helmholz Centre for Geosciences
*
*/
#include "EquilibriumWrapper.hpp" #include "EquilibriumWrapper.hpp"
EquilibriumWrapper::EquilibriumCompWrapper::EquilibriumCompWrapper( EquilibriumWrapper::EquilibriumCompWrapper::EquilibriumCompWrapper(

View File

@ -1,3 +1,16 @@
/*
* This project is subject to the original PHREEQC license. `litephreeqc` is a
* version of the PHREEQC code that has been modified to be used as a library.
*
* It adds a C++ interface on top of the original PHREEQC code, with small
* changes to the original code base.
*
* Authors of Modifications:
* - Max Luebke (mluebke@uni-potsdam.de) - University of Potsdam
* - Marco De Lucia (delucia@gfz.de) - GFZ Helmholz Centre for Geosciences
*
*/
#include "EquilibriumWrapper.hpp" #include "EquilibriumWrapper.hpp"
#include <algorithm> #include <algorithm>

View File

@ -1,3 +1,16 @@
/*
* This project is subject to the original PHREEQC license. `litephreeqc` is a
* version of the PHREEQC code that has been modified to be used as a library.
*
* It adds a C++ interface on top of the original PHREEQC code, with small
* changes to the original code base.
*
* Authors of Modifications:
* - Max Luebke (mluebke@uni-potsdam.de) - University of Potsdam
* - Marco De Lucia (delucia@gfz.de) - GFZ Helmholz Centre for Geosciences
*
*/
#pragma once #pragma once
#include "PPassemblage.h" #include "PPassemblage.h"

View File

@ -1,3 +1,16 @@
/*
* This project is subject to the original PHREEQC license. `litephreeqc` is a
* version of the PHREEQC code that has been modified to be used as a library.
*
* It adds a C++ interface on top of the original PHREEQC code, with small
* changes to the original code base.
*
* Authors of Modifications:
* - Max Luebke (mluebke@uni-potsdam.de) - University of Potsdam
* - Marco De Lucia (delucia@gfz.de) - GFZ Helmholz Centre for Geosciences
*
*/
#include "ExchangeWrapper.hpp" #include "ExchangeWrapper.hpp"
ExchangeWrapper::ExchangeCompWrapper::ExchangeCompWrapper(cxxExchComp &comp) ExchangeWrapper::ExchangeCompWrapper::ExchangeCompWrapper(cxxExchComp &comp)

View File

@ -1,3 +1,16 @@
/*
* This project is subject to the original PHREEQC license. `litephreeqc` is a
* version of the PHREEQC code that has been modified to be used as a library.
*
* It adds a C++ interface on top of the original PHREEQC code, with small
* changes to the original code base.
*
* Authors of Modifications:
* - Max Luebke (mluebke@uni-potsdam.de) - University of Potsdam
* - Marco De Lucia (delucia@gfz.de) - GFZ Helmholz Centre for Geosciences
*
*/
#include "ExchangeWrapper.hpp" #include "ExchangeWrapper.hpp"
ExchangeWrapper::ExchangeWrapper(cxxExchange *exch, ExchangeWrapper::ExchangeWrapper(cxxExchange *exch,
@ -21,36 +34,36 @@ ExchangeWrapper::ExchangeWrapper(cxxExchange *exch,
num_elements += exchange_comps.back()->size(); num_elements += exchange_comps.back()->size();
} }
// const std::size_t defined_comps = exchange->Get_exchange_comps().size(); // const std::size_t defined_comps = exchange->Get_exchange_comps().size();
// auto header_it = remaining_field_header.begin(); // auto header_it = remaining_field_header.begin();
// while (header_it != remaining_field_header.end() && // while (header_it != remaining_field_header.end() &&
// exchange_comps.size() < defined_comps) { // exchange_comps.size() < defined_comps) {
// const std::string formular = *header_it; // const std::string formular = *header_it;
// auto it = std::find_if(exchange->Get_exchange_comps().begin(), // auto it = std::find_if(exchange->Get_exchange_comps().begin(),
// exchange->Get_exchange_comps().end(), // exchange->Get_exchange_comps().end(),
// [&](const cxxExchComp &comp) { // [&](const cxxExchComp &comp) {
// return comp.Get_formula() == formular; // return comp.Get_formula() == formular;
// }); // });
// if (it != exchange->Get_exchange_comps().end()) { // if (it != exchange->Get_exchange_comps().end()) {
// const size_t i = this->exchange_comps.size(); // const size_t i = this->exchange_comps.size();
// exchange_comps.push_back(std::make_unique<ExchangeCompWrapper>(*it)); // exchange_comps.push_back(std::make_unique<ExchangeCompWrapper>(*it));
// header_it += this->exchange_comps[i]->size(); // header_it += this->exchange_comps[i]->size();
// num_elements += this->exchange_comps[i]->size(); // num_elements += this->exchange_comps[i]->size();
// continue; // continue;
// } // }
// header_it++; // header_it++;
// } // }
// if (exchange_comps.size() != defined_comps) { // if (exchange_comps.size() != defined_comps) {
// throw std::runtime_error( // throw std::runtime_error(
// "Not all exchange components found in Phreeqc variables"); // "Not all exchange components found in Phreeqc variables");
// } // }
} }
void ExchangeWrapper::get(std::span<LDBLE> &exchange) const { void ExchangeWrapper::get(std::span<LDBLE> &exchange) const {

View File

@ -1,3 +1,16 @@
/*
* This project is subject to the original PHREEQC license. `litephreeqc` is a
* version of the PHREEQC code that has been modified to be used as a library.
*
* It adds a C++ interface on top of the original PHREEQC code, with small
* changes to the original code base.
*
* Authors of Modifications:
* - Max Luebke (mluebke@uni-potsdam.de) - University of Potsdam
* - Marco De Lucia (delucia@gfz.de) - GFZ Helmholz Centre for Geosciences
*
*/
#pragma once #pragma once
#include "ExchComp.h" #include "ExchComp.h"

View File

@ -1,3 +1,16 @@
/*
* This project is subject to the original PHREEQC license. `litephreeqc` is a
* version of the PHREEQC code that has been modified to be used as a library.
*
* It adds a C++ interface on top of the original PHREEQC code, with small
* changes to the original code base.
*
* Authors of Modifications:
* - Max Luebke (mluebke@uni-potsdam.de) - University of Potsdam
* - Marco De Lucia (delucia@gfz.de) - GFZ Helmholz Centre for Geosciences
*
*/
#include "KineticWrapper.hpp" #include "KineticWrapper.hpp"
#include <cstddef> #include <cstddef>
#include <string> #include <string>

View File

@ -1,3 +1,16 @@
/*
* This project is subject to the original PHREEQC license. `litephreeqc` is a
* version of the PHREEQC code that has been modified to be used as a library.
*
* It adds a C++ interface on top of the original PHREEQC code, with small
* changes to the original code base.
*
* Authors of Modifications:
* - Max Luebke (mluebke@uni-potsdam.de) - University of Potsdam
* - Marco De Lucia (delucia@gfz.de) - GFZ Helmholz Centre for Geosciences
*
*/
#include "KineticWrapper.hpp" #include "KineticWrapper.hpp"
#include <vector> #include <vector>

View File

@ -1,3 +1,16 @@
/*
* This project is subject to the original PHREEQC license. `litephreeqc` is a
* version of the PHREEQC code that has been modified to be used as a library.
*
* It adds a C++ interface on top of the original PHREEQC code, with small
* changes to the original code base.
*
* Authors of Modifications:
* - Max Luebke (mluebke@uni-potsdam.de) - University of Potsdam
* - Marco De Lucia (delucia@gfz.de) - GFZ Helmholz Centre for Geosciences
*
*/
#pragma once #pragma once
#include "KineticsComp.h" #include "KineticsComp.h"

View File

@ -1,3 +1,16 @@
/*
* This project is subject to the original PHREEQC license. `litephreeqc` is a
* version of the PHREEQC code that has been modified to be used as a library.
*
* It adds a C++ interface on top of the original PHREEQC code, with small
* changes to the original code base.
*
* Authors of Modifications:
* - Max Luebke (mluebke@uni-potsdam.de) - University of Potsdam
* - Marco De Lucia (delucia@gfz.de) - GFZ Helmholz Centre for Geosciences
*
*/
#include "SolutionWrapper.hpp" #include "SolutionWrapper.hpp"
#include "NameDouble.h" #include "NameDouble.h"
#include <set> #include <set>

View File

@ -1,3 +1,16 @@
/*
* This project is subject to the original PHREEQC license. `litephreeqc` is a
* version of the PHREEQC code that has been modified to be used as a library.
*
* It adds a C++ interface on top of the original PHREEQC code, with small
* changes to the original code base.
*
* Authors of Modifications:
* - Max Luebke (mluebke@uni-potsdam.de) - University of Potsdam
* - Marco De Lucia (delucia@gfz.de) - GFZ Helmholz Centre for Geosciences
*
*/
#pragma once #pragma once
#include "Solution.h" #include "Solution.h"

View File

@ -1,3 +1,16 @@
/*
* This project is subject to the original PHREEQC license. `litephreeqc` is a
* version of the PHREEQC code that has been modified to be used as a library.
*
* It adds a C++ interface on top of the original PHREEQC code, with small
* changes to the original code base.
*
* Authors of Modifications:
* - Max Luebke (mluebke@uni-potsdam.de) - University of Potsdam
* - Marco De Lucia (delucia@gfz.de) - GFZ Helmholz Centre for Geosciences
*
*/
#include "SurfaceWrapper.hpp" #include "SurfaceWrapper.hpp"
SurfaceWrapper::SurfaceChargeWrapper::SurfaceChargeWrapper( SurfaceWrapper::SurfaceChargeWrapper::SurfaceChargeWrapper(

View File

@ -1,3 +1,16 @@
/*
* This project is subject to the original PHREEQC license. `litephreeqc` is a
* version of the PHREEQC code that has been modified to be used as a library.
*
* It adds a C++ interface on top of the original PHREEQC code, with small
* changes to the original code base.
*
* Authors of Modifications:
* - Max Luebke (mluebke@uni-potsdam.de) - University of Potsdam
* - Marco De Lucia (delucia@gfz.de) - GFZ Helmholz Centre for Geosciences
*
*/
#include "SurfaceWrapper.hpp" #include "SurfaceWrapper.hpp"
SurfaceWrapper::SurfaceCompWrapper::SurfaceCompWrapper(cxxSurfaceComp &comp) SurfaceWrapper::SurfaceCompWrapper::SurfaceCompWrapper(cxxSurfaceComp &comp)

View File

@ -1,3 +1,16 @@
/*
* This project is subject to the original PHREEQC license. `litephreeqc` is a
* version of the PHREEQC code that has been modified to be used as a library.
*
* It adds a C++ interface on top of the original PHREEQC code, with small
* changes to the original code base.
*
* Authors of Modifications:
* - Max Luebke (mluebke@uni-potsdam.de) - University of Potsdam
* - Marco De Lucia (delucia@gfz.de) - GFZ Helmholz Centre for Geosciences
*
*/
#include "SurfaceWrapper.hpp" #include "SurfaceWrapper.hpp"
#include "SurfaceComp.h" #include "SurfaceComp.h"

View File

@ -1,3 +1,16 @@
/*
* This project is subject to the original PHREEQC license. `litephreeqc` is a
* version of the PHREEQC code that has been modified to be used as a library.
*
* It adds a C++ interface on top of the original PHREEQC code, with small
* changes to the original code base.
*
* Authors of Modifications:
* - Max Luebke (mluebke@uni-potsdam.de) - University of Potsdam
* - Marco De Lucia (delucia@gfz.de) - GFZ Helmholz Centre for Geosciences
*
*/
#pragma once #pragma once
#include "Surface.h" #include "Surface.h"

View File

@ -0,0 +1,31 @@
/*
* This project is subject to the original PHREEQC license. `litephreeqc` is a
* version of the PHREEQC code that has been modified to be used as a library.
*
* It adds a C++ interface on top of the original PHREEQC code, with small
* changes to the original code base.
*
* Authors of Modifications:
* - Max Luebke (mluebke@uni-potsdam.de) - University of Potsdam
* - Marco De Lucia (delucia@gfz.de) - GFZ Helmholz Centre for Geosciences
*
*/
#pragma once
#include <phrqtype.h>
#include <span>
class WrapperBase {
public:
virtual ~WrapperBase() = default;
std::size_t size() const { return this->num_elements; };
virtual void get(std::span<LDBLE> &data) const = 0;
virtual void set(const std::span<LDBLE> &data) = 0;
protected:
std::size_t num_elements = 0;
};

View File

@ -0,0 +1,147 @@
// Time-stamp: "Last modified 2025-07-28 13:03:01 delucia"
#include <algorithm>
#include <cmath>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <linux/limits.h>
#include <memory>
#include <sstream>
#include <string>
#include <vector>
#include "PhreeqcEngine.hpp"
#include "PhreeqcMatrix.hpp"
#include "PhreeqcRunner.hpp"
std::string readFile(const std::string &path) {
std::string string_rpath(PATH_MAX, '\0');
if (realpath(path.c_str(), string_rpath.data()) == nullptr) {
throw std::runtime_error(":: Failed to resolve the realpath to file " +
path);
}
std::ifstream file(string_rpath);
if (!file.is_open()) {
throw std::runtime_error(":: Failed to open file: " + path);
}
std::stringstream buffer;
buffer << file.rdbuf();
return buffer.str();
}
// pretty print a vector, standard implementation from stackoverflow
template <typename T>
std::ostream &operator<<(std::ostream &os, std::vector<T> vec) {
os << "{ ";
std::copy(vec.begin(), vec.end(), std::ostream_iterator<T>(os, ", "));
os << " }";
return os;
}
int main(int argc, char *argv[]) {
if (argc < 3) {
std::cout << "::" << argv[0] << ": two args needed, script and database\n";
return 1;
}
////// INITIALISATION
// read Script and Database and put it in a std::string
auto script = readFile(argv[1]);
auto db = readFile(argv[2]);
// Create the matrix directly from database and init script
PhreeqcMatrix pqc_mat(db, script, true, true);
// How many different SOLUTIONS ("CELLS") are defined in the script?
const auto ids = pqc_mat.getIds();
int n = ids.size();
std::cout << ":: Found " << n << " distinct PHREEQC problems \n";
std::cout << ids << "\n";
const auto solutes = pqc_mat.getSolutionNames();
std::cout << ":: These are the common solutes across all the " << n
<< " problems: \n";
std::cout << solutes << "\n";
// iterate on the ids (THEY start at 1!!)
for (const auto &i : ids) {
auto pphases = pqc_mat.getEquilibriumNames(i);
if (!pphases.empty()) {
std::cout << ":: Equilibrium phases [" << (int)i << "]: \n";
std::cout << pphases << "\n";
}
auto kinetics = pqc_mat.getKineticsNames(i);
if (!kinetics.empty()) {
std::cout << ":: Kinetics [" << i << "]: \n";
std::cout << kinetics << "\n";
}
}
// The exported data type holds the matrix in a "STL format" with
// a "header" of names and their accompanying values. The values
// are stored in a row-major order per default.
auto exported_mat = pqc_mat.get();
// Get the total number of solutes
const int len = exported_mat.names.size();
// Get the values as reference to modify them in place
std::vector<double> &cell_values = exported_mat.values;
std::cout << ":: Values in the PhreeqcMatrix: \n";
//// Phreeqc RUN through the new Runner class
// optional SUBSET the matrix (i.e., the unique ids defined in
// golem map as input)
// const auto subsetted_pqc_mat = pqc_mat.subset({1, 2});
PhreeqcRunner runner(pqc_mat);
const auto stl_mat = pqc_mat.get();
const auto matrix_values = stl_mat.values;
const auto num_columns = stl_mat.names.size();
const auto spec_names = stl_mat.names;
// container to pass in/out
std::vector<std::vector<double>> simulationInOut;
// copy the values to the InOut vector. We replicate cell 1
for (std::size_t index = 0; index < n; ++index) {
simulationInOut.push_back(
std::vector<double>(matrix_values.begin() + num_columns * index,
matrix_values.begin() + num_columns * (index + 1)));
}
const double timestep = 100.;
// compute 1 timestep
runner.run(simulationInOut, timestep);
for (std::size_t cell_index = 0; cell_index < simulationInOut.size();
++cell_index) {
std::cout << "Grid element: " << cell_index << " \n";
for (std::size_t spec = 0; spec < num_columns; ++spec) {
std::cout << ":" << spec_names[spec] << "="
<< simulationInOut[cell_index][spec];
}
std::cout << "\n";
}
return 0;
}
// Oneliner for rz-vm278 relative to iphreeqc/poet/test!!
// g++ testGolemRunner.cpp -o testG -Wall -I../../poet/include -I../../src
// -I../../src/phreeqcpp -I../../src/phreeqcpp/common
// -I../../src/phreeqcpp/PhreeqcKeywords -lIPhreeqc -lIPhreeqcPOET
// -L../../bbuild/ -L../../bbuild/poet

View File

@ -1,3 +1,16 @@
/*
* This project is subject to the original PHREEQC license. `litephreeqc` is a
* version of the PHREEQC code that has been modified to be used as a library.
*
* It adds a C++ interface on top of the original PHREEQC code, with small
* changes to the original code base.
*
* Authors of Modifications:
* - Max Luebke (mluebke@uni-potsdam.de) - University of Potsdam
* - Marco De Lucia (delucia@gfz.de) - GFZ Helmholz Centre for Geosciences
*
*/
#include <stdexcept> #include <stdexcept>
#include <testInput.hpp> #include <testInput.hpp>

View File

@ -1,3 +1,16 @@
/*
* This project is subject to the original PHREEQC license. `litephreeqc` is a
* version of the PHREEQC code that has been modified to be used as a library.
*
* It adds a C++ interface on top of the original PHREEQC code, with small
* changes to the original code base.
*
* Authors of Modifications:
* - Max Luebke (mluebke@uni-potsdam.de) - University of Potsdam
* - Marco De Lucia (delucia@gfz.de) - GFZ Helmholz Centre for Geosciences
*
*/
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <testInput.hpp> #include <testInput.hpp>

View File

@ -1,3 +1,16 @@
/*
* This project is subject to the original PHREEQC license. `litephreeqc` is a
* version of the PHREEQC code that has been modified to be used as a library.
*
* It adds a C++ interface on top of the original PHREEQC code, with small
* changes to the original code base.
*
* Authors of Modifications:
* - Max Luebke (mluebke@uni-potsdam.de) - University of Potsdam
* - Marco De Lucia (delucia@gfz.de) - GFZ Helmholz Centre for Geosciences
*
*/
#include <cmath> #include <cmath>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <string> #include <string>

View File

@ -1,3 +1,16 @@
/*
* This project is subject to the original PHREEQC license. `litephreeqc` is a
* version of the PHREEQC code that has been modified to be used as a library.
*
* It adds a C++ interface on top of the original PHREEQC code, with small
* changes to the original code base.
*
* Authors of Modifications:
* - Max Luebke (mluebke@uni-potsdam.de) - University of Potsdam
* - Marco De Lucia (delucia@gfz.de) - GFZ Helmholz Centre for Geosciences
*
*/
#include "PhreeqcRunner.hpp" #include "PhreeqcRunner.hpp"
#include "utils.hpp" #include "utils.hpp"

View File

@ -1,3 +1,16 @@
/*
* This project is subject to the original PHREEQC license. `litephreeqc` is a
* version of the PHREEQC code that has been modified to be used as a library.
*
* It adds a C++ interface on top of the original PHREEQC code, with small
* changes to the original code base.
*
* Authors of Modifications:
* - Max Luebke (mluebke@uni-potsdam.de) - University of Potsdam
* - Marco De Lucia (delucia@gfz.de) - GFZ Helmholz Centre for Geosciences
*
*/
#include "utils.hpp" #include "utils.hpp"
#include <fstream> #include <fstream>

View File

@ -0,0 +1,18 @@
/*
* This project is subject to the original PHREEQC license. `litephreeqc` is a
* version of the PHREEQC code that has been modified to be used as a library.
*
* It adds a C++ interface on top of the original PHREEQC code, with small
* changes to the original code base.
*
* Authors of Modifications:
* - Max Luebke (mluebke@uni-potsdam.de) - University of Potsdam
* - Marco De Lucia (delucia@gfz.de) - GFZ Helmholz Centre for Geosciences
*
*/
#pragma once
#include <string>
std::string readFile(const std::string &path);

View File

@ -1,18 +0,0 @@
#pragma once
#include <phrqtype.h>
#include <span>
class WrapperBase {
public:
virtual ~WrapperBase() = default;
std::size_t size() const { return this->num_elements; };
virtual void get(std::span<LDBLE> &data) const = 0;
virtual void set(const std::span<LDBLE> &data) = 0;
protected:
std::size_t num_elements = 0;
};

View File

@ -1,144 +0,0 @@
// Time-stamp: "Last modified 2025-07-28 13:03:01 delucia"
#include <iostream>
#include <iomanip>
#include <linux/limits.h>
#include <sstream>
#include <fstream>
#include <algorithm>
#include <iterator>
#include <vector>
#include <string>
#include <memory>
#include <cmath>
#include "PhreeqcMatrix.hpp"
#include "PhreeqcEngine.hpp"
#include "PhreeqcRunner.hpp"
std::string readFile(const std::string &path) {
std::string string_rpath(PATH_MAX, '\0');
if (realpath(path.c_str(), string_rpath.data()) == nullptr) {
throw std::runtime_error(":: Failed to resolve the realpath to file " + path);
}
std::ifstream file(string_rpath);
if (!file.is_open()) {
throw std::runtime_error(":: Failed to open file: " + path);
}
std::stringstream buffer;
buffer << file.rdbuf();
return buffer.str();
}
// pretty print a vector, standard implementation from stackoverflow
template<typename T>
std::ostream & operator<<(std::ostream & os, std::vector<T> vec)
{
os << "{ ";
std::copy(vec.begin(), vec.end(), std::ostream_iterator<T>(os, ", "));
os << " }";
return os;
}
int main(int argc, char *argv[]) {
if (argc < 3) {
std::cout << "::" << argv[0] << ": two args needed, script and database\n";
return 1;
}
////// INITIALISATION
// read Script and Database and put it in a std::string
auto script = readFile(argv[1]);
auto db = readFile(argv[2]);
// Create the matrix directly from database and init script
PhreeqcMatrix pqc_mat(db, script, true, true);
// How many different SOLUTIONS ("CELLS") are defined in the script?
const auto ids = pqc_mat.getIds();
int n = ids.size();
std::cout << ":: Found " << n << " distinct PHREEQC problems \n";
std::cout << ids << "\n";
const auto solutes = pqc_mat.getSolutionNames();
std::cout << ":: These are the common solutes across all the " << n << " problems: \n";
std::cout << solutes << "\n";
// iterate on the ids (THEY start at 1!!)
for (const auto & i : ids) {
auto pphases = pqc_mat.getEquilibriumNames(i);
if (!pphases.empty()) {
std::cout << ":: Equilibrium phases [" << (int) i << "]: \n";
std::cout << pphases << "\n";
}
auto kinetics = pqc_mat.getKineticsNames(i);
if (!kinetics.empty()) {
std::cout << ":: Kinetics [" << i << "]: \n";
std::cout << kinetics << "\n";
}
}
// The exported data type holds the matrix in a "STL format" with
// a "header" of names and their accompanying values. The values
// are stored in a row-major order per default.
auto exported_mat = pqc_mat.get();
// Get the total number of solutes
const int len = exported_mat.names.size();
// Get the values as reference to modify them in place
std::vector<double> &cell_values = exported_mat.values;
std::cout << ":: Values in the PhreeqcMatrix: \n";
//// Phreeqc RUN through the new Runner class
// optional SUBSET the matrix (i.e., the unique ids defined in
// golem map as input)
// const auto subsetted_pqc_mat = pqc_mat.subset({1, 2});
PhreeqcRunner runner(pqc_mat);
const auto stl_mat = pqc_mat.get();
const auto matrix_values = stl_mat.values;
const auto num_columns = stl_mat.names.size();
const auto spec_names = stl_mat.names;
// container to pass in/out
std::vector<std::vector<double>> simulationInOut;
// copy the values to the InOut vector. We replicate cell 1
for (std::size_t index = 0; index < n; ++index) {
simulationInOut.push_back(std::vector<double>(
matrix_values.begin() + num_columns*index, matrix_values.begin() + num_columns*(index +1)));
}
const double timestep = 100.;
// compute 1 timestep
runner.run(simulationInOut, timestep);
for (std::size_t cell_index = 0; cell_index < simulationInOut.size(); ++cell_index) {
std::cout << "Grid element: " << cell_index << " \n";
for (std::size_t spec = 0; spec < num_columns; ++spec) {
std::cout << ":" << spec_names[spec] << "=" << simulationInOut[cell_index][spec];
}
std::cout << "\n";
}
return 0;
}
// Oneliner for rz-vm278 relative to iphreeqc/poet/test!!
// g++ testGolemRunner.cpp -o testG -Wall -I../../poet/include -I../../src -I../../src/phreeqcpp -I../../src/phreeqcpp/common -I../../src/phreeqcpp/PhreeqcKeywords -lIPhreeqc -lIPhreeqcPOET -L../../bbuild/ -L../../bbuild/poet

View File

@ -1,5 +0,0 @@
#pragma once
#include <string>
std::string readFile(const std::string &path);

View File

@ -1,3 +1,16 @@
/*
* This project is subject to the original PHREEQC license. `litephreeqc` is a
* version of the PHREEQC code that has been modified to be used as a library.
*
* It adds a C++ interface on top of the original PHREEQC code, with small
* changes to the original code base.
*
* Authors of Modifications:
* - Max Luebke (mluebke@uni-potsdam.de) - University of Potsdam
* - Marco De Lucia (delucia@gfz.de) - GFZ Helmholz Centre for Geosciences
*
*/
#include "Phreeqc.h" #include "Phreeqc.h"
#include <set> #include <set>