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

Advanced 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.1.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.1-py3-none-any.whl (24.9 kB view details)

Uploaded Python 3

File details

Details for the file exergyflow-0.1.1.tar.gz.

File metadata

  • Download URL: exergyflow-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 ca35f6e00d3c8bf49054613cc8afa5f696671325b04f98fcade937cf44b51d10
MD5 7949c85e55d8472949c6028b32397e6e
BLAKE2b-256 56862bd3f5d7d6bb739b9db8e9fb3ec5de855edb5873367b59a5fc6de2f42c45

See more details on using hashes here.

File details

Details for the file exergyflow-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: exergyflow-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 24.9 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 22ae0771f5a9335d77a6ef97619556a5353dfbacff26bdf39195175e7396ff9d
MD5 88488a0313446526988f1dccf34d9de6
BLAKE2b-256 ff41a9958c001930dca59cd028ad1de65d58773ad1a602671c0a2d0a0e79a78d

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