Skip to main content

physverify — code verification for numerical simulation

tests PyPI Python DOI Docs

Test whether simulation code behaves as the mathematics predicts. Check convergence order, agreement with exact or manufactured solutions, conservation laws, and time-integration coefficients.

A simulation can run, give plausible numbers and still be wrong: a sign slip, a missing factor of 2, one coefficient copied with a digit dropped. Comparing with one stored answer rarely shows it, because nobody knows the exact answer for a real simulation. The mathematics still predicts things you can test: the error must shrink at the method's order, a manufactured solution must come back, an insulated domain must keep its heat, a Runge–Kutta table must satisfy its order conditions. physverify runs those tests and says in plain words what was tested and what came out: PASS, FAIL, EXACT or INCONCLUSIVE, with the numbers.

Its strongest coverage is ODE time integration; PDEs are covered in selected cases (the heat equation in 1D, 2D and 3D, and 1D transport). It needs only NumPy and runs from Python, the command line, pytest or GitHub Actions. qmat and exponax-spde run its checks in their own tests. Current release: 0.10.0 (v0.10.0); actively developed, feedback welcome.

Try it

pip install physverify
physverify demo

The demo checks a correct damped-oscillator solver (all checks pass), then the same solver with the damping 10% too large. The broken one still gives a smooth, plausible curve, and every check fails:

Error against step size: the correct solver follows the slope-2 line, the broken one levels off

New to this? Start here takes about ten minutes.

Verify your simulation code

Write the reference from the physics (a textbook, a paper, the project's README), never from the code under test; otherwise a bug in the code is copied into the reference and the check passes.

What you have Start with
Errors you measured at a few step or grid sizes check_order (first example below)
Runge–Kutta, IMEX or Rosenbrock coefficients physverify.butcher.check_tableau (second example below) and its relatives
A fixed-step ODE solver function physverify init, then physverify run or pytest (third example below)
A problem with a closed-form solution physverify references lists the exact solutions
A 2D or 3D heat-equation solver the heat checks

Always include a problem where f depends on t (for example y′ = y cos t): a stage at the wrong time or a missing ∂f/∂t term does not show on y′ = λy.

Convergence order, as a pytest test. Run the solver at a few step sizes, measure the error against an exact solution, and check the order:

import numpy as np
from physverify import check_order

def midpoint_error(n):                    # y' = -y, y(0) = 1, exact y(1) = exp(-1)
    h, y = 1.0 / n, 1.0
    for _ in range(n):
        y = y + h * -(y + h / 2 * -y)
    return abs(y - np.exp(-1.0))

def test_midpoint_is_second_order():
    ns = [10, 20, 40, 80]
    result = check_order([1 / n for n in ns], [midpoint_error(n) for n in ns], expected=2)
    assert result.status == "PASS", result.message    # "observed order 2.03 (expected 2)"

A Runge–Kutta table, from the coefficients alone (no solver needed):

from physverify.butcher import check_tableau

A = [[0, 0, 0, 0], [1/2, 0, 0, 0], [0, 1/2, 0, 0], [0, 0, 1, 0]]
print(check_tableau(A, b=[1/6, 1/3, 1/3, 1/6], c=[0, 1/2, 1/2, 1], claimed=4))
# PASS: order 4 confirmed by the order conditions

Change the last row of A to [0, 0, 0.9, 0] and the verdict is FAIL: the table satisfies the order conditions only up to order 1. The same module checks embedded pairs, stability claims, dense output (check_dense_output), IMEX order and coupling conditions (check_additive) and Rosenbrock and W-methods (check_rosenbrock).

A whole solver, from a spec. physverify init verify_solver.py --solver mysolver --order 4 writes a starter spec for a fixed-step ODE solver. Fill in the right-hand side from the physics, then run physverify run verify_solver.py or pytest verify_solver.py. The starter spec runs manufactured-solution, reference-solution and exact-patch checks; add a quantity function (an energy, a mass) to check conservation as well.

On every push. A failed check fails the job, like a broken unit test (CI guide):

      - uses: rcgiri-physics/physverify@v0.10.0
        with:
          specs: tests/verify_*.py

What it checks

Check The question it answers
Order of convergence Does the error shrink as fast as the method promises?
Manufactured solutions Does the code solve these equations, source terms and all?
Reference and exact solutions Does it agree with a closed-form result or an independent, more accurate solution?
Conservation and budgets Is energy kept? Does heat leak through an insulated wall?
Exact patch tests Does it reproduce a solution it should get to round-off?
Time-integration coefficients Do the Runge–Kutta, IMEX or Rosenbrock coefficients have the order their name says?
Statistics Do the error bars mean what they say? Is a Monte Carlo sampler correct?

Every example in the documentation is a small script in docs/examples/, and the output shown is what it printed. Recipes · What a PASS means · Troubleshooting · API

With an AI coding assistant

An assistant reading code makes many claims, and reading cannot tell the right ones from the wrong ones: of 119 claims five AI reviewers made about repositories found clean earlier, check runs showed 10 were wrong and 18 stayed unsettled. A run against a reference from the physics decides. Start here has a prompt to paste into Claude Code, Codex, Cursor or Copilot, AGENTS.md gives an assistant the rules, and the assistant guide shows an agent skill and a hook that runs the checks after every edit.

The checks run your project's Python code on your computer, so use them on projects you trust, or inside the sandbox.

Runge–Kutta table census

Coefficient tables are copied by hand from papers into code, and one wrong digit can lower a method's order with no visible sign: adaptive step control hides it, and a test on y′ = λy often cannot see it. In November 2026, physverify.butcher (including the Rosenbrock, IMEX and dense-output checks added in 0.9.0) was run on 847 Runge–Kutta tables (explicit, implicit, IMEX and low-storage) from 34 libraries, and then on the Rosenbrock and W-method tables of every Rosenbrock code a GitHub search found. NodePy agreed on all 680 passing tables it was run on, and 344 tables were compared with their first published source.

  • 791 of the 847 tables pass and 39 fail; each failure was reviewed by hand, and more than half are defects (the others are by design, harmless or still open).
  • Most defects show only when f depends on t (a stage at the wrong time, a missing ∂f/∂t term) or only in the error estimate, so a test on y′ = λy passes. Test with a time-dependent problem too.
  • 23 defect reports were sent to the libraries. By 2026-11-21, 5 were confirmed by the maintainers, 2 had fixes in review and 16 were waiting for a reply; since then RungeKutta.jl and marco have confirmed and fixed theirs. A library is named here only after its maintainers confirm.

The census page has the method, the outcomes and what was not covered. The tables themselves are published as a separate dataset, runge-kutta-catalog (doi:10.5281/zenodo.24412889): every table with its library, version and source, the methods compared with their first published sources, 88 Rosenbrock tables, and scripts that re-check each one with physverify. The counts hold for these libraries only; they are not an error rate for numerical software.

Confirmed by maintainers

Three examples. The full record lists every confirmed report, each with a link to the maintainer's response or the fix.

  • qmat: three Runge–Kutta schemes were labelled one order higher than they have. The maintainers corrected them and now check their tables with physverify.butcher in their own tests (PR #24).
  • OrdinaryDiffEq.jl: one node of the 12th-order Feagin table was stored as 2 instead of 0.2, so on a time-dependent problem the method converged at first order. A maintainer confirmed it, and it is fixed (PR #5002).
  • SUNDIALS: in the symplectic SPRKStep integrator, a time-dependent force made every table first order. A maintainer reproduced it independently and proposed the fix (response).

These show that the defects were real; they are not a bug rate for physics code.

How well it works

  • Seeded bugs: of 37 bugs added one at a time to five small solvers, the checks flagged all 37 (two of them only after checks were added for those two; plain "compare with one answer" tests: 27), with no false alarms. The same person wrote the bugs and the checks, so this shows the tool works as designed, not how it does on other code. python scripts/reproduce_all.py regenerates the tables.
  • AI review claims on 100 repositories (2026-11): five AI reviewers reviewed 100 public physics repositories. On the 50 that earlier testing had found clean, 119 review claims were each checked by a run: 40 changed a result, 51 were real but minor, 10 were wrong and 18 could not be settled. Counts hold for this sample only; the labels come from two automated checkers following written rules (preprint, doi:10.5281/zenodo.24224433).
  • Earlier testing of public repositories (October 2026): of the first 74 defects reported to authors, 14 were found by a physverify check as such, 11 by running the code at all, and the rest by each repository's test script or by reading (ledger, results).

Also included

  • A spec without Python: [[tool.physverify.ode]] tables in pyproject.toml name the solver, its claimed order and the equations as text (declarative specs).
  • Compiled solvers (C, C++, Fortran, Julia) through their command line (guide).
  • physverify mutate changes the solver one small step at a time and reports which changes the specs catch, so you can see whether your checks can fail (guide).
  • physverify confirm records one suspected defect, its reference and the run that settles it, with a fixed verdict rule (guide).
  • physverify scan PATH reads source code without running it and flags a fixed set of patterns worth a closer look; a clean scan means only that those patterns were not found (command line).
  • physverify references lists exact reference solutions, and the sandbox runs code you did not write without network access.

Limits

Strongest for ODE time integration; PDE checks cover selected cases so far (the heat equation in 1D, 2D and 3D, and 1D transport). Your code needs a way to add a source term for manufactured solutions, or a small wrapper that can itself be wrong. A PASS means these checks found nothing wrong; it does not prove the simulation correct, and it is only as independent as the reference you wrote: see What a PASS means.

Contributing, citing, licence

Feedback is the most useful contribution: try physverify on a solver you know and tell us what was flagged, what was missed and where you got stuck (trial report). Questions, bug reports and small documentation fixes are all welcome; see CONTRIBUTING.md, the code of conduct, SUPPORT.md and SECURITY.md on running untrusted code.

To cite, use doi:10.5281/zenodo.23534512 or CITATION.cff. Changes: CHANGELOG.md; plans: ROADMAP.md. The methods are standard and other tools do parts of this, some better (NodePy for Runge–Kutta analysis, MASA for manufactured solutions); see related work and credits. MIT licence, copyright (c) 2026 Ram Chandra Giri.

Metadata

Release files for physverify 0.10.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for physverify 0.10.0
File Size Uploaded Provenance Actions
physverify-0.10.0.tar.gz 210.4 kB With provenance Details for physverify-0.10.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for physverify 0.10.0
File Interpreter ABI Platform Actions
physverify-0.10.0-py3-none-any.whl Python 3 none any Details for physverify-0.10.0-py3-none-any.whl

Total release size: 447.5 kB

Release files / physverify-0.10.0.tar.gz

Download URL physverify-0.10.0.tar.gz
Size 210.4 kB
Tags Source
SHA-256 checksum
How to use checksums
18795bf9241178fca5cbb8ae57656a46f094eb8125cd3368eed9a16a01dafffd
BLAKE2b-256 checksum
How to use checksums
e745c4b562052c558193d311f31b54c35bfcf5908bb7d16c254e38d9833c362a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Release files / physverify-0.10.0-py3-none-any.whl

Download URL physverify-0.10.0-py3-none-any.whl
Size 237.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f9e79b9e7bbf814055aac20cd970eb43ec32f328d015cb6d7e2a2d4173bc480a
BLAKE2b-256 checksum
How to use checksums
1d8540439eaabfad3ba299abe72302efa880d76a0064af01aa937ff4388135db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Security for physverify 0.10.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for physverify-0.10.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page