mirror of
https://git.gfz-potsdam.de/naaice/iphreeqc.git
synced 2025-12-15 16:18:22 +01:00
chore: remove unused app directory
This commit is contained in:
parent
054c1cb72e
commit
62a8f687a1
@ -471,7 +471,6 @@ if (STANDALONE_BUILD)
|
||||
endif()
|
||||
|
||||
add_subdirectory(poet)
|
||||
# add_subdirectory(app)
|
||||
|
||||
# get_cmake_property(_variableNames VARIABLES)
|
||||
# list (SORT _variableNames)
|
||||
|
||||
@ -1,25 +0,0 @@
|
||||
## Time-stamp: "Last modified 2024-08-26 17:42:18 delucia"
|
||||
|
||||
add_executable(ipqMain
|
||||
ipqMain.cpp
|
||||
)
|
||||
add_executable(ipqEngine
|
||||
ipqEngine.cpp
|
||||
)
|
||||
|
||||
# add_library(IPhreeqcPOET ${PQC_POET_SRC})
|
||||
##target_link_libraries(IPhreeqcPOET PUBLIC IPhreeqc)
|
||||
|
||||
target_include_directories(IPhreeqcPOET PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
$<INSTALL_INTERFACE:include>
|
||||
PRIVATE src)
|
||||
|
||||
|
||||
target_link_libraries(ipqMain
|
||||
IPhreeqcPOET
|
||||
)
|
||||
|
||||
target_link_libraries(ipqEngine
|
||||
IPhreeqcPOET
|
||||
)
|
||||
@ -1,140 +0,0 @@
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <cstdio>
|
||||
#include <iomanip>
|
||||
#include <linux/limits.h>
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
#include <unistd.h>
|
||||
#include <vector>
|
||||
#include <wordexp.h>
|
||||
|
||||
#include "POETInit.hpp"
|
||||
#include "PhreeqcEngine.hpp"
|
||||
#include "PhreeqcInit.hpp"
|
||||
|
||||
|
||||
static 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();
|
||||
}
|
||||
|
||||
void printVectorsAsTable(const std::vector<std::string> &names,
|
||||
const std::vector<double> &values) {
|
||||
if (names.size() != values.size()) {
|
||||
std::cerr << "Error: Vectors are not of the same length." << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
std::cout << std::left << std::setw(20) << "Array Index" << std::setw(20)
|
||||
<< "Name" << std::setw(20) << "Value" << std::endl;
|
||||
std::cout << std::string(40, '-') << std::endl;
|
||||
|
||||
for (std::size_t i = 0; i < names.size(); ++i) {
|
||||
std::cout << std::left << std::setw(20) << std::to_string(i)
|
||||
<< std::setw(20) << names[i] << std::setw(20) << values[i]
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
template <class T> void printVector(const std::vector<T> &vec) {
|
||||
for (const auto &elem : vec) {
|
||||
std::cout << elem << " ";
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static std::string TestInput = R"(SOLUTION 1
|
||||
units mol/kgw
|
||||
temp 25
|
||||
Ca 0.1
|
||||
Mg 0.1
|
||||
Cl 0.5 charge
|
||||
Na 0.1
|
||||
PURE 1
|
||||
Calcite 0.0 1
|
||||
Dolomite 0.0 0
|
||||
## RUN_CELLS
|
||||
## -cells 1
|
||||
END)";
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
if (argc < 2) {
|
||||
std::cout << "PHREEQC database needed as argument" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
const std::string &database = argv[1];
|
||||
wordexp_t exp_result;
|
||||
|
||||
// std::cout << "Reading script from file " << script << " using database "
|
||||
// << database << std::endl;
|
||||
|
||||
// expand the script and database path
|
||||
// const std::string read_script = readFile(script);
|
||||
const std::string read_database = readFile(database);
|
||||
|
||||
// initialize the module instance "ipqcmod"
|
||||
PhreeqcInit ipqcmod(read_database, TestInput);
|
||||
|
||||
// allocate tabular data
|
||||
PhreeqcInit::PhreeqcMat pqc_mat = ipqcmod.getPhreeqcMat();
|
||||
|
||||
// for (std::size_t i = 0; i < nrows; ++i) {
|
||||
auto pure_names = ipqcmod.getEquilibriumNames(pqc_mat.ids[0]);
|
||||
auto totals_names = ipqcmod.getSolutionNames(pqc_mat.ids[0]);
|
||||
|
||||
POETConfig MyConfig;
|
||||
MyConfig.database = read_database;
|
||||
MyConfig.input_script = TestInput;
|
||||
MyConfig.cell = POETInitCell{
|
||||
// H, O and charge need to be removed. I'm not sure why I did it this way.
|
||||
std::vector<std::string>(totals_names.begin() + 3, totals_names.end()),
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
pure_names,
|
||||
{},
|
||||
{}};
|
||||
|
||||
std::vector<std::string> full_names = {"ID"};
|
||||
full_names.insert(full_names.end(), pqc_mat.names.begin(),
|
||||
pqc_mat.names.end());
|
||||
|
||||
PhreeqcEngine MyEngine(MyConfig);
|
||||
std::vector<double> NewInp = pqc_mat.values[0];
|
||||
NewInp.insert(NewInp.begin(), 1);
|
||||
|
||||
std::cout << "Before running the cell:\n";
|
||||
printVectorsAsTable(full_names, NewInp);
|
||||
|
||||
// std::for_each(NewInp.begin()+3, NewInp.end(),
|
||||
// [](double a) { return a * 0.8;});
|
||||
|
||||
NewInp[5] += 0.2; // Cl
|
||||
NewInp[7] += 0.2; // Na
|
||||
MyEngine.runCell(NewInp, 200);
|
||||
|
||||
std::cout << "\n\nAfter running the cell:\n";
|
||||
printVectorsAsTable(full_names, NewInp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1,92 +0,0 @@
|
||||
// Time-stamp: "Last modified 2024-08-27 09:00:18 delucia"
|
||||
#include <cstddef>
|
||||
#include <linux/limits.h>
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
#include <unistd.h>
|
||||
#include <vector>
|
||||
#include <wordexp.h>
|
||||
|
||||
#include "POETInit.hpp"
|
||||
#include "PhreeqcEngine.hpp"
|
||||
#include "PhreeqcInit.hpp"
|
||||
|
||||
static 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();
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
const std::string &script = argv[1];
|
||||
const std::string &database = argv[2];
|
||||
// wordexp_t exp_result;
|
||||
|
||||
std::cout << "Reading script from file " << script << " using database "
|
||||
<< database << std::endl;
|
||||
|
||||
// expand the script and database path
|
||||
const std::string read_script = readFile(script);
|
||||
const std::string read_database = readFile(database);
|
||||
|
||||
// initialize the module instance "ipqcmod"
|
||||
PhreeqcInit ipqcmod(read_database, read_script);
|
||||
|
||||
// allocate tabular data
|
||||
PhreeqcInit::PhreeqcMat pqc_mat = ipqcmod.getPhreeqcMat();
|
||||
|
||||
const std::size_t ncols = pqc_mat.names.size();
|
||||
const std::size_t nrows = pqc_mat.values.size();
|
||||
|
||||
std::cout << "Script contains " << nrows << " rows and " << ncols
|
||||
<< " columns" << std::endl;
|
||||
|
||||
// pqc_mat.names.insert(pqc_mat.names.begin(), "ID");
|
||||
|
||||
// Rcpp::NumericMatrix mat(nrows, ncols + 1);
|
||||
|
||||
std::cout << std::endl << "Number of CELLS/SOLUTIONS: " << nrows << std::endl;
|
||||
|
||||
for (std::size_t i = 0; i < nrows; ++i) {
|
||||
auto pure_names = ipqcmod.getEquilibriumNames(pqc_mat.ids[i]);
|
||||
auto totals_names = ipqcmod.getSolutionNames(pqc_mat.ids[i]);
|
||||
|
||||
std::cout << std::endl << "SOL " << pqc_mat.ids[i] << " - Pure phases : ";
|
||||
for (std::size_t j = 0; j < pure_names.size(); j++) {
|
||||
std::cout << pure_names[j] << ", ";
|
||||
}
|
||||
|
||||
std::cout << std::endl << "SOL " << pqc_mat.ids[i] << " - Total concs: ";
|
||||
for (std::size_t j = 0; j < totals_names.size(); j++) {
|
||||
std::cout << totals_names[j] << ", ";
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
// alternatively, use the pqc_mat object
|
||||
std::cout << std::endl << "Total pqc_mat: " << std::endl;
|
||||
for (std::size_t i = 0; i < nrows; ++i) {
|
||||
std::cout << "ID: " << pqc_mat.ids[i] << " - ";
|
||||
for (std::size_t j = 0; j < ncols; ++j) {
|
||||
std::cout << pqc_mat.names[j] << ": " << pqc_mat.values[i][j] << ", ";
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
std::cout << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
1853
app/phreeqc.dat
1853
app/phreeqc.dat
File diff suppressed because it is too large
Load Diff
@ -1,13 +0,0 @@
|
||||
SOLUTION 1
|
||||
units mol/kgw
|
||||
temp 25
|
||||
Ca 0.1
|
||||
Mg 0.1
|
||||
Cl 0.5 charge
|
||||
Na 0.1
|
||||
PURE 1
|
||||
Calcite 0.0 1
|
||||
Dolomite 0.0 0
|
||||
## RUN_CELLS
|
||||
## -cells 1
|
||||
END
|
||||
Loading…
x
Reference in New Issue
Block a user