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)
∂u∂t(x,t,z)+∇u(x,t,z)−∇⋅[k(x,z)∇u(x,t,z)]=g(x,t)(x,t,z)∈D×[0,1]×ΓB(x,t,z)=0(x,t,z)∈∂D×[0,1]×Γu(x,t,z)=u0(x,z)(x,t,z)∈D×{t=0}×ΓFollowing [NTWSIAMNA2008], [JEGGIJNME2020] we set
g(x,t)=(1.5+cos(2πt))cos(x1),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,z)−0.5)=1+z1(√πL2)1/2+d∑k=2λkϕ(x)zk,with
λk=(√πL)1/2exp(−(⌊k2⌋πL)24)k>1,ϕ(x)={sin((⌊k2⌋πx1)Lp)k even,cos((⌊k2⌋πx1)Lp)k odd.where Lp=max, 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 firstnvars
rows ofw
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'])