Skip to main content

Sankey and Grassmann diagrams for energy and exergy analysis

Project description

ExergyFlow

Grassmann/Sankey diagrams for energy and exergy analysis

ExergyFlow diagram

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_mode options: 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=True on a process→process flow to break cycles.
  • Manual routing must alternate rect and elbow segments and start/end with rect.
  • Matplotlib-native output: export PNG, SVG, or PDF via fig.savefig(...).

Docs

Adavanced example

For an advanced example see: Example script

Project details


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)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

exergyflow-0.1.0-py3-none-any.whl (24.8 kB view details)

Uploaded Python 3

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

Hashes for exergyflow-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d580e6961f018a440fc7703918383545b73ddbd3883fad42c001c7676aff9212
MD5 c13ebb7ec2443b671f884934ab54acf2
BLAKE2b-256 82720ed2aca5879a7951d330dbac4d513243e6ca9a0cf8fd5e96d120092803cf

See more details on using hashes here.

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

Hashes for exergyflow-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0d5cf292affb33b0b188ccff70869015e60bb03ae207d3c5603641d867e4892b
MD5 85c3be10e41e17a67fcce621370c201c
BLAKE2b-256 eb581b2e32b50ee2f616bd8293cdaf32c12e7c9358e2ab030590065a1f250913

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page