This site is version 0.0.1. Most of the code on this site is drafted by an agent and needs review. I apologize for the AI-speak, we are working on rewriting it!
viv-lang.org

PDE solvers · Waves whose speed depends on wavelength (dispersive)

The time-dependent Schrödinger equation

Method
split-step Fourier (Strang splitting): the kinetic step is exact in momentum space
Checked
a free packet's spreading, a coherent state's oscillation, norm conservation, and the measured order of the splitting

Two operators, each trivial in its own basis. The potential multiplies by a phase; the kinetic energy multiplies by a phase. Neither can be applied exactly to the other's representation — but an FFT moves between them, so alternate: half a potential step, a full kinetic step, half a potential step. That is Strang splitting. Every factor is a pure phase, so the norm is conserved to rounding whatever the time step, and the error is , from the two operators failing to commute.

Free particle. With there is nothing to split and one step of any length is exact. A Gaussian packet moves at its group velocity and spreads as .

Harmonic oscillator. In the ground state displaced to is a coherent state: it keeps its shape and its center follows the classical orbit, .

Where you look for the splitting error matters. For this potential Strang splitting solves, exactly, an oscillator whose frequency is off by — so the computed center is with a phase error . After a FULL period that is : the error is quadratic in and the scheme looks fourth order. At a QUARTER period, where the orbit crosses the origin, it is , and the true order shows. Both are measured below.

What the run shows

A free Gaussian packet: it moves at k0 and spreads
t = 0t = 3
00.10.20.30.4−20−10010xprobability density
  • every step is a pure phase: the norm is conserved to rounding
  • a free packet moves at its group velocity: <x> = x0 + k0 t
  • and spreads as sigma0 sqrt(1 + (t / 2 sigma0^2)^2)
  • a coherent state follows the classical orbit: at a quarter period it is at the origin, its width unchanged
  • Strang splitting is second order, measured where the phase error shows linearly
  • and looks fourth order after a full period, where the error is the square of the phase error
free_center
-5.55112e-16
free_width
1.80278
free_norm
1
q_center
-4.84487e-05
q_width
0.707129
order
2.00012
full_order
4.00096

Computed when this page was built, by the same interpreter that runs it in your browser: 6 of 6 tests, under 0.1 s. The numbers above are the program's show lines.

The program

108 lines, 7 functions. It is editable: change it and press Run (or ⌘/Ctrl + Enter). The tests at the bottom run too, so if your change breaks the solver, a test fails.

packet
A normalized Gaussian packet of width sigma at x0, with momentum k0.
phase
exp(-i theta) for a real array theta, as a complex array.
kinetic_step
One kinetic step of length dt: exact, in momentum space. Returns a new array.
norm_of
mean_x
width_of
evolve
Evolve the coherent state for `periods` of an oscillator period in `steps` Strang steps.
Viv [1]

Open in the workbench The atlas Download schrodinger_1d.viv