src/examples/ginzburg-landau.c

The complex Ginzburg–Landau equation

The complex Ginzburg–Landau equation tA=A+(1+iα)2A(1+iβ)A2A with A a complex number, is a classical model for phenomena exhibiting Hopf bifurcations such as Rayleigh-Bénard convection or superconductivity.

Posing Ar=Re(A) and Ai=Im(A) one gets the coupled reaction–diffusion equations. tAr=2Ar+Ar(1A2)α2Ai+A2βAi tAi=2Ai+Ai(1A2)+α2ArA2βAr

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 α=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 [104:104] 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 A2.

  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 β we chose, we get a typical “frozen state” composed of “cellular structures” for A2 and stationary spirals for Ai.

Final states (click on images for animations)
A2 Ai

See also