Lesson 25 (Capstone 1): Thermodynamic Power Cycle Simulator & Data-Driven Plant Surrogate
Courses Integrated: ME 200 Thermodynamics I
+ ME 300 Thermodynamics II + Numerical Methods & Data
Analytics
Companion Datasets:
ME200_Saturated_Water_Temp_Table.csv,
ME300_Combined_Cycle_Plant_Telemetry.csv
Why This Capstone Matters
Real power-plant engineers do not just solve one idealized textbook
problem—they build end-to-end digital twins that
compute steam properties via CoolProp,
close energy and Second-Law exergy destruction (\(\dot{X}_{\text{dest}} = T_0
\dot{S}_{\text{gen}}\)) balances across every turbine, pump, and
boiler, and fit fast predictive surrogate models on
plant sensor telemetry
(ME300_Combined_Cycle_Plant_Telemetry.csv) so dispatch
operators know how a hot summer day degrades net MW output!
Stage
1: Exact Real-Fluid Superheated & Reheat Rankine Cycle
(CoolProp)
Let’s simulate a real Reheat Steam Power Plant:
- Condenser Pressure \(P_1 = 10\text{ kPa}\) (\(0.10\text{ bar}\), saturated liquid \(x_1 = 0\)), Pump isentropic efficiency \(\eta_p = 0.85\)
- High-Pressure Turbine Inlet: \(P_3 = 80\text{ bar}\) (\(8.0\text{ MPa}\)), \(T_3 = 520^\circ\text{C}\), \(\eta_{t1} = 0.88\)
- Reheat Stage at \(P_{\text{rh}} = 12\text{ bar}\), reheated back up to \(T_5 = 520^\circ\text{C}\), Low-Pressure Turbine \(\eta_{t2} = 0.88\)
- Mass Flow Rate \(\dot{m}_{\text{steam}} = 35.0\text{ kg/s}\), Dead State \(T_0 = 298.15\text{ K}\)
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from pathlib import Path
from CoolProp.CoolProp import PropsSI
# --- Stage 1: CoolProp Reheat Rankine Thermodynamic & Exergy Analyzer (ME 200 + ME 300) ---
P1 = 10e3 # 10 kPa condenser [Pa]
P2 = 80e5 # 80 bar boiler [Pa]
P_rh = 12e5 # 12 bar reheat [Pa]
T3 = 520.0 + 273.15
T5 = 520.0 + 273.15
eta_p, eta_t = 0.85, 0.88
m_dot = 35.0 # kg/s
T0 = 298.15 # Dead state ambient [K]
# State 1: Sat Liquid @ P1
h1 = PropsSI("H", "P", P1, "Q", 0, "Water") / 1000.0
s1 = PropsSI("S", "P", P1, "Q", 0, "Water") / 1000.0
T1 = PropsSI("T", "P", P1, "Q", 0, "Water")
# State 2: Pump Exit (Isentropic + Actual)
h2s = PropsSI("H", "P", P2, "S", s1 * 1000.0, "Water") / 1000.0
h2 = h1 + (h2s - h1) / eta_p
s2 = PropsSI("S", "P", P2, "H", h2 * 1000.0, "Water") / 1000.0
# State 3: HP Turbine Inlet
h3 = PropsSI("H", "P", P2, "T", T3, "Water") / 1000.0
s3 = PropsSI("S", "P", P2, "T", T3, "Water") / 1000.0
# State 4: HP Turbine Exit -> Reheat Pressure
h4s = PropsSI("H", "P", P_rh, "S", s3 * 1000.0, "Water") / 1000.0
h4 = h3 - eta_t * (h3 - h4s)
s4 = PropsSI("S", "P", P_rh, "H", h4 * 1000.0, "Water") / 1000.0
T4 = PropsSI("T", "P", P_rh, "H", h4 * 1000.0, "Water")
# State 5: Reheat Exit -> LP Turbine Inlet
h5 = PropsSI("H", "P", P_rh, "T", T5, "Water") / 1000.0
s5 = PropsSI("S", "P", P_rh, "T", T5, "Water") / 1000.0
# State 6: LP Turbine Exit -> Condenser
h6s = PropsSI("H", "P", P1, "S", s5 * 1000.0, "Water") / 1000.0
h6 = h5 - eta_t * (h5 - h6s)
s6 = PropsSI("S", "P", P1, "H", h6 * 1000.0, "Water") / 1000.0
T6 = PropsSI("T", "P", P1, "H", h6 * 1000.0, "Water")
x6 = PropsSI("Q", "P", P1, "H", h6 * 1000.0, "Water")
w_pump = h2 - h1
w_turb = (h3 - h4) + (h5 - h6)
w_net = w_turb - w_pump
q_in = (h3 - h2) + (h5 - h4)
eta_th = w_net / q_in
# Exergy Destruction per component (ME 300 Second Law: X_dest = m_dot * T0 * s_gen)
X_pump = m_dot * T0 * (s2 - s1) / 1000.0 # MW
X_hp_t = m_dot * T0 * (s4 - s3) / 1000.0
X_lp_t = m_dot * T0 * (s6 - s5) / 1000.0
print("=== Reheat Rankine Cycle Results (CoolProp Water) ===")
print(f"Net Power Output : {m_dot * w_net / 1000.0:.2f} MW (eta_th = {eta_th:.2%})")
print(f"LP Exhaust Qual. : x6 = {x6:.4f} (Moisture = {(1-x6)*100:.2f}% — safe < 12%!)")
print(f"Exergy Destr. : Pump={X_pump:.3f} MW | HP-Turb={X_hp_t:.3f} MW | LP-Turb={X_lp_t:.3f} MW")=== Reheat Rankine Cycle Results (CoolProp Water) ===
Net Power Output : 49.07 MW (eta_th = 36.99%)
LP Exhaust Qual. : x6 = 0.9983 (Moisture = 0.17% — safe < 12%!)
Exergy Destr. : Pump=0.046 MW | HP-Turb=1.269 MW | LP-Turb=4.197 MW
# --- Stage 2: Combine Cycle Visualization + ME300 Plant Telemetry Surrogate Model ---
sat_p = next(p for p in [Path("datasets/ME200_Saturated_Water_Temp_Table.csv"), Path("../datasets/ME200_Saturated_Water_Temp_Table.csv")] if p.exists())
sat = pd.read_csv(sat_p)
sat.columns = [" ".join(c.strip().split()) for c in sat.columns]
cc_p = next(p for p in [Path("datasets/ME300_Combined_Cycle_Plant_Telemetry.csv"), Path("../datasets/ME300_Combined_Cycle_Plant_Telemetry.csv")] if p.exists())
cc = pd.read_csv(cc_p)
# Fit linear thermodynamic surrogate: Net_Power_MW ~ f(T_amb_C, P_atm_kPa, Pressure_Ratio_rp, Turbine_Inlet_T3_K, Condenser_Vac_kPa)
feat_cols = ["T_amb_C", "P_atm_kPa", "Pressure_Ratio_rp", "Turbine_Inlet_T3_K", "Condenser_Vac_kPa"]
X_raw = cc[feat_cols].values
y_raw = cc["Net_Power_MW"].values
X_design = np.column_stack([np.ones(len(cc)), X_raw])
# Solve least-squares weights cleanly via np.linalg.lstsq
beta, _, _, _ = np.linalg.lstsq(X_design[:96], y_raw[:96], rcond=None)
y_pred_test = X_design[96:] @ beta
y_true_test = y_raw[96:]
rmse_mw = np.sqrt(np.mean((y_pred_test - y_true_test)**2))
r2_test = 1.0 - np.sum((y_true_test - y_pred_test)**2) / np.sum((y_true_test - y_true_test.mean())**2)
print(f"\n=== ME300 Combined-Cycle Power Surrogate (96 Train / 24 Holdout Test) ===")
print(f"Test Set R^2 = {r2_test:.4f} | Test RMSE = {rmse_mw:.2f} MW (on ~{y_raw.mean():.0f} MW plant)")
print(f"Ambient T Sensitivity dP/dTamb = {beta[1]:.2f} MW per degC warmer air!")
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(11.0, 4.3))
# Plot 1: Real Reheat T-s Path
ax1.plot(sat["Entropy (sf, kJ/kg/K)"], sat["Temp. (C)"], color="#94a3b8", lw=1.8)
ax1.plot(sat["Entropy (sg, kJ/kg/K)"], sat["Temp. (C)"], color="#94a3b8", lw=1.8)
T2 = PropsSI("T", "P", P2, "H", h2 * 1000.0, "Water")
T_cyc = np.array([T1, T2, PropsSI("T","P",P2,"Q",0,"Water"), PropsSI("T","P",P2,"Q",1,"Water"), T3, T4, T5, T6, T1]) - 273.15
s_cyc = np.array([s1, s2, PropsSI("S","P",P2,"Q",0,"Water")/1e3, PropsSI("S","P",P2,"Q",1,"Water")/1e3, s3, s4, s5, s6, s1])
ax1.plot(s_cyc, T_cyc, "o-", color="#dc2626", lw=2, markersize=5, label=f"Reheat Cycle ($\\eta_{{th}}={eta_th:.1%}$)")
ax1.set_title("Reheat Rankine $T$-$s$ Diagram (80/12 bar, 520 C)")
ax1.set_xlabel("Entropy $s$ [kJ/(kg$\\cdot$K)]"); ax1.set_ylabel("Temperature [$^\\circ$C]"); ax1.grid(True, alpha=0.3); ax1.legend()
# Plot 2: Telemetry Parity
ax2.scatter(y_true_test, y_pred_test, color="#0284c7", s=45, label="Holdout Operating Shifts")
lims = [y_true_test.min()-5, y_true_test.max()+5]
ax2.plot(lims, lims, "k--", lw=1.5, label="Exact 1:1 Parity")
ax2.set_title(f"Combined-Cycle Surrogate Test ($R^2={r2_test:.3f}$)")
ax2.set_xlabel("Measured Plant Net Power [MW]"); ax2.set_ylabel("Surrogate Predicted [MW]"); ax2.grid(True, alpha=0.3); ax2.legend()
fig.tight_layout()
=== ME300 Combined-Cycle Power Surrogate (96 Train / 24 Holdout Test) ===
Test Set R^2 = 0.9574 | Test RMSE = 3.43 MW (on ~573 MW plant)
Ambient T Sensitivity dP/dTamb = -1.79 MW per degC warmer air!
Capstone Reflection & Challenge Questions
- Notice reheat kept LP exhaust quality
x6 > 0.90even at 80 bar—what happens tox6if you expand directly from80 bar / 520 Cstraight down to10 kPawithout reheat? Check withCoolProp! - In the Combined-Cycle linear surrogate, why is the coefficient
beta[1](dP / dT_amb) negative (~-2.1 MW / C)? - (Design Challenge): Write a loop sweeping reheat
pressure
P_rhfrom4 barup to35 barto locate the thermodynamic optimum maximizing Rankine thermal efficiency!
🎬 Concept & Engineering Animation
🎬 Reheat Rankine Ts Cycle