Requires uv.
uv sync
uv run pytestAdd an entry to data/quantities.yaml:
- id: momentum
name: Linear Momentum
symbol: p
dimension: {M: 1, L: 1, T: -1}
si_unit: "kg*m/s"
description: ...
links:
- {label: Wikipedia, url: "https://..."}dimensionis an exponent vector over the SI base dimensions (M,L,T,I,Theta,N,J). Omit any dimension whose exponent is 0.description: if the quantity has a matching entry in the OpenStax College Physics 2e glossary, use that text verbatim. Otherwise write a short, mostly conceptual description.links: Wikipedia and, where one exists, Khan Academy.
Add a new file to data/equations/<id>.yaml:
id: momentum
name: Linear Momentum
description: ...
expr: "p - m*v"
latex: "p = mv"
variables:
p: {quantity: momentum}
m: {quantity: mass}
v: {quantity: velocity}
topic: momentum
requires: []
source:
ref: openstax-college-physics-2e
section: "8.1"
url: "https://openstax.org/books/college-physics-2e/pages/8-1-linear-momentum-and-force"
links:
- {label: Wikipedia, url: "https://..."}
- {label: Khan Academy, url: "https://..."}
checks:
- {given: {m: 2, v: 3}, solve_for: p, expect: 6}expris the canonical zero form (lhs - rhs), notlhs = rhs.- Every symbol used in
exprmust appear invariables, and vice versa;ofg.model.load_graphenforces this. - If a quantity appears more than once in the same equation (e.g.
vandv0), disambiguate withrole:v0: {quantity: velocity, role: initial}. source.sectionshould be the textbook section the equation comes from.checksneeds at least one numeric example that satisfies the equation.idshould match the equation's concept name directly (no-definitionor similar suffixes).
uv run pytestThis checks, for every equation:
- declared variables match the symbols in
expr(ofg.model) - dimensional consistency across every additive term (
tests/test_dimensions.py) - the numeric
checksfixtures solve correctly (tests/test_checks.py)
If you want to preview the explorer locally with your data changes, rebuild the bundle it reads from:
uv run ofg buildThis regenerates dist/openformulagraph.json. On push to master, GitHub Actions runs the same build before deploying Pages, so you do not need to commit dist/ for the live site to update.
explorer/ is a static app that reads dist/openformulagraph.json. To preview it locally:
uv run python -m http.server 8743then open http://localhost:8743/explorer/.