Merge branch 'ml/project-name' into 'main'

Change project name to `litephreeqc`

See merge request naaice/iphreeqc!32
This commit is contained in:
Max Lübke 2025-10-28 11:02:24 +01:00
commit cb44e26b69
51 changed files with 1177 additions and 850 deletions

View File

@ -1,296 +1,296 @@
name: CMake # name: CMake
#
on: # on:
push: # push:
#
pull_request: # pull_request:
branches: # branches:
- master # - master
#
schedule: # schedule:
- cron: '15 14 4,11,18,25 * *' # - cron: '15 14 4,11,18,25 * *'
#
workflow_dispatch: # workflow_dispatch:
#
env: # env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) # # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release # BUILD_TYPE: Release
NAME: IPhreeqc # NAME: IPhreeqc
#
jobs: # jobs:
#
init: # init:
runs-on: ubuntu-latest # runs-on: ubuntu-latest
# Map step outputs to job outputs # # Map step outputs to job outputs
outputs: # outputs:
VER: ${{ steps.vars.outputs.VER }} # VER: ${{ steps.vars.outputs.VER }}
REL: ${{ steps.vars.outputs.REL }} # REL: ${{ steps.vars.outputs.REL }}
DATE: ${{ steps.vars.outputs.DATE }} # DATE: ${{ steps.vars.outputs.DATE }}
DATE_RFC_3339: ${{ steps.vars.outputs.DATE_RFC_3339 }} # DATE_RFC_3339: ${{ steps.vars.outputs.DATE_RFC_3339 }}
steps: # steps:
- name: Setup vars # - name: Setup vars
id: vars # id: vars
run: | # run: |
echo VER=$(curl -sS https://raw.githubusercontent.com/usgs-coupled/phreeqc-version/main/next_ver.sh | sh) >> $GITHUB_OUTPUT # echo VER=$(curl -sS https://raw.githubusercontent.com/usgs-coupled/phreeqc-version/main/next_ver.sh | sh) >> $GITHUB_OUTPUT
echo REL=$(curl -sS https://raw.githubusercontent.com/usgs-coupled/phreeqc-version/main/rel.py | python3) >> $GITHUB_OUTPUT # echo REL=$(curl -sS https://raw.githubusercontent.com/usgs-coupled/phreeqc-version/main/rel.py | python3) >> $GITHUB_OUTPUT
echo DATE=$(date "+%x") >> $GITHUB_OUTPUT # echo DATE=$(date "+%x") >> $GITHUB_OUTPUT
echo DATE_RFC_3339=$(date --rfc-3339=date) >> $GITHUB_OUTPUT # echo DATE_RFC_3339=$(date --rfc-3339=date) >> $GITHUB_OUTPUT
#
#
test: # test:
strategy: # strategy:
fail-fast: false # fail-fast: false
matrix: # matrix:
os: [macos-latest, ubuntu-latest, windows-latest] # os: [macos-latest, ubuntu-latest, windows-latest]
#
runs-on: ${{ matrix.os }} # runs-on: ${{ matrix.os }}
env: # env:
BUILD_DIR: _ctest # set in ctest.cmake # BUILD_DIR: _ctest # set in ctest.cmake
#
steps: # steps:
- uses: actions/checkout@v4 # - uses: actions/checkout@v4
#
- name: Install ninja valgrind (Linux) # - name: Install ninja valgrind (Linux)
if: runner.os == 'Linux' # if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y ninja-build valgrind # run: sudo apt-get update && sudo apt-get install -y ninja-build valgrind
#
- name: Install ninja (macOS) # - name: Install ninja (macOS)
if: runner.os == 'macOS' # if: runner.os == 'macOS'
run: brew install ninja # run: brew install ninja
#
- name: Set up Visual Studio shell (Windows) # - name: Set up Visual Studio shell (Windows)
if: runner.os == 'Windows' # if: runner.os == 'Windows'
uses: egor-tensin/vs-shell@v2 # uses: egor-tensin/vs-shell@v2
with: # with:
arch: x64 # arch: x64
#
- name: CTest # - name: CTest
run: ctest -S ctest.cmake -V --output-on-failure --timeout 900 # run: ctest -S ctest.cmake -V --output-on-failure --timeout 900
#
- name: Upload results # - name: Upload results
uses: actions/upload-artifact@v4 # uses: actions/upload-artifact@v4
with: # with:
name: ${{ matrix.os }}-${{ github.job }}-results # name: ${{ matrix.os }}-${{ github.job }}-results
path: ${{ github.workspace }}/${{ env.BUILD_DIR }}/Testing/ # path: ${{ github.workspace }}/${{ env.BUILD_DIR }}/Testing/
#
test-shared: # test-shared:
strategy: # strategy:
fail-fast: false # fail-fast: false
matrix: # matrix:
os: [macos-latest, ubuntu-latest, windows-latest] # os: [macos-latest, ubuntu-latest, windows-latest]
#
runs-on: ${{ matrix.os }} # runs-on: ${{ matrix.os }}
env: # env:
BUILD_DIR: _ctest_shared # set in ctest-shared.cmake # BUILD_DIR: _ctest_shared # set in ctest-shared.cmake
#
steps: # steps:
- uses: actions/checkout@v4 # - uses: actions/checkout@v4
#
- name: Install ninja valgrind (Linux) # - name: Install ninja valgrind (Linux)
if: runner.os == 'Linux' # if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y ninja-build valgrind # run: sudo apt-get update && sudo apt-get install -y ninja-build valgrind
#
- name: Install ninja (macOS) # - name: Install ninja (macOS)
if: runner.os == 'macOS' # if: runner.os == 'macOS'
run: brew install ninja # run: brew install ninja
#
- name: Set up Visual Studio shell (Windows) # - name: Set up Visual Studio shell (Windows)
if: runner.os == 'Windows' # if: runner.os == 'Windows'
uses: egor-tensin/vs-shell@v2 # uses: egor-tensin/vs-shell@v2
with: # with:
arch: x64 # arch: x64
#
- name: CTest # - name: CTest
run: ctest -S ctest-shared.cmake -V --output-on-failure --timeout 900 # run: ctest -S ctest-shared.cmake -V --output-on-failure --timeout 900
#
- name: Upload results # - name: Upload results
uses: actions/upload-artifact@v4 # uses: actions/upload-artifact@v4
with: # with:
name: ${{ matrix.os }}-${{ github.job }}-results # name: ${{ matrix.os }}-${{ github.job }}-results
path: ${{ github.workspace }}/${{ env.BUILD_DIR }}/Testing/ # path: ${{ github.workspace }}/${{ env.BUILD_DIR }}/Testing/
#
test-clang: # test-clang:
strategy: # strategy:
fail-fast: false # fail-fast: false
matrix: # matrix:
os: [macos-latest, ubuntu-latest, windows-latest] # os: [macos-latest, ubuntu-latest, windows-latest]
shared_libs: [OFF, ON] # shared_libs: [OFF, ON]
enable_module: [OFF, ON] # enable_module: [OFF, ON]
#
runs-on: ${{ matrix.os }} # runs-on: ${{ matrix.os }}
env: # env:
BUILD_DIR: _build # BUILD_DIR: _build
#
steps: # steps:
- uses: actions/checkout@v4 # - uses: actions/checkout@v4
#
- name: Install ninja valgrind (Linux) # - name: Install ninja valgrind (Linux)
if: runner.os == 'Linux' # if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y ninja-build clang valgrind # run: sudo apt-get update && sudo apt-get install -y ninja-build clang valgrind
#
- name: Install ninja (macOS) # - name: Install ninja (macOS)
if: runner.os == 'macOS' # if: runner.os == 'macOS'
run: brew install ninja # run: brew install ninja
#
- name: Set up Visual Studio shell (Windows) # - name: Set up Visual Studio shell (Windows)
if: runner.os == 'Windows' # if: runner.os == 'Windows'
uses: egor-tensin/vs-shell@v2 # uses: egor-tensin/vs-shell@v2
with: # with:
arch: x64 # arch: x64
#
- name: CMake configure # - name: CMake configure
if: runner.os == 'Linux' # if: runner.os == 'Linux'
run: CC=clang CXX=clang++ cmake -B ${{ env.BUILD_DIR }} -DBUILD_SHARED_LIBS=${{ matrix.shared_libs }} -DIPHREEQC_ENABLE_MODULE=${{ matrix.enable_module }} -DCMAKE_CXX_STANDARD=20 -DCMAKE_CXX_STANDARD_REQUIRED=ON # run: CC=clang CXX=clang++ cmake -B ${{ env.BUILD_DIR }} -DBUILD_SHARED_LIBS=${{ matrix.shared_libs }} -DIPHREEQC_ENABLE_MODULE=${{ matrix.enable_module }} -DCMAKE_CXX_STANDARD=20 -DCMAKE_CXX_STANDARD_REQUIRED=ON
#
- name: CMake configure # - name: CMake configure
if: runner.os == 'macOS' # if: runner.os == 'macOS'
run: CC=$(brew --prefix llvm@15)/bin/clang CXX=$(brew --prefix llvm@15)/bin/clang++ cmake -B ${{ env.BUILD_DIR }} -DBUILD_SHARED_LIBS=${{ matrix.shared_libs }} -DIPHREEQC_ENABLE_MODULE=${{ matrix.enable_module }} -DCMAKE_CXX_STANDARD=20 -DCMAKE_CXX_STANDARD_REQUIRED=ON # run: CC=$(brew --prefix llvm@15)/bin/clang CXX=$(brew --prefix llvm@15)/bin/clang++ cmake -B ${{ env.BUILD_DIR }} -DBUILD_SHARED_LIBS=${{ matrix.shared_libs }} -DIPHREEQC_ENABLE_MODULE=${{ matrix.enable_module }} -DCMAKE_CXX_STANDARD=20 -DCMAKE_CXX_STANDARD_REQUIRED=ON
#
- name: CMake configure # - name: CMake configure
if: runner.os == 'Windows' # if: runner.os == 'Windows'
run: cmake -B ${{ env.BUILD_DIR }} -A x64 -T "ClangCL" -DBUILD_SHARED_LIBS=${{ matrix.shared_libs }} -DIPHREEQC_ENABLE_MODULE=${{ matrix.enable_module }} -DCMAKE_CXX_STANDARD=20 -DCMAKE_CXX_STANDARD_REQUIRED=ON # run: cmake -B ${{ env.BUILD_DIR }} -A x64 -T "ClangCL" -DBUILD_SHARED_LIBS=${{ matrix.shared_libs }} -DIPHREEQC_ENABLE_MODULE=${{ matrix.enable_module }} -DCMAKE_CXX_STANDARD=20 -DCMAKE_CXX_STANDARD_REQUIRED=ON
#
- name: CMake build # - name: CMake build
run: cmake --build ${{ env.BUILD_DIR }} # run: cmake --build ${{ env.BUILD_DIR }}
#
- name: CTest # - name: CTest
run: ctest --test-dir ${{ env.BUILD_DIR }} # run: ctest --test-dir ${{ env.BUILD_DIR }}
#
- name: Upload results # - name: Upload results
uses: actions/upload-artifact@v4 # uses: actions/upload-artifact@v4
with: # with:
name: ${{ matrix.os }}-${{ github.job }}-SHARED=${{ matrix.shared_libs }}-MODULE=${{ matrix.enable_module }}-results # name: ${{ matrix.os }}-${{ github.job }}-SHARED=${{ matrix.shared_libs }}-MODULE=${{ matrix.enable_module }}-results
path: ${{ github.workspace }}/${{ env.BUILD_DIR }}/Testing/ # path: ${{ github.workspace }}/${{ env.BUILD_DIR }}/Testing/
#
chm: # chm:
runs-on: windows-latest # runs-on: windows-latest
#
steps: # steps:
- name: Checkout phreeqc3-HTMLversion # - name: Checkout phreeqc3-HTMLversion
uses: actions/checkout@v4 # uses: actions/checkout@v4
with: # with:
repository: usgs-coupled-subtrees/phreeqc3-HTMLversion # repository: usgs-coupled-subtrees/phreeqc3-HTMLversion
ref: master # ref: master
#
- name: cache htmlhelp # - name: cache htmlhelp
id: cache-htmlhelp # id: cache-htmlhelp
uses: actions/cache@v4 # uses: actions/cache@v4
with: # with:
path: "C:/Program Files (x86)/HTML Help Workshop" # path: "C:/Program Files (x86)/HTML Help Workshop"
key: ${{ runner.os }}-htmlhelp # key: ${{ runner.os }}-htmlhelp
#
- name: install htmlhelp # - name: install htmlhelp
if: steps.cache-htmlhelp.outputs.cache-hit != 'true' # if: steps.cache-htmlhelp.outputs.cache-hit != 'true'
timeout-minutes: 5 # timeout-minutes: 5
run: | # run: |
curl -L -O --max-time 120 http://web.archive.org/web/20160201063255/http://download.microsoft.com/download/0/A/9/0A939EF6-E31C-430F-A3DF-DFAE7960D564/htmlhelp.exe # curl -L -O --max-time 120 http://web.archive.org/web/20160201063255/http://download.microsoft.com/download/0/A/9/0A939EF6-E31C-430F-A3DF-DFAE7960D564/htmlhelp.exe
cmd /c start /wait .\htmlhelp.exe /q /c /t:$(Get-Location)\tmp # cmd /c start /wait .\htmlhelp.exe /q /c /t:$(Get-Location)\tmp
$file = "$(Get-Location)\tmp\htmlhelp.inf" # $file = "$(Get-Location)\tmp\htmlhelp.inf"
(Get-Content $file) | Foreach-Object { $_ ` # (Get-Content $file) | Foreach-Object { $_ `
-replace '^BeginPrompt', ';;BeginPrompt' ` # -replace '^BeginPrompt', ';;BeginPrompt' `
-replace '^EndPrompt', ';;EndPrompt' ` # -replace '^EndPrompt', ';;EndPrompt' `
-replace '^49000=CustomLDID49000, 1', '49000=CustomLDID49000, 5' ` # -replace '^49000=CustomLDID49000, 1', '49000=CustomLDID49000, 5' `
-replace '^"hhupd.exe', ';;hhupd.exe' ` # -replace '^"hhupd.exe', ';;hhupd.exe' `
-replace '^DefaultInstallDir="C:\\Program Files\\HTML Help Workshop"', 'DefaultInstallDir="%ProgramFiles%\\HTML Help Workshop"' # -replace '^DefaultInstallDir="C:\\Program Files\\HTML Help Workshop"', 'DefaultInstallDir="%ProgramFiles%\\HTML Help Workshop"'
} | Set-Content $file # } | Set-Content $file
cmd /c start /wait .\tmp\setup.exe # cmd /c start /wait .\tmp\setup.exe
Remove-Item -Recurse -Force .\tmp # Remove-Item -Recurse -Force .\tmp
Remove-Item -Recurse -Force .\htmlhelp.exe # Remove-Item -Recurse -Force .\htmlhelp.exe
# the next line doesn't seem to work (supposed to set the path) # # the next line doesn't seem to work (supposed to set the path)
# echo 'C:\Program Files (x86)\HTML Help Workshop' >> $GITHUB_PATH # # echo 'C:\Program Files (x86)\HTML Help Workshop' >> $GITHUB_PATH
#
- name: compile chm # - name: compile chm
shell: bash # shell: bash
run: | # run: |
pushd HTML # pushd HTML
bash fixup_html.bash # bash fixup_html.bash
popd # popd
# hhc returns 1 on success # # hhc returns 1 on success
set +e # set +e
'C:\Program Files (x86)\HTML Help Workshop\hhc' phreeqc3.hhp | tee hhc.out # 'C:\Program Files (x86)\HTML Help Workshop\hhc' phreeqc3.hhp | tee hhc.out
status=${PIPESTATUS[0]} # status=${PIPESTATUS[0]}
set -e # set -e
if [ "$status" -eq 1 ]; then # if [ "$status" -eq 1 ]; then
echo "[OK]" # echo "[OK]"
exit 0 # exit 0
else # else
echo "[FAILED]" # echo "[FAILED]"
exit 1 # exit 1
fi # fi
#
- uses: actions/upload-artifact@v4 # - uses: actions/upload-artifact@v4
with: # with:
name: chm # name: chm
path: ${{github.workspace}}/phreeqc3.chm # path: ${{github.workspace}}/phreeqc3.chm
#
#
R-CMD-check: # R-CMD-check:
needs: [init] # needs: [init]
runs-on: ${{ matrix.config.os }} # runs-on: ${{ matrix.config.os }}
#
name: ${{ matrix.config.os }} (${{ matrix.config.r }}) # name: ${{ matrix.config.os }} (${{ matrix.config.r }})
#
strategy: # strategy:
fail-fast: false # fail-fast: false
matrix: # matrix:
config: # config:
- {os: macos-latest, r: 'release'} # - {os: macos-latest, r: 'release'}
- {os: windows-latest, r: 'release'} # - {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} # - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'} # - {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'} # - {os: ubuntu-latest, r: 'oldrel-1'}
#
steps: # steps:
- uses: actions/checkout@v4 # - uses: actions/checkout@v4
#
- name: versioning # - name: versioning
run: ./jenkins-dist.sh -v ${{ needs.init.outputs.VER }} -r ${{ needs.init.outputs.REL }} -d ${{ needs.init.outputs.DATE }} # run: ./jenkins-dist.sh -v ${{ needs.init.outputs.VER }} -r ${{ needs.init.outputs.REL }} -d ${{ needs.init.outputs.DATE }}
#
- name: Setup R # - name: Setup R
uses: r-lib/actions/setup-r@v2 # uses: r-lib/actions/setup-r@v2
with: # with:
r-version: ${{ matrix.config.r }} # r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }} # http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true # use-public-rspm: true
#
- name: create source # - name: create source
working-directory: R # working-directory: R
run: make VERSION=${{ needs.init.outputs.VER }} RELEASE_DATE=${{ needs.init.outputs.DATE_RFC_3339 }} source # run: make VERSION=${{ needs.init.outputs.VER }} RELEASE_DATE=${{ needs.init.outputs.DATE_RFC_3339 }} source
#
- name: Install dependencies # - name: Install dependencies
uses: r-lib/actions/setup-r-dependencies@v2 # uses: r-lib/actions/setup-r-dependencies@v2
with: # with:
extra-packages: any::roxygen2, any::pkgbuild, any::rcmdcheck # extra-packages: any::roxygen2, any::pkgbuild, any::rcmdcheck
needs: roxygen2, pkgbuild, check # needs: roxygen2, pkgbuild, check
working-directory: R/phreeqc # working-directory: R/phreeqc
#
- name: Display sessionInfo() # - name: Display sessionInfo()
run: sessionInfo() # run: sessionInfo()
working-directory: R/phreeqc # working-directory: R/phreeqc
shell: Rscript {0} # shell: Rscript {0}
#
- name: roxygen2::roxygenise() # - name: roxygen2::roxygenise()
run: roxygen2::roxygenise() # run: roxygen2::roxygenise()
working-directory: R/phreeqc # working-directory: R/phreeqc
shell: Rscript {0} # shell: Rscript {0}
#
- name: Check # - name: Check
uses: r-lib/actions/check-r-package@v2 # uses: r-lib/actions/check-r-package@v2
with: # with:
working-directory: R/phreeqc # working-directory: R/phreeqc
#
- name: List files # - name: List files
if: matrix.config.os == 'ubuntu-latest' && matrix.config.r == 'release' # if: matrix.config.os == 'ubuntu-latest' && matrix.config.r == 'release'
run: | # run: |
pwd # pwd
ls -lR # ls -lR
find -name "*.tar.gz" # find -name "*.tar.gz"
#
- uses: actions/upload-artifact@v4 # - uses: actions/upload-artifact@v4
if: matrix.config.os == 'ubuntu-latest' && matrix.config.r == 'release' # if: matrix.config.os == 'ubuntu-latest' && matrix.config.r == 'release'
with: # with:
name: cran # name: cran
path: ${{ github.workspace }}/R/phreeqc/check/phreeqc_*.tar.gz # path: ${{ github.workspace }}/R/phreeqc/check/phreeqc_*.tar.gz
# r-build: # r-build:
@ -373,140 +373,140 @@ jobs:
# path: ${{github.workspace}}/R/valgrind.full.out # path: ${{github.workspace}}/R/valgrind.full.out
distcheck: # distcheck:
needs: [init, chm] # needs: [init, chm]
runs-on: ubuntu-latest # runs-on: ubuntu-latest
steps: # steps:
- uses: actions/checkout@v4 # - uses: actions/checkout@v4
#
- uses: actions/download-artifact@v4 # - uses: actions/download-artifact@v4
with: # with:
name: chm # name: chm
#
- name: mv chm # - name: mv chm
run: mv phreeqc3.chm doc/. # run: mv phreeqc3.chm doc/.
#
- name: versioning # - name: versioning
run: ./jenkins-dist.sh -v ${{ needs.init.outputs.VER }} -r ${{ needs.init.outputs.REL }} -d ${{ needs.init.outputs.DATE }} # run: ./jenkins-dist.sh -v ${{ needs.init.outputs.VER }} -r ${{ needs.init.outputs.REL }} -d ${{ needs.init.outputs.DATE }}
#
- name: doxygen # - name: doxygen
run: sudo apt-get install -y doxygen && cd doc && doxygen # run: sudo apt-get install -y doxygen && cd doc && doxygen
#
- name: autoreconf # - name: autoreconf
run: autoreconf -fvi # run: autoreconf -fvi
#
- name: mkdir # - name: mkdir
run: mkdir _build # run: mkdir _build
#
- name: configure # - name: configure
working-directory: ${{github.workspace}}/_build # working-directory: ${{github.workspace}}/_build
run: ../configure --prefix=$(pwd)/INSTALL # run: ../configure --prefix=$(pwd)/INSTALL
#
- name: make # - name: make
working-directory: ${{github.workspace}}/_build # working-directory: ${{github.workspace}}/_build
run: make -j2 distcheck # run: make -j2 distcheck
#
- name: convert # - name: convert
run: | # run: |
sudo apt install -y dos2unix # sudo apt install -y dos2unix
native=" # native="
doc/Makefile \ # doc/Makefile \
doc/examples/AccumulateLine.c \ # doc/examples/AccumulateLine.c \
doc/examples/CreateIPhreeqc.c \ # doc/examples/CreateIPhreeqc.c \
doc/examples/F90ClearAccumulatedLines.f90 \ # doc/examples/F90ClearAccumulatedLines.f90 \
doc/examples/F90CreateIPhreeqc.f90 \ # doc/examples/F90CreateIPhreeqc.f90 \
doc/examples/F90DestroyIPhreeqc.f90 \ # doc/examples/F90DestroyIPhreeqc.f90 \
doc/examples/F90GetComponent.f90 \ # doc/examples/F90GetComponent.f90 \
doc/examples/F90GetDumpStringLine.f90 \ # doc/examples/F90GetDumpStringLine.f90 \
doc/examples/F90GetSelectedOutputValue.f90 \ # doc/examples/F90GetSelectedOutputValue.f90 \
doc/examples/F90GetVersionString.f90 \ # doc/examples/F90GetVersionString.f90 \
doc/examples/GetComponent.c \ # doc/examples/GetComponent.c \
doc/examples/GetDumpString.c \ # doc/examples/GetDumpString.c \
doc/examples/GetSelectedOutputValue.c \ # doc/examples/GetSelectedOutputValue.c \
doc/examples/GetVersionString.c \ # doc/examples/GetVersionString.c \
doc/examples/IPhreeqc.cpp \ # doc/examples/IPhreeqc.cpp \
doc/examples/Makefile \ # doc/examples/Makefile \
doc/examples/phreeqc.dat \ # doc/examples/phreeqc.dat \
src/CSelectedOutput.cpp \ # src/CSelectedOutput.cpp \
src/CSelectedOutput.hxx \ # src/CSelectedOutput.hxx \
src/CVar.hxx \ # src/CVar.hxx \
src/Debug.h \ # src/Debug.h \
src/ErrorReporter.hxx \ # src/ErrorReporter.hxx \
src/IPhreeqc.cpp \ # src/IPhreeqc.cpp \
src/IPhreeqc.f.inc \ # src/IPhreeqc.f.inc \
src/IPhreeqc.f90.inc \ # src/IPhreeqc.f90.inc \
src/IPhreeqc.h \ # src/IPhreeqc.h \
src/IPhreeqc.hpp \ # src/IPhreeqc.hpp \
src/IPhreeqcCallbacks.h \ # src/IPhreeqcCallbacks.h \
src/IPhreeqcF.f \ # src/IPhreeqcF.f \
src/IPhreeqcLib.cpp \ # src/IPhreeqcLib.cpp \
src/IPhreeqc_interface.F90 \ # src/IPhreeqc_interface.F90 \
src/IPhreeqc_interface_F.cpp \ # src/IPhreeqc_interface_F.cpp \
src/IPhreeqc_interface_F.h \ # src/IPhreeqc_interface_F.h \
src/Var.c \ # src/Var.c \
src/Var.h \ # src/Var.h \
src/Version.h \ # src/Version.h \
src/fimpl.h \ # src/fimpl.h \
src/fwrap.cpp \ # src/fwrap.cpp \
src/fwrap.h \ # src/fwrap.h \
src/fwrap1.cpp \ # src/fwrap1.cpp \
src/fwrap2.cpp \ # src/fwrap2.cpp \
src/fwrap3.cpp \ # src/fwrap3.cpp \
src/fwrap4.cpp \ # src/fwrap4.cpp \
src/fwrap5.cpp \ # src/fwrap5.cpp \
src/fwrap6.cpp \ # src/fwrap6.cpp \
src/fwrap7.cpp \ # src/fwrap7.cpp \
src/fwrap8.cpp \ # src/fwrap8.cpp \
src/pp_sys.cpp \ # src/pp_sys.cpp \
src/thread.h \ # src/thread.h \
test/llnl.dat \ # test/llnl.dat \
test/phreeqc.dat \ # test/phreeqc.dat \
test2/Makefile \ # test2/Makefile \
test2/wateq4f.dat \ # test2/wateq4f.dat \
test5/Makefile \ # test5/Makefile \
test5/phreeqc.dat \ # test5/phreeqc.dat \
test5/test5.c \ # test5/test5.c \
tests/main_fortran.cxx \ # tests/main_fortran.cxx \
tests/test_c.c \ # tests/test_c.c \
tests/test_cxx.cxx \ # tests/test_cxx.cxx \
tests/test_f90.F90 \ # tests/test_f90.F90 \
unit/TestCVar.cpp \ # unit/TestCVar.cpp \
unit/TestCVar.h \ # unit/TestCVar.h \
unit/TestInterface.cpp \ # unit/TestInterface.cpp \
unit/TestInterface.h \ # unit/TestInterface.h \
unit/TestSelectedOutput.cpp \ # unit/TestSelectedOutput.cpp \
unit/TestSelectedOutput.h \ # unit/TestSelectedOutput.h \
unit/TestVar.cpp \ # unit/TestVar.cpp \
unit/TestVar.h \ # unit/TestVar.h \
unit/llnl.dat.old \ # unit/llnl.dat.old \
unit/missing_e.dat \ # unit/missing_e.dat \
unit/phreeqc.dat.old \ # unit/phreeqc.dat.old \
unit/unit.cpp" # unit/unit.cpp"
for f in ${native}; do # for f in ${native}; do
unix2dos "${f}" # unix2dos "${f}"
done # done
#
- name: dist-zip # - name: dist-zip
working-directory: ${{github.workspace}}/_build # working-directory: ${{github.workspace}}/_build
run: make dist-zip # run: make dist-zip
#
- name: copy # - name: copy
run: cp doc/README IPhreeqc_ReadMe.txt # run: cp doc/README IPhreeqc_ReadMe.txt
#
- uses: actions/upload-artifact@v4 # - uses: actions/upload-artifact@v4
with: # with:
name: readme # name: readme
path: ${{github.workspace}}/IPhreeqc_ReadMe.txt # path: ${{github.workspace}}/IPhreeqc_ReadMe.txt
#
- uses: actions/upload-artifact@v4 # - uses: actions/upload-artifact@v4
with: # with:
name: tarball # name: tarball
path: ${{github.workspace}}/_build/*.tar.gz # path: ${{github.workspace}}/_build/*.tar.gz
#
- uses: actions/upload-artifact@v4 # - uses: actions/upload-artifact@v4
with: # with:
name: zipball # name: zipball
path: ${{github.workspace}}/_build/*.zip # path: ${{github.workspace}}/_build/*.zip
# build: # build:
# needs: [init] # needs: [init]

View File

@ -2,47 +2,28 @@
cmake_minimum_required(VERSION 3.20) cmake_minimum_required(VERSION 3.20)
project ( project (
IPhreeqc litephreeqc
VERSION 3.8.5 VERSION 3.8.5
LANGUAGES CXX C LANGUAGES CXX C
) )
# check if this is the root project if (WIN32)
if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) message(FATAL_ERROR "litephreeqc cannot be built on Windows systems.")
set(STANDALONE_BUILD 1)
else()
set(STANDALONE_BUILD 0)
endif() endif()
if (STANDALONE_BUILD) # Set a default build type if none was specified
# Set a default build type if none was specified set(default_build_type "Release")
set(default_build_type "Release") if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE)
STRING "Choose the type of build." FORCE) # Set the possible values of build type for cmake-gui
# Set the possible values of build type for cmake-gui set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
endif()
# overide docdir on windows
if (WIN32 AND NOT CMAKE_INSTALL_DOCDIR)
set(CMAKE_INSTALL_DOCDIR "" CACHE PATH "documentation root (doc)")
set(CMAKE_INSTALL_DOCDIR "doc")
endif() endif()
# set standard directory locations # set standard directory locations
include(GNUInstallDirs) include(GNUInstallDirs)
if (STANDALONE_BUILD AND MSVC)
option (IPHREEQC_STATIC_RUNTIME "Build with a static runtime" OFF)
if (IPHREEQC_STATIC_RUNTIME)
# compile with static runtime
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
endif()
# Fortran # Fortran
option (IPHREEQC_ENABLE_MODULE "Enable Fortran module" ON) option (IPHREEQC_ENABLE_MODULE "Enable Fortran module" ON)
if (STANDALONE_BUILD) if (STANDALONE_BUILD)
@ -60,22 +41,7 @@ endif()
# compile Var.c as c++ # compile Var.c as c++
set_source_files_properties(src/Var.c PROPERTIES LANGUAGE CXX) set_source_files_properties(src/Var.c PROPERTIES LANGUAGE CXX)
if (STANDALONE_BUILD) add_library(IPhreeqc STATIC src/IPhreeqc.cpp)
option(BUILD_SHARED_LIBS "Build Shared Libraries" OFF)
set(LIB_TYPE STATIC)
endif()
if (STANDALONE_BUILD)
if (MSVC)
option(BUILD_CLR_LIBS "Build CLR Libraries" OFF)
endif()
endif()
if (BUILD_SHARED_LIBS)
set(LIB_TYPE SHARED)
endif()
add_library(IPhreeqc ${LIB_TYPE} src/IPhreeqc.cpp)
target_sources(IPhreeqc target_sources(IPhreeqc
PRIVATE PRIVATE
@ -220,7 +186,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
@ -229,10 +195,10 @@ target_sources(IPhreeqc
target_include_directories(IPhreeqc target_include_directories(IPhreeqc
PUBLIC PUBLIC
$<BUILD_INTERFACE:${IPhreeqc_SOURCE_DIR}/src> $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>
$<BUILD_INTERFACE:${IPhreeqc_SOURCE_DIR}/src/phreeqcpp> $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src/phreeqcpp>
$<BUILD_INTERFACE:${IPhreeqc_SOURCE_DIR}/src/phreeqcpp/common> $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src/phreeqcpp/common>
$<BUILD_INTERFACE:${IPhreeqc_SOURCE_DIR}/src/phreeqcpp/PhreeqcKeywords> $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src/phreeqcpp/PhreeqcKeywords>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
) )
@ -260,37 +226,6 @@ if (NOT IPHREEQC_ENABLE_MODULE)
) )
endif() endif()
if (${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
target_compile_options(IPhreeqc PRIVATE /wd4251 /wd4275 /wd4793)
endif()
# Disable deprecation warnings for standard C and STL functions in VS2005
# and later
if (MSVC_VERSION EQUAL 1400 OR MSVC_VERSION GREATER 1400)
target_compile_definitions(IPhreeqc PUBLIC _CRT_SECURE_NO_DEPRECATE)
target_compile_definitions(IPhreeqc PUBLIC _SCL_SECURE_NO_WARNINGS)
endif()
if (WIN32 AND BUILD_SHARED_LIBS)
# Required to build IMPLIB
# (Seems to be automatically set when using Visual Studio as the generator)
target_compile_definitions(IPhreeqc PRIVATE _WINDLL)
endif()
# Allow user to override POSTFIX properties (but mandate them so that
# all builds can be installed to the same directory)
if (NOT CMAKE_DEBUG_POSTFIX)
set_target_properties(IPhreeqc PROPERTIES DEBUG_POSTFIX "d")
endif()
if (NOT CMAKE_MINSIZEREL_POSTFIX)
set_target_properties(IPhreeqc PROPERTIES MINSIZEREL_POSTFIX "msr")
endif()
if (NOT CMAKE_RELWITHDEBINFO_POSTFIX)
set_target_properties(IPhreeqc PROPERTIES RELWITHDEBINFO_POSTFIX "rwd")
endif()
set(IPhreeqc_Headers set(IPhreeqc_Headers
${PROJECT_SOURCE_DIR}/src/IPhreeqc.h ${PROJECT_SOURCE_DIR}/src/IPhreeqc.h
${PROJECT_SOURCE_DIR}/src/IPhreeqc.hpp ${PROJECT_SOURCE_DIR}/src/IPhreeqc.hpp
@ -319,158 +254,94 @@ else()
) )
endif() endif()
# Setup references for /CLR
if (MSVC AND BUILD_SHARED_LIBS AND BUILD_CLR_LIBS)
if (MSVC_VERSION LESS 1600)
message(FATAL_ERROR "CLR options must be set manually for versions prior to Visual Studio 2010")
endif()
set_target_properties(IPhreeqc PROPERTIES VS_DOTNET_REFERENCES "System;System.Drawing;System.Windows.Forms;${CMAKE_CURRENT_SOURCE_DIR}/src/phreeqcpp/ZedGraph.dll")
set_target_properties(IPhreeqc PROPERTIES COMMON_LANGUAGE_RUNTIME "")
target_compile_definitions(IPhreeqc PRIVATE "MULTICHART")
endif()
set_target_properties(IPhreeqc PROPERTIES set_target_properties(IPhreeqc PROPERTIES
VERSION "${IPhreeqc_VERSION}" VERSION "${IPhreeqc_VERSION}"
SOVERSION "${IPhreeqc_VERSION_MAJOR}" SOVERSION "${IPhreeqc_VERSION_MAJOR}"
) )
# install # install
if (STANDALONE_BUILD) include(CMakePackageConfigHelpers)
include(CMakePackageConfigHelpers) configure_package_config_file(IPhreeqcConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/IPhreeqcConfig.cmake
configure_package_config_file(IPhreeqcConfig.cmake.in INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/IPhreeqc
${CMAKE_CURRENT_BINARY_DIR}/IPhreeqcConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/IPhreeqc
)
write_basic_package_version_file("IPhreeqcConfigVersion.cmake"
VERSION ${IPhreeqc_VERSION}
COMPATIBILITY SameMajorVersion
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/IPhreeqcConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/IPhreeqcConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/IPhreeqc
)
install(TARGETS IPhreeqc
EXPORT IPhreeqcTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install(EXPORT IPhreeqcTargets
FILE IPhreeqcTargets.cmake
NAMESPACE IPhreeqc::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/IPhreeqc
)
install(FILES ${IPhreeqc_Headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
if (WIN32)
install(FILES ${IPhreeqc_SRC} DESTINATION src)
else()
install(FILES ${IPhreeqc_SRC} DESTINATION ${CMAKE_INSTALL_DOCDIR}/src)
endif()
if (BUILD_CLR_LIBS)
install(FILES "${PROJECT_SOURCE_DIR}/src/phreeqcpp/ZedGraph.dll" DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
endif()
if (BUILD_CLR_LIBS)
if (NOT BUILD_SHARED_LIBS)
message(FATAL_ERROR "BUILD_CLR_LIBS requires that BUILD_SHARED_LIBS be set")
endif()
if (IPHREEQC_STATIC_RUNTIME)
message(FATAL_ERROR "BUILD_CLR_LIBS and IPHREEQC_STATIC_RUNTIME are mutually exclusive")
endif()
# CLR files
target_sources(IPhreeqc
PRIVATE
src/phreeqcpp/ChartHandler.cpp
src/phreeqcpp/ChartHandler.h
src/phreeqcpp/ChartObject.cpp
src/phreeqcpp/ChartObject.h
src/phreeqcpp/CurveObject.cpp
src/phreeqcpp/CurveObject.h
) )
write_basic_package_version_file("IPhreeqcConfigVersion.cmake"
VERSION ${IPhreeqc_VERSION}
COMPATIBILITY SameMajorVersion
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/IPhreeqcConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/IPhreeqcConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/IPhreeqc
)
install(TARGETS IPhreeqc
EXPORT IPhreeqcTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install(EXPORT IPhreeqcTargets
FILE IPhreeqcTargets.cmake
NAMESPACE IPhreeqc::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/IPhreeqc
)
install(FILES ${IPhreeqc_Headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
if (WIN32)
install(FILES ${IPhreeqc_SRC} DESTINATION src)
else()
install(FILES ${IPhreeqc_SRC} DESTINATION ${CMAKE_INSTALL_DOCDIR}/src)
endif() endif()
if (BUILD_CLR_LIBS)
install(FILES "${PROJECT_SOURCE_DIR}/src/phreeqcpp/ZedGraph.dll" DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
include (CTest) include (CTest)
if (STANDALONE_BUILD) # add_subdirectory(database)
# add_subdirectory(doc)
# add_subdirectory(examples)
add_subdirectory(database) if (BUILD_TESTING)
add_subdirectory(doc) add_subdirectory(tests)
add_subdirectory(examples)
if (BUILD_TESTING)
add_subdirectory(tests)
endif()
if (BUILD_TESTING) # may need to add MSVC version check
include(FetchContent)
# Avoid warning about DOWNLOAD_EXTRACT_TIMESTAMP in CMake 3.24:
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
cmake_policy(SET CMP0135 NEW)
endif()
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/release-1.12.1.tar.gz
)
mark_as_advanced(
FETCHCONTENT_BASE_DIR
FETCHCONTENT_FULLY_DISCONNECTED
FETCHCONTENT_QUIET
FETCHCONTENT_SOURCE_DIR_GOOGLETEST
FETCHCONTENT_UPDATES_DISCONNECTED
FETCHCONTENT_UPDATES_DISCONNECTED_GOOGLETEST
)
# Prevent GoogleTest from overriding our compiler/linker options
# when building with Visual Studio
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
set(BUILD_GTEST ON CACHE BOOL "" FORCE)
set(BUILD_GMOCK ON CACHE BOOL "" FORCE)
set(INSTALL_GTEST OFF CACHE BOOL "" FORCE)
set(INSTALL_GMOCK OFF CACHE BOOL "" FORCE)
mark_as_advanced(
BUILD_GTEST
BUILD_GMOCK
INSTALL_GTEST
INSTALL_GMOCK
gmock_build_tests
gtest_build_tests
gtest_build_samples
gtest_disable_pthreads
gtest_force_shared_crt
gtest_hide_internal_symbols
)
FetchContent_MakeAvailable(googletest)
if (NOT googletest_POPULATED)
# Always build googletest static
set(SAVE_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
set(BUILD_SHARED_LIBS OFF)
FetchContent_MakeAvailable(googletest)
set(BUILD_SHARED_LIBS ${SAVE_BUILD_SHARED_LIBS})
endif()
add_subdirectory(gtest)
endif()
endif() endif()
add_subdirectory(poet)
if (BUILD_TESTING) # may need to add MSVC version check
include(FetchContent)
# Avoid warning about DOWNLOAD_EXTRACT_TIMESTAMP in CMake 3.24:
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
cmake_policy(SET CMP0135 NEW)
endif()
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.17.0
)
# Prevent GoogleTest from overriding our compiler/linker options
# when building with Visual Studio
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
if (NOT googletest_POPULATED)
# Always build googletest static
set(SAVE_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
set(BUILD_SHARED_LIBS OFF)
FetchContent_MakeAvailable(googletest)
set(BUILD_SHARED_LIBS ${SAVE_BUILD_SHARED_LIBS})
endif()
add_subdirectory(gtest)
endif()
add_subdirectory(litephreeqc)
# get_cmake_property(_variableNames VARIABLES) # get_cmake_property(_variableNames VARIABLES)
# list (SORT _variableNames) # list (SORT _variableNames)

View File

@ -1,4 +1,5 @@
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 +21,19 @@ set(POET_SOURCE_FILES
src/PhreeqcMatrix/Misc.cpp src/PhreeqcMatrix/Misc.cpp
) )
add_library(IPhreeqcPOET ${POET_SOURCE_FILES}) add_library(litephreeqc STATIC ${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
@ -41,15 +42,15 @@ if (BUILD_TESTING AND STANDALONE_BUILD)
test/IPhreeqcReader.cpp test/IPhreeqcReader.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)
@ -59,11 +60,11 @@ 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(testGolemRunner test/testGolemRunner.cpp) add_executable(golemrunner test/testGolemRunner.cpp)
target_link_libraries(testGolemRunner IPhreeqcPOET) target_link_libraries(golemrunner litephreeqc)
add_executable(testGetters test/testGetters.cpp) add_executable(testGetters test/testGetters.cpp)
target_link_libraries(testGetters IPhreeqcPOET) target_link_libraries(testGetters litephreeqc)

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

@ -6,7 +6,7 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#define POET_TEST(name) TEST(TestPOET, name) #define POET_TEST(name) TEST(litephreeqc, name)
namespace base_test { namespace base_test {
const std::string script = R"(SOLUTION 1 const std::string script = R"(SOLUTION 1

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>