How to plot the solution of a Partial Differential Equation?

My attempt.

I need to solve numerically the Complex Ginzburg-Laudau Equation (CGLE): $$\frac{\partial A}{\partial t}=\epsilon A-(1+i\beta)|A|^2A+(1+i\alpha)\nabla^2A$$ I'm using a uniform initial condition $A(x,y,t=0)=1$ and periodic boundary conditions: $A(-x_m/2,y,t)=A(x_m/2,y,t)$, $A(x,-y_m/2,t)=A(x,y_m/2,t)$, where I'm defining the domain $\mathcal{D}=\{(x,y):-x_m/2\leq x\leq x_m/2,-y_m/2\leq y\leq y_m/2\}$ with $t\in [0,t_m]$.

My code is the following: (parameters obtained here)

(*Parameters.*)
ϵ = 1;
α = 0;
β = 1.5;
xM = 50;
yM = 50;
tM = 10000;

(*Numerical solution*)
sol = NDSolve[{D[A[x, y, t], t] == ϵ A[x, y, t] - (1 + I β)
Norm[A[x, y, t]]^2 A[x, y, t] + (1 + I α) Laplacian[A[x, y, t], {x, y}],
A[x, y, 0] == 1, A[-xM/2, y, t] == A[xM/2, y, t], A[x, -yM/2, t] ==
A[x, yM/2, t]}, A, {x, -xM/2, xM/2}, {y, -yM/2, yM/2}, {t, 0, tM}]

with the out: Then I try to plot with:

(*Plotting*)
DensityPlot[Evaluate[Re[A[x, y, 10000]] /. sol], {x, -xM/2 + 1,
xM/2 - 1}, {y, -yM/2 + 1, yM/2 - 1}, PlotPoints -> 100]

but I just obtain an odd graphic: I'm supposed to obtain a frozen picture of the following (see here): Question. What am I doing wrong and how can I fix it?

• Your TeX equation and the Mathematica equation are different. The Tex has Abs[A[x, y, t]]^2 and the code has Norm[A[x, y, t]]. – Michael E2 Apr 27 '15 at 1:56
• @MichaelE2 You're right. I just edited the code (Norm[A] and Abs[A] give the same result for a complex A: Sqrt[Re[A]^2+Im[A]^2]). BTW I'm still getting the same blue square after the correction. – Ana S. H. Apr 27 '15 at 2:16
• There's no difference between Norm and Abs on 1D vectors/scalars. Norm is meant (in Mathematica) for vectors and Abs for scalars. (For example Norm[{x, y}] evaluates to Sqrt[Abs[x]^2 + Abs[y]^2].) So Abs seems more consistent with Mathematica idiom, but it makes no difference in the result. -- What version are you using? I did not get a blue square in the original code. I get a convergence error and NDSolve quits before t gets past t == 1 or so with the new code. – Michael E2 Apr 27 '15 at 2:27
• Actually, NDSolve does not consistently stop at the same time t each time I try it. Strange. I'm using to it being deterministic. I just stopped at t = 8.42, much farther than any earlier trial run. – Michael E2 Apr 27 '15 at 2:29
• If I replace Norm[_]^2 with _ * Conjugate[_] I get a convergence error extremely quickly, always at t==0.9567275319519298. Replacing it with Abs[_]^2 gives me an error at t < 0.025 after some time, and using Norm[_]^2 gives me an error at t < 10 after a long time. Mathematica 10.0.0.0, Windows 8.1 64-bit. – 2012rcampion Apr 27 '15 at 3:14

The differential equation, its initial condition, and its boundary conditions are translationally invariant in space. Consequently, the solution must be independent of x and y. Indeed, solving the equations as given in the Question does give a spatially constant solution that oscillates in time. For instance,

DensityPlot[Evaluate[Re[A[x, y, 10000]] /. sol], {x, -xM/2, xM/2}, {y, -yM/2,
yM/2}, PlotPoints -> 100, PlotRange -> {-1, 1}, ColorFunctionScaling -> False]

gives a constant color plot. (Note that omitting ColorFunctionScaling -> False yields a blotchy plot that varies in time, but this spatial variation is nothing but tiny roundoff errors.)

A segment of the time history at any spatial position is given by

Plot[Evaluate[Re[A[0, 0, t]] /. sol], {t, 9000, 9100}, PlotRange -> All] It seems likely that you did not obtain the pattern shown in your animation, because the animation was produced using different initial conditions.

Incidentally, I find it strange that NDSolve produces the error message,

NDSolve::eerr: Warning: scaled local spatial error estimate of 151.69068701912053 at t = 10000.` in the direction of independent variable x is much greater than the prescribed error tolerance. Grid spacing with 15 points may be too large to achieve the desired accuracy or precision. A singularity may have formed or a smaller grid spacing can be specified using the MaxStepSize or MinPoints method options. >>

because the solution is well behaved there and, as noted earlier, constant in space up to tiny roundoff errors.

• I think the is error is because it is so flat. Since it is a scaled estimate, the noise is magnified (I think). – Michael E2 Apr 28 '15 at 2:46
• @MichaelE2 I would have expected the error to be scaled to the RMS value of the solution. In any case, I have run the 1D (in time) calculation and the error message goes away. – bbgodfrey Apr 28 '15 at 2:51
• I just changed my initial condition for $A(x,y,t=0)=\sin (x)$, and also changed the domain for $\{(x,y): -\pi \leq x \leq \pi, -\pi \leq y \leq \pi \}$ keeping the periodic boundary conditions. But now, for tM=100, I get this "Maximum number of 51693 steps reached at the point t == 0.00217" and "Warning: scaled local spatial error estimate of 366.156 at t = 0.00217". What could it be? @MichaelE2 – Ana S. H. Apr 28 '15 at 4:27