Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fcfa45169d |
Binary file not shown.
@ -43,13 +43,13 @@ At a glance:
|
|||||||
\centering
|
\centering
|
||||||
\begin{tabular}{|c|c|}
|
\begin{tabular}{|c|c|}
|
||||||
\hline
|
\hline
|
||||||
Grid & 200x200 \\ \hline
|
Grid & 200x200 \\ \hline
|
||||||
Size & 1x1~m$^2$ \\ \hline
|
Size & 1x1~m$^2$ \\ \hline
|
||||||
Timestep & 1000~s \\ \hline
|
Timestep & 1000~s \\ \hline
|
||||||
Iterations & 50 \\ \hline
|
Iterations & 50 \\ \hline
|
||||||
$\alpha_x, \alpha_y$ & heter., aniso. \\\hline
|
$\alpha_x, \alpha_y$ & heter., aniso. \\\hline
|
||||||
Species \# & 7 \\ \hline
|
Species \# & 7 \\ \hline
|
||||||
Init & homog. \\ \hline
|
Init & homog. \\ \hline
|
||||||
\end{tabular}
|
\end{tabular}
|
||||||
\caption{Summary of parameters for the barite\_200 benchmark}
|
\caption{Summary of parameters for the barite\_200 benchmark}
|
||||||
\label{tab:b200}
|
\label{tab:b200}
|
||||||
@ -68,9 +68,9 @@ value of 0.1 molal \chem{BaCl_2}. All other boundaries are closed.
|
|||||||
\begin{table*}[!h]
|
\begin{table*}[!h]
|
||||||
\centering
|
\centering
|
||||||
\begin{tabular}{|r|r|r|r|r|r|r|r|}\hline
|
\begin{tabular}{|r|r|r|r|r|r|r|r|}\hline
|
||||||
& H & O & Charge & Ba & Cl & S\_6\_ & Sr \\\hline
|
& H & O & Charge & Ba & Cl & S\_6\_ & Sr \\\hline
|
||||||
\textbf{IC} & 110.0124 & 55.5086 & -1.2163e-09 & 4.4553e-07 & 2.0e-12 & 6.1516e-5 & 6.1472e-5 \\\hline
|
\textbf{IC} & 110.0124 & 55.5086 & -1.2163e-09 & 4.4553e-07 & 2.0e-12 & 6.1516e-5 & 6.1472e-5 \\\hline
|
||||||
\textbf{BC} & 111.0124 & 55.5062 & -3.3370e-08 & 0.1 & 0.2 & 0 & 0 \\\hline
|
\textbf{BC} & 111.0124 & 55.5062 & -3.3370e-08 & 0.1 & 0.2 & 0 & 0 \\\hline
|
||||||
\end{tabular}
|
\end{tabular}
|
||||||
\caption{Initial and boundary values of all transported variables in
|
\caption{Initial and boundary values of all transported variables in
|
||||||
the \texttt{barite\_200} benchmark.}
|
the \texttt{barite\_200} benchmark.}
|
||||||
@ -87,8 +87,8 @@ for $\alpha_x$ and $\alpha_y$ respectively:
|
|||||||
|
|
||||||
\begin{equation*}
|
\begin{equation*}
|
||||||
\begin{cases}
|
\begin{cases}
|
||||||
\displaystyle \alpha_x & \displaystyle = 10^{-7} + 10^{-6} \frac{\mathcal{F}-\min{(\mathcal{F})}}{\max{(\mathcal{F})}} \\
|
\displaystyle \alpha_x & \displaystyle = 10^{-7} + 10^{-6} \frac{\mathcal{F}-\min{(\mathcal{F})}}{\max{(\mathcal{F})}}\\
|
||||||
\alpha_y & \displaystyle = 10^{-7} + 10^{-7} \frac{\mathcal{F}-\min{(\mathcal{F})}}{\max{(\mathcal{F})}}
|
\alpha_y & \displaystyle = 10^{-7} + 10^{-7} \frac{\mathcal{F}-\min{(\mathcal{F})}}{\max{(\mathcal{F})}}
|
||||||
\end{cases}
|
\end{cases}
|
||||||
\end{equation*}
|
\end{equation*}
|
||||||
|
|
||||||
@ -111,7 +111,7 @@ benchmark.
|
|||||||
\end{figure}
|
\end{figure}
|
||||||
|
|
||||||
|
|
||||||
This benchmarks runs in $\sim$ 1.8~s on 18 CPUs on a System @ PERFACCT.
|
This benchmarks runs in $\sim$11~s on 8 CPUs on my desktop.
|
||||||
|
|
||||||
\clearpage
|
\clearpage
|
||||||
|
|
||||||
@ -128,13 +128,13 @@ At a glance:
|
|||||||
\centering
|
\centering
|
||||||
\begin{tabular}{|c|c|}
|
\begin{tabular}{|c|c|}
|
||||||
\hline
|
\hline
|
||||||
Grid & 1000x1000 \\ \hline
|
Grid & 1000x1000 \\ \hline
|
||||||
Size & 10x10~m \\ \hline
|
Size & 10x10~m \\ \hline
|
||||||
Timestep & 100~s \\ \hline
|
Timestep & 100~s \\ \hline
|
||||||
Iterations & 50 \\ \hline
|
Iterations & 50 \\ \hline
|
||||||
$\alpha$ & homog. 1E-6 \\\hline
|
$\alpha$ & homog. 1E-6 \\\hline
|
||||||
Species \# & 7 \\ \hline
|
Species \# & 7 \\ \hline
|
||||||
Init & heter. \\ \hline
|
Init & heter. \\ \hline
|
||||||
\end{tabular}
|
\end{tabular}
|
||||||
\caption{Summary of parameters for the \texttt{barite\_large} benchmark}
|
\caption{Summary of parameters for the \texttt{barite\_large} benchmark}
|
||||||
\label{tab:blarge}
|
\label{tab:blarge}
|
||||||
@ -181,7 +181,7 @@ record. The non-rounded values are read from file
|
|||||||
\texttt{barite\_200} benchmark\label{fig:blarge}}
|
\texttt{barite\_200} benchmark\label{fig:blarge}}
|
||||||
\end{figure}
|
\end{figure}
|
||||||
|
|
||||||
This benchmark runs in $\sim$6.4~s on my desktop using 18 CPUs.
|
This benchmark runs in $\sim$30~s on my desktop using 8 CPUs.
|
||||||
|
|
||||||
\clearpage
|
\clearpage
|
||||||
|
|
||||||
@ -197,7 +197,7 @@ glance:
|
|||||||
\centering
|
\centering
|
||||||
\begin{tabular}{|c|c|}
|
\begin{tabular}{|c|c|}
|
||||||
\hline
|
\hline
|
||||||
Grid & 200x100 \\ \hline
|
Grid & 200x100 \\ \hline
|
||||||
Size & 0.02x0.01~m \\ \hline
|
Size & 0.02x0.01~m \\ \hline
|
||||||
Timestep & 3600~s (1~h) \\ \hline
|
Timestep & 3600~s (1~h) \\ \hline
|
||||||
Iterations & 20 \\ \hline
|
Iterations & 20 \\ \hline
|
||||||
@ -216,28 +216,28 @@ boundaries are set to constant \textbf{BC} values. \textbf{Initial
|
|||||||
\begin{table*}[!h]
|
\begin{table*}[!h]
|
||||||
\centering
|
\centering
|
||||||
\begin{tabular}{|l|r|r|}\hline
|
\begin{tabular}{|l|r|r|}\hline
|
||||||
& \textbf{IC} & \textbf{BC} \\ \hline
|
& \textbf{IC} & \textbf{BC} \\ \hline
|
||||||
H & 1.11e+02 & 120.0 \\ \hline
|
H & 1.11e+02 & 120.0 \\ \hline
|
||||||
O & 5.55e+01 & 55.1 \\ \hline
|
O & 5.55e+01 & 55.1 \\ \hline
|
||||||
Charge & -2.0e-13 & 8.0e-17 \\ \hline
|
Charge & -2.0e-13 & 8.0e-17 \\ \hline
|
||||||
C & 2.0e-16 & 2.0e-15 \\ \hline
|
C & 2.0e-16 & 2.0e-15 \\ \hline
|
||||||
CH4 & 2.0e-03 & 0.2 \\ \hline
|
CH4 & 2.0e-03 & 0.2 \\ \hline
|
||||||
Ca & 2.0e-01 & 0.03 \\ \hline
|
Ca & 2.0e-01 & 0.03 \\ \hline
|
||||||
Cl & 3.0e-01 & 0.5 \\ \hline
|
Cl & 3.0e-01 & 0.5 \\ \hline
|
||||||
Fe2 & 1.4e-04 & 0.0002 \\ \hline
|
Fe2 & 1.4e-04 & 0.0002 \\ \hline
|
||||||
Fe3 & 1.3e-09 & 2.0e-08 \\ \hline
|
Fe3 & 1.3e-09 & 2.0e-08 \\ \hline
|
||||||
H0 & 6.0e-12 & 2.0e-11 \\ \hline
|
H0 & 6.0e-12 & 2.0e-11 \\ \hline
|
||||||
K & 2.0e-03 & 1.0e-05 \\ \hline
|
K & 2.0e-03 & 1.0e-05 \\ \hline
|
||||||
Mg & 1.0e-02 & 0.2 \\ \hline
|
Mg & 1.0e-02 & 0.2 \\ \hline
|
||||||
Na & 2.0e-01 & 0.3 \\ \hline
|
Na & 2.0e-01 & 0.3 \\ \hline
|
||||||
HS2 & 5.9e-10 & 0 \\ \hline
|
HS2 & 5.9e-10 & 0 \\ \hline
|
||||||
S2 & 8.3e-15 & 8.3e-12 \\ \hline
|
S2 & 8.3e-15 & 8.3e-12 \\ \hline
|
||||||
S4 & 2.1e-14 & 5.1e-14 \\ \hline
|
S4 & 2.1e-14 & 5.1e-14 \\ \hline
|
||||||
S6 & 1.6e-02 & 0.026 \\ \hline
|
S6 & 1.6e-02 & 0.026 \\ \hline
|
||||||
Sr & 4.5e-04 & 0.045 \\ \hline
|
Sr & 4.5e-04 & 0.045 \\ \hline
|
||||||
U4 & 2.5e-09 & 2.5e-08 \\ \hline
|
U4 & 2.5e-09 & 2.5e-08 \\ \hline
|
||||||
U5 & 1.6e-10 & 1.6e-10 \\ \hline
|
U5 & 1.6e-10 & 1.6e-10 \\ \hline
|
||||||
U6 & 2.3e-07 & 1.0e-05 \\ \hline
|
U6 & 2.3e-07 & 1.0e-05 \\ \hline
|
||||||
\end{tabular}
|
\end{tabular}
|
||||||
\caption{\texttt{surfex} benchmark, homogeneous initial conditions
|
\caption{\texttt{surfex} benchmark, homogeneous initial conditions
|
||||||
\textbf{IC} and boundary values \textbf{BC}}
|
\textbf{IC} and boundary values \textbf{BC}}
|
||||||
@ -260,7 +260,7 @@ boundaries are set to constant \textbf{BC} values. \textbf{Initial
|
|||||||
benchmark\label{fig:bsurf}}
|
benchmark\label{fig:bsurf}}
|
||||||
\end{figure}
|
\end{figure}
|
||||||
|
|
||||||
This benchmark runs in $\sim$1.1~s on my desktop using 18 CPUs.
|
This benchmark runs in $\sim$7~s on my desktop using 8 CPUs.
|
||||||
|
|
||||||
\clearpage
|
\clearpage
|
||||||
|
|
||||||
@ -314,7 +314,7 @@ equivalent):
|
|||||||
\begin{equation}
|
\begin{equation}
|
||||||
\label{eq:GMAQ}
|
\label{eq:GMAQ}
|
||||||
\text{Geometric Mean of Absolute Quotients} = \left(\prod
|
\text{Geometric Mean of Absolute Quotients} = \left(\prod
|
||||||
\left|\frac{\hat{y}_{i}}{y_i}\right|\right)^{\frac {1}{N}}
|
\left|\frac{\hat{y}_{i}}{y_i}\right|\right)^{\frac {1}{N}}
|
||||||
\end{equation}
|
\end{equation}
|
||||||
|
|
||||||
The geometric mean of the quotients would be 1 if the two variables
|
The geometric mean of the quotients would be 1 if the two variables
|
||||||
@ -325,7 +325,7 @@ of the terms:
|
|||||||
\begin{equation}
|
\begin{equation}
|
||||||
\label{eq:5}
|
\label{eq:5}
|
||||||
\exp \left[{\frac {1}{N}}\sum\log a_{i}\right]= \left(\prod
|
\exp \left[{\frac {1}{N}}\sum\log a_{i}\right]= \left(\prod
|
||||||
a_{i}\right)^{\frac {1}{N}}
|
a_{i}\right)^{\frac {1}{N}}
|
||||||
\end{equation}
|
\end{equation}
|
||||||
|
|
||||||
So the \chem{MAE_{log}} is the logarithm of the actual geometric mean
|
So the \chem{MAE_{log}} is the logarithm of the actual geometric mean
|
||||||
@ -337,9 +337,9 @@ error $\alpha_i$ as:
|
|||||||
\label{eq:relalpha}
|
\label{eq:relalpha}
|
||||||
\alpha_i =
|
\alpha_i =
|
||||||
\begin{cases}
|
\begin{cases}
|
||||||
\displaystyle \frac{ y_i-\hat{y_i}}{y_i} & \text{if~} \hspace{0.1cm} y_i,\hat{y}_i \neq 0 \\
|
\displaystyle \frac{ y_i-\hat{y_i}}{y_i} & \text{if~} \hspace{0.1cm} y_i,\hat{y}_i \neq 0 \\
|
||||||
1 & \text{if~} \hspace{0.1cm} y_i=0 \text{\hspace{0.1cm} and \hspace{0.1cm}} \hat{y}_i \neq 0 \\
|
1 & \text{if~} \hspace{0.1cm} y_i=0 \text{\hspace{0.1cm} and \hspace{0.1cm}} \hat{y}_i \neq 0 \\
|
||||||
0 & \text{if~} \hspace{0.1cm} y_i=0 \text{\hspace{0.1cm} and \hspace{0.1cm}} \hat{y}_i = 0 \\
|
0 & \text{if~} \hspace{0.1cm} y_i=0 \text{\hspace{0.1cm} and \hspace{0.1cm}} \hat{y}_i = 0 \\
|
||||||
\end{cases}
|
\end{cases}
|
||||||
\end{equation}
|
\end{equation}
|
||||||
|
|
||||||
@ -351,12 +351,12 @@ Absolute Percentage Error (\textbf{MAPE}) and Relative RMSE
|
|||||||
|
|
||||||
\begin{equation}
|
\begin{equation}
|
||||||
\label{eq:MAPE}
|
\label{eq:MAPE}
|
||||||
\text{MAPE} = \frac{100\%}{N}\sum \left| \alpha_i \right|
|
\text{MAPE} = \frac{100\%}{N}\sum \left| \alpha_i \right|
|
||||||
\end{equation}
|
\end{equation}
|
||||||
|
|
||||||
\begin{equation}
|
\begin{equation}
|
||||||
\label{eq:RRMSE}
|
\label{eq:RRMSE}
|
||||||
\text{RRMSE} = \sqrt{\frac{1}{N}\sum \left( \alpha_i\right)^2}
|
\text{RRMSE} = \sqrt{\frac{1}{N}\sum \left( \alpha_i\right)^2}
|
||||||
\end{equation}
|
\end{equation}
|
||||||
|
|
||||||
These relative measures account for discrepancies across all
|
These relative measures account for discrepancies across all
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
## Time-stamp: "Last modified 2024-04-10 22:38:14 delucia"
|
## Time-stamp: "Last modified 2024-04-11 15:28:06 delucia"
|
||||||
|
|
||||||
## Compile the fortran code. On Linux, if a fortran compiler is
|
## Compile the fortran code. On Linux, if a fortran compiler is
|
||||||
## installed, it should work out of the box
|
## installed, it should work out of the box
|
||||||
here <- getwd()
|
|
||||||
setwd("/home/work/simR/Rphree/SpecSim/")
|
setwd("/home/work/simR/Rphree/SpecSim/")
|
||||||
system("R CMD SHLIB SS_Sim.f SS_Vario.f -o SSlib.so")
|
system("R CMD SHLIB SS_Sim.f SS_Vario.f -o SSlib.so")
|
||||||
dyn.load("SSlib.so")
|
dyn.load("SSlib.so")
|
||||||
@ -10,11 +10,60 @@ dyn.load("SSlib.so")
|
|||||||
## Load the functions
|
## Load the functions
|
||||||
source("SS_Fun_sim.R")
|
source("SS_Fun_sim.R")
|
||||||
source("SS_Fun_vario.R")
|
source("SS_Fun_vario.R")
|
||||||
setwd(here)
|
setwd("/home/work/simR/Rphree/NAAICE_tug_input/build")
|
||||||
|
|
||||||
library(lattice)
|
library(lattice)
|
||||||
library(PoetUtils)
|
library(PoetUtils)
|
||||||
|
|
||||||
|
PlotField2 <- function (data, grid, nx, ny, contour = TRUE, nlevels = 12, breaks,
|
||||||
|
palette = "heat.colors", rev.palette = TRUE, scale = TRUE,
|
||||||
|
plot.axes = TRUE, ...)
|
||||||
|
{
|
||||||
|
if (!missing(grid)) {
|
||||||
|
xc <- unique(sort(grid$cell$XCOORD))
|
||||||
|
yc <- unique(sort(grid$cell$YCOORD))
|
||||||
|
nx <- length(xc)
|
||||||
|
ny <- length(yc)
|
||||||
|
if (!length(data) == nx * ny)
|
||||||
|
stop("Wrong nx, ny or grid")
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
xc <- seq(1, nx)
|
||||||
|
yc <- seq(1, ny)
|
||||||
|
}
|
||||||
|
z <- matrix(round(data, 6), ncol = nx, nrow = ny, byrow = TRUE)
|
||||||
|
pp <- t(z[rev(seq(1, nrow(z))), ])
|
||||||
|
if (missing(breaks)) {
|
||||||
|
breaks <- pretty(data, n = nlevels)
|
||||||
|
}
|
||||||
|
breakslen <- length(breaks)
|
||||||
|
colors <- do.call(palette, list(n = breakslen - 1))
|
||||||
|
if (rev.palette)
|
||||||
|
colors <- rev(colors)
|
||||||
|
if (scale) {
|
||||||
|
par(mfrow = c(1, 2))
|
||||||
|
nf <- layout(matrix(c(1, 2), 1, 2, byrow = TRUE), widths = c(4,
|
||||||
|
1))
|
||||||
|
}
|
||||||
|
par(las = 1, mar = c(5, 5, 3, 1))
|
||||||
|
image(xc, yc, pp, las = 1, asp = 1, breaks = breaks, col = colors,
|
||||||
|
axes = FALSE, ann = plot.axes, ...)
|
||||||
|
if (plot.axes) {
|
||||||
|
axis(1)
|
||||||
|
axis(2)
|
||||||
|
}
|
||||||
|
if (contour)
|
||||||
|
contour(unique(sort(xc)), unique(sort(yc)), pp, breaks = breaks,
|
||||||
|
add = TRUE)
|
||||||
|
if (scale) {
|
||||||
|
par(las = 1, mar = c(5, 1, 5, 5))
|
||||||
|
PlotImageScale(data, breaks = breaks, add.axis = FALSE,
|
||||||
|
axis.pos = 4, col = colors)
|
||||||
|
axis(4, at = breaks)
|
||||||
|
}
|
||||||
|
invisible(pp)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
## generate a grid. At the moment it must be a cartesian square grid
|
## generate a grid. At the moment it must be a cartesian square grid
|
||||||
## with number of cells a power of two, e.g. 128, 256, ...
|
## with number of cells a power of two, e.g. 128, 256, ...
|
||||||
@ -72,54 +121,6 @@ range(ax)
|
|||||||
range(ay)
|
range(ay)
|
||||||
|
|
||||||
|
|
||||||
PlotField2 <- function (data, grid, nx, ny, contour = TRUE, nlevels = 12, breaks,
|
|
||||||
palette = "heat.colors", rev.palette = TRUE, scale = TRUE,
|
|
||||||
plot.axes = TRUE, ...)
|
|
||||||
{
|
|
||||||
if (!missing(grid)) {
|
|
||||||
xc <- unique(sort(grid$cell$XCOORD))
|
|
||||||
yc <- unique(sort(grid$cell$YCOORD))
|
|
||||||
nx <- length(xc)
|
|
||||||
ny <- length(yc)
|
|
||||||
if (!length(data) == nx * ny)
|
|
||||||
stop("Wrong nx, ny or grid")
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
xc <- seq(1, nx)
|
|
||||||
yc <- seq(1, ny)
|
|
||||||
}
|
|
||||||
z <- matrix(round(data, 6), ncol = nx, nrow = ny, byrow = TRUE)
|
|
||||||
pp <- t(z[rev(seq(1, nrow(z))), ])
|
|
||||||
if (missing(breaks)) {
|
|
||||||
breaks <- pretty(data, n = nlevels)
|
|
||||||
}
|
|
||||||
breakslen <- length(breaks)
|
|
||||||
colors <- do.call(palette, list(n = breakslen - 1))
|
|
||||||
if (rev.palette)
|
|
||||||
colors <- rev(colors)
|
|
||||||
if (scale) {
|
|
||||||
par(mfrow = c(1, 2))
|
|
||||||
nf <- layout(matrix(c(1, 2), 1, 2, byrow = TRUE), widths = c(4,
|
|
||||||
1))
|
|
||||||
}
|
|
||||||
par(las = 1, mar = c(5, 5, 3, 1))
|
|
||||||
image(xc, yc, pp, las = 1, asp = 1, breaks = breaks, col = colors,
|
|
||||||
axes = FALSE, ann = plot.axes, ...)
|
|
||||||
if (plot.axes) {
|
|
||||||
axis(1)
|
|
||||||
axis(2)
|
|
||||||
}
|
|
||||||
if (contour)
|
|
||||||
contour(unique(sort(xc)), unique(sort(yc)), pp, breaks = breaks,
|
|
||||||
add = TRUE)
|
|
||||||
if (scale) {
|
|
||||||
par(las = 1, mar = c(5, 1, 5, 5))
|
|
||||||
PlotImageScale(data, breaks = breaks, add.axis = FALSE,
|
|
||||||
axis.pos = 4, col = colors)
|
|
||||||
axis(4, at = breaks)
|
|
||||||
}
|
|
||||||
invisible(pp)
|
|
||||||
}
|
|
||||||
|
|
||||||
PlotField2(log10(ax), nx=200, ny=200, contour = FALSE, xaxs="i", yaxs="i", nlevels=6, plot.axes = FALSE)
|
PlotField2(log10(ax), nx=200, ny=200, contour = FALSE, xaxs="i", yaxs="i", nlevels=6, plot.axes = FALSE)
|
||||||
|
|
||||||
@ -322,3 +323,125 @@ PlotField2((out$Cl), nx=nx, ny=ny, contour = FALSE, nlevels=10,
|
|||||||
|
|
||||||
dev.off()
|
dev.off()
|
||||||
|
|
||||||
|
##### debug, grid 200x100
|
||||||
|
|
||||||
|
nx <- 200
|
||||||
|
ny <- 100
|
||||||
|
|
||||||
|
alphamat <- matrix(1.1e-11, nrow = ny, ncol = nx)
|
||||||
|
data.table::fwrite(alphamat, "debug_alpha.csv", col.names = FALSE)
|
||||||
|
|
||||||
|
a <- read.table(
|
||||||
|
textConnection(
|
||||||
|
"H 1.11e+02 120.0,
|
||||||
|
O 5.55e+01 55.1,
|
||||||
|
Charge -2.0e-13 8.0e-17,
|
||||||
|
C(-4) 2.0e-16 2.0e-15,
|
||||||
|
C(4) 2.0e-03 0.2,
|
||||||
|
Ca 2.0e-01 0.03,
|
||||||
|
Cl 3.0e-01 0.5,
|
||||||
|
Fe(2) 1.4e-04 0.0002,
|
||||||
|
Fe(3) 1.3e-09 2.0e-08,
|
||||||
|
H(0) 6.0e-12 2.0e-11,
|
||||||
|
K 2.0e-03 1.0e-05,
|
||||||
|
Mg 1.0e-02 0.2,
|
||||||
|
Na 2.0e-01 0.3,
|
||||||
|
S(-2) 5.9e-10 0,
|
||||||
|
S(2) 8.3e-15 8.3e-12,
|
||||||
|
S(4) 2.1e-14 5.1e-14,
|
||||||
|
S(6) 1.6e-02 0.026,
|
||||||
|
Sr 4.5e-04 0.045,
|
||||||
|
U(4) 2.5e-09 2.5e-08,
|
||||||
|
U(5) 1.6e-10 1.6e-10,
|
||||||
|
U(6) 2.3e-07 1.0e-05"
|
||||||
|
))
|
||||||
|
vals <- t(a[, 2:3])
|
||||||
|
|
||||||
|
nams <- c("H", "O", "Charge", "CH4", "C", "Ca", "Cl", "Fe2", "Fe3",
|
||||||
|
"H0", "K", "Mg", "Na", "HS2", "S2", "S4", "S6","Sr", "U4",
|
||||||
|
"U5", "U6")
|
||||||
|
colnames(vals) <- nams
|
||||||
|
rownames(vals) <- c("IC", "BC")
|
||||||
|
vals
|
||||||
|
|
||||||
|
length(nams)
|
||||||
|
|
||||||
|
dim(vals)
|
||||||
|
t(vals)
|
||||||
|
|
||||||
|
ic <- matrix(rep(vals[1,], nx*ny), nrow = nx*ny, byrow = TRUE)
|
||||||
|
|
||||||
|
colnames(ic) <- nams
|
||||||
|
|
||||||
|
data.table::fwrite(ic, "debug_init.csv", col.names = TRUE)
|
||||||
|
|
||||||
|
|
||||||
|
dput(vals[2,])
|
||||||
|
|
||||||
|
out <- fread("debug_output.csv")
|
||||||
|
|
||||||
|
x11()
|
||||||
|
|
||||||
|
## cairo_pdf("debug_field_U6.pdf", width = 10, height = 6, family="serif")
|
||||||
|
# out <- fread("./debug_output.csv")
|
||||||
|
PlotField2(log10(out$U6), nx=nx, ny=ny, contour = FALSE, nlevels=10,
|
||||||
|
palette = "cm.colors", plot.axes = FALSE, rev.palette = FALSE)
|
||||||
|
##dev.off()
|
||||||
|
|
||||||
|
## cairo_pdf("debug_field_Na.pdf", width = 10, height = 6, family="serif")
|
||||||
|
out2 <- fread("./debug_output.csv")
|
||||||
|
PlotField2(out2$Na, nx=nx, ny=ny, contour = FALSE, nlevels=10,
|
||||||
|
palette = "topo.colors", plot.axes = FALSE, rev.palette = TRUE)
|
||||||
|
## dev.off()
|
||||||
|
out2$Na[seq(1, 200)]
|
||||||
|
|
||||||
|
range(out2$Na)
|
||||||
|
|
||||||
|
|
||||||
|
PlotField2(log10(out$U4), nx=nx, ny=ny, contour = FALSE, nlevels=10,
|
||||||
|
palette = "terrain.colors", plot.axes = FALSE)
|
||||||
|
out$U4[seq(50*200, 51*200)]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
PlotField2(out2$Fe3, nx=nx, ny=ny, contour = FALSE, nlevels=10,
|
||||||
|
palette = "terrain.colors", plot.axes = FALSE)
|
||||||
|
|
||||||
|
out2$Na[seq(20*200, 21*200)]
|
||||||
|
|
||||||
|
out$Cl[seq(50*200, 51*200)]
|
||||||
|
|
||||||
|
|
||||||
|
PlotField2(log10(out$Fe2), nx=nx, ny=ny, contour = FALSE, nlevels=12,
|
||||||
|
palette = "terrain.colors", plot.axes = FALSE)
|
||||||
|
|
||||||
|
PlotField2((out$Cl), nx=nx, ny=ny, contour = FALSE, nlevels=10,
|
||||||
|
palette = "terrain.colors", plot.axes = FALSE)
|
||||||
|
|
||||||
|
|
||||||
|
dev.off()
|
||||||
|
|
||||||
|
library(Rcpp)
|
||||||
|
|
||||||
|
cppFunction("static const std::vector<int> gen_seq(int from, int to) {
|
||||||
|
int vsize = to - from + 1;
|
||||||
|
std::vector<int> vec(vsize);
|
||||||
|
for (int i = 0; i < vsize; i++) {
|
||||||
|
vec[i] = i+from;
|
||||||
|
}
|
||||||
|
return vec;
|
||||||
|
}")
|
||||||
|
|
||||||
|
gen_seq(24, 49)
|
||||||
|
|
||||||
|
cppFunction("static const std::vector<int> gen_vec(int elems) {
|
||||||
|
std::vector<int> vec(elems);
|
||||||
|
for (int i = 0; i < elems; i++) {
|
||||||
|
vec[i] = i;
|
||||||
|
}
|
||||||
|
return vec;
|
||||||
|
}")
|
||||||
|
|
||||||
|
|
||||||
|
gen_vec(20)
|
||||||
|
|||||||
@ -41,14 +41,12 @@ static const std::vector<int> gen_vec(int elems) {
|
|||||||
return vec;
|
return vec;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const std::vector<int> gen_vec_rev(int from, int to) {
|
static const std::vector<int> gen_seq(int from, int to) {
|
||||||
int size = to - from+1;
|
int vsize = to - from + 1;
|
||||||
std::vector<int> vec(size);
|
std::vector<int> vec(vsize);
|
||||||
for (int i = from; i < to; i++) {
|
for (int i = 0; i < vsize; i++) {
|
||||||
vec[i] = i;
|
vec[i] = i+from;
|
||||||
std::cout << "i: " << i << "\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return vec;
|
return vec;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,6 +85,7 @@ static bench_input barite_large_input = {
|
|||||||
.iterations = 5
|
.iterations = 5
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static bench_input surfex_input = {
|
static bench_input surfex_input = {
|
||||||
.csv_file_init = "@SURFEX_BENCH@/surfex_init.csv",
|
.csv_file_init = "@SURFEX_BENCH@/surfex_init.csv",
|
||||||
.csv_alpha_x = "@SURFEX_BENCH@/surfex_alpha.csv",
|
.csv_alpha_x = "@SURFEX_BENCH@/surfex_alpha.csv",
|
||||||
@ -124,30 +123,41 @@ static bench_input surfex_input = {
|
|||||||
.iterations = 20
|
.iterations = 20
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static bench_input debug_input = {
|
||||||
|
.csv_file_init = "@SURFEX_BENCH@/surfex_init.csv",
|
||||||
|
.csv_alpha_x = "@SURFEX_BENCH@/surfex_alpha.csv",
|
||||||
|
.csv_alpha_y = "@SURFEX_BENCH@/surfex_alpha.csv",
|
||||||
|
.ncols = 200,
|
||||||
|
.nrows = 100,
|
||||||
|
.s_x = 0.02,
|
||||||
|
.s_y = 0.01,
|
||||||
|
.boundary = {.north_const = gen_vec(100),
|
||||||
|
.south_const = gen_seq(1, 19),
|
||||||
|
.east_const = {},
|
||||||
|
.west_const = gen_seq(50, 99),
|
||||||
|
.values = {120.0, // H
|
||||||
|
55.1, // O
|
||||||
|
8.0e-17, // Charge
|
||||||
|
2.0e-15, // CH4
|
||||||
|
0.2, // C
|
||||||
|
0.03, // Ca
|
||||||
|
0.5, // Cl
|
||||||
|
0.0002, // Fe2
|
||||||
|
2.0e-08, // Fe3
|
||||||
|
2.0e-11, // H0
|
||||||
|
1.0e-05, // K
|
||||||
|
0.2, // Mg
|
||||||
|
0.3, // Na
|
||||||
|
0, // HS2
|
||||||
|
8.3e-12, // S2
|
||||||
|
5.1e-14, // S4
|
||||||
|
0.026, // S6
|
||||||
|
0.045, // Sr
|
||||||
|
2.5e-08, // U4
|
||||||
|
1.6e-10, // U5
|
||||||
|
1.0e-05}}, // U6
|
||||||
|
.timestep = 86400,
|
||||||
|
.iterations = 20
|
||||||
|
};
|
||||||
|
|
||||||
#endif // _BENCH_DEFS_HPP
|
#endif // _BENCH_DEFS_HPP
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
43
src/main.cpp
43
src/main.cpp
@ -23,29 +23,40 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (with_output) {
|
if (with_output) {
|
||||||
std::cout << "BARITE_200 started with output... ";
|
// std::cout << "BARITE_200 started with output... ";
|
||||||
timings[0] = run_bench(barite_200_input, "barite_200_output.csv");
|
// timings[0] = run_bench(barite_200_input, "barite_200_output.csv");
|
||||||
std::cout << "Runtime: " << timings[0] << " [ms]\n";
|
// std::cout << "Runtime: " << timings[0] << " [ms]\n";
|
||||||
|
|
||||||
std::cout << "BARITE_LARGE started with output... ";
|
// std::cout << "BARITE_LARGE started with output... ";
|
||||||
timings[1] = run_bench(barite_large_input, "barite_large_output.csv");
|
// timings[1] = run_bench(barite_large_input, "barite_large_output.csv");
|
||||||
std::cout << "Runtime: " << timings[1] << " [ms]\n";
|
// std::cout << "Runtime: " << timings[1] << " [ms]\n";
|
||||||
|
|
||||||
std::cout << "SURFEX started with output... ";
|
// std::cout << "SURFEX started with output... ";
|
||||||
timings[2] = run_bench(surfex_input, "surfex_output.csv");
|
// timings[2] = run_bench(surfex_input, "surfex_output.csv");
|
||||||
|
// std::cout << "Runtime: " << timings[2] << " [ms]\n";
|
||||||
|
|
||||||
|
std::cout << "DEBUG started with output... ";
|
||||||
|
timings[2] = run_bench(debug_input, "debug_output.csv");
|
||||||
std::cout << "Runtime: " << timings[2] << " [ms]\n";
|
std::cout << "Runtime: " << timings[2] << " [ms]\n";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
std::cout << "BARITE_200 started with no output... ";
|
|
||||||
timings[0] = run_bench(barite_200_input);
|
|
||||||
std::cout << " Runtime: " << timings[0] << " [ms]\n";
|
|
||||||
|
|
||||||
std::cout << "BARITE_LARGE started with no output... ";
|
// std::cout << "BARITE_200 started with no output... ";
|
||||||
timings[1] = run_bench(barite_large_input);
|
// timings[0] = run_bench(barite_200_input);
|
||||||
std::cout << "Runtime: " << timings[1] << " [ms]\n";
|
// std::cout << " Runtime: " << timings[0] << " [ms]\n";
|
||||||
|
|
||||||
std::cout << "SURFEX started with no output... ";
|
// std::cout << "BARITE_LARGE started with no output... ";
|
||||||
timings[2] = run_bench(surfex_input);
|
// timings[1] = run_bench(barite_large_input);
|
||||||
|
// std::cout << "Runtime: " << timings[1] << " [ms]\n";
|
||||||
|
|
||||||
|
// std::cout << "SURFEX started with no output... ";
|
||||||
|
// timings[2] = run_bench(surfex_input);
|
||||||
|
// std::cout << "Runtime: " << timings[2] << " [ms]\n";
|
||||||
|
|
||||||
|
std::cout << "DEBUG started with no output... ";
|
||||||
|
timings[2] = run_bench(debug_input);
|
||||||
std::cout << "Runtime: " << timings[2] << " [ms]\n";
|
std::cout << "Runtime: " << timings[2] << " [ms]\n";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
|||||||
25
src/run.cpp
25
src/run.cpp
@ -15,6 +15,26 @@
|
|||||||
|
|
||||||
#include <Eigen/Eigen>
|
#include <Eigen/Eigen>
|
||||||
|
|
||||||
|
using TugType = double;
|
||||||
|
|
||||||
|
using RowMajorMat =
|
||||||
|
Eigen::Matrix<TugType, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>;
|
||||||
|
|
||||||
|
static inline std::vector<TugType>
|
||||||
|
eigenMatrix_to_vector(const Eigen::MatrixX<TugType> &mat) {
|
||||||
|
if (mat.IsRowMajor) {
|
||||||
|
return std::vector<TugType>(mat.data(), mat.data() + mat.size());
|
||||||
|
} else {
|
||||||
|
std::vector<TugType> out_vec(mat.size());
|
||||||
|
for (int i = 0; i < mat.rows(); i++) {
|
||||||
|
for (int j = 0; j < mat.cols(); j++) {
|
||||||
|
out_vec[i * mat.cols() + j] = mat(i, j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out_vec;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
double run_bench(const bench_input &input, const std::string &output_file) {
|
double run_bench(const bench_input &input, const std::string &output_file) {
|
||||||
std::vector<std::vector<double>> raw_data =
|
std::vector<std::vector<double>> raw_data =
|
||||||
read_conc_csv<double>(input.csv_file_init, input.ncols, input.nrows);
|
read_conc_csv<double>(input.csv_file_init, input.ncols, input.nrows);
|
||||||
@ -65,11 +85,6 @@ double run_bench(const bench_input &input, const std::string &output_file) {
|
|||||||
|
|
||||||
tug::Simulation<TugType> sim(grid, boundary);
|
tug::Simulation<TugType> sim(grid, boundary);
|
||||||
|
|
||||||
if (const char *out = std::getenv("OMP_NUM_THREADS")) {
|
|
||||||
int ompNumThreads = std::stoi(out, NULL);
|
|
||||||
sim.setNumberThreads(ompNumThreads);
|
|
||||||
}
|
|
||||||
|
|
||||||
sim.setTimestep(input.timestep);
|
sim.setTimestep(input.timestep);
|
||||||
sim.setIterations(input.iterations);
|
sim.setIterations(input.iterations);
|
||||||
|
|
||||||
|
|||||||
21
src/run.hpp
21
src/run.hpp
@ -1,29 +1,8 @@
|
|||||||
#ifndef _RUN_HPP
|
#ifndef _RUN_HPP
|
||||||
#define _RUN_HPP
|
#define _RUN_HPP
|
||||||
|
|
||||||
#include <Eigen/Eigen>
|
|
||||||
#include <bench_defs.hpp>
|
#include <bench_defs.hpp>
|
||||||
|
|
||||||
using TugType = double;
|
|
||||||
|
|
||||||
using RowMajorMat =
|
|
||||||
Eigen::Matrix<TugType, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>;
|
|
||||||
|
|
||||||
double run_bench(const bench_input &input, const std::string &output_file = "");
|
double run_bench(const bench_input &input, const std::string &output_file = "");
|
||||||
|
|
||||||
static inline std::vector<TugType>
|
|
||||||
eigenMatrix_to_vector(const Eigen::MatrixX<TugType> &mat) {
|
|
||||||
if (mat.IsRowMajor) {
|
|
||||||
return std::vector<TugType>(mat.data(), mat.data() + mat.size());
|
|
||||||
} else {
|
|
||||||
std::vector<TugType> out_vec(mat.size());
|
|
||||||
for (int i = 0; i < mat.rows(); i++) {
|
|
||||||
for (int j = 0; j < mat.cols(); j++) {
|
|
||||||
out_vec[i * mat.cols() + j] = mat(i, j);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return out_vec;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // _RUN_HPP
|
#endif // _RUN_HPP
|
||||||
Loading…
x
Reference in New Issue
Block a user