Skip to content
pascal.tremblin edited this page Nov 29, 2026 · 3 revisions

Convergence study of the canoP studio tutorial

The order of convergence of the finite-volume scheme of canoP, measured on a smooth problem with a known solution. This is the campaign convergence of the tutorial of canoP studio (third page, docs/tutorial/campaign.md in canoP); its files are in this repository (README).

The problem

A sine wave of density advected at uniform velocity in a periodic domain:

  • density m = m0 + A sin(2πx) sin(2πy), with m0 = 1 and A = 0.2; pressure P = 1; velocity (1, 1);
  • domain [0, 1]², periodic in x and y; final time t = 1, when the wave is back at its initial position. The exact solution at time t is the initial wave moved by (vx, vy) t.

Scheme: model onephase, HLLC flux, MUSCL reconstruction with the minmod limiter, SSP Runge-Kutta 2, CFL 0.4.

Meshes: uniform, with every block refined up to amr.max_refine (amr.epsilon_refine = amr.epsilon_coarsen = -1). The campaign varies amr.max_refine = 5, 6, 7, 8, 9, that is 32², 64², 128², 256² and 512² cells.

Runs: 2026-11-29, canoP 5620403 (main), physics d80a072 of this repository, 1 MPI process of 16 OpenMP threads per run (Slurm, one node).

The initial condition

A new file of the physics of the campaign, physics/onephase/initial_conditions/sine.py, chosen by physics.initial_condition = sine. Its parameters are read in the [sine] section of the input file by params, in Python; initial_state is translated into C++ by pykokkos and compiled:

@pk.function
def initial_state(x: float, y: float, z: float, ip: ICParameters, domain: pk.View1D[pk.double],
                  dim: int) -> Prim:
    q: Prim = Prim(0.0, 0.0, 0.0, 0.0, 0.0, 0.0)
    sx: float = pk.sin(2.0 * math.pi * (x - domain[0]) / domain[3])
    sy: float = pk.sin(2.0 * math.pi * (y - domain[1]) / domain[4])
    q.m = ip.m0 + ip.amplitude * sx * sy
    q.P = ip.P0
    q.vx = ip.vx
    q.vy = ip.vy
    return q

The error

analysis.py of the campaign reads the last output of each run (t = 1) and computes the L1 error of the density, Σ |m - m_exact| S / Σ S over the cells (S: area of a cell), and the observed order between two successive meshes, log(e_coarse / e_fine) / log(n_fine / n_coarse) with n the number of cells per direction.

L1 error of the density against the number of cells per direction, with a line of order 2

Cells L1 error of the density Observed order Duration (s) Mcell-updates/s
32² 1.117e-2 7 0.15
64² 3.462e-3 1.69 7 0.66
128² 1.079e-3 1.68 45 1.69
256² 3.185e-4 1.76 68 3.13
512² 8.960e-5 1.83 473 3.48

Discussion

  • The observed order rises from 1.69 to 1.83 and approaches 2, the order of the scheme. It is below 2 because the minmod limiter flattens the slopes at the extrema of the wave, where the reconstruction falls to order 1; these regions shrink as the mesh is refined.
  • From 256² to 512² the duration is multiplied by 7, close to 8, the work of one more level in 2D: 4 times more cells and twice more time steps. On the smallest meshes the duration is mostly the start of canoP and the outputs, and 16 threads are not filled (0.15 Mcell-updates/s on 32² against 3.5 on 512²).

Reproduce

See the README: canoP at commit 5620403, this repository cloned as _campaigns/convergence, then Prepare again and Launch the prepared runs in canoP studio. The Analysis tab shows this plot and table once the runs are finished.

Clone this wiki locally