implementations.problem_classes.AdvectionEquation_ND_FD module¶
- class advectionNd(nvars=512, c=1.0, freq=2, stencil_type='center', order=2, lintol=1e-12, liniter=10000, solver_type='direct', bc='periodic', sigma=0.06)[source]¶
Bases:
GenericNDimFinDiff
Example implementing the unforced ND advection equation with periodic or Dirichlet boundary conditions in \([0,1]^N\)
\[\frac{\partial u}{\partial t} = -c \frac{\partial u}{\partial x},\]and initial solution of the form
\[u({\bf x},0) = \prod_{i=1}^N \sin(f\pi x_i),\]with \(x_i\) the coordinate in \(i^{th}\) dimension. Discretization uses central finite differences.
- Parameters:
nvars (int of tuple, optional) – Spatial resolution (same in all dimensions). Using a tuple allows to consider several dimensions, e.g
nvars=(16,16)
for a 2D problem.c (float, optional) – Advection speed (same in all dimensions).
freq (int of tuple, optional) – Spatial frequency \(f\) of the initial conditions, can be tuple.
stencil_type (str, optional) – Type of the finite difference stencil.
order (int, optional) – Order of the finite difference discretization.
lintol (float, optional) – Tolerance for spatial solver (GMRES).
liniter (int, optional) – Max. iterations number for GMRES.
solver_type (str, optional) – Solve the linear system directly or using GMRES or CG
bc (str, optional) – Boundary conditions, either
'periodic'
or'dirichlet'
.sigma (float, optional) –
If
freq=-1
andndim=1
, uses a Gaussian initial solution of the form\[u(x,0) = e^{ \frac{\displaystyle 1}{\displaystyle 2} \left( \frac{\displaystyle x-1/2}{\displaystyle \sigma} \right)^2 }\]
- A¶
FD discretization matrix of the ND grad operator.
- Type:
sparse matrix (CSC)
- Id¶
Identity matrix of the same dimension as A.
- Type:
sparse matrix (CSC)
Note
Args can be set as values or as tuples, which will increase the dimension. Do, however, take care that all spatial parameters have the same dimension.