mirror of
https://git.gfz-potsdam.de/naaice/tug.git
synced 2025-12-15 18:38:23 +01:00
MDL updating docs and docs_sphinx
This commit is contained in:
parent
2294922a3e
commit
eb2a9774a5
@ -1,6 +1,7 @@
|
|||||||
#+TITLE: Finite Difference Schemes for the numerical solution of heterogeneous diffusion equation in 2D
|
#+TITLE: Finite Difference Schemes for the numerical solution of heterogeneous diffusion equation in 2D
|
||||||
#+LaTeX_CLASS_OPTIONS: [a4paper,10pt]
|
#+LaTeX_CLASS_OPTIONS: [a4paper,10pt]
|
||||||
#+LATEX_HEADER: \usepackage{fullpage}
|
#+LATEX_HEADER: \usepackage{fullpage}
|
||||||
|
#+LATEX_HEADER: \usepackage{charter}
|
||||||
#+LATEX_HEADER: \usepackage{amsmath, systeme, cancel, xcolor}
|
#+LATEX_HEADER: \usepackage{amsmath, systeme, cancel, xcolor}
|
||||||
#+OPTIONS: toc:nil
|
#+OPTIONS: toc:nil
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@ -1,12 +1,12 @@
|
|||||||
#+TITLE: 2D Validation Examples
|
#+TITLE: Validation Examples for 2D Heterogeneous Diffusion
|
||||||
#+AUTHOR: MDL <delucia@gfz-potsdam.de>
|
#+AUTHOR: MDL <delucia@gfz-potsdam.de>
|
||||||
#+DATE: 2023-07-31
|
#+DATE: 2023-08-26
|
||||||
#+STARTUP: inlineimages
|
#+STARTUP: inlineimages
|
||||||
#+LATEX_CLASS_OPTIONS: [a4paper,9pt]
|
#+LATEX_CLASS_OPTIONS: [a4paper,9pt]
|
||||||
#+LATEX_HEADER: \usepackage{fullpage}
|
#+LATEX_HEADER: \usepackage{fullpage}
|
||||||
#+LATEX_HEADER: \usepackage{amsmath, systeme}
|
#+LATEX_HEADER: \usepackage{amsmath, systeme}
|
||||||
#+LATEX_HEADER: \usepackage{graphicx}
|
#+LATEX_HEADER: \usepackage{graphicx}
|
||||||
#+LATEX_HEADER: \usepackage{}
|
#+LATEX_HEADER: \usepackage{charter}
|
||||||
#+OPTIONS: toc:nil
|
#+OPTIONS: toc:nil
|
||||||
|
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ constant in 4 quadrants:
|
|||||||
The relevant part of the R script used to produce these results is
|
The relevant part of the R script used to produce these results is
|
||||||
presented in listing 1; the whole script is at [[file:scripts/HetDiff.R]].
|
presented in listing 1; the whole script is at [[file:scripts/HetDiff.R]].
|
||||||
A visualization of the output of the reference simulation is given in
|
A visualization of the output of the reference simulation is given in
|
||||||
figure [[#fig:1][1]].
|
figure [[fig:1][1]].
|
||||||
|
|
||||||
Note: all results from this script are stored in the =outc= matrix by
|
Note: all results from this script are stored in the =outc= matrix by
|
||||||
the =deSolve= function. I stored a different version into
|
the =deSolve= function. I stored a different version into
|
||||||
@ -47,68 +47,69 @@ for each time step including initial conditions) and 121 rows, one for
|
|||||||
each domain element, with no headers.
|
each domain element, with no headers.
|
||||||
|
|
||||||
#+caption: Result of ReacTran/deSolve solution of the above problem at 4
|
#+caption: Result of ReacTran/deSolve solution of the above problem at 4
|
||||||
|
#+name: fig:1
|
||||||
[[./images/deSolve_AlphaHet1.png]]
|
[[./images/deSolve_AlphaHet1.png]]
|
||||||
|
|
||||||
|
|
||||||
#+name: lst:1
|
#+name: lst:1
|
||||||
#+begin_src R :language R :frame single :caption Listing 1, generate reference simulation using R packages deSolve/ReacTran :captionpos b :label lst:1
|
#+begin_src R :language R :frame single :caption Listing 1, generate reference simulation using R packages deSolve/ReacTran :captionpos b :label lst:1
|
||||||
library(ReacTran)
|
library(ReacTran)
|
||||||
library(deSolve)
|
library(deSolve)
|
||||||
|
|
||||||
## harmonic mean
|
## harmonic mean
|
||||||
harm <- function(x,y) {
|
harm <- function(x,y) {
|
||||||
if (length(x) != 1 || length(y) != 1)
|
if (length(x) != 1 || length(y) != 1)
|
||||||
stop("x & y have different lengths")
|
stop("x & y have different lengths")
|
||||||
2/(1/x+1/y)
|
2/(1/x+1/y)
|
||||||
}
|
}
|
||||||
|
|
||||||
N <- 11 # number of grid cells
|
N <- 11 # number of grid cells
|
||||||
ini <- 1 # initial value at x=0
|
ini <- 1 # initial value at x=0
|
||||||
N2 <- ceiling(N/2)
|
N2 <- ceiling(N/2)
|
||||||
L <- 10 # domain side
|
L <- 10 # domain side
|
||||||
|
|
||||||
## Define diff.coeff per cell, in 4 quadrants
|
## Define diff.coeff per cell, in 4 quadrants
|
||||||
alphas <- matrix(0, N, N)
|
alphas <- matrix(0, N, N)
|
||||||
alphas[1:N2, 1:N2] <- 1
|
alphas[1:N2, 1:N2] <- 1
|
||||||
alphas[1:N2, seq(N2+1,N)] <- 0.1
|
alphas[1:N2, seq(N2+1,N)] <- 0.1
|
||||||
alphas[seq(N2+1,N), 1:N2] <- 0.01
|
alphas[seq(N2+1,N), 1:N2] <- 0.01
|
||||||
alphas[seq(N2+1,N), seq(N2+1,N)] <- 0.001
|
alphas[seq(N2+1,N), seq(N2+1,N)] <- 0.001
|
||||||
|
|
||||||
cmpharm <- function(x) {
|
cmpharm <- function(x) {
|
||||||
y <- c(0, x, 0)
|
y <- c(0, x, 0)
|
||||||
ret <- numeric(length(x)+1)
|
ret <- numeric(length(x)+1)
|
||||||
for (i in seq(2, length(y))) {
|
for (i in seq(2, length(y))) {
|
||||||
ret[i-1] <- harm(y[i], y[i-1])
|
ret[i-1] <- harm(y[i], y[i-1])
|
||||||
}
|
}
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
|
|
||||||
## Construction of the 2D grid
|
## Construction of the 2D grid
|
||||||
x.grid <- setup.grid.1D(x.up = 0, L = L, N = N)
|
x.grid <- setup.grid.1D(x.up = 0, L = L, N = N)
|
||||||
y.grid <- setup.grid.1D(x.up = 0, L = L, N = N)
|
y.grid <- setup.grid.1D(x.up = 0, L = L, N = N)
|
||||||
grid2D <- setup.grid.2D(x.grid, y.grid)
|
grid2D <- setup.grid.2D(x.grid, y.grid)
|
||||||
dx <- dy <- L/N
|
dx <- dy <- L/N
|
||||||
|
|
||||||
D.grid <- list()
|
D.grid <- list()
|
||||||
## Diffusion coefs on x-interfaces
|
## Diffusion coefs on x-interfaces
|
||||||
D.grid$x.int <- apply(alphas, 1, cmpharm)
|
D.grid$x.int <- apply(alphas, 1, cmpharm)
|
||||||
## Diffusion coefs on y-interfaces
|
## Diffusion coefs on y-interfaces
|
||||||
D.grid$y.int <- t(apply(alphas, 2, cmpharm))
|
D.grid$y.int <- t(apply(alphas, 2, cmpharm))
|
||||||
|
|
||||||
# The model
|
# The model
|
||||||
Diff2Dc <- function(t, y, parms) {
|
Diff2Dc <- function(t, y, parms) {
|
||||||
CONC <- matrix(nrow = N, ncol = N, data = y)
|
CONC <- matrix(nrow = N, ncol = N, data = y)
|
||||||
dCONC <- tran.2D(CONC, dx = dx, dy = dy, D.grid = D.grid)$dC
|
dCONC <- tran.2D(CONC, dx = dx, dy = dy, D.grid = D.grid)$dC
|
||||||
return(list(dCONC))
|
return(list(dCONC))
|
||||||
}
|
}
|
||||||
|
|
||||||
## initial condition: 0 everywhere, except in central point
|
## initial condition: 0 everywhere, except in central point
|
||||||
y <- matrix(nrow = N, ncol = N, data = 0)
|
y <- matrix(nrow = N, ncol = N, data = 0)
|
||||||
y[N2, N2] <- ini # initial concentration in the central point...
|
y[N2, N2] <- ini # initial concentration in the central point...
|
||||||
|
|
||||||
## solve for 10 time units
|
## solve for 10 time units
|
||||||
times <- 0:10
|
times <- 0:10
|
||||||
outc <- ode.2D(y = y, func = Diff2Dc, t = times, parms = NULL,
|
outc <- ode.2D(y = y, func = Diff2Dc, t = times, parms = NULL,
|
||||||
dim = c(N, N), lrw = 1860000)
|
dim = c(N, N), lrw = 1860000)
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
|||||||
@ -5,12 +5,25 @@
|
|||||||
|
|
||||||
Welcome to Tug's documentation!
|
Welcome to Tug's documentation!
|
||||||
===============================
|
===============================
|
||||||
|
|
||||||
Welcome to the documentation of the TUG project, a simulation program
|
Welcome to the documentation of the TUG project, a simulation program
|
||||||
for solving one- and two-dimensional diffusion problems with heterogeneous diffusion coefficients, more
|
for solving transport equations in one- and two-dimensional uniform
|
||||||
generally, for solving the following differential equation
|
grids using cell centered finite differences.
|
||||||
|
|
||||||
|
Diffusion
|
||||||
|
-----------
|
||||||
|
|
||||||
|
TUG can solve diffusion problems with heterogeneous and anisotropic
|
||||||
|
diffusion coefficients. The partial differential equation expressing
|
||||||
|
diffusion reads:
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
\frac{\partial C}{\partial t} = \alpha_x \frac{\partial^2 C}{\partial x^2} + \alpha_y \frac{\partial^2 C}{\partial y^2}.
|
\frac{\partial C}{\partial t} = \nabla \cdot \left[ \mathbf{\alpha} \nabla C \right]
|
||||||
|
|
||||||
|
In 2D, the equation reads:
|
||||||
|
|
||||||
|
.. math::
|
||||||
|
\frac{\partial C}{\partial t} = \frac{\partial}{\partial x}\left[ \alpha_x \frac{\partial C}{\partial x}\right] + \frac{\partial}{\partial y}\left[ \alpha_y \frac{\partial C}{\partial y}\right]
|
||||||
|
|
||||||
.. toctree::
|
.. toctree::
|
||||||
:maxdepth: 2
|
:maxdepth: 2
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user