Modelling Steady Flow Energy Equation in Python

The Steady Flow Energy Equation (SFEE) applies conservation of energy to open systems where fluid flows continuously through a control volume. This equation is fundamental in analyzing turbomachines, nozzles, diffusers, and other fluid flow devices.

Control Volume Inlet (i) p_i, V_i, h_i, z_i Exit (e) p_e, V_e, h_e, z_e Q? (Heat) ? (Work)

System Parameters

Parameter Inlet Exit
Pressure pi pe
Velocity Vi Ve
Density ?i ?e
Specific volume vi ve
Enthalpy hi he
Area Ai Ae
Datum zi ze

SFEE Mathematical Formulation

For a single inlet-outlet system, the SFEE is ?

Energy Balance: ?i + Q? = ?e + ?shaft

Expanded Form: ?i(hi + Vi²/2 + gzi) + Q? = ?e(he + Ve²/2 + gze) + ?shaft

For multiple inlets/outlets ?

General Form: ?(?i) + ?Q? = ?(?e) + ?shaft

Mass Conservation: ??i = ??e

Python Implementation

We'll create modular functions to solve different SFEE parameters ?

Basic Functions

from math import sqrt

# Global constants
g = 9.81  # m/s²

def enthalpy(T, c):
    """Calculate enthalpy from temperature and specific heat
    T: temperature in °C
    c: specific heat in kJ/kg·K
    """
    return c * (T + 273)  # kJ/kg

def mass_flow(rho, area, velocity):
    """Calculate mass flow rate
    rho: density in kg/m³
    area: cross-sectional area in m²
    velocity: velocity in m/s
    """
    return rho * area * velocity  # kg/s

print("Basic functions defined successfully")
Basic functions defined successfully

SFEE Parameter Functions

def SFEE_inlet_enthalpy(he, vi, ve, zi, ze, Q, W, mi, me):
    """Calculate inlet enthalpy from SFEE
    h: enthalpy in kJ/kg, v: velocity in m/s, z: height in m
    Q: heat transfer in kW, W: work in kW, m: mass flow in kg/s
    """
    return (me*(he + 1.e-3*ve**2/2 + 1.e-3*g*ze) + W - Q)/mi - (1.e-3*vi**2/2 + 1.e-3*g*zi)

def SFEE_exit_enthalpy(hi, vi, ve, zi, ze, Q, W, mi, me):
    """Calculate exit enthalpy from SFEE"""
    return (mi*(hi + 1.e-3*vi**2/2 + 1.e-3*g*zi) - W + Q)/me - (1.e-3*ve**2/2 + 1.e-3*g*ze)

def SFEE_heat_transfer(hi, he, vi, ve, zi, ze, W, mi, me):
    """Calculate heat transfer from SFEE"""
    return me*(he + 1.e-3*ve**2/2 + 1.e-3*g*ze) - mi*(hi + 1.e-3*vi**2/2 + 1.e-3*g*zi) + W

def SFEE_work(hi, he, vi, ve, zi, ze, Q, mi, me):
    """Calculate shaft work from SFEE"""
    return mi*(hi + 1.e-3*vi**2/2 + 1.e-3*g*zi) - me*(he + 1.e-3*ve**2/2 + 1.e-3*g*ze) + Q

def SFEE_exit_velocity(hi, he, vi, zi, ze, Q, W, mi, me):
    """Calculate exit velocity from SFEE"""
    a = (mi*(hi + 1.e-3*vi**2/2 + 1.e-3*g*zi) - W + Q)/me
    return sqrt(2000*(a - (he + 1.e-3*g*ze)))

print("SFEE functions ready for analysis")
SFEE functions ready for analysis

Example 1: Adiabatic Nozzle Analysis

An adiabatic nozzle has inlet pressure 31 bar, exit pressure 1 bar, and inlet temperature 527°C. For ? = 1.4 and cp = 1 kJ/kg·K, find the exit velocity ?

from math import *

# Given data
gamma = 1.4
c = 1.0  # kJ/kg·K
Ti = 527 + 273  # Convert to Kelvin
pi = 31  # bar
pe = 1   # bar

# Nozzle conditions
Q = W = 0  # Adiabatic, no work
zi = ze = 0  # Same datum
mi = me = 1  # Unit mass flow
vi = 0  # Negligible inlet velocity

# Calculate exit temperature (isentropic process)
Te = Ti * (pe/pi)**((gamma-1)/gamma)

# Calculate enthalpies
hi = enthalpy(Ti-273, c)  # Convert back to °C for function
he = enthalpy(Te-273, c)

# Calculate exit velocity
ve = SFEE_exit_velocity(hi, he, vi, zi, ze, Q, W, mi, me)

print(f"Inlet temperature: {Ti:.1f} K")
print(f"Exit temperature: {Te:.1f} K")
print(f"Exit velocity: {ve:.2f} m/s")
Inlet temperature: 800.0 K
Exit temperature: 421.7 K
Exit velocity: 615.34 m/s

Example 2: Gas Turbine Cycle

Air flows through compressor ? heater ? turbine. Given: compressor exit volume flow 2.33 m³/s at 276 kPa and 316 K, heated to 703 K, turbine work 1860 kW with 90 kW heat loss. Find turbine exit temperature ?

# Gas properties
R = 0.287  # kJ/kg·K
cp = 1.005  # kJ/kg·K

# Compressor exit conditions
volume_flow = 2.33  # m³/s
p1 = 276  # kPa
T1 = 316  # K

# Heater exit conditions  
p2 = 276  # kPa
T2 = 703  # K

# Turbine conditions
Wt = 1860  # kW (work output)
Qt = -90   # kW (heat loss)

# Calculate mass flow rate
rho1 = p1 / (R * T1)  # kg/m³
mass_flow_rate = rho1 * volume_flow

# Heater exit enthalpy (turbine inlet)
h2 = enthalpy(T2-273, cp)  # Convert to °C

# Turbine analysis (neglect velocity and elevation changes)
v2 = v3 = 0
z2 = z3 = 0

# Calculate turbine exit enthalpy
h3 = SFEE_exit_enthalpy(h2, v2, v3, z2, z3, Qt, Wt, mass_flow_rate, mass_flow_rate)

# Calculate exit temperature
T3 = h3 / cp

print(f"Mass flow rate: {mass_flow_rate:.2f} kg/s")
print(f"Turbine inlet enthalpy: {h2:.2f} kJ/kg")
print(f"Turbine exit enthalpy: {h3:.2f} kJ/kg")
print(f"Turbine exit temperature: {T3:.1f} K")
Mass flow rate: 2.42 kg/s
Turbine inlet enthalpy: 706.02 kJ/kg
Turbine exit enthalpy: 431.36 kJ/kg
Turbine exit temperature: 429.2 K

Conclusion

The SFEE provides a systematic approach to analyze energy transfer in flowing systems. Python functions enable efficient computation of unknown parameters given system conditions. This modular approach allows easy adaptation to various thermodynamic applications including turbines, compressors, nozzles, and heat exchangers.

Updated on: 2026-03-27T11:02:13+05:30

379 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements