implementations.problem_classes.AllenCahn_2D_FFT module

class allencahn2d_imex(nvars=None, nu=2, eps=0.04, radius=0.25, L=1.0, init_type='circle')[source]

Bases: ptype

Example implementing the two-dimensional Allen-Cahn equation with periodic boundary conditions \(u \in [-1, 1]^2\)

\[\frac{\partial u}{\partial t} = \Delta u + \frac{1}{\varepsilon^2} u (1 - u^\nu)\]

on a spatial domain \([-\frac{L}{2}, \frac{L}{2}]^2\), and constant parameter \(\nu\). Different initial conditions can be used, for example, circles of the form

\[u({\bf x}, 0) = \tanh\left(\frac{r - \sqrt{x_i^2 + y_j^2}}{\sqrt{2}\varepsilon}\right),\]

or checker-board

\[u({\bf x}, 0) = \sin(2 \pi x_i) \sin(2 \pi y_j),\]

or uniform distributed random numbers in \([-1, 1]\) for \(i, j=0,..,N-1\), where \(N\) is the number of spatial grid points. For time-stepping, the problem is treated semi-implicitly, i.e., the diffusion part is solved by Fast-Fourier Tranform (FFT) and the nonlinear term is treated explicitly.

An exact solution is not known, but instead the numerical solution can be compared via a generated reference solution computed by a SciPy routine.

Parameters:
  • nvars (List of int tuples, optional) – Number of unknowns in the problem, e.g. nvars=[(128, 128), (128, 128)].

  • nu (float, optional) – Problem parameter \(\nu\).

  • eps (float, optional) – Scaling parameter \(\varepsilon\).

  • radius (float, optional) – Radius of the circles.

  • L (float, optional) – Denotes the period of the function to be approximated for the Fourier transform.

  • init_type (str, optional) – Indicates which type of initial condition is used.

xvalues

Grid points in space.

Type:

np.1darray

dx

Mesh width.

Type:

float

lap

Spectral operator for Laplacian.

Type:

np.1darray

dtype_f

alias of imex_mesh

dtype_u

alias of mesh

eval_f(u, t)[source]

Routine to evaluate the right-hand side of the problem.

Parameters:
  • u (dtype_u) – Current values of the numerical solution.

  • t (float) – Current time of the numerical solution is computed.

Returns:

f – The right-hand side of the problem.

Return type:

dtype_f

solve_system(rhs, factor, u0, t)[source]

Simple FFT solver for the diffusion part.

Parameters:
  • rhs (dtype_f) – Right-hand side for the linear system.

  • factor (float) – Abbrev. for the node-to-node stepsize (or any other factor required).

  • u0 (dtype_u) – Initial guess for the iterative solver (not used here so far).

  • t (float) – Current time (e.g. for time-dependent BCs).

Returns:

me – The solution as mesh.

Return type:

dtype_u

u_exact(t, u_init=None, t_init=None)[source]

Routine to compute the exact solution at time \(t\).

Parameters:
  • t (float) – Time of the exact solution.

  • u_init (pySDC.implementations.problem_classes.allencahn2d_imex.dtype_u) – Initial conditions for getting the exact solution.

  • t_init (float) – The starting time.

Returns:

me – The exact solution.

Return type:

dtype_u

class allencahn2d_imex_stab(nvars=None, nu=2, eps=0.04, radius=0.25, L=1.0, init_type='circle')[source]

Bases: allencahn2d_imex

This implements the two-dimensional Allen-Cahn equation with periodic boundary conditions \(u \in [-1, 1]^2\) with stabilized splitting

\[\frac{\partial u}{\partial t} = \Delta u + \frac{1}{\varepsilon^2} u (1 - u^\nu) + \frac{2}{\varepsilon^2}u\]

on a spatial domain \([-\frac{L}{2}, \frac{L}{2}]^2\), and constant parameter \(\nu\). Different initial conditions can be used here, for example, circles of the form

\[u({\bf x}, 0) = \tanh\left(\frac{r - \sqrt{x_i^2 + y_j^2}}{\sqrt{2}\varepsilon}\right),\]

or checker-board

\[u({\bf x}, 0) = \sin(2 \pi x_i) \sin(2 \pi y_j),\]

or uniform distributed random numbers in \([-1, 1]\) for \(i, j=0,..,N-1\), where \(N\) is the number of spatial grid points. For time-stepping, the problem is treated semi-implicitly, i.e., the diffusion part is solved with Fast-Fourier Tranform (FFT) and the nonlinear term is treated explicitly.

An exact solution is not known, but instead the numerical solution can be compared via a generated reference solution computed by a SciPy routine.

Parameters:
  • nvars (List of int tuples, optional) – Number of unknowns in the problem, e.g. nvars=[(128, 128), (128, 128)].

  • nu (float, optional) – Problem parameter \(\nu\).

  • eps (float, optional) – Scaling parameter \(\varepsilon\).

  • radius (float, optional) – Radius of the circles.

  • L (float, optional) – Denotes the period of the function to be approximated for the Fourier transform.

  • init_type (str, optional) – Indicates which type of initial condition is used.

xvalues

Grid points in space.

Type:

np.1darray

dx

Mesh width.

Type:

float

lap

Spectral operator for Laplacian.

Type:

np.1darray

eval_f(u, t)[source]

Routine to evaluate the right-hand side of the problem.

Parameters:
  • u (dtype_u) – Current values of the numerical solution.

  • t (float) – Current time of the numerical solution is computed.

Returns:

f – The right-hand side of the problem.

Return type:

dtype_f

solve_system(rhs, factor, u0, t)[source]

Simple FFT solver for the diffusion part.

Parameters:
  • rhs (dtype_f) – Right-hand side for the linear system.

  • factor (float) – Abbrev. for the node-to-node stepsize (or any other factor required).

  • u0 (dtype_u) – Initial guess for the iterative solver (not used here so far).

  • t (float) – Current time (e.g. for time-dependent BCs).

Returns:

me – The solution as mesh.

Return type:

dtype_u