I want to solve the Gross-Pitaevskii equation with NDSolve, I tried the following code:
a = 100;
sig = a/10;
sol = NDSolve[{I D[u[t, x], t] == (-1/2) D[u[t, x], {x, 2}] +
x^2/2 u[t, x] - Abs[u[t, x]]^2 u[t, x],
u[0., x] == Exp[-((x + 30)^2./(2*sig^2))], u[t, a] == 0,
u[t, -a] == 0}, u, {t, 0, 1130}, {x, -a, a}, MaxStepSize -> 0.05,
AccuracyGoal -> 4, PrecisionGoal -> 4];
Animate[Plot[Evaluate[Abs[u[t, x] /. First[sol]]^2], {x, -a, a},
PlotRange -> {0, 10}], {t, 0, 413}]
DynamicNDSolve::ndsz: At t == 0.9724326016597982`, step size is effectively
zero; singularity or stiff system suspected.
DynamicNDSolve::eerr: Warning: scaled local spatial error estimate of
1420.198482935478` at t = 0.9724326016597982` in the direction of
independent variable x is much greater than the prescribed error tolerance.
Grid spacing with 4001 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.
I also tried setting the methods:
Method -> {"MethodOfLines",
"SpatialDiscretization" -> {"TensorProductGrid",
"DifferenceOrder" -> "Pseudospectral"}}, AccuracyGoal -> 4,
PrecisionGoal -> 4]
without success.
Reformulation: as recommended below I read some papers of the literature, and I tried to reproduce their results with Mathematica. Everything goes fine until I added rotation to the BEC. I tried the following code:
a = 8;
sig = a/10;
Epsilon = 1.;
Kappa = 1;
Omega_s = 0.;
tfin = 2 Pi;
sol = NDSolve[{I Epsilon D[u[t, x, y],
t] == (-Epsilon^2/2) (
D[u[t, x, y], {x, 2}] + D[u[t, x, y], {y, 2}]) + (x^2 + y^2)/
2 u[t, x, y] +
I Epsilon Omega_s (x D[u[t, x, y], {y, 1}] -
y D[u[t, x, y], {x, 1}]) + Kappa Abs[u[t, x, y]]^2 u[t,
x, y], u[0.,x,y] == (1/Sqrt[Pi sig] ) Exp[-(x^2 + y^2)/(2 sig)],
u[t, a, y] == u[t, -a, y], u[t, x, a] == u[t, x, -a]},
u, {t, 0, tfin}, {x, -a, a}, {y, -a, a}];
Animate[Plot[Evaluate[Abs[u[t, x, 0] /. First[sol]]^2], {x, -a, a},
PlotRange -> {0, 3}], {t, 0, tfin}]
which runs fine if the rotation frequency Omega_s is close to zero, but when I try to reach the critical value for vortex formation (Omega_s=0.25) the code break.
I already did it using the pseudospectral method described above!, very cool Mathematica ! (I'll try to apply the FEM package to see if it can resolve this problem as well).



AccuracyGoal,PrecisionGoal, andMaxStepSize, and limiting the integration to $(0,1)$, which should reproduce your error according to the value of $t$ in the error. However, it worked fine, albeit slowly. Do you know that you need such a tiny step size over such a long time period? You could also useMaxStepFractionto ensure that a certain number of steps are taken. – MarcoB May 01 '18 at 19:42