Skip to main content
1 of 6
Nobody
  • 823
  • 4
  • 11

How to solve PDE with complex function

I need to solve the PDE for a complex function $A(x,t)=A_r(x,t)+iA_i(x,t)$

eq = D[A[x, t], t] + 1/4*Conjugate[A[x, t]]*A[x, t]^2 - D[A[x, t], {x, 2}] - 2*A[x, t] == 0; 

over $[-L,L]$ and $[0,t_\text{max}]$. The equation is subject to a random initial condition and the boundary conditions as follows: $A_r(-L,t)=A_r(L,t)$ and $A_i(-L,t)=-A_i(L,t)$

L = 30; tmax = 30; ini[x_] = 1/10*BSplineFunction[RandomReal[{-1, 1}, 20], SplineClosed -> True, SplineDegree -> 5][x/(2*L)]; ibcs = {Re[A[-L, t]] == Re[A[L, t]], Im[A[-L, t]] == -Im[A[L, t]], A[x, 0] == ini[x]}; 

Then, I solve it with NDSolve

sol = NDSolve[{eq, ibcs}, A, {x, -L, L}, {t, 0, tmax}, Method -> {"MethodOfLines", "SpatialDiscretization" -> {"TensorProductGrid", "MinPoints" -> 201, "MaxPoints" -> 201, "DifferenceOrder" -> "Pseudospectral"}}, AccuracyGoal -> 20] 

But I received the error

NDSolve::bcedge: Boundary condition Im[A[-30,t]]==-Im[A[30,t]] is not specified on a single edge of the boundary of the computational domain.>>

I didn't understand the error. Why the boundary conditions (bcs) must be specified on a single edge. Should not we set the bcs at both sides? Any suggestion is highly appreciated.

Nobody
  • 823
  • 4
  • 11