Domain-specific models and model-building tools for Twine.
twine-models offers opinionated Model implementations for engineering domains, along with the supporting utilities needed to build and compose them.
It is organized into two top-level modules:
models— ready-to-useModelimplementationssupport— utilities used by models, also available for downstream use
See the crate docs for details on each module.
Recuperator— a discretized counter-flow heat exchanger that solves for outlet conditions given a UA value and inlet streams
StratifiedTank— a multi-node stratified thermal storage tank with configurable ports, auxiliary heat, conductive losses, and buoyancy-driven mixing
| Feature | What it enables | Default |
|---|---|---|
coolprop-dylib |
CoolProp model via prebuilt shared library |
no |
coolprop-static |
CoolProp model compiled from source (cmake + vendored) |
no |
The two CoolProp features are mutually exclusive.
Links against prebuilt shared libraries from platform-specific coolprop-sys-* crates.
Fast builds, good for local development. Works from crates.io.
twine-models = { version = "0.2", features = ["coolprop-dylib"] }Compiles CoolProp from source as a static library via cmake.
Slower first build (cached after), but self-contained.
Works for native, Python wheels, and WASM (wasm32-unknown-emscripten).
Requires a git clone with submodules — the CoolProp source tree (~240MB) exceeds crates.io's package size limit, so this feature is not available from a crates.io install.
git clone --recurse-submodules https://github.com/isentropic-dev/twine-modelsIf you have a local CoolProp checkout (e.g., when installing from crates.io), set
COOLPROP_SOURCE_DIR to point build.rs at it instead of the vendored submodule:
COOLPROP_SOURCE_DIR=/path/to/CoolProp cargo build --features coolprop-staticFor WASM builds, the Emscripten SDK must be installed with em-config on PATH:
brew install emscripten # macOS
rustup target add wasm32-unknown-emscripten
cargo test --target wasm32-unknown-emscripten --features coolprop-static --testsSimulates five days of residential hot water tank operation with a thermostat-controlled heating element, a daily draw schedule, and an interactive time-series plot.
cargo run --example stratified_tank --releaseModules in support are public because they're useful, but their APIs are not yet stable — breaking changes may occur. The lifecycle for utility code is:
- Model-specific — starts private inside a model's
coremodule - Domain-specific — moves to a domain support module when useful across models in a domain
- Crate-level — moves to
supportwhen useful across domains - Standalone — may become its own crate if broadly useful and stable
| Crate | Description |
|---|---|
twine-core |
Model trait and core abstractions |
twine-solvers |
ODE solvers (Euler, etc.) |
twine-observers |
Observer utilities (plotting, logging) |