Turbine
Compressor

Turbine Calculator

Isentropic Expansion Solver
Inlet Conditions (State 1)
Outlet Constraint (State 2)
Initializing Python Engine...
packages = ["pyXSteam"] from pyXSteam.XSteam import XSteam from js import document import js steamTable = XSteam(XSteam.UNIT_SYSTEM_MKS) def calculate_system(*args): try: mode = js.currentMode # Inputs P_in = float(document.getElementById("P_in").value) T_in = float(document.getElementById("T_in").value) P_out = float(document.getElementById("P_out").value) m_dot = float(document.getElementById("m_dot").value) eta = float(document.getElementById("efficiency").value) # State 1 h1 = steamTable.h_pt(P_in, T_in) s1 = steamTable.s_pt(P_in, T_in) # State 2s (Ideal) h2s = steamTable.h_ps(P_out, s1) t2s = steamTable.t_ps(P_out, s1) # Calculate Ideal Temp # Logic Branch if mode == 'turbine': w_ideal = h1 - h2s w_actual = w_ideal * eta h2a = h1 - w_actual else: w_ideal = h2s - h1 w_actual = w_ideal / eta h2a = h1 + w_actual # State 2a (Actual) t2a = steamTable.t_ph(P_out, h2a) s2a = steamTable.s_ph(P_out, h2a) x2a = steamTable.x_ph(P_out, h2a) # Quality Formatting if x2a == 0.0 and t2a < steamTable.tsat_p(P_out): x_str = "Liquid" elif x2a >= 1.0 or x2a < 0: x_str = "Superheated" else: x_str = f"{x2a:.3f}" delta_s = s2a - s1 power_ideal = w_ideal * m_dot power_actual = w_actual * m_dot # UI Update document.getElementById("res_power_ideal").innerText = f"{power_ideal:.4f} kW" document.getElementById("res_power_actual").innerText = f"{power_actual:.4f} kW" document.getElementById("res_h2a").innerText = f"{h2a:.4f} kJ/kg" document.getElementById("res_t2a").innerText = f"{t2a:.4f} °C" document.getElementById("res_x2a").innerText = x_str document.getElementById("res_ds").innerText = f"{delta_s:.4f} kJ/kgK" # New Ideal Reference Section document.getElementById("res_h2s").innerText = f"{h2s:.4f} kJ/kg" document.getElementById("res_t2s").innerText = f"{t2s:.4f} °C" document.getElementById("results-area").style.display = "block" except Exception as e: print(f"Error: {e}") document.getElementById("res_power_actual").innerText = "Error" document.getElementById("loading").style.display = "none"