Yong Yi Bay
Optimization-driven search for stable high-order summation-by-parts (SBP) boundary closures. A symbolic generator (Mathematica, Maxima) solves the SBP and boundary-accuracy conditions with the remaining coefficients left as free parameters and emits them as a Fortran subroutine. A nonlinear optimizer then searches the free parameters for closures that keep the compressible Euler equations stable. The search returned 105 stable SBP(4,3) closures and 6 stable SBP(6,5) closures, run to t = 1000 on grids up to 401 x 201. The generator covers SBP(4,3), SBP(6,5) and SBP(8,7).
High-order finite differences lose stability at the boundary: an SBP operator D1 = H-1Q fixes the interior stencil but leaves the boundary block underdetermined, and most members of that family blow up on nonlinear problems. The closures here use a restricted norm, which makes strong (injection) boundary conditions energy-stable without SAT penalty terms, artificial dissipation or filtering, and the free parameters are tuned by search rather than chosen by hand.
| Result | Value |
|---|---|
| Stable closures from the compressible Euler search | 105 SBP(4,3), 6 SBP(6,5); t = 1000, grids 51 x 26 to 401 x 201, CFL 0.1 and 0.8 |
| Free parameters left by the accuracy conditions (exact, rational arithmetic) | restricted SBP(4,3): 3, SBP(6,5): 4, SBP(8,7): 5 |
| SBP identity Q + QT = diag(-1, 0, ..., 0, 1), every closure | residual 0 (exact in floating point) |
| Injection eigenvalues, N+1 = 31, 61, 91: restricted SBP(4,3), SBP(6,5) | max Re λ = -6.5e-4, -2.4e-5 (stable) |
| Same test, full-norm SBP(6,5), SBP(8,7) | max Re λ = +0.45, +20.1 (unstable) |
| Energy identity H̃D̃ + (H̃D̃)T = eNeNT, restricted norms | residual ≤ 2.5e-13 |
| L∞ convergence rate of D1f | 2.98, 4.96, 7.06 for SBP(4,3), (6,5), (8,7) (boundary order 3, 5, 7) |
| Python free-parameter search, restricted SBP(4,3): leading boundary truncation constant | 0.250 → 0.029; L∞ error at N = 401 8.4x lower, still energy-stable |
| Same search, restricted SBP(6,5) | 0.167 → 0.096; cond(H0) 2925 → 355 |
| Generated Fortran subroutine vs linear closure family | match to 6.8e-13; exact through cubics |
Figure 1. Stable boundary closures returned by the free-parameter search on the compressible Euler screening problems: 105 at fourth order and 6 at sixth order. The screening runs extend to t = 1000 on inviscid vortex transport with grids from 51 x 26 to 401 x 201 at CFL 0.1 and 0.8.
Figure 2. Sixth-order closures with injected boundary data for ut + ux = 0. Left: eigenvalues of -D̃1 on 61 points. The full-norm closure has a pair of eigenvalues at Re λ = 0.43; the restricted closure stays in the left half-plane. Right: discrete energy from a random initial state with zero inflow. The restricted norm gives a monotone energy decay, as the energy identity requires; the full norm grows by more than three orders of magnitude by t = 20.
Figure 3. L∞ error of D1 applied to exp(sin 8x + cos 8x) for the restricted closures from the symbolic solve (dashed) and after the Python free-parameter search (solid). Minimizing the leading boundary truncation constant E under an SPD and conditioning constraint lowers the fourth-order error by 8.4x at N = 401 with the convergence rate unchanged.
SBP operators. D1 = H-1Q with H symmetric positive definite and Q + QT = diag(-1, 0, ..., 0, 1), so uTHD1v + (D1u)THv = uNvN - u0v0, the discrete integration by parts. H = I in the interior with an r x r block H0 at each wall; the interior of Q is the central stencil of order 2p, and the r boundary rows of Q0 span r + p columns. SBP(2p, 2p-1) means interior order 2p and boundary order 2p - 1.
Restricted norm and injection. For ut + ux = 0 with u(0, t) = g(t), injection removes u0 and evolves ũ with dũ/dt = -D̃1ũ. The energy argument needs H̃D̃1 = (HD1)~, which holds exactly when the first row and column of H0 are zero off the diagonal. Then d/dt ‖ũ‖²H̃ = -uN², so every closure with an SPD restricted norm is energy-stable under injection. A restricted norm needs r ≥ 2p + 1 boundary rows.
Symbolic generation. The accuracy conditions D1xk = kxk-1, k = 0, ..., 2p - 1, give 2p(2p + 1) equations in 2p(2p + 1) + 1 unknowns for the restricted SBP(2p, 2p-1) block, with H0 = LLT written in Cholesky variables so that positivity is built in. Some equations are linearly dependent, and the solve in symbolic/wolfram/ leaves a three-parameter family at SBP(4,3). emit_fortran_sbp43r.wls runs common-subexpression elimination on H0-1Q0 and writes the 5 x 7 boundary block, left and right walls, as a Fortran subroutine in the free parameters (a0, a1, a2) = (q04, q14, l41): 701 temporaries, all literals in double precision.
Euler search. The generated subroutine is the parameter-to-stencil map called by a nonlinear optimizer that targets stability of the compressible Euler equations. Candidate closures were screened on: a 2-D Euler Gaussian density pulse (181² to 361², CFL 0.1 to 0.8, t = 27); the injection eigenvalue test (N + 1 = 31, 61, 91); a neutrally stable 2 x 2 hyperbolic standing-wave system (N = 21 to 101, t = 500); a 2-D variable-coefficient scalar wave equation (N = 21 to 81, t = 1000); and inviscid vortex transport with supersonic inflow/outflow and periodic cross-stream boundaries (51 x 26 to 401 x 201, CFL 0.1 and 0.8, t = 1000).
Linear family and Python search. In (Q0, H0) entries the accuracy conditions Q0xk = kH0xk-1 are linear. sbpopt.family solves them in exact rational arithmetic and returns every closure as z(θ) = z0 + Nθ. All shipped closures lie in these families (fit residual ≤ 2.4e-11), and so does every block produced by the generated Fortran. sbpopt.search then minimizes the leading boundary truncation constant E(θ) = maxi |(H0-1(Q0x2p - 2pH0x2p-1))i| / (2p)! subject to λmin(H0) ≥ 0.1 and cond(H0) ≤ 10³. Each random start runs two downhill-simplex phases: the first drives the constraint violation to zero, the second minimizes E with exact penalties. Every candidate is then checked on its own for SPD, the SBP identity, boundary accuracy, the energy identity, and max Re λ ≤ 0 on 31, 61 and 91 points. On restricted SBP(4,3), all 40 starts converge to the same optimum, E = 0.0290.
Conservation. The _w.csv weights are the row sums of H0. With W = diag(w), the columns of WD1 sum to (-1, 0, ..., 0, 1), so the scheme conserves discretely in the quadrature defined by the norm.
| Component | File |
|---|---|
| Interior stencils, operator assembly D1 = H-1Q, SBP and accuracy residuals, convergence | sbpopt/operators.py |
| Exact rational solve of the accuracy conditions, affine family z0 + Nθ | sbpopt/family.py |
| Injection operator, eigenvalue test, energy identity, energy history | sbpopt/stability.py |
| Truncation constant, constrained multi-start search, candidate verification | sbpopt/search.py |
| Interpreter for the generated Fortran block, fit to the linear family | sbpopt/fortran.py |
| Symbolic solve in Cholesky variables, SBP(4,3) / (6,5) / (8,7), full and restricted | symbolic/wolfram/ |
| Fortran code generation with common-subexpression elimination | symbolic/wolfram/emit_fortran_sbp43r.wls |
| Maxima variants: diagonal SBP(4,2), elimination for full SBP(4,3), constrained COBYLA prototype | symbolic/maxima/ |
| Generated closure subroutine and driver | fortran/ |
| Closure coefficients | closures/ |
sbpopt/ Python package: operators, exact families, stability, search, Fortran check, verify
symbolic/wolfram/ wolframscript generators (sbp43_restricted.wls -> emit_fortran_sbp43r.wls, ...)
symbolic/maxima/ Maxima solves and a COBYLA search prototype
closures/ <name>_H.csv (r x r, row-major), <name>_Q.csv (r x (r+p)), <name>_w.csv (weights)
fortran/ dirichlet_sbp43r.f90 (generated), check_dirichlet_sbp43r.f90, Makefile
analysis/ spectra.py, convergence.py, search_free_parameters.py; results/ holds their CSV output
tests/ pytest numerical validation (67 checks)
benchmarks/ bench_pipeline.py and results.csv
tools/ make_readme_assets.py (figures), promote_fortran_literals.py
assets/ README figures
Closures in closures/: sbp43_full, sbp43_restricted, sbp65_full, sbp65_restricted, sbp87_full from the symbolic solve, and sbp43_restricted_optimized, sbp65_restricted_optimized from the Python search.
pip install -e ".[test]" # or: uv sync --extra test
make verify # python -m sbpopt.verify, about 5 s
make test # pytest, 67 checks
make search # regenerate optimized closures and analysis/results/search_*.csv
make analysis # spectra.csv and convergence.csv
make figures # assets/*.png
make fortran # gfortran build and run of the generated subroutineExpected make verify output (timings vary):
Closure catalog (injection eigenvalue test on N+1 = 31, 61, 91 points)
closure SBP res SPD acc res max Re(lam) energy res L_inf order E_trunc verdict
sbp43_full 0.0e+00 True 5.7e-14 -1.285e-03 1.9e-01 2.98 0.2546 stable
sbp43_restricted 0.0e+00 True 2.8e-14 -6.527e-04 3.5e-16 2.98 0.2500 stable
sbp65_full 0.0e+00 True 5.7e-14 4.474e-01 1.6e+00 4.96 0.1693 UNSTABLE
sbp65_restricted 0.0e+00 True 4.5e-13 -2.358e-05 2.5e-13 4.96 0.1667 stable
sbp87_full 0.0e+00 True 9.1e-13 2.013e+01 3.4e+00 7.06 0.1225 UNSTABLE
sbp43_restricted_optimized 0.0e+00 True 6.6e-12 -1.363e-03 2.9e-16 3.04 0.0290 stable
sbp65_restricted_optimized 0.0e+00 True 4.6e-11 -3.431e-04 6.1e-15 5.08 0.0960 stable
Exact free-parameter count of each closure family (rational arithmetic)
SBP(4,3) full r = 4: 16 unknowns, 2 free parameters
SBP(4,3) restricted r = 5: 21 unknowns, 3 free parameters
SBP(6,5) full r = 6: 36 unknowns, 3 free parameters
SBP(6,5) restricted r = 7: 43 unknowns, 4 free parameters
SBP(8,7) full r = 8: 64 unknowns, 4 free parameters
SBP(8,7) restricted r = 9: 73 unknowns, 5 free parameters
Generated Fortran (fortran/dirichlet_sbp43r.f90) vs linear restricted SBP(4,3) family
(a0, a1, a2) = (0.0, -1.0, 1.0): accuracy residual 3.6e-13, family match 6.8e-13, H0 SPD True
(a0, a1, a2) = (0.1, -0.5, 0.8): accuracy residual 2.1e-13, family match 5.5e-13, H0 SPD True
Optimized vs reference restricted closures (L_inf error of D1 f, N = 401)
SBP(4,3) restricted: E_trunc 0.2500 -> 0.0290, error 2.585e-04 -> 3.090e-05 (8.4x lower), max Re(lam) -1.36e-03
SBP(6,5) restricted: E_trunc 0.1667 -> 0.0960, error 8.146e-07 -> 4.648e-07 (1.8x lower), max Re(lam) -3.43e-04
Fresh free-parameter search, restricted SBP(4,3), 8 random starts
8/8 candidates verified stable in 2.9 s; best E_trunc 0.0290, cond(H0) 17.6, max Re(lam) -1.36e-03
Symbolic generator. With wolframscript: wolframscript -file sbp43_restricted.wls (writes sbp43_restricted.mx), then wolframscript -file emit_fortran_sbp43r.wls (writes dirichlet_sbp43r.f90), then python tools/promote_fortran_literals.py dirichlet_sbp43r.f90. The other sbp*.wls scripts write <name>_{H,Q,w}.csv in the closures/ format.
python benchmarks/bench_pipeline.py, single thread, Intel Core Ultra 7 265F, Python 3.14, NumPy 2.5:
| Family | Stage | Size | Time |
|---|---|---|---|
| SBP(4,3) restricted | exact rational solve of accuracy conditions | 21 unknowns | 1.5 ms |
| SBP(6,5) restricted | exact rational solve | 43 unknowns | 7.3 ms |
| SBP(8,7) restricted | exact rational solve | 73 unknowns | 45 ms |
| SBP(4,3) / (6,5) / (8,7) | objective evaluation (assembly, SPD, E) | 3 / 4 / 5 parameters | 25 / 31 / 45 µs |
| SBP(4,3) / (6,5) / (8,7) | full verification of one candidate (incl. 3 eigenvalue solves) | 2.8 / 2.9 / 5.9 ms | |
| SBP(4,3) restricted | one search start (two simplex phases + verification) | 3 parameters | 0.76 s |
| SBP(6,5) restricted | one search start | 4 parameters | 2.0 s |
| SBP(4,3) restricted | interpret generated Fortran block | 701 temporaries | 13 ms |
@software{bay_sbp_closure_optimizer,
author = {Bay, Yong Yi},
title = {sbp-closure-optimizer: optimization-driven search for stable high-order summation-by-parts boundary closures},
year = {2026},
url = {https://github.com/bay-yearick-lab/sbp-closure-optimizer}
}See also CITATION.cff.
MIT, see LICENSE.



