3
$\begingroup$

I am trying to used NDsolve to solve Nonlinear Schroedinger Equation:

 NDSolve[{I D[u[x, t], t] == -0.5*D[u[x, t], x, x] + 0.5*x^2*u[x, t] + 
 Abs[u[x, t]]^2 u[x, t], u[x, 0] == Exp[I*x]}, u, {t, 0, 2}, {x, 0,
 2}]

The above step is not working, I need to get the value of u may be real and imaginary and plot3D for both.

Thanks

$\endgroup$
6
  • $\begingroup$ You have a floating u[x, 0] in the equations... where is the equals sign? u[x, 0] == ... ? Same thing for Exp[I*x]. $\endgroup$
    – flinty
    Commented Sep 15, 2021 at 14:22
  • $\begingroup$ u[x, 0] == Exp[I*x], thanks but still not working!!! $\endgroup$
    – user62716
    Commented Sep 15, 2021 at 14:26
  • $\begingroup$ You say it's not working but you should supply the error message in the question. I get a solution with warnings: NDSolve::bcart: Warning: an insufficient number of boundary conditions have been specified for the direction of independent variable x. Artificial boundary effects may be present in the solution. and also this warning: NDSolve::eerr: Warning: scaled local spatial error estimate of 575.7474776220557` at t = 2.` in the direction of independent variable x is much greater than the prescribed error tolerance... I'm using v12.3.1. $\endgroup$
    – flinty
    Commented Sep 15, 2021 at 14:28
  • $\begingroup$ NDSolve::bcart: Warning: an insufficient number of boundary conditions have been specified for the direction of independent variable x. Artificial boundary effects may be present in the solution. NDSolve::eerr: Warning: scaled local spatial error estimate of 361.1054605875608` at t = 2.` in the direction of independent variable x is much greater than the prescribed error tolerance. Grid spacing with 25 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 $\endgroup$
    – user62716
    Commented Sep 15, 2021 at 14:31
  • $\begingroup$ As mentioned in the bcart warning, the b.c. is insufficient. Please notice this is a serious problem. To be more specific, you haven't give any b.c. to NDSolve. I know you're solving problem defining in open domain and in traditional math the b.c. isn't often explicitly given, but b.c.s approximating the open boundary is necessary for numeric calcalation, see e.g. this. You'll find even more related question under boundary-condition-at-infinity. $\endgroup$
    – xzczd
    Commented Sep 15, 2021 at 16:15

1 Answer 1

7
$\begingroup$

For almost exactly your case I gave an answer here:

Gross-Pitaevskii equation with NDSolve

There are tips in that post on how to work with numerics of nonlinear PDEs.

Your biggest missing point here is to apply cyclic (looped) boundary condition (non-lopped possible, but more tricky). But there is more to the story. Nonlinear Schrödinger Equation (NLS) was solved many times in different circumstances in Wolfram Language (WL) including using NDsolve. A lot depends on which features are you looking for in the solution: solitons? initial wave-packet evolution? stationary state? etc. NLS describes many different applied problems.

In your case with a trapping potential, often NLS is called Gross–Pitaevskii equation or GPE (that iconically descries Bose–Einstein condensate).

Another useful links for you are:

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.