Skip to main content

dualis for Python

Coupled physics whose conservation audit is an exception you can catch.

pip install dualis        # wheels for linux, macos and windows; abi3, so 3.10 upward
import dualis

sim = dualis.Simulation(schedule="multirate", conservation_tolerance=1e-9)
sim.add_heater("element", watts=2.0, reserve_j=6.0)
sim.add_bar("bar", length_m=0.020, cells=41, area_m2=1e-4)

for _ in range(8):
    sim.advance(0.5)          # raises dualis.Violation if the books do not close

print(sim.temperature("bar"))     # 294.39 K
print(sim.profile("bar")[:3])     # warmer at the fed end

Several bodies and the drop between them

add_lump gives you one temperature for a whole assembly. The number that decides whether a motor survives is the winding, which is hotter than the case by however much the joint between them resists — so for that, a network:

sim = dualis.Simulation(schedule="staggered")
sim.add_heater("losses", watts=6.0, reserve_j=5_400.0)
sim.add_network("motor",
    nodes=[{"name": "winding", "material": "copper", "volume_m3": 18e-6,
            "thickness_m": 2e-3, "initial_k": 298.15},
           {"name": "case", "material": "aluminium", "volume_m3": 220e-6,
            "thickness_m": 4e-3, "initial_k": 298.15,
            "ambient_k": 298.15, "area_m2": 0.042}],   # both keys, or neither
    links=[{"from": "winding", "to": "case", "w_per_k": 0.9}],
    absorbing="winding")

for _ in range(900):
    sim.advance(1.0)

dict(sim.node_temperatures("motor"))     # {'winding': 311.2, 'case': 304.9}
sim.heat_flow_w("motor", "winding", "case")   # 5.585 W crossing the joint

Materials: copper, aluminium, electrical_steel, fr4, pla. A node with ambient_k and area_m2 loses heat to still air; a node with neither is interior. Giving one without the other is refused rather than quietly producing a node that looks like it is cooling and is not.

Names are resolved once, when the network is built, so a link to a node that does not exist raises before any stepping happens and lists the nodes that do. That matters more here than it looks: a link adds +q to one node and −q to another in the same sum, so a missing or misdirected link passes the conservation audit at machine precision and simply reports the wrong temperature forever.

temperature() refuses a network rather than averaging it — the reason to build one is that its nodes differ, so a mean would describe no part of it.

Why this rather than numpy

Write physics in numpy and a wrong model runs happily, producing plausible output. There is no signal; you find out when somebody notices the answer is silly.

Every advance here either moves the clock or raises, and the exception is addressable rather than a sentence to parse:

try:
    sim.advance(0.5)
except dualis.Violation as v:
    v.quantity     # 'energy'
    v.site         # 'bus (published but not consumed)'
    v.before, v.after, v.scale, v.tolerance
    sim.time       # unchanged — a refused step does not advance the clock

Be clear about what it catches. Quantities appearing or vanishing, amounts left unclaimed on the bus, and a domain refusing a step it cannot take. It does not catch a model that is internally consistent and physically wrong. For that, check against something the library did not compute — which is what aluminium_heat_capacity_j_per_k is exported for, and what tests/test_dualis.py does throughout.

What crosses the boundary, and what does not

Values cross as SI floats with the unit in the parameter name: length_m, watts, initial_k. dualis's dimensional types are a compile-time thing — Length + Time does not compile in Rust — and Python cannot have that. A runtime Quantity wrapper would cost an allocation and a check per operation to catch, at run time, a class of error a Python caller mostly does not make, because it passes values in and reads them out rather than doing algebra on them. So the types stay on the Rust side and the units stay in the names.

What crosses instead is the audit, which is the part worth having.

What this cannot do

You cannot write a domain in Python. That means calling back into the interpreter from inside the step loop, holding the GIL across it, and deciding what an exception raised mid-sweep does to a half-advanced simulation. All three are answerable and none cheaply, so this binds the physics the library has and says so rather than shipping a subtly wrong version of that.

So: enough to run and audit coupled physics from Python, not enough to extend it. The extending lives in Rust, and the workspace is where.

A Simulation is also bound to the thread that created it. Domain is not Send, and the binding says so rather than asking the kernel for a bound it does not offer.

Building

Its own cargo workspace, deliberately: pyo3 brings about fifteen crates and links libpython, and the library's lockfile, licence allow-list and WebAssembly jobs are promises that should not have to accommodate a Python extension.

cd bindings/python
pip install "maturin>=1.7,<2.0"
maturin build --release          # an abi3 wheel: one build serves 3.10 upward
pip install target/wheels/dualis-*.whl
python tests/test_dualis.py

maturin develop works too, in a virtualenv. CI builds the wheel, installs it and runs those tests on every commit — because "it compiles" proves neither half of "pip install then import".

Metadata

Release files for dualis 0.5.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 dualis 0.5.0
File Size Uploaded
dualis-0.5.0.tar.gz 574.8 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for dualis 0.5.0
File
dualis-0.5.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
dualis-0.5.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details
dualis-0.5.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details
dualis-0.5.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details
dualis-0.5.0-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details

Total release size: 2.2 MB

Release files / dualis-0.5.0.tar.gz

Download URL dualis-0.5.0.tar.gz
Size 574.8 kB
Tags Source
SHA-256 checksum
How to use checksums
56f1fd22afc2dc32fa143a68b2e8849792f5707b710d35d047ee5167389ddf60
BLAKE2b-256 checksum
How to use checksums
26eb0d4a8af2167383d0a26b6b9222cf9857cab71d8722bccb74306425ef9afd
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 Aug 9, 2026.

Transparency log

Release files / dualis-0.5.0-cp310-abi3-win_amd64.whl

Download URL dualis-0.5.0-cp310-abi3-win_amd64.whl
Size 229.4 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
812986d39b15120e72360ddf4b4f7daf6a97389f8193cea5a95e88861bb52845
BLAKE2b-256 checksum
How to use checksums
ca20d261fc3db9c91f515601e494db61f4ba7fa1d9fe8e1404393f8826999f25
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 Aug 9, 2026.

Transparency log

Release files / dualis-0.5.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL dualis-0.5.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 376.6 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
1922113392860234522f8e308fdb4d1b59f35e6f72c521514e5feb3b61b1e9ae
BLAKE2b-256 checksum
How to use checksums
920bfc67b11836fcb0c59d5f010fedcbe0dd32d5775b0a615b175a0a48124568
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 Aug 9, 2026.

Transparency log

Release files / dualis-0.5.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL dualis-0.5.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 365.5 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
d7e49b76049e906a4346ea7d3e9d24f777a1c2008e1ba03a5ed8cc5fe246886e
BLAKE2b-256 checksum
How to use checksums
f06b846f298abc50f86ce4b26b1034afc6042635a4d1c7b6cd9f7bcdf0ba3a37
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 Aug 9, 2026.

Transparency log

Release files / dualis-0.5.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL dualis-0.5.0-cp310-abi3-macosx_11_0_arm64.whl
Size 333.1 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
4dd6716ba2996507949f626dea1914d1e2ea64f5b4e38f58f912b252c0460cf6
BLAKE2b-256 checksum
How to use checksums
3944858bc5ca0c133004f5545fffc2eae00ac66656dbcb40804bc544920e5064
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 Aug 9, 2026.

Transparency log

Release files / dualis-0.5.0-cp310-abi3-macosx_10_12_x86_64.whl

Download URL dualis-0.5.0-cp310-abi3-macosx_10_12_x86_64.whl
Size 336.2 kB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
20e2224f79a52408eb34d3867a5713e9edecc0eba316e14a8b7f8486bb349749
BLAKE2b-256 checksum
How to use checksums
179bfd5377ec5b82a6d0868ebc42c9fa1bf43637bdadec70d95bfd4598281c1f
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 Aug 9, 2026.

Transparency log

Release history Release notifications | RSS feed

0.15.0

6 release files

0.14.0

6 release files

0.13.0

6 release files

0.12.0

6 release files

0.11.0

6 release files

0.10.0

6 release files

0.9.0

6 release files

0.8.0

6 release files

0.7.0

6 release files

0.6.0

6 release files

This release

0.5.0 This release

6 release files

0.4.0

6 release files

0.3.0

6 release files

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