Example Brayton Cycle - Nouman090/ThermoSim GitHub Wiki

Cycle Description

       Combustor (Q_in)
    2 ──────────────→ 3
    ↑                  ↓
 Compressor        Turbine (W_out)
    ↑                  ↓
    1 ←──────────── 4
       Cooler (Q_out)

Complete Code

from ThermoSim import (
    ThermodynamicModel, Compressor, Turbine, HeatExchanger,
)
from ThermoSim.plotting import CyclePlotter

Model = ThermodynamicModel()
Model.set_dead_state()

# Parameters
fluid  = 'Air'
T1     = 300       # 27°C  (compressor inlet)
P1     = 1e5       # 1 bar
rp     = 10        # pressure ratio
T3     = 1200      # 927°C (turbine inlet)
P2     = P1 * rp   # 10 bar
eta_c  = 0.85
eta_t  = 0.90
m_dot  = 1.0

# State points
Model.add_point(fluid, '1', P=P1, T=T1, Mass_flowrate=m_dot)
Model.add_point(fluid, '2', P=P2)
Model.add_point(fluid, '3', P=P2, T=T3)
Model.add_point(fluid, '4', P=P1)

# Components
Compressor(Model, 'Compressor', '1', '2', n_isen=eta_c)

HeatExchanger(Model, 'Combustor', PPT=5, HEX_type='SimpleHEX',
              HeatAdded=True,
              Hot_In_state=None, Hot_Out_state=None,
              Cold_In_state='2', Cold_Out_state='3')

Turbine(Model, 'Turbine', '3', '4', n_isen=eta_t)

HeatExchanger(Model, 'Cooler', PPT=5, HEX_type='SimpleHEX',
              HeatAdded=False,
              Hot_In_state='4', Hot_Out_state='1',
              Cold_In_state=None, Cold_Out_state=None)

# Results
Model.Solve(verbose=1)
Model.ModelSummary()

print(f"\nPressure ratio:  {Model.Component['Compressor'].pressure_ratio:.1f}")
print(f"Compressor work: {Model.Component['Compressor'].work/1e3:.2f} kW")
print(f"Turbine work:    {Model.Component['Turbine'].work/1e3:.2f} kW")

# Plots
plotter = CyclePlotter(Model)
plotter.plot_Ts_diagram(['1', '2', '3', '4', '1'],
                        title='Simple Brayton Cycle')
plotter.plot_exergy_bar(as_percentage=True)