Verify a KdV pulse with a convergence study
How do you tell whether a computed solitary wave follows the KdV equation accurately? In this laboratory you compare a numerical trajectory with an exact pulse, refine time, space and domain separately, and measure conserved integrals. The most revealing result is a failure: a poorly resolved pulse can conserve several integrals almost perfectly.
Required background. Use the KdV travelling wave and the three conserved integrals. You need elementary Python to run or change the experiment. The Fourier convention and time update are developed below.
A line pulse on a periodic numerical grid
Section titled “A line pulse on a periodic numerical grid”The exact real-line solution of
is
Set , and . The pulse moves from to , keeps height , and has inverse width . The model fixes the zero-background, rapidly decaying regime.
Our computer instead represents a periodic function on . Sample at , , and impose periodicity through a Fourier series. A restricted line pulse does not satisfy exact periodic matching at the endpoints. Making the box longer reduces this mismatch, but does not turn the torus into the real line. The domain study tests its effect during this finite interval.
Check your error calculation
Section titled “Check your error calculation”If an approximate profile is at every grid point, what are its relative and maximum errors? What if instead?
Solution and preparation
Both relative errors are for the uniform amplitude change. The shifted profile needs a pointwise comparison; equal heights do not imply equal functions. To first order, its difference is . This is why the experiment compares profiles before aligning their centers: alignment would hide the phase error we want to measure.
Fourier differentiation and quadratic aliasing
Section titled “Fourier differentiation and quadratic aliasing”Use Fourier modes , . Differentiation multiplies a coefficient by . Since , the Fourier evolution has the sign
The factor comes from . NumPy’s forward FFT has no factor; its inverse supplies that factor. The code uses this pair consistently.
Multiplying sampled functions can wrap high frequencies into low ones. To prevent that error for the quadratic term, retain only integer modes satisfying , project the initial field, and apply the same projection after every nonlinear evaluation. If two retained modes sum outside the retained band, their wrapped sum cannot fall back inside it. The strict inequality removes the borderline case. This is the 2/3 dealiasing rule.
Thus grid points retain 341 Fourier modes. Dealiasing makes the retained quadratic convolution correct; it cannot recover an unresolved narrow pulse. The experiment independently compares the FFT product with an explicit non-circular convolution on a small random Fourier polynomial.
Integrate dispersion exactly within each time step
Section titled “Integrate dispersion exactly within each time step”Write the finite Fourier system as , with . On one step, introduce the local variable
Apply ordinary fourth-order Runge–Kutta to this equation and restore . The linear dispersive phase is exact, while the nonlinear evolution still has time error. This is integrating-factor RK4, as described by Kassam and Trefethen 2005, pp. 1215–1216, equations (1.5)–(1.9), PDF. It is distinct from their ETDRK4 method.
For the diagonal multiplier , the implemented stages are
The code checks these stages against a separate implementation of RK4 in . It also sets and checks the exact Airy wave , catching a reversed dispersive sign. Removing linear stiffness does not make arbitrarily large nonlinear steps reliable.
Reproduce and interpret the experiment
Section titled “Reproduce and interpret the experiment”Download and extract the complete KdV experiment (ZIP), then open its kdv folder. Individual files are also available: experiment.py, inputs.json, results.json, requirements.txt, and computation notes. The recorded run used Python 3.9.6, NumPy 2.0.2 and binary64 arithmetic. With Python 3.9–3.12, run in that folder:
python3 -m venv .venv.venv/bin/python -m pip install -r requirements.txt.venv/bin/python experiment.py --checkOn Windows the virtual-environment executable is .venv\Scripts\python.exe. In an existing checkout with NumPy installed, run python3 public/computations/kdv/experiment.py --check. The check recomputes all studies without changing files. Running without a flag prints fresh results; --write deliberately regenerates the saved JSON. Modify a separate working copy when exploring new inputs.
For grid samples , report
These are normalized discrete approximations to the two norms, at . They include projection, evolution and finite-domain discrepancies. The profiles are not shifted to improve their agreement.
Refine time at fixed space and domain
Section titled “Refine time at fixed space and domain”Hold and fixed.
| Time step | ||
|---|---|---|
The successive estimates are , and , approaching the method’s fourth order. These measurements apply to the tested smooth pulse and resolutions; they are not a universal stability guarantee.
Refine space without enlarging the box
Section titled “Refine space without enlarging the box”Now hold and fixed. Monitor
For the exact line pulse these are , and . The model’s translation generator and Hamiltonian are and . The code records maximum drift from each initial discrete value over all time steps, divided by its exact line value; it also records the initial line-integral error separately.
| Grid points | Larger normalized drift of | ||
|---|---|---|---|
| 64 | |||
| 96 | |||
| 128 | |||
| 192 | |||
| 256 | |||
| 384 |
At , the profile error is about even though the conserved quantities barely drift. The truncated Fourier dynamics can preserve its integrals while representing the continuum pulse poorly. In the following figure, compare the separation of the solid and dashed curves at the coarsest grid.
Small invariant drift does not imply an accurate KdV profile. These quantitative curves use the table above, with , , , and . The dashed curve is the larger normalized drift of and over the sampled time steps. The vertical axis is logarithmic; the lines only connect tested resolutions.
Enlarge the domain at fixed spacing
Section titled “Enlarge the domain at fixed spacing”Finally hold and fixed, increasing with .
| Period length | Grid points | ||
|---|---|---|---|
| 16 | 128 | ||
| 24 | 192 | ||
| 32 | 256 | ||
| 48 | 384 |
The initial/final endpoint values, as fractions of the pulse height, fall from at to at . The last two errors form a floor set by remaining time and spatial errors. Their small difference does not establish that the smaller box is more accurate in general. Holding fixed while enlarging the box would coarsen and mix two effects.
The separate reference run at , and has and . Its largest normalized integral drift is .
A false solution with perfect line integrals
Section titled “A false solution with perfect line integrals”Translate the correct shape at half the correct speed:
Translation leaves unchanged, yet substitution gives
which is nonzero. At , its relative error is , while the three sampled integrals differ from the exact line values by at most relative. This deliberately incorrect trajectory shows why an equation residual or independent solution comparison is indispensable.
Exercises
Section titled “Exercises”Guided: measure the order
Section titled “Guided: measure the order”
Using the last two temporal errors, compute the observed order and predict the error after one more halving if fourth-order behavior dominates. State one reason the prediction can fail.
Hint
Divide the errors, take the base-two logarithm, then use a factor of for the prediction.
Solution
The ratio is about , giving order . Fourth-order scaling predicts . A remaining spatial, domain or roundoff error can spoil this scaling; the coefficient can also change before the asymptotic regime is reached. An observed order is evidence about this refinement, not an exact law for every step size.
Independent: expose the conservation blind spot
Section titled “Independent: expose the conservation blind spot”
Use the spatial result to assess the claim: “The pulse is accurate to twelve digits because its conserved quantities drift by less than .” Distinguish the initial projection, the finite Fourier evolution and the continuum solution.
Hint
Inspect the profile error and the separate initial-projection fields in the saved JSON. Conservation measures change along a trajectory, not its distance from the requested trajectory.
Solution
The claim is false: the final profile has relative error about . Projection discards high Fourier modes before time stepping. The retained system then evolves different finite-dimensional data and can nearly preserve its own discrete integrals. Neither that preservation nor agreement of a few initial integrals bounds the full field error. The spatial-refinement comparison directly tests the lost-resolution effect.
Transfer: resolve a narrower pulse
Section titled “Transfer: resolve a narrower pulse”
Change from to . How should spatial resolution, time interval and time step scale to compare the same dimensionless motion? Explain why doubling alone is insufficient.
Hint
Use , and .
Solution
To keep the scaled grid and motion fixed, halve , divide and by eight, and halve the period length and initial center when scaling the whole physical setup. Equivalently, on an unchanged large box one needs at least twice as many points to keep the same points per width, while still refining time for the eightfold nonlinear/dispersive time scale. Doubling alone leaves the temporal and domain comparisons uncontrolled. Run new separate refinements; the saved acceptance results cover the original parameter set.