physverify
A tool that checks whether a physics simulation is solving the right equations correctly, not just running without errors.
Status: early version (0.2.0). It has been tried on 20 public physics repositories (see below), but nobody besides the author has used it yet, so feedback is very welcome.
The problem it addresses
A simulation can run, produce nice plots and still be wrong: a minus sign in the wrong place, a factor of 2 missing, a time step that is off by one. Ordinary tests often miss these, because nobody knows the "right answer" for a real simulation to compare against.
How it works, in plain words
physverify uses a few standard ideas from numerical analysis:
- Make up an answer, then check the code finds it. Pick a smooth function, work out what extra push (a "source term") would make it an exact solution, give that push to your code, and see if your code reproduces the function. This is called the Method of Manufactured Solutions.
- Check the error shrinks at the right speed. If your method is supposed to be 4th order, halving the time step should make the error about 16 times smaller. If it only gets 2 times smaller, something is wrong, even if the error looked small.
- Check conserved quantities. Energy, mass or momentum should stay constant (or drift in a predictable way).
- Check known special cases. For example, a projectile with no air resistance has a range you can write down by hand.
- Exact "patch" tests. Some solutions should be reproduced to computer precision. This catches small bugs that the other checks let through.
- Algebraic checks on the method itself. For a Runge-Kutta method, whether the coefficients really have the order they claim can be settled exactly, with no test problem (the "order conditions").
Each check reports PASS, FAIL, EXACT or INCONCLUSIVE.
There is also a separate set of checks for random (Monte Carlo) simulations, using the 2D Ising model as the example.
Does it actually catch bugs?
To test it, 37 bugs were added one at a time to five small solvers (projectile, double pendulum, planet orbit, heat equation, shock tube):
- 35 of 37 bugs were caught. Plain "compare with one answer" tests caught 27.
- 0 false alarms on the bug-free versions.
- The 2 missed bugs are explained in the technical details.
For the Monte Carlo checks, all 21 seeded bugs were caught with no false alarms.
The bugs and the checks were written by the same person, so these numbers show the tool works as designed. They are not a promise about bugs in other people's code.
Trying it on other people's code
To see what it does on code it was not written for, 40 public Python physics repositories were drawn at random from GitHub searches (October 2026) and run in a locked-down container: no network, the repository read-only, nothing from it run on the author's computer.
- 20 of the 40 could be tested. Most of the others were not numerical solvers (neural networks, apps and games, analysis tools), one needed a recent NVIDIA GPU, and a few need more set-up.
- 9 confirmed bugs in 6 of the 20. For example: a measured energy that counts the magnetic-field term twice; backward time-stepping that is only first-order accurate; Runge-Kutta coefficient tables labelled with a higher order than they have; error-estimate weights that do not sum to zero; a spectral derivative that crashes for an odd number of grid points; a crash on NumPy 2.
- The other 14 had no confirmed bug. Most passed every check that applied, often to 1e-13 or better; one raised a question for its authors rather than a bug report.
- Our own adapters were wrong about 15 times before checking (a wrong constant, too-coarse steps, and so on). Every FAIL was checked by hand before being called a bug, and these mistakes are recorded, not hidden.
Each lesson became a new check or a clearer message in physverify. The testing and write-ups were done with help from an AI assistant; every number comes from running the code. Authors are told about a finding before their project is named, so the repositories are listed by ID: results/corpus/SUMMARY.md.
Try it
You need Python 3.10 or newer.
pip install physverify
The example below lives in the repository, so clone it to follow along:
git clone https://github.com/rcgiri-physics/physverify.git
cd physverify
physverify run examples/verify_damped_oscillator.py
You should see a list of checks, all passing. Now open examples/damped_oscillator.py, change the damping by 10%, and run the same command again: the checks fail.
To check your own code you write a short "spec" file. It tells physverify two things: the equations your code is meant to solve (written independently of your code), and how to run your code. examples/verify_damped_oscillator.py is a complete example to copy.
Other ways to run it:
physverify run my_spec.py --html report.html # a web page with convergence plots
physverify run my_spec.py --json - # machine-readable output
pytest my_spec.py # each check becomes a pytest test
What it can and cannot do
- Works best for ordinary differential equations (orbits, pendulums, projectiles).
- Partial differential equations: only 1D examples so far (heat equation, shock tube).
- Your code needs a way to accept an extra source term, or a small wrapper ("adapter") around it. The wrapper can itself contain mistakes.
- Passing all checks does not prove the code is correct, only that these tests found nothing wrong.
More
- results/corpus/SUMMARY.md: the 40 public repositories, what was tested and what was found.
- sandbox/README.md: the locked-down container used to run other people's code.
- results/own_work/SUMMARY.md: results on four of the author's own public physics projects (two real bugs found and fixed).
- docs/technical.md: full details, benchmark tables, limits and related work.
- docs/patch.md: what the exact "patch" checks assume.
- docs/ising.md: checks for Monte Carlo codes.
- docs/agent.md: using it with an AI coding assistant.
- CHANGELOG.md
Run the project's own tests with pip install -e .[dev] then python -m pytest -q (about 1.5 minutes).
Licence
MIT. Copyright (c) 2026 Ram Chandra Giri.
Metadata
Release files for physverify 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| physverify-0.2.0.tar.gz | 95.9 kB | With provenance | Details for physverify-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| physverify-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for physverify-0.2.0-py3-none-any.whl |
Total release size: 189.9 kB
Release files / physverify-0.2.0.tar.gz
| Download URL | physverify-0.2.0.tar.gz |
|---|---|
| Size | 95.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bd27d0849a988cd4283067d6a6752684f97aa50cf4f1cecebfc80a48de37a1ef
|
|
BLAKE2b-256 checksum How to use checksums |
38878f7e7e13718a99911d7c5ee04f453cf3404e7644f667f58d6ae7805c0670
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 20, 2026.
Transparency logRelease files / physverify-0.2.0-py3-none-any.whl
| Download URL | physverify-0.2.0-py3-none-any.whl |
|---|---|
| Size | 94.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ae883f38a1cf8412039a0c90972636394349b1fd900d4c847f31b0aff47a2490
|
|
BLAKE2b-256 checksum How to use checksums |
1a447aa4eed6233714ad24ca3768bfe3f9eeac0347e534ace4f7c1c12024fb6b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 20, 2026.
Transparency logSecurity for physverify 0.2.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.
Attestation for physverify-0.2.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 Oct 20, 2026.
Transparency logA 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.