Skip to content

A3 Spectral properties ​

IDGroupTypeBackendsFigureProgram
A3AccuracyPthe rows (exact, Python); CPU (gfortran R4P, R8P, R16P; nvfortran) for the compiled kernelsyesgideon_test_spectral, gideon_vv_advection

Case and scope ​

An order of accuracy describes the error as h→0. At a finite resolution, what an operator does to each Fourier mode decides: how fast it propagates a wave (dispersion) and whether it damps or amplifies it (dissipation). This case computes the modified wavenumber of every first and second derivative at a node or over a cell: from the exact rows, for the figures and tables, and from the compiled kernels, which must agree with them. It then advects a wave packet with three compiled kernels, so that the two effects are seen on a solution.

Models and numerics ​

ItemChoiceCode
Symbolσ(ξ)=∑owoeioξ, ξ=kh; for cell averages the averaging factor sin⁡(ξ/2)/(ξ/2) of the data and of the target cancels, so node (fd) and cell (fv) operators are read alike
First derivativeξ~=−iσ, exact ξ~=ξ. Re ξ~ is the dispersion; for ut+aux=0, a>0, a mode grows like eaImξ~t/h: Im ξ~<0 dissipates, Im ξ~>0 amplifies
Second derivativeξ~2=−σ, exact ξ2
From the rowsthe generator's exact weights (--json), in double precisionmake_tables.py symbol_exact
From the kernelseach kernel on cos⁡(oξ) and sin⁡(oξ) (h=1), σ=k(cos)+ik(sin), at ξ=jπ/256, j=1…256gideon_test_spectral.F90
Asserted (frozen)centred kernels: |Im|≤64ε∑|c| at every ξ; left-side d1 of 1 and 2 cells: Im ≤ the same; every left-side kernel the mirror of its right twin, σul=(−1)nσur―. The left-side d1 that amplify a band are listed, not failed
Resolutionthe largest ξ/π below which |Reξ~−ξ|/ξ<1% (the resolving efficiency of Martín et al. 2006; for d2 the same on ξ~2)resolution
Advectionut+ux=0 on the periodic [0,1), 128 cells, cell averages, RK4 at CFL 0.25 (SELAH's SCHEME_RK4, the stepper on the rank-1 field), two periods; du/dx from gideon_fv_d1_c2, gideon_fv_d1_c4, gideon_fv_d1_ul2; the packet e−((x−1/2)/0.07)2sin⁡(16πx), its carrier at ξ=π/8; asserted: the mass kept to 103ε, the energy never growing, the upwind kernel losing at least half of it, c4 more accurate than c2gideon_vv_advection.F90

Program ​

bash
./exe/gideon_test_spectral
./exe/gideon_vv_advection
scripts/run_report.sh          # the CSV of the symbols and the frames of the packet, then figures and casts

Results ​

Centred derivatives ​

Modified wavenumber of the centred first and second derivatives

Re ξ~ of the first derivatives and ξ~2 of the second ones, orders 2 to 10. The imaginary parts are zero. The FD node kernels and the FV cell-average kernels of one order have the same row (C1): one curve for both.

Kernel (= fv_ twin)DerivativeOrderResolution ξ/π (1 % dispersion)Value at ξ = πExact at π
fd_d1_c2d120.0780.00003.1416
fd_d1_c4d140.2390.00003.1416
fd_d1_c6d160.3500.00003.1416
fd_d1_c8d180.4260.00003.1416
fd_d1_c10d1100.4810.00003.1416
fd_d2_c2d220.1104.00009.8696
fd_d2_c4d240.3175.33339.8696
fd_d2_c6d260.4466.04449.8696
fd_d2_c8d280.5306.50169.8696
fd_d2_c10d2100.5886.82679.8696

Upwind first derivatives ​

Dispersion and dissipation of the left-side first derivatives

The left-side first derivatives gideon_fv_d1_ul1 to _ul9 (upwind for a>0): Re ξ~ (left, clipped) and Im ξ~ (right, on a symmetric log scale). Above the dashed line a mode grows.

KernelOrderResolution ξ/πMin Im ξ̃ (dissipation)Max Im ξ̃Amplifying band ξ/π
fv_d1_ul110.078-2.0000none
fv_d1_ul220.055-4.0000none
fv_d1_ul330.138-6.667+0.0830.000-0.419
fv_d1_ul440.171-10.667+0.6670.004-0.608
fv_d1_ul550.186-17.067+2.3270.234-0.711
fv_d1_ul660.242-27.733+6.0750.383-0.775
fv_d1_ul770.237-46.019+13.8380.013-0.817
fv_d1_ul880.244-78.019+29.3110.022-0.847
fv_d1_ul990.279-134.908+59.5660.123-0.868

The compiled kernels against the rows ​

BuildKernelsWavenumbersLargest |compiled − exact| / Σ|c|WhereTest failures
gfortran, R4P542562.0⋅10−7fv_d1_ur80
gfortran, R8P542564.6⋅10−16fv_d1_ur70
gfortran, R16P542569.1⋅10−16fv_d1_ul80

A wave packet ​

The packet over two periods, every frame computed by GIDEON's compiled kernels (gideon_vv_advection, report mode).

The packet after two periods

After two periods: c2 lags (its group velocity at ξ=π/8 is below 1) and leaves a train of waves behind; c4 nearly keeps up; ul2 has damped the packet and shifted it.

Kernelt (periods)max |u − exact|Energy kept
fv_d1_c22.0000.9881.0000
fv_d1_c42.0000.1971.0000
fv_d1_ul22.0000.9220.1835

Findings ​

  • Centred kernels do not dissipate. Their imaginary part is zero to round-off in every kind, from the rows and from the compiled kernels: the pair form makes the first derivative antisymmetric and the second symmetric exactly. The energy of the centred runs is kept to the digits printed (RK4 alone damps it, below them). A centred scheme gets its dissipation, if it needs one, from elsewhere.
  • Dispersion falls with the order, but slowly. The 1% resolution grows from order 2 to 10 (table): a wider row resolves more of the band, never all of it. At ξ=π every centred first derivative returns 0 (the odd-even mode does not move), and the second derivatives fall short of π2.
  • Only the one- and two-cell left-side first derivatives dissipate every mode. From three cells on, every fully one-sided first derivative has a band where Im ξ~>0: a mode of ut+aux=0 in that band grows, whatever the time step. For gideon_fv_d1_ul3 the band is every wavenumber below arccos⁡(1/4) (its growth rate is ah(1−cos⁡ξ)2(4cos⁡ξ−1)/3); the band of each kernel is in the table. The right-side kernels are their mirrors and do the same for a<0. These rows are exact and verified, and they are kept as building blocks (the candidate stencils of an upwind-biased or WENO reconstruction); as the only spatial operator of an advection scheme, they are unstable.
  • The compiled kernels are the rows. Their symbols agree with the exact rows' to the precision of the kind (table), and the mirrors hold in the symbols as in the values (C3).
  • The packet confirms both effects on a solution. With its carrier at ξ=π/8, c2 disperses the packet into a trailing train and keeps its energy; ul2 keeps the mass and loses most of the energy.

Released under your choice of GPL-3.0-or-later, BSD-2-Clause, BSD-3-Clause or MIT.