Expand description
pantometry: physics for simulated worlds, in one dependency.
A facade over the workspace. Nothing is implemented here — the point is that a
consumer writes pantometry = "0.16" rather than naming eleven crates, and that the
integration tests which need two domains at once have somewhere to live.
use pantometry::prelude::*;
// A lamp, a filter, and the question that needs both.
let lamp = SpectralPower::new(
Spectrum::blackbody(3200.0),
Power::w(1.0),
VISIBLE_RANGE,
);
let green = Spectrum::bands(vec![[500.0, 560.0]], 0.95, 0.0);
let through = lamp.through(&green);
assert!(through < lamp.total());§Start here
Three ideas carry the whole library.
- Units are types. Dimensions live in the type, so
Length + Timedoes not compile. One place may hold a factor of a thousand — a unit-bearing constructor — andto_si()is the only way back to a baref64. - A domain is anything that steps.
Domainrequiresnameandstep; everything else has a default. Overrideledgerso the audit has something to check. - Domains never call each other. They meet on
Exchange, a bus of named channels carrying SI amounts — joules, not watts. A ledger says what you are holding, not what has passed through you.
And the reason to pick this over a general-purpose engine: conservation is audited every
step, so a wrong model does not run quietly. advance returns a
Violation naming the quantity, the site, and the before and
after — a correctness signal you can act on without a human noticing first.
energy destroyed at simulation: 5.000000e2 became 4.995000e2,
a relative change of 1.000e-3 against a tolerance of 1.000e-9Be clear about the limit: the audit catches quantities appearing or vanishing, amounts
left unclaimed on the bus, and fluxes disagreeing face by face across a shared boundary.
It does not catch a model that is internally consistent and physically wrong — publish
a power where a joule was wanted and both sides agree perfectly about a number off by
1/dt. For that, check against something the code did not compute: a closed form, an
exact limit, or a convergence rate.
cargo run --example agents_quickstart is all of the above as a running program,
including a deliberate leak so the failure is visible. AGENTS.md in the repository is
the one-page version.
§The dependency rule
pantometry-units no dependencies but glam and serde
pantometry-core depends on units the kernel: what evolves, what it conserves
pantometry-optics depends on core ┐
pantometry-thermal depends on core │
pantometry-mechanics depends on core ├ one crate per physics, and none knows another
pantometry-acoustic depends on core │
pantometry-molecular depends on core │
pantometry-electrical depends on core ┘
pantometry-scene depends on core where things are, and what a run looks like
pantometry-view depends on scene how to draw that, chosen by the data's shape
pantometry depends on all of themNone of the ten domains knows about any of the others. They meet on the kernel’s
Exchange, and each one that arrived left the others
untouched — which is the claim the split was made to test, now held six times.
scene and view are layers up rather than domains, and they are bound by the same rule
from the other side: neither names a domain. A physics that arrives tomorrow is captured
without scene being edited, and drawn without view being edited, because the scene asks
each domain what it offers and the view dispatches on the shape of what came back.
ARCHITECTURE.md is the long version.
Re-exports§
pub use pantometry_acoustic as acoustic;pub use pantometry_core as core;pub use pantometry_elastic as elastic;pub use pantometry_electrical as electrical;pub use pantometry_em as em;pub use pantometry_fluid as fluid;pub use pantometry_mechanics as mechanics;pub use pantometry_molecular as molecular;pub use pantometry_optics as optics;pub use pantometry_porous as porous;pub use pantometry_quantum as quantum;pub use pantometry_scene as scene;pub use pantometry_shape as shape;pub use pantometry_thermal as thermal;pub use pantometry_units as units;pub use pantometry_view as view;
Modules§
- prelude
- Everything most simulations need, in one
use.