mirror of
https://git.gfz-potsdam.de/naaice/iphreeqc.git
synced 2025-12-16 16:44:49 +01:00
Compare commits
2 Commits
dcff790306
...
3ad62fc101
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3ad62fc101 | ||
|
|
7c2eed2d03 |
@ -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)
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
set(POET_SOURCE_FILES
|
set(LPQC_SOURCE_FILES
|
||||||
src/Engine.cpp
|
src/Engine.cpp
|
||||||
src/Runner.cpp
|
src/Runner.cpp
|
||||||
src/Knobs.cpp
|
src/Knobs.cpp
|
||||||
@ -20,19 +20,19 @@ set(POET_SOURCE_FILES
|
|||||||
src/PhreeqcMatrix/Misc.cpp
|
src/PhreeqcMatrix/Misc.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
add_library(IPhreeqcPOET ${POET_SOURCE_FILES})
|
add_library(litephreeqc ${LPQC_SOURCE_FILES})
|
||||||
target_link_libraries(IPhreeqcPOET PUBLIC IPhreeqc)
|
target_link_libraries(litephreeqc PUBLIC IPhreeqc)
|
||||||
target_include_directories(IPhreeqcPOET PUBLIC
|
target_include_directories(litephreeqc PUBLIC
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
$<INSTALL_INTERFACE:include>)
|
$<INSTALL_INTERFACE:include>)
|
||||||
|
|
||||||
# Set C++20 standard
|
# Set C++20 standard
|
||||||
target_compile_features(IPhreeqcPOET PUBLIC cxx_std_20)
|
target_compile_features(litephreeqc PUBLIC cxx_std_20)
|
||||||
|
|
||||||
if (BUILD_TESTING AND STANDALONE_BUILD)
|
if (BUILD_TESTING AND STANDALONE_BUILD)
|
||||||
enable_testing()
|
enable_testing()
|
||||||
|
|
||||||
set(POET_TEST_SOURCE_FILES
|
set(LPQC_TEST_SOURCE_FILES
|
||||||
test/testPhreeqcEngine.cpp
|
test/testPhreeqcEngine.cpp
|
||||||
test/testPhreeqcMatrix.cpp
|
test/testPhreeqcMatrix.cpp
|
||||||
test/testPhreeqcRunner.cpp
|
test/testPhreeqcRunner.cpp
|
||||||
@ -40,15 +40,15 @@ if (BUILD_TESTING AND STANDALONE_BUILD)
|
|||||||
test/utils.cpp
|
test/utils.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable(poet_test ${POET_TEST_SOURCE_FILES})
|
add_executable(litephreeqc_test ${LPQC_TEST_SOURCE_FILES})
|
||||||
|
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
poet_test
|
litephreeqc_test
|
||||||
IPhreeqcPOET
|
litephreeqc
|
||||||
GTest::gtest_main
|
GTest::gtest_main
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(poet_test PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
target_include_directories(litephreeqc_test PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
||||||
# read file and store in variable
|
# read file and store in variable
|
||||||
file(REAL_PATH "${PROJECT_SOURCE_DIR}/database/phreeqc.dat" POET_PHREEQCDAT_DB)
|
file(REAL_PATH "${PROJECT_SOURCE_DIR}/database/phreeqc.dat" POET_PHREEQCDAT_DB)
|
||||||
@ -58,8 +58,8 @@ if (BUILD_TESTING AND STANDALONE_BUILD)
|
|||||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/test/testInput.hpp.in" "${CMAKE_CURRENT_BINARY_DIR}/testInput.hpp")
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/test/testInput.hpp.in" "${CMAKE_CURRENT_BINARY_DIR}/testInput.hpp")
|
||||||
|
|
||||||
include(GoogleTest)
|
include(GoogleTest)
|
||||||
gtest_discover_tests(poet_test)
|
gtest_discover_tests(litephreeqc_test)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_executable(golemrunner test/testGolemRunner.cpp)
|
add_executable(golemrunner test/testGolemRunner.cpp)
|
||||||
target_link_libraries(golemrunner IPhreeqcPOET)
|
target_link_libraries(golemrunner litephreeqc)
|
||||||
10
litephreeqc/LICENSE.txt
Normal file
10
litephreeqc/LICENSE.txt
Normal 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
|
||||||
|
|
||||||
@ -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"
|
||||||
@ -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>
|
||||||
@ -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>
|
||||||
@ -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"
|
||||||
@ -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>
|
||||||
@ -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>
|
||||||
@ -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>
|
||||||
@ -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"
|
||||||
@ -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"
|
||||||
@ -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>
|
||||||
@ -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"
|
||||||
@ -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(
|
||||||
@ -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>
|
||||||
@ -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"
|
||||||
@ -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)
|
||||||
@ -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,
|
||||||
@ -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"
|
||||||
@ -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>
|
||||||
@ -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>
|
||||||
|
|
||||||
@ -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"
|
||||||
@ -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>
|
||||||
@ -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"
|
||||||
@ -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(
|
||||||
@ -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)
|
||||||
@ -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"
|
||||||
|
|
||||||
@ -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"
|
||||||
31
litephreeqc/src/Wrapper/WrapperBase.hpp
Normal file
31
litephreeqc/src/Wrapper/WrapperBase.hpp
Normal 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;
|
||||||
|
};
|
||||||
174
litephreeqc/test/testGolemRunner.cpp
Normal file
174
litephreeqc/test/testGolemRunner.cpp
Normal file
@ -0,0 +1,174 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Time-stamp: "Last modified 2024-12-02 17:37:08 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);
|
||||||
|
|
||||||
|
// 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";
|
||||||
|
|
||||||
|
// std::cout << exported_mat.names << "\n";
|
||||||
|
// std::cout << cell_values << "\n";
|
||||||
|
// END INIT
|
||||||
|
|
||||||
|
//// 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;
|
||||||
|
|
||||||
|
// grid cells
|
||||||
|
const std::size_t num_cells = 10;
|
||||||
|
const std::size_t half_cells = 5;
|
||||||
|
|
||||||
|
// copy the values to the InOut vector. We replicate cell 1
|
||||||
|
for (std::size_t index = 0; index < num_cells; ++index) {
|
||||||
|
if (index < half_cells) {
|
||||||
|
simulationInOut.push_back(std::vector<double>(
|
||||||
|
matrix_values.begin(), matrix_values.begin() + num_columns));
|
||||||
|
} else {
|
||||||
|
simulationInOut.push_back(std::vector<double>(
|
||||||
|
matrix_values.begin() + num_columns, matrix_values.end()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const double timestep = 100.;
|
||||||
|
|
||||||
|
// compute 1 timestep
|
||||||
|
runner.run(simulationInOut, timestep);
|
||||||
|
|
||||||
|
for (std::size_t cell_index = 0; cell_index < simulationInOut.size();
|
||||||
|
++cell_index) {
|
||||||
|
const bool is_first_half = cell_index < half_cells;
|
||||||
|
if (is_first_half) {
|
||||||
|
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
|
||||||
@ -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>
|
||||||
@ -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>
|
||||||
|
|
||||||
@ -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>
|
||||||
@ -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"
|
||||||
|
|
||||||
@ -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>
|
||||||
18
litephreeqc/test/utils.hpp
Normal file
18
litephreeqc/test/utils.hpp
Normal 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);
|
||||||
@ -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;
|
|
||||||
};
|
|
||||||
@ -1,161 +0,0 @@
|
|||||||
// Time-stamp: "Last modified 2024-12-02 17:37:08 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);
|
|
||||||
|
|
||||||
// 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";
|
|
||||||
|
|
||||||
// std::cout << exported_mat.names << "\n";
|
|
||||||
// std::cout << cell_values << "\n";
|
|
||||||
// END INIT
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//// 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;
|
|
||||||
|
|
||||||
// grid cells
|
|
||||||
const std::size_t num_cells = 10;
|
|
||||||
const std::size_t half_cells = 5;
|
|
||||||
|
|
||||||
// copy the values to the InOut vector. We replicate cell 1
|
|
||||||
for (std::size_t index = 0; index < num_cells; ++index) {
|
|
||||||
if (index < half_cells) {
|
|
||||||
simulationInOut.push_back(std::vector<double>(
|
|
||||||
matrix_values.begin(), matrix_values.begin() + num_columns));
|
|
||||||
} else {
|
|
||||||
simulationInOut.push_back(std::vector<double>(
|
|
||||||
matrix_values.begin() + num_columns, matrix_values.end()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const double timestep = 100.;
|
|
||||||
|
|
||||||
// compute 1 timestep
|
|
||||||
runner.run(simulationInOut, timestep);
|
|
||||||
|
|
||||||
for (std::size_t cell_index = 0; cell_index < simulationInOut.size(); ++cell_index) {
|
|
||||||
const bool is_first_half = cell_index < half_cells;
|
|
||||||
if (is_first_half) {
|
|
||||||
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
|
|
||||||
@ -1,5 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
std::string readFile(const std::string &path);
|
|
||||||
@ -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>
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user