implementations.problem_classes.AdvectionDiffusionEquation_1D_FFT module¶
- class advectiondiffusion1d_imex(nvars=256, c=1.0, freq=-1, nu=0.02, L=1.0)[source]¶
Bases:
ProblemExample implementing the unforced one-dimensional advection diffusion equation
\[\frac{\partial u(x,t)}{\partial t} = - c \frac{\partial u(x,t)}{\partial x} + \nu \frac{\partial^2 u(x,t)}{\partial x^2}\]with periodic boundary conditions in \([-\frac{L}{2}, \frac{L}{2}]\) in spectral space. The advection part \(- c \frac{\partial u(x,t)}{\partial x}\) is treated explicitly, whereas the diffusion part \(\nu \frac{\partial^2 u(x,t)}{\partial x^2}\) will be treated numerically in an implicit way. The exact solution is given by
\[u(x, t) = \sin(\omega (x - c t)) \exp(-t \nu \omega^2)\]for \(\omega=2 \pi k\), where \(k\) denotes the wave number. Fast Fourier transform is used for the spatial discretization.
- Parameters:
nvars (int, optional) – Number of points in spatial discretization.
c (float, optional) – Advection speed \(c\).
freq (int, optional) – Wave number \(k\).
nu (float, optional) – Diffusion coefficient \(\nu\).
L (float, optional) – Denotes the period of the function to be approximated for the Fourier transform.
- xvalues¶
Contains the grid points in space.
- Type:
np.1darray
- ddx¶
Spectral operator for gradient.
- Type:
np.1darray
- lap¶
Spectral operator for Laplacian.
- Type:
np.1darray
- dtype_f¶
alias of
imex_mesh
- dtype_u¶
alias of
mesh
- class advectiondiffusion1d_implicit(nvars=256, c=1.0, freq=-1, nu=0.02, L=1.0)[source]¶
Bases:
advectiondiffusion1d_imexExample implementing the unforced one-dimensional advection diffusion equation
\[\frac{\partial u(x,t)}{\partial t} = - c \frac{\partial u(x,t)}{\partial x} + \nu \frac{\partial^2 u(x,t)}{\partial x^2}\]with periodic boundary conditions in \([-\frac{L}{2}, \frac{L}{2}]\) in spectral space. This class implements the problem solving it with fully-implicit time-stepping. The exact solution is given by
\[u(x, t) = \sin(\omega (x - c t)) \exp(-t \nu \omega^2)\]for \(\omega=2 \pi k\), where \(k\) denotes the wave number. Fast Fourier transform is used for the spatial discretization.
Note
This class has the same attributes as the class it inherits from.
- dtype_f¶
alias of
mesh
- dtype_u¶
alias of
mesh