MDL/golem: some cosmetic fixes

This commit is contained in:
Marco De Lucia 2025-07-28 20:16:08 +02:00
parent 6864285820
commit 22e1fae555
3 changed files with 22 additions and 40 deletions

View File

@ -343,7 +343,7 @@ public:
@return std::vector<std::string> vector of names
*/
std::vector<std::string> getMatrixMustTransport() const;
std::vector<std::string> getMatrixTransported() const;
/*

View File

@ -252,19 +252,19 @@ std::vector<std::string> PhreeqcMatrix::getMatrixKinetics() const {
for (auto nam : pqc_kinnames ) {
for (auto mat_name : this->get().names){
if (mat_name.starts_with(nam)) {
names.push_back(mat_name);
// check if we already have this mat_name
if (std::find(names.begin(), names.end(), mat_name) == names.end()) {
names.push_back(mat_name);
}
}
}
}
}
std::sort(names.begin(), names.end());
std::vector<std::string>::iterator it;
it = std::unique(names.begin(), names.end());
names.resize(std::distance(names.begin(),it) );
return names;
}
// MDL
std::vector<std::string> PhreeqcMatrix::getMatrixEquilibrium() const {
std::vector<std::string> names;
@ -275,6 +275,7 @@ std::vector<std::string> PhreeqcMatrix::getMatrixEquilibrium() const {
for (auto nam : pqc_eqnames ) {
for (auto mat_name : mat_names){
if (mat_name.starts_with(nam)) {
// check if we already have this mat_name
if (std::find(names.begin(), names.end(), mat_name) == names.end()) {
names.push_back(mat_name);
}
@ -282,14 +283,11 @@ std::vector<std::string> PhreeqcMatrix::getMatrixEquilibrium() const {
}
}
}
// std::sort(names.begin(), names.end());
// std::vector<std::string>::iterator it;
// it = std::unique(names.begin(), names.end());
// names.resize(std::distance(names.begin(),it) );
return names;
}
std::vector<std::string> PhreeqcMatrix::getMatrixMustTransport() const {
// MDL
std::vector<std::string> PhreeqcMatrix::getMatrixTransported() const {
std::vector<std::string> names;
const std::vector<std::string> to_remove = {
@ -307,6 +305,7 @@ std::vector<std::string> PhreeqcMatrix::getMatrixMustTransport() const {
return names;
}
// MDL
std::vector<std::string> PhreeqcMatrix::getMatrixOutOnly() const {
// MDL we must append here selected_output / user_punch
std::vector<std::string> defaultnames = {
@ -318,21 +317,3 @@ std::vector<std::string> PhreeqcMatrix::getMatrixOutOnly() const {
}
return ret;
}
// std::vector<std::string> PhreeqcMatrix::getTransported() const {
// std::vector<std::string> names;
// const auto &first_element = _m_map.begin()->second;
// for (const auto &element : _m_map.begin()->second) {
// // assuming the element vector always starts with the solution components
// if (element.type != PhreeqcComponent::SOLUTION) {
// break;
// }
// names.push_back(element.name);
// }
// return names;
// }

View File

@ -1,4 +1,4 @@
// Time-stamp: "Last modified 2025-07-28 19:54:57 delucia"
// Time-stamp: "Last modified 2025-07-28 20:14:08 delucia"
#include <iostream>
#include <iomanip>
#include <linux/limits.h>
@ -69,7 +69,6 @@ int main(int argc, char *argv[]) {
int n = ids.size();
std::cout << ":: Found " << n << " distinct PHREEQC problems \n";
std::cout << ids << "\n";
std::cout << ":: getSolutionsNames(): the common solutes across all problems: \n";
const auto solutes1 = pqc_mat1.getSolutionNames();
@ -77,24 +76,26 @@ int main(int argc, char *argv[]) {
// auto expmat = pqc_mat1.get();
auto allvars = pqc_mat1.get().names;
std::cout << ":: pqc_mat1.get().names: \n";
std::cout << allvars << "\n";
std::cout << ":: pqc_mat1.get().names (all names in the PhreeqcMatrix): \n";
std::cout << allvars << "\n\n";
std::cout << "\n-- Now the new getMatrix*() --\n\n";
auto transported = pqc_mat1.getMatrixTransported();
std::cout << ":: pqc_mat1.getMatrixTransported(): \n";
std::cout << transported << "\n\n";
auto MatNamesKin = pqc_mat1.getMatrixKinetics();
std::cout << ":: pqc_mat1.getMatrixKinetics(): \n";
std::cout << MatNamesKin << "\n";
std::cout << MatNamesKin << "\n\n";
auto MatNamesEqui = pqc_mat1.getMatrixEquilibrium();
std::cout << ":: pqc_mat1.getMatrixEquilibrium(): \n";
std::cout << MatNamesEqui << "\n";
auto transported = pqc_mat1.getMatrixMustTransport();
std::cout << ":: pqc_mat1.getMatrixMustTransport(): \n";
std::cout << transported << "\n";
std::cout << MatNamesEqui << "\n\n";
auto outonly = pqc_mat1.getMatrixOutOnly();
std::cout << ":: pqc_mat1.getMatrixOutOnly(): \n";
std::cout << outonly << "\n";
std::cout << outonly << "\n\n";
return 0;
}