implementations.problem_classes.AllenCahn_Temp_MPIFFT module

class allencahn_temp_imex(nvars=None, eps=0.04, radius=0.25, spectral=None, TM=1.0, D=10.0, dw=0.0, L=1.0, init_type='circle', comm=None)[source]

Bases: ptype

This class implements the \(N\)-dimensional Allen-Cahn equation with periodic boundary conditions \(u \in [0, 1]^2\)

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

on a spatial domain \([-\frac{L}{2}, \frac{L}{2}]^2\), with driving force \(d_w\), and \(N=2,3\). \(D\) and \(T_M\) are fixed parameters. 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 nonlinear system is solved by Fast-Fourier Tranform (FFT) and the linear parts in the right-hand side will be treated explicitly using mpi4py-fft [1] to solve them.

nvars

Number of unknowns in the problem, e.g. nvars=[(128, 128), (64, 64)].

Type:

List of int tuples, optional

eps

Scaling parameter \(\varepsilon\).

Type:

float, optional

radius

Radius of the circles.

Type:

float, optional

spectral

Indicates if spectral initial condition is used.

Type:

bool, optional

TM

Problem parameter \(T_M\).

Type:

float, optional

D

Problem parameter \(D\).

Type:

float, optional

dw

Driving force.

Type:

float, optional

L

Denotes the period of the function to be approximated for the Fourier transform.

Type:

float, optional

init_type

Initialises type of initial state.

Type:

str, optional

comm

Communicator.

Type:

bool, optional

fft

Object for FFT.

Type:

fft object

X

Grid coordinates in real space.

Type:

np.ogrid

K2

Laplace operator in spectral space.

Type:

np.ndarray

dx

Mesh width in x direction.

Type:

float

dy

Mesh width in y direction.

Type:

float

References

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)[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