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 - Filling between two spheres in SphericalPlot3D

Manipulate[ SphericalPlot3D[{1, 2 - n}, {θ, 0, Pi}, {ϕ, 0, 1.5 Pi}, Mesh -> None, PlotPoints -> 15, PlotRange -> {-2.2, 2.2}], {n, 0, 1}] I cant' seem to be able to make a filling between two spheres. I've already tried the obvious Filling -> {1 -> {2}} but Mathematica doesn't seem to like that option. Is there any easy way around this or ... Answer There is no built-in filling in SphericalPlot3D . One option is to use ParametricPlot3D to draw the surfaces between the two shells: Manipulate[ Show[SphericalPlot3D[{1, 2 - n}, {θ, 0, Pi}, {ϕ, 0, 1.5 Pi}, PlotPoints -> 15, PlotRange -> {-2.2, 2.2}], ParametricPlot3D[{ r {Sin[t] Cos[1.5 Pi], Sin[t] Sin[1.5 Pi], Cos[t]}, r {Sin[t] Cos[0 Pi], Sin[t] Sin[0 Pi], Cos[t]}}, {r, 1, 2 - n}, {t, 0, Pi}, PlotStyle -> Yellow, Mesh -> {2, 15}]], {n, 0, 1}]

plotting - Plot 4D data with color as 4th dimension

I have a list of 4D data (x position, y position, amplitude, wavelength). I want to plot x, y, and amplitude on a 3D plot and have the color of the points correspond to the wavelength. I have seen many examples using functions to define color but my wavelength cannot be expressed by an analytic function. Is there a simple way to do this? Answer Here a another possible way to visualize 4D data: data = Flatten[Table[{x, y, x^2 + y^2, Sin[x - y]}, {x, -Pi, Pi,Pi/10}, {y,-Pi,Pi, Pi/10}], 1]; You can use the function Point along with VertexColors . Now the points are places using the first three elements and the color is determined by the fourth. In this case I used Hue, but you can use whatever you prefer. Graphics3D[ Point[data[[All, 1 ;; 3]], VertexColors -> Hue /@ data[[All, 4]]], Axes -> True, BoxRatios -> {1, 1, 1/GoldenRatio}]

plotting - Mathematica: 3D plot based on combined 2D graphs

I have several sigmoidal fits to 3 different datasets, with mean fit predictions plus the 95% confidence limits (not symmetrical around the mean) and the actual data. I would now like to show these different 2D plots projected in 3D as in but then using proper perspective. In the link here they give some solutions to combine the plots using isometric perspective, but I would like to use proper 3 point perspective. Any thoughts? Also any way to show the mean points per time point for each series plus or minus the standard error on the mean would be cool too, either using points+vertical bars, or using spheres plus tubes. Below are some test data and the fit function I am using. Note that I am working on a logit(proportion) scale and that the final vertical scale is Log10(percentage). (* some test data *) data = Table[Null, {i, 4}]; data[[1]] = {{1, -5.8}, {2, -5.4}, {3, -0.8}, {4, -0.2}, {5, 4.6}, {1, -6.4}, {2, -5.6}, {3, -0.7}, {4, 0.04}, {5, 1.0}, {1, -6.8}, {2, -4.7}, {3, -1.