# The complex Ginzburg–Landau equation

The complex Ginzburg–Landau equation ${\partial }_{t}A=A+\left(1+i\alpha \right){\nabla }^{2}A-\left(1+i\beta \right){\mid A\mid }^{2}A$ with $A$ a complex number, is a classical model for phenomena exhibiting Hopf bifurcations such as Rayleigh-Bénard convection or superconductivity.

Posing ${A}_{r}=Re\left(A\right)$ and ${A}_{i}=Im\left(A\right)$ one gets the coupled reaction–diffusion equations. ${\partial }_{t}{A}_{r}={\nabla }^{2}{A}_{r}+{A}_{r}\left(1-{\mid A\mid }^{2}\right)-\alpha {\nabla }^{2}{A}_{i}+{\mid A\mid }^{2}\beta {A}_{i}$ ${\partial }_{t}{A}_{i}={\nabla }^{2}{A}_{i}+{A}_{i}\left(1-{\mid A\mid }^{2}\right)+\alpha {\nabla }^{2}{A}_{r}-{\mid A\mid }^{2}\beta {A}_{r}$

This system can be solved with the reaction–diffusion solver.

``````#include "grid/multigrid.h"
#include "run.h"
#include "diffusion.h"

scalar Ar[], Ai[], A2[];``````

In this example, we only consider the case when $\alpha =0$.

``double β;``

The generic time loop needs a timestep. We will store the statistics on the diffusion solvers in `mgd1` and `mgd2`.

``````double dt;
mgstats mgd1, mgd2;``````

## Parameters

We change the size of the domain `L0`.

``````int main() {
β = 1.5;
size (100);
init_grid (256);
run();
}``````

## Initial conditions

We use a white noise in $\left[-{10}^{-4}:{10}^{-4}\right]$ for both components.

``````event init (i = 0) {
foreach() {
Ar[] = 1e-4*noise();
Ai[] = 1e-4*noise();
}
boundary ({Ar,Ai});
}``````

## Time integration

``event integration (i++) {``

We first set the timestep according to the timing of upcoming events. We choose a maximum timestep of 0.05 which ensures the stability of the reactive terms for this example.

``  dt = dtnext (0.05);``

We compute $\mid A{\mid }^{2}$.

``````  foreach()
A2[] = sq(Ar[]) + sq(Ai[]);
boundary ({A2});``````

We use the diffusion solver (twice) to advance the system from $t$ to $t+dt$.

``````  scalar r[], λ[];
foreach() {
r[] = A2[]*β*Ai[];
λ[] = 1. - A2[];
}
mgd1 = diffusion (Ar, dt, r = r, β = λ);
foreach() {
r[] = - A2[]*β*Ar[];
λ[] = 1. - A2[];
}
mgd1 = diffusion (Ai, dt, r = r, β = λ);
}``````

## Outputs

Here we create mpeg animations for both components. The `spread` parameter sets the color scale to $±$ twice the standard deviation.

``````event movies (i += 3; t <= 150) {
fprintf (stderr, "%g %g\n", t, sqrt(normf(A2).max));

static FILE * fp = popen ("ppm2mpeg > Ai.mpg", "w");
output_ppm (Ai, fp, spread = 2, linear = true);
static FILE * fp1 = popen ("ppm2mpeg > A2.mpg", "w");
output_ppm (A2, fp1, spread = 2, linear = true);
}``````

At the end of the simulation, we create snapshot images of both fields, in PNG format.

``````event pictures (t = end) {
output_ppm (Ai, file = "Ai.png", spread = 2, linear = true);
output_ppm (A2, file = "A2.png", spread = 2, linear = true);
}``````

For the value of $\beta$ we chose, we get a typical “frozen state” composed of “cellular structures” for $\mid A{\mid }^{2}$ and stationary spirals for ${A}_{i}$.

 $\mid A{\mid }^{2}$ ${A}_{i}$