Skip to main content

Complex valued 2+1D PDE Schrödinger equation, numerical method for `NDSolve`?


Based on the heat equation of the Mathematica Manual tutorial, I wrote the complex counterpart (Schrödinger) equation, for the free particle propagation of an initial wavepacket.


NDSolve[

{
I D[u[t, x, y], t] == -D[u[t, x, y], {x, 2}] -
D[u[t, x, y], {y, 2}], u[0., x, y] == Exp[-(x^2. + y^2.)],
u[t, -5., y] == u[t, 5., y], u[t, x, -5.] == u[t, x, 5.]
}, u, {t, 0., 1.}, {x, -5., 5.}, {y, -5., 5.}
]

However the solver chokes with serveral warnings, the most serious being that the Maximum number of iterations has been reached that stops the calculation at t == 0.48. But the worst is that the solutions (plotted with Table[Plot3D[ Evaluate[Abs[u[t, x, y] /. First[sol]]^2], {x, -5, 5}, {y, -5, 5}, PlotRange -> All, PlotPoints -> 100, Mesh -> False], {t, 0.0, 0.05, 0.01}]) looks completely wrong with diverging values.


I know the NDSolve is not magic but does anybody know of an option to pass that will make this problem tractable with NDSolve?


I couldn't find a coherent explanation of the NDSolve options in the manual or anywhere else. Otherwise I would be playing with known methods of propagation, like Crank-Nicolson (for time propagation) and spectral methods (for spatial coordinates). A first nice step would to control the spatial (x and y) resolution and the time (t) resolution independently.



Note 1: One knows that the time propagation of this problem for that particular initial condition is a simple spreading Gaussian probability, in particular the solution is well defined and smooth.


Note 2: I tried with and without periodic boundary conditions in both cases the result is numerically wrong (diverging values).


Note 3: I did some progress for the simpler 1+1D equation, that problem is well undercontrol with most of the defaults/automatics of NDSolve, I can propagate for a while:


sol = NDSolve[
{
I D[u[t, x], t] == -D[u[t, x], {x, 2}], u[0., x] == Exp[-(x^2.)],
u[t, 5.] == 0, u[t, -5.] == 0
}, u, {t, 0., 20.}, {x, -5., 5.}, MaxStepSize -> 0.1
]
Animate[Plot[Evaluate[Abs[u[t, x] /. First[sol]]^2], {x, -5, 5},

PlotRange -> {0, 1}], {t, 0, 17, 0.01}]

Answer



I think it's worth pointing out that the problem can be solved "straightforwardly" (i.e., really using only NDSolve) once you know the options that Stefan used in ProcessEquations (which I upvoted because those options are the main ingredient):


Below I show the original problem of a Gaussian wave packet with no initial momentum, and then a modified case where an initial momentum has been imparted, making the initial condition complex as well. I call the complex wave function $\psi$ and plot its absolute value:


ψ = u /. 
First@NDSolve[{I D[u[t, x, y], t] == -D[u[t, x, y], {x, 2}] -
D[u[t, x, y], {y, 2}], u[0., x, y] == Exp[-(x^2. + y^2.)],
u[t, -5., y] == u[t, 5., y], u[t, x, -5.] == u[t, x, 5.]},
u, {t, 0., 2.}, {x, -5., 5.}, {y, -5., 5.},
Method -> {"MethodOfLines",

"SpatialDiscretization" -> {"TensorProductGrid",
"DifferenceOrder" -> "Pseudospectral"}}];

pl =
Table[Plot3D[Abs[ψ[t, x, y]], {x, -5, 5}, {y, -5, 5},
PlotRange -> {0, 1}], {t, 0, 2, .1}];

Export["spreading.gif", pl, AnimationRepetitions -> Infinity,
"DisplayDurations" -> .4]


spreading


ψ = 
u /. First@
NDSolve[{I D[u[t, x, y], t] == -D[u[t, x, y], {x, 2}] -
D[u[t, x, y], {y, 2}],
u[0., x, y] == Exp[-(x^2. + y^2.)] Exp[3 I x],
u[t, -10., y] == u[t, 10., y], u[t, x, -10.] == u[t, x, 10.]},
u, {t, 0., 1.}, {x, -10., 10.}, {y, -10., 10.},
Method -> {"MethodOfLines",
"SpatialDiscretization" -> {"TensorProductGrid",

"DifferenceOrder" -> "Pseudospectral"}}]

pl =
Table[Plot3D[Abs[ψ[t, x, y]], {x, -10, 10}, {y, -10, 10},
PlotRange -> {0, 1}], {t, 0, 1, .1}];

Export["moving.gif", pl, AnimationRepetitions -> Infinity,
"DisplayDurations" -> .4]

moving



Edit 2: Adding a potential energy term.


The above numerical solutions are basically for a free particle, except that the spatial grid is forcing us to choose some boundary conditions on the sides of the square. Periodic boundary conditions are a common choice. But the whole effort is overkill for a free particle because the solutions can be obtained analytically. It gets more interesting if we add an arbitrary potential energy to see how the wave packet is deflected over time.


The periodic boundary conditions in this calculation allow you to add a potential energy to the Hamiltonian, as long as it doesn't conflict with the periodicity of box. Here is an example where I added the potential


$$V(x, y) = - 20 \cos(\frac{\pi x}{10}) \cos(\frac{\pi y}{10})$$


with a box of side length $10$. This potential vanishes on the box boundaries, and has an attractive center at the origin.


Also, I started the Gaussian slightly offset from the center, with a momentum tangential to the equipotential lines, so we expect it to go around with some angular momentum:


ψ = u /. 
First@NDSolve[{I D[u[t, x, y], t] == -D[u[t, x, y], {x, 2}] -
D[u[t, x, y], {y, 2}] -
20 Cos[Pi x/10] Cos[Pi y/10] u[t, x, y],

u[0., x, y] == Exp[-((x - 1)^2. + y^2.)] Exp[I y],
u[t, -5., y] == u[t, 5., y], u[t, x, -5.] == u[t, x, 5.]},
u, {t, 0., 3.}, {x, -5., 5.}, {y, -5., 5.},
Method -> {"MethodOfLines",
"SpatialDiscretization" -> {"TensorProductGrid",
"DifferenceOrder" -> "Pseudospectral"}}];

pl = Table[
Plot3D[Abs[ψ[t, x, y]], {x, -5, 5}, {y, -5, 5},
PlotRange -> {0, 1}], {t, 0, 3, .1}];


Export["revolve.gif", pl, AnimationRepetitions -> Infinity,
"DisplayDurations" -> .1]

revolve


The packet still disperses but is clearly trapped in the potential minimum, as expected.


Comments

Popular posts from this blog

plotting - How to draw lines between specified dots on ListPlot?

I would like to create a plot where I have unconnected dots and some connected. So far, I have figured out how to draw the dots. My code is the following: ListPlot[{{1, 1}, {2, 2}, {3, 3}, {4, 4}, {1, 4}, {2, 5}, {3, 6}, {4, 7}, {1, 7}, {2, 8}, {3, 9}, {4, 10}, {1, 10}, {2, 11}, {3, 12}, {4,13}, {2.5, 7}}, Ticks -> {{1, 2, 3, 4}, None}, AxesStyle -> Thin, TicksStyle -> Directive[Black, Bold, 12], Mesh -> Full] I have thought using ListLinePlot command, but I don't know how to specify to the command to draw only selected lines between the dots. Do have any suggestions/hints on how to do that? Thank you. Answer One possibility would be to use Epilog with Line : ListPlot[ {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {1, 4}, {2, 5}, {3, 6}, {4, 7}, {1, 7}, {2, 8}, {3, 9}, {4, 10}, {1, 10}, {2, 11}, {3, 12}, {4, 13}, {2.5, 7}}, Ticks -> {{1, 2, 3, 4}, None}, AxesStyle -> Thin, TicksStyle -> Directive[Black, Bold, 12], Mesh -> Full, Epilog -> { Line[ ...

equation solving - Invert and fit implicitly defined curve

I need to fit an implicitly defined curve. I thought I could get some data out of Solve , and then using FindFit . Therefore, I would like to find the relation the parametric curve defined by $F(x,y)=0$: Solve[-(1/2) + 1/2 (0.41202 BesselK[0, 0.1 Sqrt[x^2 + y^2]] + (0.101483 x BesselK[1, 0.1 Sqrt[x^2 + y^2]])/Sqrt[x^2 + y^2]) == 0, y] But I can't get an output: Solve was unable to solve the system with inexact coefficients or the system obtained by direct rationalization of inexact numbers present in the system. Since many of the methods used by Solve require exact input, providing Solve with an exact version of the system may help. >> Edit: In particular, I would like to fit the data coming from the curve with the expression of another curve, and not with a function $f(x)$. In particular, since this clearly looks like a cardioid , I would like it to fit to something like it. What other strategies could I try?

dynamic - How can I make a clickable ArrayPlot that returns input?

I would like to create a dynamic ArrayPlot so that the rectangles, when clicked, provide the input. Can I use ArrayPlot for this? Or is there something else I should have to use? Answer ArrayPlot is much more than just a simple array like Grid : it represents a ranged 2D dataset, and its visualization can be finetuned by options like DataReversed and DataRange . These features make it quite complicated to reproduce the same layout and order with Grid . Here I offer AnnotatedArrayPlot which comes in handy when your dataset is more than just a flat 2D array. The dynamic interface allows highlighting individual cells and possibly interacting with them. AnnotatedArrayPlot works the same way as ArrayPlot and accepts the same options plus Enabled , HighlightCoordinates , HighlightStyle and HighlightElementFunction . data = {{Missing["HasSomeMoreData"], GrayLevel[ 1], {RGBColor[0, 1, 1], RGBColor[0, 0, 1], GrayLevel[1]}, RGBColor[0, 1, 0]}, {GrayLevel[0], GrayLevel...