setup_advection_diffusion_benchmark

pyapprox.fenics_models.advection_diffusion_wrappers.setup_advection_diffusion_benchmark(nvars, corr_len, max_eval_concurrency=1)[source]

Compute functionals of the following model of transient advection-diffusion (with 3 configure variables which control the two spatial mesh resolutions and the timestep)

\[\begin{split}\frac{\partial u}{\partial t}(x,t,\rv) + \nabla u(x,t,\rv)-\nabla\cdot\left[k(x,\rv) \nabla u(x,t,\rv)\right] &=g(x,t) \qquad (x,t,\rv)\in D\times [0,1]\times\rvdom\\ \mathcal{B}(x,t,\rv)&=0 \qquad\qquad (x,t,\rv)\in \partial D\times[0,1]\times\rvdom\\ u(x,t,\rv)&=u_0(x,\rv) \qquad (x,t,\rv)\in D\times\{t=0\}\times\rvdom\end{split}\]

Following [NTWSIAMNA2008], [JEGGIJNME2020] we set

\[g(x,t)=(1.5+\cos(2\pi t))\cos(x_1),\]

the initial condition as \(u(x,z)=0\), \(B(x,t,z)\) to be zero dirichlet boundary conditions.

and we model the diffusivity \(k\) as a random field represented by the Karhunen-Loeve (like) expansion (KLE)

\[\log(k(x,\rv)-0.5)=1+\rv_1\left(\frac{\sqrt{\pi L}}{2}\right)^{1/2}+\sum_{k=2}^d \lambda_k\phi(x)\rv_k,\]

with

\[\begin{split}\lambda_k=\left(\sqrt{\pi L}\right)^{1/2}\exp\left(-\frac{(\lfloor\frac{k}{2}\rfloor\pi L)^2}{4}\right) k>1, \qquad\qquad \phi(x)= \begin{cases} \sin\left(\frac{(\lfloor\frac{k}{2}\rfloor\pi x_1)}{L_p}\right) & k \text{ even}\,,\\ \cos\left(\frac{(\lfloor\frac{k}{2}\rfloor\pi x_1)}{L_p}\right) & k \text{ odd}\,. \end{cases}\end{split}\]

where \(L_p=\max(1,2L_c)\), \(L=\frac{L_c}{L_p}\).

The quantity of interest \(f(z)\) is the measurement of the solution at a location \(x_k\) at the final time \(T=1\) obtained via the linear functional

\[f(z)=\int_D u(x,T,z)\frac{1}{2\pi\sigma^2}\exp\left(-\frac{\lVert x-x_k \rVert^2_2}{\sigma^2}\right) dx\]
Parameters
nvarsinteger

The number of variables of the KLE

corr_lenfloat

The correlation length \(L_c\) of the covariance kernel

max_eval_concurrencyinteger

The maximum number of simulations that can be run in parallel. Should be no more than the maximum number of cores on the computer being used

Returns
benchmarkpya.Benchmark

Object containing the benchmark attributes documented below

funcallable

The quantity of interest \(f(w)\) with signature

fun(w) -> np.ndarray

where w is a 2D np.ndarray with shape (nvars+3,nsamples) and the output is a 2D np.ndarray with shape (nsamples,1). The first nvars rows of w are realizations of the random variables. The last 3 rows are configuration variables specifying the numerical discretization of the PDE model. Specifically the first and second configuration variables specify the levels \(l_{x_1}\) and \(l_{x_2}\) which dictate the resolution of the FEM mesh in the directions \({x_1}\) and \({x_2}\) respectively. The number of cells in the \({x_i}\) direction is given by \(2^{l_{x_i}+2}\). The third configuration variable specifies the level \(l_t\) of the temporal discretization. The number of timesteps satisfies \(2^{l_{t}+2}\) so the timestep size is and \(T/2^{l_{t}+2}\).

variablepya.IndependentMultivariateRandomVariable

Object containing information of the joint density of the inputs z which is the tensor product of independent and identically distributed uniform variables on \([-\sqrt{3},\sqrt{3}]\).

Examples

>>> from pyapprox.benchmarks.benchmarks import setup_benchmark
>>> benchmark=setup_benchmark('advection-diffusion',nvars=2)
>>> print(benchmark.keys())
dict_keys(['fun', 'variable'])