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 nonlinear Schrödinger equation

Method
split-step Fourier: the nonlinear step is ALSO exact, because it conserves the modulus
Checked
the bright soliton sech(x) exp(it/2): its shape, its phase, the conserved norm, and the measured order

Light in a fiber, a Bose-Einstein condensate, deep-water wave envelopes. Dispersion spreads a pulse; the focusing nonlinearity squeezes it. When they balance the pulse is a soliton, and the simplest is : a shape that does not change at all, with a phase that turns at a steady rate.

Split-step works even better here than for the linear equation. The nonlinear part alone, , leaves unchanged — so its solution is exactly , no time-stepping error. Both halves are exact; the only error is the splitting itself.

What the run shows

A bright soliton: the modulus does not move
t = 0t = 2
00.51.0−20−10010x|ψ|
  • the soliton keeps its shape: |psi| is still sech(x)
  • its phase turns at rate 1/2: arg psi(0, t) = t/2
  • the norm, 2 for sech(x), is conserved to rounding
  • the splitting is second order
shape_error
4.9692e-06
norm
2
phase_now
0.999997
order
1.99982

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

The program

71 lines, 3 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.

phase
exp(+i theta) for a real array theta.
evolve
Evolve the soliton to time t_end in `steps` Strang steps.
center_phase
The phase of psi at x = 0, in radians.
Viv [1]

Open in the workbench The atlas Download nls_soliton.viv