mirror of
https://git.gfz-potsdam.de/naaice/poet.git
synced 2025-12-15 12:28:22 +01:00
Merge branch 'ml/iphreeqc-v0.3' into 'main'
Update IPhreeqc Submodule to v0.3 See merge request naaice/poet!40
This commit is contained in:
commit
5c92a2156f
@ -1,61 +1,83 @@
|
||||
FROM gcc:11.2.0
|
||||
FROM gcc:11.2.0 AS builder
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y \
|
||||
git \
|
||||
sudo \
|
||||
git \
|
||||
ninja-build \
|
||||
fzf \
|
||||
libblas-dev && \
|
||||
libmpfr-dev \
|
||||
python3-dev && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /tmp
|
||||
|
||||
RUN curl -Ls https://download.open-mpi.org/release/open-mpi/v5.0/openmpi-5.0.5.tar.gz | tar xz && \
|
||||
cd openmpi-5.0.5 && \
|
||||
ARG OPENMPI_VERSION=4.1.1
|
||||
ADD https://download.open-mpi.org/release/open-mpi/v${OPENMPI_VERSION%.*}/openmpi-${OPENMPI_VERSION}.tar.gz /tmp/openmpi.tar.gz
|
||||
|
||||
RUN mkdir openmpi && \
|
||||
tar xf openmpi.tar.gz -C openmpi --strip-components 1 && \
|
||||
cd openmpi && \
|
||||
./configure --prefix=/usr/local && \
|
||||
make -j $(nproc) && \
|
||||
make install && \
|
||||
rm -rf /tmp/openmpi-5.0.5
|
||||
rm -rf /tmp/openmpi tmp/openmpi.tar.gz
|
||||
|
||||
RUN curl -Lo cmake.sh https://github.com/Kitware/CMake/releases/download/v3.30.5/cmake-3.30.5-linux-x86_64.sh \
|
||||
&& bash ./cmake.sh --skip-license --prefix=/usr/local \
|
||||
ARG CMAKE_VERSION=3.30.5
|
||||
ADD https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-x86_64.sh /tmp/cmake.sh
|
||||
|
||||
RUN bash ./cmake.sh --skip-license --prefix=/usr/local \
|
||||
&& rm cmake.sh
|
||||
|
||||
RUN curl -Ls https://github.com/Reference-LAPACK/lapack/archive/refs/tags/v3.12.0.tar.gz | tar xz && \
|
||||
cd lapack-3.12.0 && \
|
||||
ARG LAPACK_VERSION=3.12.0
|
||||
ADD https://github.com/Reference-LAPACK/lapack/archive/refs/tags/v${LAPACK_VERSION}.tar.gz /tmp/lapack.tar.gz
|
||||
|
||||
RUN mkdir lapack && \
|
||||
tar xf lapack.tar.gz -C lapack --strip-components 1 && \
|
||||
cd lapack && \
|
||||
mkdir build && \
|
||||
cd build && \
|
||||
cmake .. -G Ninja -DBUILD_SHARED_LIBS=ON && \
|
||||
ninja install && \
|
||||
rm -rf /tmp/lapack-3.12.0
|
||||
rm -rf /tmp/lapack tmp/lapack.tar.gz
|
||||
|
||||
RUN curl -Ls https://cran.r-project.org/src/base/R-4/R-4.4.2.tar.gz | tar xz && \
|
||||
cd R-4.4.2 && \
|
||||
ARG R_VERSION=4.4.2
|
||||
ADD https://cran.r-project.org/src/base/R-${R_VERSION%%.*}/R-${R_VERSION}.tar.gz /tmp/R.tar.gz
|
||||
|
||||
RUN mkdir R && \
|
||||
tar xf R.tar.gz -C R --strip-components 1 && \
|
||||
cd R && \
|
||||
./configure --prefix=/usr/local --enable-R-shlib --with-blas --with-lapack && \
|
||||
make -j $(nproc) && \
|
||||
make install && \
|
||||
rm -rf /tmp/R-4.4.2
|
||||
rm -rf /tmp/R tmp/R.tar.gz
|
||||
|
||||
RUN /usr/local/bin/R -q -e "install.packages(c('Rcpp', 'RInside', 'qs'), repos='https://cran.rstudio.com/')"
|
||||
|
||||
RUN curl -Ls https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.tar.bz2 | tar xj \
|
||||
&& mkdir /tmp/eigen-3.4.0/build \
|
||||
&& cd /tmp/eigen-3.4.0/build \
|
||||
&& cmake .. -G Ninja \
|
||||
&& ninja install \
|
||||
&& rm -rf /tmp/eigen-3.4.0
|
||||
ARG EIGEN_VERSION=3.4.0
|
||||
ADD https://gitlab.com/libeigen/eigen/-/archive/${EIGEN_VERSION}/eigen-${EIGEN_VERSION}.tar.bz2 /tmp/eigen.tar.bz2
|
||||
|
||||
RUN git clone https://github.com/doctest/doctest.git /doctest \
|
||||
&& cd /doctest \
|
||||
&& mkdir build \
|
||||
&& cd build \
|
||||
&& cmake .. \
|
||||
&& make install \
|
||||
&& rm -rf /doctest
|
||||
RUN mkdir eigen && \
|
||||
tar xf eigen.tar.bz2 -C eigen --strip-components 1 && \
|
||||
cd eigen && \
|
||||
mkdir build && \
|
||||
cd build && \
|
||||
cmake .. -G Ninja && \
|
||||
ninja install && \
|
||||
rm -rf /tmp/eigen tmp/eigen.tar.bz2
|
||||
|
||||
ARG GDB_VERSION=15.2
|
||||
ADD https://ftp.gnu.org/gnu/gdb/gdb-${GDB_VERSION}.tar.xz /tmp/gdb.tar.xz
|
||||
|
||||
RUN mkdir gdb && \
|
||||
tar xf gdb.tar.xz -C gdb --strip-components 1 && \
|
||||
cd gdb && \
|
||||
./configure --prefix=/usr/local && \
|
||||
make -j $(nproc) && \
|
||||
make install && \
|
||||
rm -rf /tmp/gdb tmp/gdb.tar.xz
|
||||
|
||||
RUN useradd -m -s /bin/bash -G sudo vscode \
|
||||
&& echo "vscode ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
|
||||
@ -64,7 +86,23 @@ USER vscode
|
||||
|
||||
ENV LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
|
||||
|
||||
RUN sudo apt-get update && \
|
||||
sudo apt-get install -y zsh && \
|
||||
sudo apt-get clean && \
|
||||
sudo rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN sh -c "$(wget -O- https://github.com/deluan/zsh-in-docker/releases/download/v1.2.1/zsh-in-docker.sh)" -- \
|
||||
-t agnoster
|
||||
-t agnoster \
|
||||
-p zsh-syntax-highlighting
|
||||
|
||||
RUN zsh -c "git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting"
|
||||
|
||||
RUN zsh -c "git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf && ~/.fzf/install"
|
||||
|
||||
RUN mkdir -p /home/vscode/.config/gdb \
|
||||
&& echo "set auto-load safe-path /" > /home/vscode/.config/gdb/gdbinit
|
||||
|
||||
ENV CMAKE_GENERATOR=Ninja
|
||||
ENV CMAKE_EXPORT_COMPILE_COMMANDS=ON
|
||||
|
||||
WORKDIR /home/vscode
|
||||
|
||||
@ -1 +1 @@
|
||||
Subproject commit 61214a01ad4cf99527f657e6a41c68282e4886c4
|
||||
Subproject commit 38268b4aad03e6ce4755315f4cd690f007fa2720
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
#include "PhreeqcEngine.hpp"
|
||||
#include "PhreeqcMatrix.hpp"
|
||||
#include "PhreeqcRunner.hpp"
|
||||
#include "SurrogateModels/DHT_Wrapper.hpp"
|
||||
#include "SurrogateModels/Interpolation.hpp"
|
||||
|
||||
@ -170,16 +171,9 @@ poet::ChemistryModule::ChemistryModule(
|
||||
if (!is_master) {
|
||||
PhreeqcMatrix pqc_mat =
|
||||
PhreeqcMatrix(chem_params.database, chem_params.pqc_script);
|
||||
for (const auto &cell_id : chem_params.pqc_ids) {
|
||||
this->phreeqc_instances[cell_id] =
|
||||
std::make_unique<PhreeqcEngine>(pqc_mat, cell_id);
|
||||
}
|
||||
// for (std::size_t i = 0; i < chem_params.pqc_ids.size(); i++) {
|
||||
// this->phreeqc_instances[chem_params.pqc_ids[i]] =
|
||||
// std::make_unique<PhreeqcWrapper>(
|
||||
// chem_params.database, chem_params.pqc_scripts[i],
|
||||
// chem_params.pqc_sol_order, chem_params.field_header, wp_size_);
|
||||
// }
|
||||
|
||||
this->pqc_runner =
|
||||
std::make_unique<PhreeqcRunner>(pqc_mat.subset(chem_params.pqc_ids));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -8,10 +8,11 @@
|
||||
#include "ChemistryDefs.hpp"
|
||||
|
||||
#include "Init/InitialList.hpp"
|
||||
#include "NameDouble.h"
|
||||
#include "SurrogateModels/DHT_Wrapper.hpp"
|
||||
#include "SurrogateModels/Interpolation.hpp"
|
||||
|
||||
#include "PhreeqcEngine.hpp"
|
||||
#include "PhreeqcRunner.hpp"
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
@ -390,7 +391,7 @@ protected:
|
||||
|
||||
const InitialList::ChemistryInit params;
|
||||
|
||||
std::map<int, std::unique_ptr<PhreeqcEngine>> phreeqc_instances;
|
||||
std::unique_ptr<PhreeqcRunner> pqc_runner;
|
||||
};
|
||||
} // namespace poet
|
||||
|
||||
|
||||
@ -48,13 +48,15 @@ void poet::ChemistryModule::WorkerLoop() {
|
||||
case CHEM_FIELD_INIT: {
|
||||
ChemBCast(&this->prop_count, 1, MPI_UINT32_T);
|
||||
if (this->ai_surrogate_enabled) {
|
||||
this->ai_surrogate_validity_vector.resize(this->n_cells); // resize statt reserve?
|
||||
this->ai_surrogate_validity_vector.resize(
|
||||
this->n_cells); // resize statt reserve?
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CHEM_AI_BCAST_VALIDITY: {
|
||||
// Receive the index vector of valid ai surrogate predictions
|
||||
MPI_Bcast(&this->ai_surrogate_validity_vector.front(), this->n_cells, MPI_INT, 0, this->group_comm);
|
||||
MPI_Bcast(&this->ai_surrogate_validity_vector.front(), this->n_cells,
|
||||
MPI_INT, 0, this->group_comm);
|
||||
break;
|
||||
}
|
||||
case CHEM_WORK_LOOP: {
|
||||
@ -187,7 +189,6 @@ void poet::ChemistryModule::WorkerDoWork(MPI_Status &probe_status,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
phreeqc_time_start = MPI_Wtime();
|
||||
|
||||
WorkerRunWorkPackage(s_curr_wp, current_sim_time, dt);
|
||||
@ -300,28 +301,19 @@ void poet::ChemistryModule::WorkerRunWorkPackage(WorkPackage &work_package,
|
||||
double dSimTime,
|
||||
double dTimestep) {
|
||||
|
||||
std::vector<std::vector<double>> inout_chem = work_package.input;
|
||||
std::vector<std::size_t> to_ignore;
|
||||
|
||||
for (std::size_t wp_id = 0; wp_id < work_package.size; wp_id++) {
|
||||
if (work_package.mapping[wp_id] != CHEM_PQC) {
|
||||
continue;
|
||||
to_ignore.push_back(wp_id);
|
||||
}
|
||||
}
|
||||
this->pqc_runner->run(inout_chem, dTimestep, to_ignore);
|
||||
|
||||
auto curr_input = work_package.input[wp_id];
|
||||
const auto pqc_id = static_cast<int>(curr_input[0]);
|
||||
|
||||
auto &phreeqc_instance = this->phreeqc_instances[pqc_id];
|
||||
work_package.output[wp_id] = work_package.input[wp_id];
|
||||
|
||||
curr_input.erase(std::remove_if(curr_input.begin(), curr_input.end(),
|
||||
[](double d) { return std::isnan(d); }),
|
||||
curr_input.end());
|
||||
|
||||
phreeqc_instance->runCell(curr_input, dTimestep);
|
||||
|
||||
std::size_t output_index = 0;
|
||||
for (std::size_t i = 0; i < work_package.output[wp_id].size(); i++) {
|
||||
if (!std::isnan(work_package.output[wp_id][i])) {
|
||||
work_package.output[wp_id][i] = curr_input[output_index++];
|
||||
}
|
||||
for (std::size_t wp_id = 0; wp_id < work_package.size; wp_id++) {
|
||||
if (work_package.mapping[wp_id] == CHEM_PQC) {
|
||||
work_package.output[wp_id] = inout_chem[wp_id];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user