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
Advanced example
For an advanced example see: Example script
Citation
If you use ExergyFlow in your scientific work, please consider citing it to support ongoing development. You can cite ExergyFlow using the following BibTeX entry:
@software{ExergyFlow,
author = {Gómez González, Juan Andrés},
title = {{ExergyFlow}: Energy and Exergy Diagrams in Python},
year = {2026},
version = {0.1.2},
url = {https://github.com/GOMGON777/exergyflow},
note = {Python package available on PyPI}
}
License
MIT License
Copyright (c) 2026 Juan Andrés Gómez González
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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
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.2.tar.gz.
File metadata
- Download URL: exergyflow-0.1.2.tar.gz
- Upload date:
- Size: 37.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4fbdb728a92b1d2bdf6f03c4d915b456cffa1f8fb620d3b2906ecf711b43184a
|
|
| MD5 |
02f0bf2bcd60e8104515e99c29ea39db
|
|
| BLAKE2b-256 |
ee2cba0e7deb43bbbac164907e43094c1598ae0956ced539cb2680bc2cf547e0
|
File details
Details for the file exergyflow-0.1.2-py3-none-any.whl.
File metadata
- Download URL: exergyflow-0.1.2-py3-none-any.whl
- Upload date:
- Size: 25.2 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 |
8644e3ba3224d5404b15fabcb87d44047f8183962c8c6221539fc0b16cde9e18
|
|
| MD5 |
6e534a9fb40b9b0ae8e38ca6831b9797
|
|
| BLAKE2b-256 |
e4e11c858a3d3fb9f473a97deee1675c65ac43c38492dfc939984a355e7f06c2
|