Sankey and Grassmann diagrams for energy and exergy analysis
Project description
ExergyFlow
Grassmann/Sankey diagrams for energy and exergy analysis
Install
python -m pip install exergyflow
Quickstart
from exergyflow import Diagram, DiagramConfig, RouteSegment
d = Diagram(DiagramConfig(auto_scale=True, auto_scale_target=1.0))
d.add_process("P1")
d.add_flow("F1", 10, source=None, target="P1")
d.add_flow("F2", 5, source="P1", target=None)
route1 = [RouteSegment(kind='rect', length=0.25, direction='right'),
RouteSegment(kind='elbow', length=0.25, turn='rightup'),
RouteSegment(kind='rect', length=0.5, direction='up')]
d.add_flow("F3", 2, source="P1", target=None, route=route1)
fig, ax = d.draw()
fig.savefig("diagram.png", dpi=300, bbox_inches="tight")
Real engineering example
A simplified Brayton flow sketch (values illustrative):
from exergyflow import Diagram, DiagramConfig, RouteSegment
cfg = DiagramConfig(flow_value_unit="kW", flow_value_format=".0f",
auto_scale=True, auto_scale_target=2.0)
d = Diagram(cfg)
# Processes
d.add_process("Compressor", direction="up", length=2.5,
label_rotation=90, color="#59a2d3")
d.add_process("Combustor", direction="right", length=2.5, color="#59a2d3")
d.add_process("Turbine", direction="down", label_rotation=-90, color="#59a2d3")
# Routes
route_work_out = [
RouteSegment(kind='rect', length=0.25, direction='down'),
RouteSegment(kind='elbow', length=0.5, turn='downright'),
RouteSegment(kind='rect', length=2.5, direction='right')
]
route_exhaust = [
RouteSegment(kind='rect', length=1.5, direction='down'),
RouteSegment(kind='elbow', length=0.5, turn='downright'),
RouteSegment(kind='rect', length=2.6, direction='right')
]
route_air = [
RouteSegment(kind='rect', length=3.5, direction='right'),
RouteSegment(kind='elbow', length=0.5, turn='rightup'),
RouteSegment(kind='rect', length=0.5, direction='up')
]
# Flows
d.add_flow("Work_out", 220, source="Turbine",
target=None, label="W_t", route=route_work_out)
d.add_flow("Exhaust", 180, source="Turbine", target=None,
label="E_exh", route=route_exhaust)
d.add_flow("Work_in", 80, source="Turbine",
target="Compressor", label="W_c", cycle_breaker=True, label_dy=-0.3)
d.add_flow("Air", 280, source=None,
target="Compressor", label="E_air", route=route_air)
d.add_flow("Compressed", 300, source="Compressor",
target="Combustor", label="E_2", label_dy=0.2)
d.add_flow("Fuel", 700, source=None,
target="Combustor", length=7.75, label="E_f")
d.add_flow("Hot_gas", 560, source="Combustor",
target="Turbine", label="E_3", label_dy=0.2)
fig, ax = d.draw()
fig.savefig("brayton.svg", dpi=300, bbox_inches="tight")
Advantages
- Built for thermodynamic energy and exergy conventions, including imbalance triangles and process-aware flow direction rules.
- Auto-layout for fast drafts, manual routing for publication-grade control.
- Matplotlib-native output for crisp vector export (SVG/PDF) without extra tooling.
- Deterministic layout and explicit routing rules help reproduce figures consistently.
- Built-in unit formatting for labels keeps diagrams engineering-ready.
Details
- Supported Python versions: 3.9–3.14 (see
pyproject.toml). flow_label_modeoptions:name_value_units(default),value_units,value_only.- Units formatting:
flow_value_unit,flow_value_format,flow_value_unit_sep. - Auto-layout expects a DAG; use
cycle_breaker=Trueon a process→process flow to break cycles. - Manual routing must alternate
rectandelbowsegments and start/end withrect. - Matplotlib-native output: export PNG, SVG, or PDF via
fig.savefig(...).
Docs
Adavanced example
For an advanced example see: Example script
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
exergyflow-0.1.0.tar.gz
(36.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file exergyflow-0.1.0.tar.gz.
File metadata
- Download URL: exergyflow-0.1.0.tar.gz
- Upload date:
- Size: 36.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d580e6961f018a440fc7703918383545b73ddbd3883fad42c001c7676aff9212
|
|
| MD5 |
c13ebb7ec2443b671f884934ab54acf2
|
|
| BLAKE2b-256 |
82720ed2aca5879a7951d330dbac4d513243e6ca9a0cf8fd5e96d120092803cf
|
File details
Details for the file exergyflow-0.1.0-py3-none-any.whl.
File metadata
- Download URL: exergyflow-0.1.0-py3-none-any.whl
- Upload date:
- Size: 24.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0d5cf292affb33b0b188ccff70869015e60bb03ae207d3c5603641d867e4892b
|
|
| MD5 |
85c3be10e41e17a67fcce621370c201c
|
|
| BLAKE2b-256 |
eb581b2e32b50ee2f616bd8293cdaf32c12e7c9358e2ab030590065a1f250913
|