Twine Models
Domain-specific models and model-building tools for Twine.
What this crate provides
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.
Models
Thermal
Heat exchangers (models::thermal::hx)
Recuperator— a discretized counter-flow heat exchanger that solves for outlet conditions given a UA value and inlet streams
Tanks (models::thermal::tank)
StratifiedTank— a multi-node stratified thermal storage tank with configurable ports, auxiliary heat, conductive losses, and buoyancy-driven mixing
Feature flags
| 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.
coolprop-dylib
Links against prebuilt shared libraries from platform-specific coolprop-sys-* crates.
Fast builds, good for local development. Works from crates.io.
= { = "0.2", = ["coolprop-dylib"] }
coolprop-static
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.
For WASM builds, the Emscripten SDK must be installed with em-config on PATH:
Examples
Stratified tank simulation
Simulates five days of residential hot water tank operation with a thermostat-controlled heating element, a daily draw schedule, and an interactive time-series plot.
Utility code (support)
Modules 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
Twine ecosystem
| Crate | Description |
|---|---|
twine-core |
Model trait and core abstractions |
twine-solvers |
ODE solvers (Euler, etc.) |
twine-observers |
Observer utilities (plotting, logging) |