implementations.problem_classes.AllenCahn_MPIFFT module

class allencahn_imex(eps=0.04, radius=0.25, dw=0.0, init_type='circle', **kwargs)[source]

Bases: IMEX_Laplacian_MPIFFT

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

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

on a spatial domain \([-\frac{L}{2}, \frac{L}{2}]^2\), driving force \(d_w\), and \(N=2,3\). Different initial conditions can be used, for example, circles of the form

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

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 linear part is solved with Fast-Fourier Transform (FFT) and the nonlinear part in the right-hand side will be treated explicitly using mpi4py-fft [1] to solve them.

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

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

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

  • spectral (bool, optional) – Indicates if spectral initial condition is used.

  • dw (float, optional) – Driving force.

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

  • init_type (str, optional) – Initialises type of initial state.

  • comm (bool, optional) – Communicator for parallelization.

fft

Object for FFT.

Type:

fft object

X

Grid coordinates in real space.

Type:

np.ogrid

K2

Laplace operator in spectral space.

Type:

np.1darray

dx

Mesh width in x direction.

Type:

float

dy

Mesh width in y direction.

Type:

float

References

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

u_exact(t, **kwargs)[source]

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

Parameters:

t (float) – Time of the exact solution.

Returns:

me – The exact solution.

Return type:

dtype_u

class allencahn_imex_timeforcing(eps=0.04, radius=0.25, dw=0.0, init_type='circle', **kwargs)[source]

Bases: allencahn_imex

Example implementing the \(N\)-dimensional Allen-Cahn equation with periodic boundary conditions \(u \in [0, 1]^2\) using time-dependent forcing

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

on a spatial domain \([-\frac{L}{2}, \frac{L}{2}]^2\), driving force \(d_w\), and \(N=2,3\). Different initial conditions can be used, for example, circles of the form

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

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 linear part is solved with Fast-Fourier Transform (FFT) using mpi4py-fft [1] and the nonlinear part in the right-hand side will be treated explicitly.

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