Quick Start - Nouman090/ThermoSim GitHub Wiki
Quick Start - Your First Cycle in 5 Minutes
This guide walks you through building a Simple Rankine Cycle step by step.
The Cycle
Boiler
4 ---------> 1
| |
Pump Turbine
| |
3 <--------- 2
Condenser
- 1 → 2: Turbine (steam expansion, work output)
- 2 → 3: Condenser (heat rejection, steam → water)
- 3 → 4: Pump (water compression, work input)
- 4 → 1: Boiler (heat addition, water → steam)
Step 1: Import
from ThermoSim import (
ThermodynamicModel,
Turbine, Pump, HeatExchanger,
)
Step 2: Create Model and Set Dead State
Model = ThermodynamicModel()
Model.set_dead_state(T0=298.15, P0=101325) # 25°C, 1 atm
The dead state is the reference environment for exergy calculations.
Step 3: Define State Points
Each state point needs a fluid name, a unique name, and two independent properties.
# State 1: Turbine inlet (superheated steam)
Model.add_point('water', '1', P=8e6, T=480+273.15, Mass_flowrate=1)
# State 2: Turbine outlet (only pressure known — turbine will calculate the rest)
Model.add_point('water', '2', P=0.008e6)
# State 3: Condenser outlet (saturated liquid)
Model.add_point('water', '3', P=0.008e6, Q=0)
# State 4: Pump outlet (only pressure known — pump will calculate the rest)
Model.add_point('water', '4', P=8e6)
Step 4: Add Components
# Turbine: expands from state 1 to state 2
Turbine(Model, 'Turbine', In_state='1', Out_state='2',
n_isen=0.85)
# Condenser: rejects heat (SimpleHEX — no second fluid modelled)
HeatExchanger(Model, 'Condenser', PPT=5, HEX_type='SimpleHEX',
HeatAdded=False,
Hot_In_state='2', Hot_Out_state='3',
Cold_In_state=None, Cold_Out_state=None)
# Pump: compresses from state 3 to state 4
Pump(Model, 'Pump', In_state='3', Out_state='4',
n_isen=0.85)
# Boiler: adds heat (SimpleHEX)
HeatExchanger(Model, 'Boiler', PPT=5, HEX_type='SimpleHEX',
HeatAdded=True,
Hot_In_state=None, Hot_Out_state=None,
Cold_In_state='4', Cold_Out_state='1')
Step 5: Print Results
Model.Solve()
print(Model)
Output:
ENERGY ANALYSIS
Net power: XXXXX W
Efficiency (%): XX.XX %
EXERGY ANALYSIS
Component Ex_destruction
Turbine XXXXX
Condenser ...
...
State Point Table
fluid Mass_flowrate StatePointName P T H Q
water 1.0 1 80.00 480.00 ... ...
water 1.0 2 0.08 ... ... ...
...
Step 6: Plot the Cycle
from ThermoSim.plotting import CyclePlotter
plotter = CyclePlotter(Model)
plotter.plot_Ts_diagram(['1', '2', '3', '4', '1'])
This shows a T-s diagram with the saturation dome and your cycle plotted on it.
Complete Script
from ThermoSim import (
ThermodynamicModel, Turbine, Pump, HeatExchanger,
)
from ThermoSim.plotting import CyclePlotter
# Create model
Model = ThermodynamicModel()
Model.set_dead_state()
# Define state points
Model.add_point('water', '1', P=8e6, T=753.15, Mass_flowrate=1)
Model.add_point('water', '2', P=0.008e6)
Model.add_point('water', '3', P=0.008e6, Q=0)
Model.add_point('water', '4', P=8e6)
# Add components
Turbine(Model, 'Turbine', '1', '2', n_isen=0.85)
HeatExchanger(Model, 'Condenser', PPT=5, HEX_type='SimpleHEX',
HeatAdded=False, Hot_In_state='2', Hot_Out_state='3',
Cold_In_state=None, Cold_Out_state=None)
Pump(Model, 'Pump', '3', '4', n_isen=0.85)
HeatExchanger(Model, 'Boiler', PPT=5, HEX_type='SimpleHEX',
HeatAdded=True, Hot_In_state=None, Hot_Out_state=None,
Cold_In_state='4', Cold_Out_state='1')
# Results
Model.Solve()
Model.ModelSummary()
Model.Point_print()
# Plot
plotter = CyclePlotter(Model)
plotter.plot_Ts_diagram(['1', '2', '3', '4', '1'])
plotter.plot_exergy_bar()
Next Steps
- Learn about State-Points in detail
- Explore all Turbine, Pump, Heat-Exchanger options
- See complete Example-Regenerative-Rankine and Example-Brayton-Cycle