mirror of
https://git.gfz-potsdam.de/naaice/iphreeqc.git
synced 2025-12-15 16:18:22 +01:00
Compare commits
28 Commits
3ad62fc101
...
dcff790306
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dcff790306 | ||
|
|
646f166f24 | ||
|
|
0ed073309f | ||
|
|
5c398186fd | ||
|
|
a46bf4d4fe | ||
|
|
9d48f28708 | ||
|
|
cd4c26beed | ||
|
|
5e972551a8 | ||
|
|
9a454b4ce5 | ||
|
|
85762ad3f3 | ||
|
|
953c752431 | ||
|
|
a23a1a9f40 | ||
|
|
24b55af288 | ||
|
|
9cead329e2 | ||
|
|
b7c2574a0d | ||
|
|
769b02452d | ||
|
|
90c5ec80f4 | ||
|
|
22e1fae555 | ||
|
|
6864285820 | ||
|
|
cdd360fc2c | ||
|
|
52cd3ed731 | ||
|
|
979cc7dec0 | ||
|
|
64d9685b97 | ||
|
|
281595c39f | ||
|
|
265cd0ae27 | ||
|
|
2f2faae5a2 | ||
|
|
31250c0857 | ||
|
|
4ea034e4e3 |
854
.github/workflows/cmake.yml
vendored
854
.github/workflows/cmake.yml
vendored
@ -1,296 +1,296 @@
|
||||
name: CMake
|
||||
|
||||
on:
|
||||
push:
|
||||
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
schedule:
|
||||
- cron: '15 14 4,11,18,25 * *'
|
||||
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
|
||||
BUILD_TYPE: Release
|
||||
NAME: IPhreeqc
|
||||
|
||||
jobs:
|
||||
|
||||
init:
|
||||
runs-on: ubuntu-latest
|
||||
# Map step outputs to job outputs
|
||||
outputs:
|
||||
VER: ${{ steps.vars.outputs.VER }}
|
||||
REL: ${{ steps.vars.outputs.REL }}
|
||||
DATE: ${{ steps.vars.outputs.DATE }}
|
||||
DATE_RFC_3339: ${{ steps.vars.outputs.DATE_RFC_3339 }}
|
||||
steps:
|
||||
- name: Setup vars
|
||||
id: vars
|
||||
run: |
|
||||
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 DATE=$(date "+%x") >> $GITHUB_OUTPUT
|
||||
echo DATE_RFC_3339=$(date --rfc-3339=date) >> $GITHUB_OUTPUT
|
||||
|
||||
|
||||
test:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-latest, ubuntu-latest, windows-latest]
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
env:
|
||||
BUILD_DIR: _ctest # set in ctest.cmake
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install ninja valgrind (Linux)
|
||||
if: runner.os == 'Linux'
|
||||
run: sudo apt-get update && sudo apt-get install -y ninja-build valgrind
|
||||
|
||||
- name: Install ninja (macOS)
|
||||
if: runner.os == 'macOS'
|
||||
run: brew install ninja
|
||||
|
||||
- name: Set up Visual Studio shell (Windows)
|
||||
if: runner.os == 'Windows'
|
||||
uses: egor-tensin/vs-shell@v2
|
||||
with:
|
||||
arch: x64
|
||||
|
||||
- name: CTest
|
||||
run: ctest -S ctest.cmake -V --output-on-failure --timeout 900
|
||||
|
||||
- name: Upload results
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.os }}-${{ github.job }}-results
|
||||
path: ${{ github.workspace }}/${{ env.BUILD_DIR }}/Testing/
|
||||
|
||||
test-shared:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-latest, ubuntu-latest, windows-latest]
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
env:
|
||||
BUILD_DIR: _ctest_shared # set in ctest-shared.cmake
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install ninja valgrind (Linux)
|
||||
if: runner.os == 'Linux'
|
||||
run: sudo apt-get update && sudo apt-get install -y ninja-build valgrind
|
||||
|
||||
- name: Install ninja (macOS)
|
||||
if: runner.os == 'macOS'
|
||||
run: brew install ninja
|
||||
|
||||
- name: Set up Visual Studio shell (Windows)
|
||||
if: runner.os == 'Windows'
|
||||
uses: egor-tensin/vs-shell@v2
|
||||
with:
|
||||
arch: x64
|
||||
|
||||
- name: CTest
|
||||
run: ctest -S ctest-shared.cmake -V --output-on-failure --timeout 900
|
||||
|
||||
- name: Upload results
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.os }}-${{ github.job }}-results
|
||||
path: ${{ github.workspace }}/${{ env.BUILD_DIR }}/Testing/
|
||||
|
||||
test-clang:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-latest, ubuntu-latest, windows-latest]
|
||||
shared_libs: [OFF, ON]
|
||||
enable_module: [OFF, ON]
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
env:
|
||||
BUILD_DIR: _build
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install ninja valgrind (Linux)
|
||||
if: runner.os == 'Linux'
|
||||
run: sudo apt-get update && sudo apt-get install -y ninja-build clang valgrind
|
||||
|
||||
- name: Install ninja (macOS)
|
||||
if: runner.os == 'macOS'
|
||||
run: brew install ninja
|
||||
|
||||
- name: Set up Visual Studio shell (Windows)
|
||||
if: runner.os == 'Windows'
|
||||
uses: egor-tensin/vs-shell@v2
|
||||
with:
|
||||
arch: x64
|
||||
|
||||
- name: CMake configure
|
||||
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
|
||||
|
||||
- name: CMake configure
|
||||
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
|
||||
|
||||
- name: CMake configure
|
||||
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
|
||||
|
||||
- name: CMake build
|
||||
run: cmake --build ${{ env.BUILD_DIR }}
|
||||
|
||||
- name: CTest
|
||||
run: ctest --test-dir ${{ env.BUILD_DIR }}
|
||||
|
||||
- name: Upload results
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.os }}-${{ github.job }}-SHARED=${{ matrix.shared_libs }}-MODULE=${{ matrix.enable_module }}-results
|
||||
path: ${{ github.workspace }}/${{ env.BUILD_DIR }}/Testing/
|
||||
|
||||
chm:
|
||||
runs-on: windows-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout phreeqc3-HTMLversion
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: usgs-coupled-subtrees/phreeqc3-HTMLversion
|
||||
ref: master
|
||||
|
||||
- name: cache htmlhelp
|
||||
id: cache-htmlhelp
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: "C:/Program Files (x86)/HTML Help Workshop"
|
||||
key: ${{ runner.os }}-htmlhelp
|
||||
|
||||
- name: install htmlhelp
|
||||
if: steps.cache-htmlhelp.outputs.cache-hit != 'true'
|
||||
timeout-minutes: 5
|
||||
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
|
||||
cmd /c start /wait .\htmlhelp.exe /q /c /t:$(Get-Location)\tmp
|
||||
$file = "$(Get-Location)\tmp\htmlhelp.inf"
|
||||
(Get-Content $file) | Foreach-Object { $_ `
|
||||
-replace '^BeginPrompt', ';;BeginPrompt' `
|
||||
-replace '^EndPrompt', ';;EndPrompt' `
|
||||
-replace '^49000=CustomLDID49000, 1', '49000=CustomLDID49000, 5' `
|
||||
-replace '^"hhupd.exe', ';;hhupd.exe' `
|
||||
-replace '^DefaultInstallDir="C:\\Program Files\\HTML Help Workshop"', 'DefaultInstallDir="%ProgramFiles%\\HTML Help Workshop"'
|
||||
} | Set-Content $file
|
||||
cmd /c start /wait .\tmp\setup.exe
|
||||
Remove-Item -Recurse -Force .\tmp
|
||||
Remove-Item -Recurse -Force .\htmlhelp.exe
|
||||
# the next line doesn't seem to work (supposed to set the path)
|
||||
# echo 'C:\Program Files (x86)\HTML Help Workshop' >> $GITHUB_PATH
|
||||
|
||||
- name: compile chm
|
||||
shell: bash
|
||||
run: |
|
||||
pushd HTML
|
||||
bash fixup_html.bash
|
||||
popd
|
||||
# hhc returns 1 on success
|
||||
set +e
|
||||
'C:\Program Files (x86)\HTML Help Workshop\hhc' phreeqc3.hhp | tee hhc.out
|
||||
status=${PIPESTATUS[0]}
|
||||
set -e
|
||||
if [ "$status" -eq 1 ]; then
|
||||
echo "[OK]"
|
||||
exit 0
|
||||
else
|
||||
echo "[FAILED]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: chm
|
||||
path: ${{github.workspace}}/phreeqc3.chm
|
||||
|
||||
|
||||
R-CMD-check:
|
||||
needs: [init]
|
||||
runs-on: ${{ matrix.config.os }}
|
||||
|
||||
name: ${{ matrix.config.os }} (${{ matrix.config.r }})
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
config:
|
||||
- {os: macos-latest, r: 'release'}
|
||||
- {os: windows-latest, r: 'release'}
|
||||
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
|
||||
- {os: ubuntu-latest, r: 'release'}
|
||||
- {os: ubuntu-latest, r: 'oldrel-1'}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: versioning
|
||||
run: ./jenkins-dist.sh -v ${{ needs.init.outputs.VER }} -r ${{ needs.init.outputs.REL }} -d ${{ needs.init.outputs.DATE }}
|
||||
|
||||
- name: Setup R
|
||||
uses: r-lib/actions/setup-r@v2
|
||||
with:
|
||||
r-version: ${{ matrix.config.r }}
|
||||
http-user-agent: ${{ matrix.config.http-user-agent }}
|
||||
use-public-rspm: true
|
||||
|
||||
- name: create source
|
||||
working-directory: R
|
||||
run: make VERSION=${{ needs.init.outputs.VER }} RELEASE_DATE=${{ needs.init.outputs.DATE_RFC_3339 }} source
|
||||
|
||||
- name: Install dependencies
|
||||
uses: r-lib/actions/setup-r-dependencies@v2
|
||||
with:
|
||||
extra-packages: any::roxygen2, any::pkgbuild, any::rcmdcheck
|
||||
needs: roxygen2, pkgbuild, check
|
||||
working-directory: R/phreeqc
|
||||
|
||||
- name: Display sessionInfo()
|
||||
run: sessionInfo()
|
||||
working-directory: R/phreeqc
|
||||
shell: Rscript {0}
|
||||
|
||||
- name: roxygen2::roxygenise()
|
||||
run: roxygen2::roxygenise()
|
||||
working-directory: R/phreeqc
|
||||
shell: Rscript {0}
|
||||
|
||||
- name: Check
|
||||
uses: r-lib/actions/check-r-package@v2
|
||||
with:
|
||||
working-directory: R/phreeqc
|
||||
|
||||
- name: List files
|
||||
if: matrix.config.os == 'ubuntu-latest' && matrix.config.r == 'release'
|
||||
run: |
|
||||
pwd
|
||||
ls -lR
|
||||
find -name "*.tar.gz"
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: matrix.config.os == 'ubuntu-latest' && matrix.config.r == 'release'
|
||||
with:
|
||||
name: cran
|
||||
path: ${{ github.workspace }}/R/phreeqc/check/phreeqc_*.tar.gz
|
||||
# name: CMake
|
||||
#
|
||||
# on:
|
||||
# push:
|
||||
#
|
||||
# pull_request:
|
||||
# branches:
|
||||
# - master
|
||||
#
|
||||
# schedule:
|
||||
# - cron: '15 14 4,11,18,25 * *'
|
||||
#
|
||||
# workflow_dispatch:
|
||||
#
|
||||
# env:
|
||||
# # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
|
||||
# BUILD_TYPE: Release
|
||||
# NAME: IPhreeqc
|
||||
#
|
||||
# jobs:
|
||||
#
|
||||
# init:
|
||||
# runs-on: ubuntu-latest
|
||||
# # Map step outputs to job outputs
|
||||
# outputs:
|
||||
# VER: ${{ steps.vars.outputs.VER }}
|
||||
# REL: ${{ steps.vars.outputs.REL }}
|
||||
# DATE: ${{ steps.vars.outputs.DATE }}
|
||||
# DATE_RFC_3339: ${{ steps.vars.outputs.DATE_RFC_3339 }}
|
||||
# steps:
|
||||
# - name: Setup vars
|
||||
# id: vars
|
||||
# run: |
|
||||
# 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 DATE=$(date "+%x") >> $GITHUB_OUTPUT
|
||||
# echo DATE_RFC_3339=$(date --rfc-3339=date) >> $GITHUB_OUTPUT
|
||||
#
|
||||
#
|
||||
# test:
|
||||
# strategy:
|
||||
# fail-fast: false
|
||||
# matrix:
|
||||
# os: [macos-latest, ubuntu-latest, windows-latest]
|
||||
#
|
||||
# runs-on: ${{ matrix.os }}
|
||||
# env:
|
||||
# BUILD_DIR: _ctest # set in ctest.cmake
|
||||
#
|
||||
# steps:
|
||||
# - uses: actions/checkout@v4
|
||||
#
|
||||
# - name: Install ninja valgrind (Linux)
|
||||
# if: runner.os == 'Linux'
|
||||
# run: sudo apt-get update && sudo apt-get install -y ninja-build valgrind
|
||||
#
|
||||
# - name: Install ninja (macOS)
|
||||
# if: runner.os == 'macOS'
|
||||
# run: brew install ninja
|
||||
#
|
||||
# - name: Set up Visual Studio shell (Windows)
|
||||
# if: runner.os == 'Windows'
|
||||
# uses: egor-tensin/vs-shell@v2
|
||||
# with:
|
||||
# arch: x64
|
||||
#
|
||||
# - name: CTest
|
||||
# run: ctest -S ctest.cmake -V --output-on-failure --timeout 900
|
||||
#
|
||||
# - name: Upload results
|
||||
# uses: actions/upload-artifact@v4
|
||||
# with:
|
||||
# name: ${{ matrix.os }}-${{ github.job }}-results
|
||||
# path: ${{ github.workspace }}/${{ env.BUILD_DIR }}/Testing/
|
||||
#
|
||||
# test-shared:
|
||||
# strategy:
|
||||
# fail-fast: false
|
||||
# matrix:
|
||||
# os: [macos-latest, ubuntu-latest, windows-latest]
|
||||
#
|
||||
# runs-on: ${{ matrix.os }}
|
||||
# env:
|
||||
# BUILD_DIR: _ctest_shared # set in ctest-shared.cmake
|
||||
#
|
||||
# steps:
|
||||
# - uses: actions/checkout@v4
|
||||
#
|
||||
# - name: Install ninja valgrind (Linux)
|
||||
# if: runner.os == 'Linux'
|
||||
# run: sudo apt-get update && sudo apt-get install -y ninja-build valgrind
|
||||
#
|
||||
# - name: Install ninja (macOS)
|
||||
# if: runner.os == 'macOS'
|
||||
# run: brew install ninja
|
||||
#
|
||||
# - name: Set up Visual Studio shell (Windows)
|
||||
# if: runner.os == 'Windows'
|
||||
# uses: egor-tensin/vs-shell@v2
|
||||
# with:
|
||||
# arch: x64
|
||||
#
|
||||
# - name: CTest
|
||||
# run: ctest -S ctest-shared.cmake -V --output-on-failure --timeout 900
|
||||
#
|
||||
# - name: Upload results
|
||||
# uses: actions/upload-artifact@v4
|
||||
# with:
|
||||
# name: ${{ matrix.os }}-${{ github.job }}-results
|
||||
# path: ${{ github.workspace }}/${{ env.BUILD_DIR }}/Testing/
|
||||
#
|
||||
# test-clang:
|
||||
# strategy:
|
||||
# fail-fast: false
|
||||
# matrix:
|
||||
# os: [macos-latest, ubuntu-latest, windows-latest]
|
||||
# shared_libs: [OFF, ON]
|
||||
# enable_module: [OFF, ON]
|
||||
#
|
||||
# runs-on: ${{ matrix.os }}
|
||||
# env:
|
||||
# BUILD_DIR: _build
|
||||
#
|
||||
# steps:
|
||||
# - uses: actions/checkout@v4
|
||||
#
|
||||
# - name: Install ninja valgrind (Linux)
|
||||
# if: runner.os == 'Linux'
|
||||
# run: sudo apt-get update && sudo apt-get install -y ninja-build clang valgrind
|
||||
#
|
||||
# - name: Install ninja (macOS)
|
||||
# if: runner.os == 'macOS'
|
||||
# run: brew install ninja
|
||||
#
|
||||
# - name: Set up Visual Studio shell (Windows)
|
||||
# if: runner.os == 'Windows'
|
||||
# uses: egor-tensin/vs-shell@v2
|
||||
# with:
|
||||
# arch: x64
|
||||
#
|
||||
# - name: CMake configure
|
||||
# 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
|
||||
#
|
||||
# - name: CMake configure
|
||||
# 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
|
||||
#
|
||||
# - name: CMake configure
|
||||
# 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
|
||||
#
|
||||
# - name: CMake build
|
||||
# run: cmake --build ${{ env.BUILD_DIR }}
|
||||
#
|
||||
# - name: CTest
|
||||
# run: ctest --test-dir ${{ env.BUILD_DIR }}
|
||||
#
|
||||
# - name: Upload results
|
||||
# uses: actions/upload-artifact@v4
|
||||
# with:
|
||||
# name: ${{ matrix.os }}-${{ github.job }}-SHARED=${{ matrix.shared_libs }}-MODULE=${{ matrix.enable_module }}-results
|
||||
# path: ${{ github.workspace }}/${{ env.BUILD_DIR }}/Testing/
|
||||
#
|
||||
# chm:
|
||||
# runs-on: windows-latest
|
||||
#
|
||||
# steps:
|
||||
# - name: Checkout phreeqc3-HTMLversion
|
||||
# uses: actions/checkout@v4
|
||||
# with:
|
||||
# repository: usgs-coupled-subtrees/phreeqc3-HTMLversion
|
||||
# ref: master
|
||||
#
|
||||
# - name: cache htmlhelp
|
||||
# id: cache-htmlhelp
|
||||
# uses: actions/cache@v4
|
||||
# with:
|
||||
# path: "C:/Program Files (x86)/HTML Help Workshop"
|
||||
# key: ${{ runner.os }}-htmlhelp
|
||||
#
|
||||
# - name: install htmlhelp
|
||||
# if: steps.cache-htmlhelp.outputs.cache-hit != 'true'
|
||||
# timeout-minutes: 5
|
||||
# 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
|
||||
# cmd /c start /wait .\htmlhelp.exe /q /c /t:$(Get-Location)\tmp
|
||||
# $file = "$(Get-Location)\tmp\htmlhelp.inf"
|
||||
# (Get-Content $file) | Foreach-Object { $_ `
|
||||
# -replace '^BeginPrompt', ';;BeginPrompt' `
|
||||
# -replace '^EndPrompt', ';;EndPrompt' `
|
||||
# -replace '^49000=CustomLDID49000, 1', '49000=CustomLDID49000, 5' `
|
||||
# -replace '^"hhupd.exe', ';;hhupd.exe' `
|
||||
# -replace '^DefaultInstallDir="C:\\Program Files\\HTML Help Workshop"', 'DefaultInstallDir="%ProgramFiles%\\HTML Help Workshop"'
|
||||
# } | Set-Content $file
|
||||
# cmd /c start /wait .\tmp\setup.exe
|
||||
# Remove-Item -Recurse -Force .\tmp
|
||||
# Remove-Item -Recurse -Force .\htmlhelp.exe
|
||||
# # the next line doesn't seem to work (supposed to set the path)
|
||||
# # echo 'C:\Program Files (x86)\HTML Help Workshop' >> $GITHUB_PATH
|
||||
#
|
||||
# - name: compile chm
|
||||
# shell: bash
|
||||
# run: |
|
||||
# pushd HTML
|
||||
# bash fixup_html.bash
|
||||
# popd
|
||||
# # hhc returns 1 on success
|
||||
# set +e
|
||||
# 'C:\Program Files (x86)\HTML Help Workshop\hhc' phreeqc3.hhp | tee hhc.out
|
||||
# status=${PIPESTATUS[0]}
|
||||
# set -e
|
||||
# if [ "$status" -eq 1 ]; then
|
||||
# echo "[OK]"
|
||||
# exit 0
|
||||
# else
|
||||
# echo "[FAILED]"
|
||||
# exit 1
|
||||
# fi
|
||||
#
|
||||
# - uses: actions/upload-artifact@v4
|
||||
# with:
|
||||
# name: chm
|
||||
# path: ${{github.workspace}}/phreeqc3.chm
|
||||
#
|
||||
#
|
||||
# R-CMD-check:
|
||||
# needs: [init]
|
||||
# runs-on: ${{ matrix.config.os }}
|
||||
#
|
||||
# name: ${{ matrix.config.os }} (${{ matrix.config.r }})
|
||||
#
|
||||
# strategy:
|
||||
# fail-fast: false
|
||||
# matrix:
|
||||
# config:
|
||||
# - {os: macos-latest, r: 'release'}
|
||||
# - {os: windows-latest, r: 'release'}
|
||||
# - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
|
||||
# - {os: ubuntu-latest, r: 'release'}
|
||||
# - {os: ubuntu-latest, r: 'oldrel-1'}
|
||||
#
|
||||
# steps:
|
||||
# - uses: actions/checkout@v4
|
||||
#
|
||||
# - name: versioning
|
||||
# run: ./jenkins-dist.sh -v ${{ needs.init.outputs.VER }} -r ${{ needs.init.outputs.REL }} -d ${{ needs.init.outputs.DATE }}
|
||||
#
|
||||
# - name: Setup R
|
||||
# uses: r-lib/actions/setup-r@v2
|
||||
# with:
|
||||
# r-version: ${{ matrix.config.r }}
|
||||
# http-user-agent: ${{ matrix.config.http-user-agent }}
|
||||
# use-public-rspm: true
|
||||
#
|
||||
# - name: create source
|
||||
# working-directory: R
|
||||
# run: make VERSION=${{ needs.init.outputs.VER }} RELEASE_DATE=${{ needs.init.outputs.DATE_RFC_3339 }} source
|
||||
#
|
||||
# - name: Install dependencies
|
||||
# uses: r-lib/actions/setup-r-dependencies@v2
|
||||
# with:
|
||||
# extra-packages: any::roxygen2, any::pkgbuild, any::rcmdcheck
|
||||
# needs: roxygen2, pkgbuild, check
|
||||
# working-directory: R/phreeqc
|
||||
#
|
||||
# - name: Display sessionInfo()
|
||||
# run: sessionInfo()
|
||||
# working-directory: R/phreeqc
|
||||
# shell: Rscript {0}
|
||||
#
|
||||
# - name: roxygen2::roxygenise()
|
||||
# run: roxygen2::roxygenise()
|
||||
# working-directory: R/phreeqc
|
||||
# shell: Rscript {0}
|
||||
#
|
||||
# - name: Check
|
||||
# uses: r-lib/actions/check-r-package@v2
|
||||
# with:
|
||||
# working-directory: R/phreeqc
|
||||
#
|
||||
# - name: List files
|
||||
# if: matrix.config.os == 'ubuntu-latest' && matrix.config.r == 'release'
|
||||
# run: |
|
||||
# pwd
|
||||
# ls -lR
|
||||
# find -name "*.tar.gz"
|
||||
#
|
||||
# - uses: actions/upload-artifact@v4
|
||||
# if: matrix.config.os == 'ubuntu-latest' && matrix.config.r == 'release'
|
||||
# with:
|
||||
# name: cran
|
||||
# path: ${{ github.workspace }}/R/phreeqc/check/phreeqc_*.tar.gz
|
||||
|
||||
|
||||
# r-build:
|
||||
@ -373,140 +373,140 @@ jobs:
|
||||
# path: ${{github.workspace}}/R/valgrind.full.out
|
||||
|
||||
|
||||
distcheck:
|
||||
needs: [init, chm]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: chm
|
||||
|
||||
- name: mv chm
|
||||
run: mv phreeqc3.chm doc/.
|
||||
|
||||
- name: versioning
|
||||
run: ./jenkins-dist.sh -v ${{ needs.init.outputs.VER }} -r ${{ needs.init.outputs.REL }} -d ${{ needs.init.outputs.DATE }}
|
||||
|
||||
- name: doxygen
|
||||
run: sudo apt-get install -y doxygen && cd doc && doxygen
|
||||
|
||||
- name: autoreconf
|
||||
run: autoreconf -fvi
|
||||
|
||||
- name: mkdir
|
||||
run: mkdir _build
|
||||
|
||||
- name: configure
|
||||
working-directory: ${{github.workspace}}/_build
|
||||
run: ../configure --prefix=$(pwd)/INSTALL
|
||||
|
||||
- name: make
|
||||
working-directory: ${{github.workspace}}/_build
|
||||
run: make -j2 distcheck
|
||||
|
||||
- name: convert
|
||||
run: |
|
||||
sudo apt install -y dos2unix
|
||||
native="
|
||||
doc/Makefile \
|
||||
doc/examples/AccumulateLine.c \
|
||||
doc/examples/CreateIPhreeqc.c \
|
||||
doc/examples/F90ClearAccumulatedLines.f90 \
|
||||
doc/examples/F90CreateIPhreeqc.f90 \
|
||||
doc/examples/F90DestroyIPhreeqc.f90 \
|
||||
doc/examples/F90GetComponent.f90 \
|
||||
doc/examples/F90GetDumpStringLine.f90 \
|
||||
doc/examples/F90GetSelectedOutputValue.f90 \
|
||||
doc/examples/F90GetVersionString.f90 \
|
||||
doc/examples/GetComponent.c \
|
||||
doc/examples/GetDumpString.c \
|
||||
doc/examples/GetSelectedOutputValue.c \
|
||||
doc/examples/GetVersionString.c \
|
||||
doc/examples/IPhreeqc.cpp \
|
||||
doc/examples/Makefile \
|
||||
doc/examples/phreeqc.dat \
|
||||
src/CSelectedOutput.cpp \
|
||||
src/CSelectedOutput.hxx \
|
||||
src/CVar.hxx \
|
||||
src/Debug.h \
|
||||
src/ErrorReporter.hxx \
|
||||
src/IPhreeqc.cpp \
|
||||
src/IPhreeqc.f.inc \
|
||||
src/IPhreeqc.f90.inc \
|
||||
src/IPhreeqc.h \
|
||||
src/IPhreeqc.hpp \
|
||||
src/IPhreeqcCallbacks.h \
|
||||
src/IPhreeqcF.f \
|
||||
src/IPhreeqcLib.cpp \
|
||||
src/IPhreeqc_interface.F90 \
|
||||
src/IPhreeqc_interface_F.cpp \
|
||||
src/IPhreeqc_interface_F.h \
|
||||
src/Var.c \
|
||||
src/Var.h \
|
||||
src/Version.h \
|
||||
src/fimpl.h \
|
||||
src/fwrap.cpp \
|
||||
src/fwrap.h \
|
||||
src/fwrap1.cpp \
|
||||
src/fwrap2.cpp \
|
||||
src/fwrap3.cpp \
|
||||
src/fwrap4.cpp \
|
||||
src/fwrap5.cpp \
|
||||
src/fwrap6.cpp \
|
||||
src/fwrap7.cpp \
|
||||
src/fwrap8.cpp \
|
||||
src/pp_sys.cpp \
|
||||
src/thread.h \
|
||||
test/llnl.dat \
|
||||
test/phreeqc.dat \
|
||||
test2/Makefile \
|
||||
test2/wateq4f.dat \
|
||||
test5/Makefile \
|
||||
test5/phreeqc.dat \
|
||||
test5/test5.c \
|
||||
tests/main_fortran.cxx \
|
||||
tests/test_c.c \
|
||||
tests/test_cxx.cxx \
|
||||
tests/test_f90.F90 \
|
||||
unit/TestCVar.cpp \
|
||||
unit/TestCVar.h \
|
||||
unit/TestInterface.cpp \
|
||||
unit/TestInterface.h \
|
||||
unit/TestSelectedOutput.cpp \
|
||||
unit/TestSelectedOutput.h \
|
||||
unit/TestVar.cpp \
|
||||
unit/TestVar.h \
|
||||
unit/llnl.dat.old \
|
||||
unit/missing_e.dat \
|
||||
unit/phreeqc.dat.old \
|
||||
unit/unit.cpp"
|
||||
for f in ${native}; do
|
||||
unix2dos "${f}"
|
||||
done
|
||||
|
||||
- name: dist-zip
|
||||
working-directory: ${{github.workspace}}/_build
|
||||
run: make dist-zip
|
||||
|
||||
- name: copy
|
||||
run: cp doc/README IPhreeqc_ReadMe.txt
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: readme
|
||||
path: ${{github.workspace}}/IPhreeqc_ReadMe.txt
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: tarball
|
||||
path: ${{github.workspace}}/_build/*.tar.gz
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: zipball
|
||||
path: ${{github.workspace}}/_build/*.zip
|
||||
# distcheck:
|
||||
# needs: [init, chm]
|
||||
# runs-on: ubuntu-latest
|
||||
# steps:
|
||||
# - uses: actions/checkout@v4
|
||||
#
|
||||
# - uses: actions/download-artifact@v4
|
||||
# with:
|
||||
# name: chm
|
||||
#
|
||||
# - name: mv chm
|
||||
# run: mv phreeqc3.chm doc/.
|
||||
#
|
||||
# - name: versioning
|
||||
# run: ./jenkins-dist.sh -v ${{ needs.init.outputs.VER }} -r ${{ needs.init.outputs.REL }} -d ${{ needs.init.outputs.DATE }}
|
||||
#
|
||||
# - name: doxygen
|
||||
# run: sudo apt-get install -y doxygen && cd doc && doxygen
|
||||
#
|
||||
# - name: autoreconf
|
||||
# run: autoreconf -fvi
|
||||
#
|
||||
# - name: mkdir
|
||||
# run: mkdir _build
|
||||
#
|
||||
# - name: configure
|
||||
# working-directory: ${{github.workspace}}/_build
|
||||
# run: ../configure --prefix=$(pwd)/INSTALL
|
||||
#
|
||||
# - name: make
|
||||
# working-directory: ${{github.workspace}}/_build
|
||||
# run: make -j2 distcheck
|
||||
#
|
||||
# - name: convert
|
||||
# run: |
|
||||
# sudo apt install -y dos2unix
|
||||
# native="
|
||||
# doc/Makefile \
|
||||
# doc/examples/AccumulateLine.c \
|
||||
# doc/examples/CreateIPhreeqc.c \
|
||||
# doc/examples/F90ClearAccumulatedLines.f90 \
|
||||
# doc/examples/F90CreateIPhreeqc.f90 \
|
||||
# doc/examples/F90DestroyIPhreeqc.f90 \
|
||||
# doc/examples/F90GetComponent.f90 \
|
||||
# doc/examples/F90GetDumpStringLine.f90 \
|
||||
# doc/examples/F90GetSelectedOutputValue.f90 \
|
||||
# doc/examples/F90GetVersionString.f90 \
|
||||
# doc/examples/GetComponent.c \
|
||||
# doc/examples/GetDumpString.c \
|
||||
# doc/examples/GetSelectedOutputValue.c \
|
||||
# doc/examples/GetVersionString.c \
|
||||
# doc/examples/IPhreeqc.cpp \
|
||||
# doc/examples/Makefile \
|
||||
# doc/examples/phreeqc.dat \
|
||||
# src/CSelectedOutput.cpp \
|
||||
# src/CSelectedOutput.hxx \
|
||||
# src/CVar.hxx \
|
||||
# src/Debug.h \
|
||||
# src/ErrorReporter.hxx \
|
||||
# src/IPhreeqc.cpp \
|
||||
# src/IPhreeqc.f.inc \
|
||||
# src/IPhreeqc.f90.inc \
|
||||
# src/IPhreeqc.h \
|
||||
# src/IPhreeqc.hpp \
|
||||
# src/IPhreeqcCallbacks.h \
|
||||
# src/IPhreeqcF.f \
|
||||
# src/IPhreeqcLib.cpp \
|
||||
# src/IPhreeqc_interface.F90 \
|
||||
# src/IPhreeqc_interface_F.cpp \
|
||||
# src/IPhreeqc_interface_F.h \
|
||||
# src/Var.c \
|
||||
# src/Var.h \
|
||||
# src/Version.h \
|
||||
# src/fimpl.h \
|
||||
# src/fwrap.cpp \
|
||||
# src/fwrap.h \
|
||||
# src/fwrap1.cpp \
|
||||
# src/fwrap2.cpp \
|
||||
# src/fwrap3.cpp \
|
||||
# src/fwrap4.cpp \
|
||||
# src/fwrap5.cpp \
|
||||
# src/fwrap6.cpp \
|
||||
# src/fwrap7.cpp \
|
||||
# src/fwrap8.cpp \
|
||||
# src/pp_sys.cpp \
|
||||
# src/thread.h \
|
||||
# test/llnl.dat \
|
||||
# test/phreeqc.dat \
|
||||
# test2/Makefile \
|
||||
# test2/wateq4f.dat \
|
||||
# test5/Makefile \
|
||||
# test5/phreeqc.dat \
|
||||
# test5/test5.c \
|
||||
# tests/main_fortran.cxx \
|
||||
# tests/test_c.c \
|
||||
# tests/test_cxx.cxx \
|
||||
# tests/test_f90.F90 \
|
||||
# unit/TestCVar.cpp \
|
||||
# unit/TestCVar.h \
|
||||
# unit/TestInterface.cpp \
|
||||
# unit/TestInterface.h \
|
||||
# unit/TestSelectedOutput.cpp \
|
||||
# unit/TestSelectedOutput.h \
|
||||
# unit/TestVar.cpp \
|
||||
# unit/TestVar.h \
|
||||
# unit/llnl.dat.old \
|
||||
# unit/missing_e.dat \
|
||||
# unit/phreeqc.dat.old \
|
||||
# unit/unit.cpp"
|
||||
# for f in ${native}; do
|
||||
# unix2dos "${f}"
|
||||
# done
|
||||
#
|
||||
# - name: dist-zip
|
||||
# working-directory: ${{github.workspace}}/_build
|
||||
# run: make dist-zip
|
||||
#
|
||||
# - name: copy
|
||||
# run: cp doc/README IPhreeqc_ReadMe.txt
|
||||
#
|
||||
# - uses: actions/upload-artifact@v4
|
||||
# with:
|
||||
# name: readme
|
||||
# path: ${{github.workspace}}/IPhreeqc_ReadMe.txt
|
||||
#
|
||||
# - uses: actions/upload-artifact@v4
|
||||
# with:
|
||||
# name: tarball
|
||||
# path: ${{github.workspace}}/_build/*.tar.gz
|
||||
#
|
||||
# - uses: actions/upload-artifact@v4
|
||||
# with:
|
||||
# name: zipball
|
||||
# path: ${{github.workspace}}/_build/*.zip
|
||||
|
||||
# build:
|
||||
# needs: [init]
|
||||
|
||||
287
CMakeLists.txt
287
CMakeLists.txt
@ -2,47 +2,28 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
project (
|
||||
IPhreeqc
|
||||
litephreeqc
|
||||
VERSION 3.8.5
|
||||
LANGUAGES CXX C
|
||||
)
|
||||
|
||||
# check if this is the root project
|
||||
if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
|
||||
set(STANDALONE_BUILD 1)
|
||||
else()
|
||||
set(STANDALONE_BUILD 0)
|
||||
if (WIN32)
|
||||
message(FATAL_ERROR "litephreeqc cannot be built on Windows systems.")
|
||||
endif()
|
||||
|
||||
if (STANDALONE_BUILD)
|
||||
# Set a default build type if none was specified
|
||||
set(default_build_type "Release")
|
||||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
|
||||
STRING "Choose the type of build." FORCE)
|
||||
# Set the possible values of build type for cmake-gui
|
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
|
||||
"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")
|
||||
# Set a default build type if none was specified
|
||||
set(default_build_type "Release")
|
||||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
|
||||
STRING "Choose the type of build." FORCE)
|
||||
# Set the possible values of build type for cmake-gui
|
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
|
||||
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
|
||||
endif()
|
||||
|
||||
# set standard directory locations
|
||||
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
|
||||
option (IPHREEQC_ENABLE_MODULE "Enable Fortran module" ON)
|
||||
if (STANDALONE_BUILD)
|
||||
@ -60,22 +41,7 @@ endif()
|
||||
# compile Var.c as c++
|
||||
set_source_files_properties(src/Var.c PROPERTIES LANGUAGE CXX)
|
||||
|
||||
if (STANDALONE_BUILD)
|
||||
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)
|
||||
add_library(IPhreeqc STATIC src/IPhreeqc.cpp)
|
||||
|
||||
target_sources(IPhreeqc
|
||||
PRIVATE
|
||||
@ -229,10 +195,10 @@ target_sources(IPhreeqc
|
||||
|
||||
target_include_directories(IPhreeqc
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${IPhreeqc_SOURCE_DIR}/src>
|
||||
$<BUILD_INTERFACE:${IPhreeqc_SOURCE_DIR}/src/phreeqcpp>
|
||||
$<BUILD_INTERFACE:${IPhreeqc_SOURCE_DIR}/src/phreeqcpp/common>
|
||||
$<BUILD_INTERFACE:${IPhreeqc_SOURCE_DIR}/src/phreeqcpp/PhreeqcKeywords>
|
||||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>
|
||||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src/phreeqcpp>
|
||||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src/phreeqcpp/common>
|
||||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src/phreeqcpp/PhreeqcKeywords>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
||||
)
|
||||
|
||||
@ -260,37 +226,6 @@ if (NOT IPHREEQC_ENABLE_MODULE)
|
||||
)
|
||||
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
|
||||
${PROJECT_SOURCE_DIR}/src/IPhreeqc.h
|
||||
${PROJECT_SOURCE_DIR}/src/IPhreeqc.hpp
|
||||
@ -319,155 +254,91 @@ else()
|
||||
)
|
||||
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
|
||||
VERSION "${IPhreeqc_VERSION}"
|
||||
SOVERSION "${IPhreeqc_VERSION_MAJOR}"
|
||||
)
|
||||
|
||||
# install
|
||||
if (STANDALONE_BUILD)
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
||||
configure_package_config_file(IPhreeqcConfig.cmake.in
|
||||
${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
|
||||
configure_package_config_file(IPhreeqcConfig.cmake.in
|
||||
${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()
|
||||
|
||||
|
||||
include (CTest)
|
||||
|
||||
if (STANDALONE_BUILD)
|
||||
# add_subdirectory(database)
|
||||
# add_subdirectory(doc)
|
||||
# add_subdirectory(examples)
|
||||
|
||||
add_subdirectory(database)
|
||||
add_subdirectory(doc)
|
||||
add_subdirectory(examples)
|
||||
|
||||
if (BUILD_TESTING)
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
if (BUILD_TESTING)
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
|
||||
|
||||
if (BUILD_TESTING) # may need to add MSVC version check
|
||||
include(FetchContent)
|
||||
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()
|
||||
# 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
|
||||
)
|
||||
FetchContent_Declare(
|
||||
googletest
|
||||
GIT_REPOSITORY https://github.com/google/googletest.git
|
||||
GIT_TAG v1.17.0
|
||||
)
|
||||
|
||||
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
|
||||
)
|
||||
# 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)
|
||||
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)
|
||||
set(BUILD_SHARED_LIBS ${SAVE_BUILD_SHARED_LIBS})
|
||||
endif()
|
||||
|
||||
add_subdirectory(gtest)
|
||||
endif()
|
||||
|
||||
add_subdirectory(litephreeqc)
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
|
||||
set(LPQC_SOURCE_FILES
|
||||
src/Engine.cpp
|
||||
src/Runner.cpp
|
||||
@ -20,7 +21,7 @@ set(LPQC_SOURCE_FILES
|
||||
src/PhreeqcMatrix/Misc.cpp
|
||||
)
|
||||
|
||||
add_library(litephreeqc ${LPQC_SOURCE_FILES})
|
||||
add_library(litephreeqc STATIC ${LPQC_SOURCE_FILES})
|
||||
target_link_libraries(litephreeqc PUBLIC IPhreeqc)
|
||||
target_include_directories(litephreeqc PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
@ -38,6 +39,7 @@ if (BUILD_TESTING AND STANDALONE_BUILD)
|
||||
test/testPhreeqcRunner.cpp
|
||||
test/testPhreeqcKnobs.cpp
|
||||
test/utils.cpp
|
||||
test/IPhreeqcReader.cpp
|
||||
)
|
||||
|
||||
add_executable(litephreeqc_test ${LPQC_TEST_SOURCE_FILES})
|
||||
@ -63,3 +65,6 @@ endif()
|
||||
|
||||
add_executable(golemrunner test/testGolemRunner.cpp)
|
||||
target_link_libraries(golemrunner litephreeqc)
|
||||
|
||||
add_executable(testGetters test/testGetters.cpp)
|
||||
target_link_libraries(testGetters litephreeqc)
|
||||
|
||||
@ -326,6 +326,48 @@ public:
|
||||
*/
|
||||
bool withRedox() const { return _m_with_redox; }
|
||||
|
||||
// MDL
|
||||
/**
|
||||
* @brief Returns all column names of the Matrix pertaining to KINETICS
|
||||
*
|
||||
* This function returns a string vector.
|
||||
*
|
||||
* @return std::vector<std::string> Whole vector of names. Empty if no KINETICS
|
||||
* is defined
|
||||
*/
|
||||
std::vector<std::string> getMatrixKinetics() const;
|
||||
|
||||
/**
|
||||
* @brief Returns all column names of the Matrix pertaining to EQUILIBRIUM
|
||||
*
|
||||
* This function returns a string vector.
|
||||
*
|
||||
* @return std::vector<std::string> Whole vector of names. Empty if no EQUILIBRIUM
|
||||
* is defined
|
||||
*/
|
||||
std::vector<std::string> getMatrixEquilibrium() const;
|
||||
|
||||
|
||||
/*
|
||||
|
||||
@brief Returns all column names of the Matrix pertaining to
|
||||
quantities that must be transported
|
||||
|
||||
@return std::vector<std::string> vector of names
|
||||
|
||||
*/
|
||||
std::vector<std::string> getMatrixTransported() const;
|
||||
|
||||
/*
|
||||
|
||||
@brief Returns all column names of the Matrix pertaining to
|
||||
quantities that must NOT be transported but have to be included in
|
||||
the output
|
||||
|
||||
@return std::vector<std::string> vector of names
|
||||
*/
|
||||
std::vector<std::string> getMatrixOutOnly() const;
|
||||
|
||||
private:
|
||||
std::map<int, std::vector<element>> _m_map;
|
||||
std::map<int, std::vector<base_names>> _m_internal_names;
|
||||
@ -343,4 +385,4 @@ private:
|
||||
|
||||
bool _m_with_h0_o0;
|
||||
bool _m_with_redox;
|
||||
};
|
||||
};
|
||||
|
||||
@ -143,6 +143,12 @@ void PhreeqcEngine::Impl::run(double time_step) {
|
||||
const std::string runs_string =
|
||||
"RUN_CELLS\n -cells 1\n -time_step " + time_ss.str() + "\nEND\n";
|
||||
this->RunString(runs_string.c_str());
|
||||
|
||||
if (this->GetErrorStringLineCount() > 0) {
|
||||
std::cerr << ":: Error in Phreeqc script: " << this->GetErrorString()
|
||||
<< "\n";
|
||||
throw std::runtime_error("Phreeqc script error");
|
||||
}
|
||||
}
|
||||
|
||||
void PhreeqcEngine::Impl::init_wrappers(const InitCell &cell) {
|
||||
@ -255,4 +261,4 @@ void PhreeqcEngine::Impl::set_essential_values(const std::span<double> &data) {
|
||||
data.subspan(offset, this->surfaceWrapperPtr->size())};
|
||||
this->surfaceWrapperPtr->set(surf_span);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -132,6 +132,7 @@ PhreeqcMatrix::STLExport PhreeqcMatrix::get(VectorExportType type,
|
||||
for (; column_index < result.names.size(); column_index++) {
|
||||
for (const auto &[_, elements] : _m_map) {
|
||||
double value_to_add = std::numeric_limits<double>::quiet_NaN();
|
||||
// double value_to_add;
|
||||
for (const auto &curr_element : elements) {
|
||||
const std::string &curr_element_name = curr_element.name;
|
||||
|
||||
@ -251,4 +252,81 @@ double PhreeqcMatrix::operator()(int cell_id, const std::string &name) const {
|
||||
}
|
||||
|
||||
return it->value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MDL
|
||||
std::vector<std::string> PhreeqcMatrix::getMatrixKinetics() const {
|
||||
std::vector<std::string> names;
|
||||
|
||||
auto n = this->getIds().size();
|
||||
for (auto i = 0; i<n; ++i) {
|
||||
auto pqc_kinnames = this->getKineticsNames(i);
|
||||
for (auto nam : pqc_kinnames ) {
|
||||
for (auto mat_name : this->get().names){
|
||||
if (mat_name.starts_with(nam)) {
|
||||
// check if we already have this mat_name
|
||||
if (std::find(names.begin(), names.end(), mat_name) == names.end()) {
|
||||
names.push_back(mat_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
|
||||
// MDL
|
||||
std::vector<std::string> PhreeqcMatrix::getMatrixEquilibrium() const {
|
||||
|
||||
std::vector<std::string> names;
|
||||
std::vector<std::string> mat_names = this->get().names;
|
||||
auto n = this->getIds().size();
|
||||
for (auto i = 0; i<n; ++i) {
|
||||
auto pqc_eqnames = this->getEquilibriumNames(i);
|
||||
for (auto nam : pqc_eqnames ) {
|
||||
for (auto mat_name : mat_names){
|
||||
if (mat_name.starts_with(nam)) {
|
||||
// check if we already have this mat_name
|
||||
if (std::find(names.begin(), names.end(), mat_name) == names.end()) {
|
||||
names.push_back(mat_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
// MDL
|
||||
std::vector<std::string> PhreeqcMatrix::getMatrixTransported() const {
|
||||
std::vector<std::string> names;
|
||||
|
||||
const std::vector<std::string> to_remove = {
|
||||
"tc", "patm", "SolVol", "pH", "pe"
|
||||
};
|
||||
|
||||
// sols contains all solutes; we must remove { tc, patm, SolVol, pH, pe }
|
||||
auto sols = this->getSolutionNames();
|
||||
for (auto name : sols) {
|
||||
if (std::find(to_remove.begin(), to_remove.end(), name) == to_remove.end()) {
|
||||
names.push_back(name);
|
||||
}
|
||||
}
|
||||
|
||||
return names;
|
||||
}
|
||||
|
||||
// MDL
|
||||
std::vector<std::string> PhreeqcMatrix::getMatrixOutOnly() const {
|
||||
// MDL we must append here selected_output / user_punch
|
||||
std::vector<std::string> defaultnames = {
|
||||
"tc", "patm", "SolVol", "pH", "pe"
|
||||
};
|
||||
std::vector<std::string> ret;
|
||||
for (auto nm : defaultnames) {
|
||||
ret.push_back(nm);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -31,6 +31,12 @@ PhreeqcMatrix::PhreeqcMatrix(const std::string &database,
|
||||
this->_m_pqc->LoadDatabaseString(database.c_str());
|
||||
this->_m_pqc->RunString(input_script.c_str());
|
||||
|
||||
if (this->_m_pqc->GetErrorStringLineCount() > 0) {
|
||||
std::cerr << ":: Error in Phreeqc script: "
|
||||
<< this->_m_pqc->GetErrorString() << "\n";
|
||||
throw std::runtime_error("Phreeqc script error");
|
||||
}
|
||||
|
||||
this->_m_knobs =
|
||||
std::make_shared<PhreeqcKnobs>(this->_m_pqc.get()->GetPhreeqcPtr());
|
||||
|
||||
@ -65,4 +71,4 @@ PhreeqcMatrix::PhreeqcMatrix(const std::string &database,
|
||||
// _m_database = other._m_database;
|
||||
|
||||
// return *this;
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -21,6 +21,9 @@ ExchangeWrapper::ExchangeCompWrapper::ExchangeCompWrapper(cxxExchComp &comp)
|
||||
|
||||
void ExchangeWrapper::ExchangeCompWrapper::get(
|
||||
std::span<LDBLE> &exchange) const {
|
||||
|
||||
std::size_t exch_index = this->NUM_NOT_TOTALS;
|
||||
|
||||
exchange[0] = exch_comp.Get_totals().find(exch_comp.Get_formula())->second;
|
||||
exchange[1] = exch_comp.Get_charge_balance();
|
||||
exchange[2] = exch_comp.Get_la();
|
||||
@ -29,15 +32,16 @@ void ExchangeWrapper::ExchangeCompWrapper::get(
|
||||
|
||||
for (const auto &[name, value] : exch_comp.Get_totals()) {
|
||||
if (name != exch_comp.Get_formula()) {
|
||||
exchange[NUM_NOT_TOTALS +
|
||||
std::distance(exch_comp.Get_totals().begin(),
|
||||
exch_comp.Get_totals().find(name))] = value;
|
||||
exchange[exch_index++] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ExchangeWrapper::ExchangeCompWrapper::set(
|
||||
const std::span<LDBLE> &exchange) {
|
||||
|
||||
std::size_t exch_index = this->NUM_NOT_TOTALS;
|
||||
|
||||
exch_comp.Get_totals().find(exch_comp.Get_formula())->second = exchange[0];
|
||||
exch_comp.Set_charge_balance(exchange[1]);
|
||||
exch_comp.Set_la(exchange[2]);
|
||||
@ -46,9 +50,7 @@ void ExchangeWrapper::ExchangeCompWrapper::set(
|
||||
|
||||
for (auto &[name, value] : exch_comp.Get_totals()) {
|
||||
if (name != exch_comp.Get_formula()) {
|
||||
value = exchange[NUM_NOT_TOTALS +
|
||||
std::distance(exch_comp.Get_totals().begin(),
|
||||
exch_comp.Get_totals().find(name))];
|
||||
value = exchange[exch_index++];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,11 +43,11 @@ KineticWrapper::KineticCompWrapper::names(const cxxKineticsComp &comp) {
|
||||
std::vector<std::string> names;
|
||||
|
||||
const std::string &comp_name = comp.Get_rate_name();
|
||||
names.push_back(comp_name);
|
||||
names.push_back(comp_name + "_kin");
|
||||
|
||||
for (std::size_t i = 0; i < comp.Get_d_params().size(); i++) {
|
||||
names.push_back(comp_name + "_p" + std::to_string(i + 1));
|
||||
}
|
||||
|
||||
return names;
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,6 +31,11 @@ void SolutionWrapper::get(std::span<LDBLE> &data) const {
|
||||
data[0] = solution->Get_total_h();
|
||||
data[1] = solution->Get_total_o();
|
||||
data[2] = solution->Get_cb();
|
||||
data[3] = solution->Get_tc();
|
||||
data[4] = solution->Get_patm();
|
||||
data[5] = solution->Get_soln_vol();
|
||||
data[6] = solution->Get_ph();
|
||||
data[7] = solution->Get_pe();
|
||||
|
||||
const cxxNameDouble &totals =
|
||||
(_with_redox ? solution->Get_totals()
|
||||
@ -54,6 +59,8 @@ void SolutionWrapper::set(const std::span<LDBLE> &data) {
|
||||
const double &total_h = data[0];
|
||||
const double &total_o = data[1];
|
||||
const double &cb = data[2];
|
||||
const double &tc = data[3];
|
||||
const double &patm = data[4];
|
||||
|
||||
for (const auto &tot_name : solution_order) {
|
||||
const double value = data[i++];
|
||||
@ -64,7 +71,7 @@ void SolutionWrapper::set(const std::span<LDBLE> &data) {
|
||||
new_totals[tot_name] = value;
|
||||
}
|
||||
|
||||
this->solution->Update(total_h, total_o, cb,
|
||||
this->solution->Update(total_h, total_o, cb, tc, patm,
|
||||
_with_redox ? new_totals
|
||||
: new_totals.Simplify_redox());
|
||||
}
|
||||
@ -98,4 +105,4 @@ SolutionWrapper::names(cxxSolution *solution, bool include_h0_o0,
|
||||
|
||||
names.insert(names.end(), names_set.begin(), names_set.end());
|
||||
return names;
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,10 +40,12 @@ private:
|
||||
cxxSolution *solution;
|
||||
const std::vector<std::string> solution_order;
|
||||
|
||||
static constexpr std::array<const char *, 3> ESSENTIALS = {"H", "O",
|
||||
"Charge"};
|
||||
static constexpr std::array<const char *, 8> ESSENTIALS = {
|
||||
"H", "O", "Charge", "tc", "patm",
|
||||
|
||||
"SolVol", "pH", "pe"}; // MDL; ML: only output
|
||||
|
||||
static constexpr std::size_t NUM_ESSENTIALS = ESSENTIALS.size();
|
||||
|
||||
const bool _with_redox;
|
||||
};
|
||||
};
|
||||
|
||||
139
litephreeqc/test/IPhreeqcReader.cpp
Normal file
139
litephreeqc/test/IPhreeqcReader.cpp
Normal file
@ -0,0 +1,139 @@
|
||||
#include "IPhreeqcReader.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <regex>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
IPhreeqcReader::IPhreeqcReader(const std::string &database,
|
||||
const std::string &script) {
|
||||
|
||||
_m_pqc = std::make_unique<IPhreeqc>();
|
||||
|
||||
_m_pqc->LoadDatabaseString(database.c_str());
|
||||
_m_pqc->RunString(script.c_str());
|
||||
|
||||
if (_m_pqc->GetErrorStringLineCount() > 0) {
|
||||
std::cerr << ":: Error in Phreeqc script: " << _m_pqc->GetErrorString()
|
||||
<< "\n";
|
||||
throw std::runtime_error("Phreeqc script error");
|
||||
}
|
||||
}
|
||||
|
||||
void IPhreeqcReader::setOutputID(std::uint32_t cell_id) {
|
||||
|
||||
_m_pqc->SetDumpStringOn(true);
|
||||
|
||||
const std::string call_string =
|
||||
"DUMP\n -cells " + std::to_string(cell_id) + "\nEND\n";
|
||||
|
||||
_m_pqc->RunString(call_string.c_str());
|
||||
|
||||
if (_m_pqc->GetErrorStringLineCount() > 0) {
|
||||
std::cerr << ":: Error in Phreeqc script: " << _m_pqc->GetErrorString()
|
||||
<< "\n";
|
||||
throw std::runtime_error("Possibly invalid cell ID: " +
|
||||
std::to_string(cell_id));
|
||||
}
|
||||
|
||||
_m_raw_output = _m_pqc->GetDumpString();
|
||||
|
||||
_m_pqc->SetDumpStringOn(false);
|
||||
}
|
||||
|
||||
double IPhreeqcReader::operator[](const std::string &name) const {
|
||||
if (_m_raw_output.empty()) {
|
||||
throw std::runtime_error("No output set. Call setOutputID first.");
|
||||
}
|
||||
|
||||
std::size_t pos;
|
||||
|
||||
auto it = _m_rename_map.find(name);
|
||||
|
||||
if (it != _m_rename_map.end()) {
|
||||
pos = _m_raw_output.find(it->second);
|
||||
|
||||
if (pos == std::string::npos) {
|
||||
throw std::runtime_error("Renamed name not found in output: " +
|
||||
it->second);
|
||||
}
|
||||
|
||||
} else if (name.ends_with("_eq") || name.ends_with("_si")) {
|
||||
// remove the suffix and check for the base name
|
||||
std::string base_name(name, 0, name.size() - 3); // remove "_eq"
|
||||
|
||||
pos = _m_raw_output.find(base_name);
|
||||
|
||||
if (pos == std::string::npos) {
|
||||
return std::numeric_limits<double>::quiet_NaN();
|
||||
}
|
||||
|
||||
if (name.ends_with("_eq")) {
|
||||
// if it ends with '_eq', we need to find '-moles'
|
||||
pos = _m_raw_output.find("-moles", pos);
|
||||
} else {
|
||||
// if it ends with '_si', we need to find '-si'
|
||||
pos = _m_raw_output.find("-si", pos);
|
||||
}
|
||||
} else {
|
||||
// if not, we first need to find '-totals'
|
||||
pos = _m_raw_output.find("-totals");
|
||||
if (pos == std::string::npos) {
|
||||
throw std::runtime_error("Name not found in output: " + name);
|
||||
}
|
||||
|
||||
std::size_t next_field_pos = _m_raw_output.find(" -", pos);
|
||||
|
||||
// Then, find the name in the output
|
||||
pos = _m_raw_output.find(name, pos);
|
||||
|
||||
if (pos >= next_field_pos) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
std::size_t end_pos = _m_raw_output.find('\n', pos);
|
||||
|
||||
if (end_pos == std::string::npos) {
|
||||
throw std::runtime_error("End of line not found in output for name: " +
|
||||
name);
|
||||
}
|
||||
|
||||
std::regex fp_regex(
|
||||
R"( +([+-]?(?=\.\d|\d)(?:\d+)?(?:\.?\d*))(?:[Ee]([+-]?\d+))?)");
|
||||
std::smatch match;
|
||||
|
||||
const std::string line_to_parse = _m_raw_output.substr(pos, end_pos - pos);
|
||||
|
||||
if (!std::regex_search(line_to_parse, match, fp_regex)) {
|
||||
throw std::runtime_error("No floating point number found in line: " +
|
||||
line_to_parse);
|
||||
}
|
||||
|
||||
return std::stod(match[0].str());
|
||||
}
|
||||
|
||||
void IPhreeqcReader::run(double dt, std::vector<std::uint32_t> &&cell_ids) {
|
||||
std::string run_string =
|
||||
"RUN_CELLS\n -time_step " + std::to_string(dt) + "\n -cells ";
|
||||
|
||||
for (const auto &cell_id : cell_ids) {
|
||||
run_string += std::to_string(cell_id) + " ";
|
||||
}
|
||||
|
||||
run_string += "\nEND\n";
|
||||
|
||||
_m_pqc->RunString(run_string.c_str());
|
||||
|
||||
if (_m_pqc->GetErrorStringLineCount() > 0) {
|
||||
std::cerr << ":: Error in Phreeqc script: " << _m_pqc->GetErrorString()
|
||||
<< "\n";
|
||||
throw std::runtime_error("Phreeqc run error");
|
||||
}
|
||||
|
||||
_m_raw_output.clear();
|
||||
}
|
||||
28
litephreeqc/test/IPhreeqcReader.hpp
Normal file
28
litephreeqc/test/IPhreeqcReader.hpp
Normal file
@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include "IPhreeqc.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
class IPhreeqcReader {
|
||||
public:
|
||||
IPhreeqcReader(const std::string &database, const std::string &script);
|
||||
|
||||
void setOutputID(std::uint32_t cell_id);
|
||||
double operator[](const std::string &name) const;
|
||||
|
||||
void run(double dt, std::vector<std::uint32_t> &&cell_ids);
|
||||
|
||||
private:
|
||||
std::unique_ptr<IPhreeqc> _m_pqc;
|
||||
|
||||
std::string _m_raw_output = "";
|
||||
|
||||
const std::map<std::string, std::string> _m_rename_map = {
|
||||
{"H", "-total_h"}, {"O", "-total_o"}, {"Charge", "-cb"},
|
||||
{"tc", "-temp"}, {"patm", "-pressure"}, {"SolVol", "-soln_vol"},
|
||||
{"pH", "-pH"}, {"pe", "-pe"}};
|
||||
};
|
||||
1497
litephreeqc/test/phreeqc_kin.dat
Normal file
1497
litephreeqc/test/phreeqc_kin.dat
Normal file
File diff suppressed because it is too large
Load Diff
110
litephreeqc/test/run_kin_cor_end2.pqi
Normal file
110
litephreeqc/test/run_kin_cor_end2.pqi
Normal file
@ -0,0 +1,110 @@
|
||||
SOLUTION 1
|
||||
units mol/kgw
|
||||
temp 35
|
||||
pH 7
|
||||
pe 4
|
||||
Cl 0.003 charge
|
||||
Na 0.003
|
||||
PURE 1
|
||||
Calcite 0.0 10
|
||||
|
||||
SOLUTION 2
|
||||
units mol/kgw
|
||||
pH 6.921
|
||||
pe -1.258
|
||||
water 1
|
||||
temp 17
|
||||
Na 1e-15
|
||||
Cl 1e-15 charge
|
||||
Ca 1e-15
|
||||
C 1e-15
|
||||
Fe 1e-15
|
||||
S 1e-15
|
||||
Al 1e-15
|
||||
Si 7.963e-5
|
||||
|
||||
PURE 2
|
||||
Pyrite 0.0 2.1e-4
|
||||
|
||||
KINETICS 2
|
||||
Quartz
|
||||
-m 2.2e-4
|
||||
-parms 0.01 1
|
||||
|
||||
SOLUTION 3
|
||||
units mol/kgw
|
||||
pH 9.963
|
||||
pe -6.769
|
||||
temp 17
|
||||
Na 1e-15
|
||||
Cl 1e-15
|
||||
Ca 1.345e-4
|
||||
C 1.345e-4
|
||||
Fe 1.433e-8
|
||||
S 2.866e-8
|
||||
Al 2.692e-5
|
||||
Si 2.692e-5
|
||||
|
||||
PURE 3
|
||||
Pyrite 0 2e-4
|
||||
Calcite 0 1e-4
|
||||
|
||||
KINETICS 3
|
||||
Kaolinite
|
||||
-m 1.4e-3
|
||||
-parms 0.6 1000
|
||||
Siderite
|
||||
-m 1.2e-12
|
||||
-parms 1.2 10
|
||||
|
||||
SOLUTION 4
|
||||
units mol/kgw
|
||||
temp 17
|
||||
pH 5.576
|
||||
pe 4 O2(g) -1
|
||||
Cl 0.0003 charge
|
||||
Na 0.0003
|
||||
C 1e-15 CO2(g) -3.38
|
||||
Ca 1e-15
|
||||
Fe 1e-15
|
||||
S 1e-15
|
||||
Al 1e-15
|
||||
Si 1e-15
|
||||
|
||||
|
||||
SOLUTION 5
|
||||
units mol/kgw
|
||||
pH 6.653
|
||||
pe -3.167
|
||||
water 1
|
||||
temp 17
|
||||
Na 1e-15
|
||||
Cl 1e-15 charge
|
||||
Ca 1e-15
|
||||
C 1e-15
|
||||
Fe 4.386e-9
|
||||
S 8.772e-9
|
||||
Al 5.031e-7
|
||||
Si 5.031e-7
|
||||
|
||||
PURE 5
|
||||
Pyrite 0.0 2.5e-4
|
||||
|
||||
KINETICS 5
|
||||
Kaolinite
|
||||
-m 1.5e-4
|
||||
-parms 0.6 100000
|
||||
|
||||
SOLUTION 6
|
||||
units mol/kgw
|
||||
temp 35
|
||||
pH 7
|
||||
pe 4
|
||||
Cl 0.003 charge
|
||||
Na 0.003
|
||||
PURE 6
|
||||
Calcite 0.0 10
|
||||
|
||||
RUN_CELLS
|
||||
-cells 1 2 3 4 5 6
|
||||
END
|
||||
104
litephreeqc/test/testGetters.cpp
Normal file
104
litephreeqc/test/testGetters.cpp
Normal file
@ -0,0 +1,104 @@
|
||||
// Time-stamp: "Last modified 2025-07-28 20:14: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
|
||||
std::cout << ":: Creating a PhreeqcMatrix with valence states and H(0)/O(0) \n";
|
||||
PhreeqcMatrix pqc_mat1(db, script, true, true);
|
||||
|
||||
// How many different SOLUTIONS ("CELLS") are defined in the script?
|
||||
const auto ids = pqc_mat1.getIds();
|
||||
|
||||
int n = ids.size();
|
||||
|
||||
std::cout << ":: Found " << n << " distinct PHREEQC problems \n";
|
||||
|
||||
std::cout << ":: getSolutionsNames(): the common solutes across all problems: \n";
|
||||
const auto solutes1 = pqc_mat1.getSolutionNames();
|
||||
std::cout << solutes1 << "\n";
|
||||
|
||||
// auto expmat = pqc_mat1.get();
|
||||
auto allvars = pqc_mat1.get().names;
|
||||
std::cout << ":: pqc_mat1.get().names (all names in the PhreeqcMatrix): \n";
|
||||
std::cout << allvars << "\n\n";
|
||||
|
||||
std::cout << "\n-- Now the new getMatrix*() --\n\n";
|
||||
|
||||
auto transported = pqc_mat1.getMatrixTransported();
|
||||
std::cout << ":: pqc_mat1.getMatrixTransported(): \n";
|
||||
std::cout << transported << "\n\n";
|
||||
|
||||
auto MatNamesKin = pqc_mat1.getMatrixKinetics();
|
||||
std::cout << ":: pqc_mat1.getMatrixKinetics(): \n";
|
||||
std::cout << MatNamesKin << "\n\n";
|
||||
|
||||
auto MatNamesEqui = pqc_mat1.getMatrixEquilibrium();
|
||||
std::cout << ":: pqc_mat1.getMatrixEquilibrium(): \n";
|
||||
std::cout << MatNamesEqui << "\n\n";
|
||||
|
||||
auto outonly = pqc_mat1.getMatrixOutOnly();
|
||||
std::cout << ":: pqc_mat1.getMatrixOutOnly(): \n";
|
||||
std::cout << outonly << "\n\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,17 +1,4 @@
|
||||
/*
|
||||
* 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"
|
||||
// Time-stamp: "Last modified 2025-07-28 13:03:01 delucia"
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <fstream>
|
||||
@ -70,7 +57,7 @@ int main(int argc, char *argv[]) {
|
||||
auto db = readFile(argv[2]);
|
||||
|
||||
// Create the matrix directly from database and init script
|
||||
PhreeqcMatrix pqc_mat(db, script);
|
||||
PhreeqcMatrix pqc_mat(db, script, true, true);
|
||||
|
||||
// How many different SOLUTIONS ("CELLS") are defined in the script?
|
||||
const auto ids = pqc_mat.getIds();
|
||||
@ -111,10 +98,6 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
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
|
||||
@ -130,19 +113,11 @@ int main(int argc, char *argv[]) {
|
||||
// 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()));
|
||||
}
|
||||
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.;
|
||||
@ -152,15 +127,13 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
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";
|
||||
|
||||
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;
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#define POET_TEST(name) TEST(TestPOET, name)
|
||||
#define POET_TEST(name) TEST(litephreeqc, name)
|
||||
|
||||
namespace base_test {
|
||||
const std::string script = R"(SOLUTION 1
|
||||
@ -24,26 +24,10 @@ RUN_CELLS
|
||||
END)";
|
||||
|
||||
const std::vector<std::string> expected_names = {
|
||||
"ID", "H", "O", "Charge", "C(-4)", "C(4)", "Ca",
|
||||
"Cl", "Mg", "Na", "Calcite_eq", "Calcite_si", "Dolomite_eq", "Dolomite_si"};
|
||||
|
||||
const std::vector<double> expected_values = {1,
|
||||
111.01243522078478,
|
||||
55.506323405120348,
|
||||
-4.7919630342304069e-13,
|
||||
0,
|
||||
3.500625006800175e-05,
|
||||
0.12131244646561848,
|
||||
0.49999844804496646,
|
||||
0.078722559784449683,
|
||||
0.099999999999999978,
|
||||
0.95741011331883141,
|
||||
0,
|
||||
0.021277440215550378,
|
||||
0};
|
||||
|
||||
const std::vector<double> expected_errors = {
|
||||
0, 1e-3, 1e-3, 1e-15, 1e-5, 1e-5, 1e-5, 1e-5, 1e-5, 1e-5, 1e-5, 0, 1e-5, 0};
|
||||
"ID", "H", "O", "Charge", "tc",
|
||||
"patm", "SolVol", "pH", "pe", "C(-4)",
|
||||
"C(4)", "Ca", "Cl", "Mg", "Na",
|
||||
"Calcite_eq", "Calcite_si", "Dolomite_eq", "Dolomite_si"};
|
||||
|
||||
const std::string phreeqc_database = R"database(@POET_PHREEQCDAT_DB@)database";
|
||||
} // namespace base_test
|
||||
@ -56,59 +40,45 @@ const std::vector<std::string> expected_names = {"ID",
|
||||
"H",
|
||||
"O",
|
||||
"Charge",
|
||||
"tc",
|
||||
"patm",
|
||||
"SolVol",
|
||||
"pH",
|
||||
"pe",
|
||||
"Ba",
|
||||
"Cl",
|
||||
"S(-2)",
|
||||
"S(6)",
|
||||
"Sr",
|
||||
"Barite",
|
||||
"Barite_kin",
|
||||
"Barite_p1",
|
||||
"Celestite",
|
||||
"Celestite_kin",
|
||||
"Celestite_p1",
|
||||
"Celestite_eq",
|
||||
"Celestite_si"};
|
||||
|
||||
const std::vector<double> expected_values_line_one = {
|
||||
1,
|
||||
111.01243359383071,
|
||||
55.508698688362124,
|
||||
-1.2153078399577636e-09,
|
||||
1.0000001848805677e-12,
|
||||
1.0000000116187218e-12,
|
||||
0,
|
||||
0.00062047270964839664,
|
||||
0.00062047270964840271,
|
||||
std::numeric_limits<double>::quiet_NaN(),
|
||||
std::numeric_limits<double>::quiet_NaN(),
|
||||
std::numeric_limits<double>::quiet_NaN(),
|
||||
std::numeric_limits<double>::quiet_NaN(),
|
||||
0.99937952729135193,
|
||||
0};
|
||||
|
||||
const std::vector<double> expected_errors = {
|
||||
0,
|
||||
1e-3,
|
||||
1e-3,
|
||||
1e-15,
|
||||
1e-5,
|
||||
1e-5,
|
||||
1e-5,
|
||||
1e-5,
|
||||
1e-5,
|
||||
std::numeric_limits<double>::quiet_NaN(),
|
||||
std::numeric_limits<double>::quiet_NaN(),
|
||||
std::numeric_limits<double>::quiet_NaN(),
|
||||
std::numeric_limits<double>::quiet_NaN(),
|
||||
1e-5,
|
||||
0};
|
||||
|
||||
const std::vector<std::string> expected_names_erased = {
|
||||
"ID", "H", "O", "Charge", "Ba", "Cl", "S(-2)",
|
||||
"S(6)", "Sr", "Barite", "Barite_p1", "Celestite", "Celestite_p1"};
|
||||
const std::vector<std::string> expected_names_erased = {"ID",
|
||||
"H",
|
||||
"O",
|
||||
"Charge",
|
||||
"tc",
|
||||
"patm",
|
||||
"SolVol",
|
||||
"pH",
|
||||
"pe",
|
||||
"Ba",
|
||||
"Cl",
|
||||
"S(-2)",
|
||||
"S(6)",
|
||||
"Sr",
|
||||
"Barite_kin",
|
||||
"Barite_p1",
|
||||
"Celestite_kin",
|
||||
"Celestite_p1"};
|
||||
|
||||
const std::vector<std::string> expected_names_subset = {
|
||||
"ID", "H", "O", "Charge", "Ba", "Cl",
|
||||
"S(-2)", "S(6)", "Sr", "Celestite_eq", "Celestite_si"};
|
||||
"ID", "H", "O", "Charge", "tc", "patm", "SolVol", "pH",
|
||||
"pe", "Ba", "Cl", "S(-2)", "S(6)", "Sr", "Celestite_eq", "Celestite_si"};
|
||||
} // namespace barite_test
|
||||
|
||||
namespace test_engine {
|
||||
@ -128,4 +98,4 @@ const std::string script = R"(SOLUTION 1
|
||||
|
||||
const std::string phreeqc_database = R"database(@POET_PHREEQCDAT_DB@)database";
|
||||
|
||||
} // namespace test_engine
|
||||
} // namespace test_engine
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "IPhreeqcReader.hpp"
|
||||
#include "PhreeqcEngine.hpp"
|
||||
#include "PhreeqcMatrix.hpp"
|
||||
#include "utils.hpp"
|
||||
@ -36,20 +37,29 @@ POET_TEST(PhreeqcEngineStep) {
|
||||
|
||||
PhreeqcEngine engine(pqc_mat, 1);
|
||||
|
||||
IPhreeqcReader pqc_compare(test_database, base_test::script);
|
||||
|
||||
std::vector<double> cell_values = pqc_mat.get().values;
|
||||
std::vector<std::string> cell_names = pqc_mat.get().names;
|
||||
cell_values.erase(cell_values.begin(), cell_values.begin() + 1);
|
||||
cell_names.erase(cell_names.begin(), cell_names.begin() + 1);
|
||||
|
||||
EXPECT_NO_THROW(engine.runCell(cell_values, 0));
|
||||
EXPECT_NO_THROW(engine.runCell(cell_values, 100));
|
||||
|
||||
for (std::size_t i = 0; i < cell_values.size(); ++i) {
|
||||
// skip Charge, H(0) and O(0)
|
||||
if (i >= 2 && i <= 4) {
|
||||
pqc_compare.run(0, {1});
|
||||
pqc_compare.run(100, {1});
|
||||
|
||||
pqc_compare.setOutputID(1);
|
||||
|
||||
for (std::size_t i = 0; i < cell_names.size(); ++i) {
|
||||
// Somehow 'pe' will not result in a expected near value, therefore we skip
|
||||
// it
|
||||
if (cell_names[i] == "pe") {
|
||||
continue;
|
||||
}
|
||||
EXPECT_NEAR(cell_values[i], base_test::expected_values[i + 1],
|
||||
base_test::expected_errors[i + 1]);
|
||||
EXPECT_NEAR(cell_values[i], pqc_compare[cell_names[i]], 1e-6);
|
||||
}
|
||||
|
||||
EXPECT_THROW(engine.runCell(cell_values, -1), std::invalid_argument);
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
|
||||
#include <testInput.hpp>
|
||||
|
||||
#include "IPhreeqcReader.hpp"
|
||||
#include "PhreeqcMatrix.hpp"
|
||||
#include "utils.hpp"
|
||||
|
||||
@ -38,12 +39,18 @@ POET_TEST(PhreeqcMatrixOneSolution) {
|
||||
|
||||
PhreeqcMatrix::STLExport exported_init = pqc_mat.get();
|
||||
// ID + H,O,Charge + 6 Solutions + 4 Equil incl. params
|
||||
EXPECT_EQ(exported_init.names.size(), 14);
|
||||
EXPECT_EQ(exported_init.names.size(), 19);
|
||||
|
||||
IPhreeqcReader pqc_compare(base_db, base_test::script);
|
||||
pqc_compare.setOutputID(1);
|
||||
|
||||
EXPECT_EQ(exported_init.names, base_test::expected_names);
|
||||
for (std::size_t i = 0; i < exported_init.values.size(); ++i) {
|
||||
EXPECT_NEAR(exported_init.values[i], base_test::expected_values[i],
|
||||
base_test::expected_errors[i]);
|
||||
EXPECT_EQ(exported_init.values[0], 1);
|
||||
for (std::size_t i = 1; i < exported_init.values.size(); ++i) {
|
||||
EXPECT_NEAR(exported_init.values[i], pqc_compare[exported_init.names[i]],
|
||||
1e-7);
|
||||
// EXPECT_NEAR(exported_init.values[i], base_test::expected_values[i],
|
||||
// base_test::expected_errors[i]);
|
||||
}
|
||||
|
||||
auto dumps = pqc_mat.getDumpStringsPQI();
|
||||
@ -63,9 +70,12 @@ POET_TEST(PhreeqcMatrixOneSolution) {
|
||||
|
||||
POET_TEST(PhreeqcMatrixBracketOperator) {
|
||||
PhreeqcMatrix pqc_mat(base_db, base_test::script);
|
||||
IPhreeqcReader pqc_compare(base_db, base_test::script);
|
||||
|
||||
pqc_compare.setOutputID(1);
|
||||
|
||||
EXPECT_NO_THROW(pqc_mat(1, "H"));
|
||||
EXPECT_NEAR(pqc_mat(1, "H"), base_test::expected_values[1], 1e-5);
|
||||
EXPECT_NEAR(pqc_mat(1, "H"), pqc_compare["H"], 1e-7);
|
||||
EXPECT_ANY_THROW(pqc_mat(1, "J"));
|
||||
EXPECT_ANY_THROW(pqc_mat(2, "H"));
|
||||
}
|
||||
@ -76,6 +86,8 @@ const std::string barite_script = readFile(barite_test::script);
|
||||
POET_TEST(PhreeqcMatrixMultiSolution) {
|
||||
PhreeqcMatrix pqc_mat(barite_db, barite_script);
|
||||
|
||||
IPhreeqcReader pqc_compare(barite_db, barite_script);
|
||||
|
||||
const auto ids = pqc_mat.getIds();
|
||||
EXPECT_EQ(ids.size(), 4);
|
||||
EXPECT_EQ(ids[0], 1);
|
||||
@ -86,13 +98,17 @@ POET_TEST(PhreeqcMatrixMultiSolution) {
|
||||
PhreeqcMatrix::STLExport exported = pqc_mat.get();
|
||||
|
||||
EXPECT_EQ(exported.names, barite_test::expected_names);
|
||||
for (std::size_t i = 0; i < exported.names.size(); i++) {
|
||||
if (i > 8 && i < 13) {
|
||||
|
||||
pqc_compare.setOutputID(1);
|
||||
|
||||
for (std::size_t i = 1; i < exported.names.size(); i++) {
|
||||
if (i > 13 && i < 18) {
|
||||
EXPECT_TRUE(std::isnan(exported.values[i]));
|
||||
continue;
|
||||
}
|
||||
EXPECT_NEAR(exported.values[i], barite_test::expected_values_line_one[i],
|
||||
barite_test::expected_errors[i]);
|
||||
EXPECT_NEAR(exported.values[i], pqc_compare[exported.names[i]], 1e-7);
|
||||
// EXPECT_NEAR(exported.values[i], barite_test::expected_values_line_one[i],
|
||||
// barite_test::expected_errors[i]);
|
||||
}
|
||||
|
||||
auto dumps = pqc_mat.getDumpStringsPQI();
|
||||
@ -127,6 +143,8 @@ POET_TEST(PhreeqcMatrixCtor) {
|
||||
PhreeqcMatrix pqc_mat_copy(pqc_mat);
|
||||
PhreeqcMatrix pqc_mat_move(std::move(pqc_mat_copy));
|
||||
|
||||
IPhreeqcReader pqc_compare(barite_db, barite_script);
|
||||
|
||||
const auto ids = pqc_mat_move.getIds();
|
||||
EXPECT_EQ(ids.size(), 4);
|
||||
EXPECT_EQ(ids[0], 1);
|
||||
@ -137,13 +155,17 @@ POET_TEST(PhreeqcMatrixCtor) {
|
||||
PhreeqcMatrix::STLExport exported = pqc_mat_move.get();
|
||||
|
||||
EXPECT_EQ(exported.names, barite_test::expected_names);
|
||||
for (std::size_t i = 0; i < exported.names.size(); i++) {
|
||||
if (i > 8 && i < 13) {
|
||||
|
||||
pqc_compare.setOutputID(1);
|
||||
|
||||
for (std::size_t i = 1; i < exported.names.size(); i++) {
|
||||
if (i > 13 && i < 18) {
|
||||
EXPECT_TRUE(std::isnan(exported.values[i]));
|
||||
continue;
|
||||
}
|
||||
EXPECT_NEAR(exported.values[i], barite_test::expected_values_line_one[i],
|
||||
barite_test::expected_errors[i]);
|
||||
EXPECT_NEAR(exported.values[i], pqc_compare[exported.names[i]], 1e-7);
|
||||
// EXPECT_NEAR(exported.values[i], barite_test::expected_values_line_one[i],
|
||||
// barite_test::expected_errors[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -151,6 +173,8 @@ POET_TEST(PhreeqcMatrixOperator) {
|
||||
PhreeqcMatrix pqc_mat(barite_db, barite_script);
|
||||
PhreeqcMatrix pqc_mat_copy = pqc_mat;
|
||||
|
||||
IPhreeqcReader pqc_compare(barite_db, barite_script);
|
||||
|
||||
const auto ids = pqc_mat_copy.getIds();
|
||||
|
||||
EXPECT_EQ(ids.size(), 4);
|
||||
@ -162,13 +186,17 @@ POET_TEST(PhreeqcMatrixOperator) {
|
||||
PhreeqcMatrix::STLExport exported = pqc_mat_copy.get();
|
||||
|
||||
EXPECT_EQ(exported.names, barite_test::expected_names);
|
||||
for (std::size_t i = 0; i < exported.names.size(); i++) {
|
||||
if (i > 8 && i < 13) {
|
||||
|
||||
pqc_compare.setOutputID(1);
|
||||
|
||||
for (std::size_t i = 1; i < exported.names.size(); i++) {
|
||||
if (i > 13 && i < 18) {
|
||||
EXPECT_TRUE(std::isnan(exported.values[i]));
|
||||
continue;
|
||||
}
|
||||
EXPECT_NEAR(exported.values[i], barite_test::expected_values_line_one[i],
|
||||
barite_test::expected_errors[i]);
|
||||
EXPECT_NEAR(exported.values[i], pqc_compare[exported.names[i]], 1e-7);
|
||||
// EXPECT_NEAR(exported.values[i], barite_test::expected_values_line_one[i],
|
||||
// barite_test::expected_errors[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -227,8 +255,9 @@ POET_TEST(PhreeqcMatrixWithoutRedoxAndH0O0) {
|
||||
PhreeqcMatrix pqc_mat(barite_db, barite_script, false, false);
|
||||
|
||||
const std::vector<std::string> expected_names_without_redox = {
|
||||
"H", "O", "Charge", "Ba", "Cl", "S", "Sr",
|
||||
"H", "O", "Charge", "tc", "patm", "SolVol",
|
||||
"pH", "pe", "Ba", "Cl", "S", "Sr",
|
||||
};
|
||||
|
||||
EXPECT_EQ(expected_names_without_redox, pqc_mat.getSolutionNames());
|
||||
}
|
||||
}
|
||||
|
||||
@ -61,10 +61,10 @@ POET_TEST(PhreeqcRunnerSimulation) {
|
||||
const bool is_first_half = cell_index < half_cells;
|
||||
if (is_first_half) {
|
||||
EXPECT_EQ(simulationInOut[cell_index][0], expected_value_first_half);
|
||||
EXPECT_TRUE(std::isnan(simulationInOut[cell_index][9]));
|
||||
EXPECT_TRUE(std::isnan(simulationInOut[cell_index][14]));
|
||||
} else {
|
||||
EXPECT_EQ(simulationInOut[cell_index][0], expected_value_second_half);
|
||||
EXPECT_FALSE(std::isnan(simulationInOut[cell_index][9]));
|
||||
EXPECT_FALSE(std::isnan(simulationInOut[cell_index][14]));
|
||||
}
|
||||
|
||||
EXPECT_NEAR(simulationInOut[cell_index][1], 111, 1);
|
||||
@ -107,4 +107,4 @@ POET_TEST(PhreeqcRunnerSimulationWithIgnoredCells) {
|
||||
for (std::size_t i = 0; i < num_columns; ++i) {
|
||||
EXPECT_DOUBLE_EQ(simulationInOut[0][i], second_line[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1061,26 +1061,26 @@ void cxxSolution::read_raw(CParser &parser, bool check) {
|
||||
return;
|
||||
}
|
||||
|
||||
void cxxSolution::Update(LDBLE h_tot, LDBLE o_tot, LDBLE charge,
|
||||
void cxxSolution::Update(LDBLE h_tot, LDBLE o_tot, LDBLE charge, LDBLE tc, LDBLE patm,
|
||||
const cxxNameDouble &const_nd) {
|
||||
this->new_def = false;
|
||||
this->patm = 1.0;
|
||||
this->potV = 0.0;
|
||||
this->tc = 25.0;
|
||||
this->ph = 7.0;
|
||||
this->pe = 4.0;
|
||||
this->mu = 1e-7;
|
||||
this->ah2o = 1.0;
|
||||
this->patm = patm;
|
||||
// this->potV = 0.0;
|
||||
this->tc = tc;
|
||||
// this->ph = 7.0;
|
||||
// this->pe = 4.0;
|
||||
// this->mu = 1e-7;
|
||||
// this->ah2o = 1.0;
|
||||
// H, O, charge, totals, and activities of solution are updated
|
||||
this->total_h = h_tot;
|
||||
this->total_o = o_tot;
|
||||
this->cb = charge;
|
||||
this->mass_water = o_tot / 55.55;
|
||||
|
||||
this->density = 1.0;
|
||||
this->viscosity = 1.0;
|
||||
this->soln_vol = 1.0;
|
||||
this->total_alkalinity = 0.0;
|
||||
// this->density = 1.0;
|
||||
// this->viscosity = 1.0;
|
||||
// this->soln_vol = 1.0;
|
||||
// this->total_alkalinity = 0.0;
|
||||
|
||||
this->master_activity.clear();
|
||||
this->species_gamma.clear();
|
||||
|
||||
@ -123,7 +123,7 @@ public:
|
||||
// void modify_activities(const cxxSolution & original);
|
||||
// void Simplify_totals();
|
||||
void Update(const cxxNameDouble &nd);
|
||||
void Update(LDBLE h_tot, LDBLE o_tot, LDBLE charge, const cxxNameDouble &nd);
|
||||
void Update(LDBLE h_tot, LDBLE o_tot, LDBLE charge, LDBLE tc, LDBLE patm, const cxxNameDouble &nd);
|
||||
void Update_activities(const cxxNameDouble &original_tot);
|
||||
void Serialize(Dictionary &dictionary, std::vector<int> &ints,
|
||||
std::vector<double> &doubles);
|
||||
|
||||
@ -14,7 +14,8 @@
|
||||
#include "Phreeqc.h"
|
||||
#include <set>
|
||||
|
||||
const std::set<std::string> to_ignore = {"H", "O", "Charge", "H(0)", "O(0)"};
|
||||
const std::set<std::string> to_ignore = {
|
||||
"H", "O", "Charge", "tc", "patm", "SolVol", "pH", "pe", "H(0)", "O(0)"};
|
||||
|
||||
std::vector<std::string> Phreeqc::find_all_valence_states(
|
||||
const std::vector<std::string> &solution_names) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user