ISENTROPIC_WORK
Overview
Calculate work of compression or expansion for a gas in an isentropic process.
Excel Usage
=ISENTROPIC_WORK(temp_init, k_isentropic, p_inlet, p_outlet, comp_factor, efficiency)
temp_init(float, required): Initial temperature of the gas [K]k_isentropic(float, required): Isentropic exponent of the gas (Cp/Cv) [-]p_inlet(float, required): Inlet pressure [Pa]p_outlet(float, required): Outlet pressure [Pa]comp_factor(float, optional, default: 1): Compressibility factor of the gas [-]efficiency(float, optional, default: 1): Isentropic efficiency of the process [-]
Returns (float): Work performed per mole of gas compressed/expanded [J/mol]
Examples
Example 1: Compression with 10x pressure ratio
Inputs:
| temp_init | k_isentropic | p_inlet | p_outlet |
|---|---|---|---|
| 300 | 1.4 | 100000 | 1000000 |
Excel formula:
=ISENTROPIC_WORK(300, 1.4, 100000, 1000000)
Expected output:
8125.164049379897
Example 2: Compression with 78% efficiency
Inputs:
| temp_init | k_isentropic | p_inlet | p_outlet | efficiency |
|---|---|---|---|---|
| 300 | 1.4 | 100000 | 1000000 | 0.78 |
Excel formula:
=ISENTROPIC_WORK(300, 1.4, 100000, 1000000, 0.78)
Expected output:
10416.876986384483
Example 3: Expansion (negative work)
Inputs:
| temp_init | k_isentropic | p_inlet | p_outlet |
|---|---|---|---|
| 300 | 1.4 | 1000000 | 100000 |
Excel formula:
=ISENTROPIC_WORK(300, 1.4, 1000000, 100000)
Expected output:
-4208.408145836292
Example 4: Small pressure ratio compression
Inputs:
| temp_init | k_isentropic | p_inlet | p_outlet |
|---|---|---|---|
| 350 | 1.3 | 100000 | 200000 |
Excel formula:
=ISENTROPIC_WORK(350, 1.3, 100000, 200000)
Expected output:
2187.3829408281313
Python Code
import micropip
await micropip.install(["fluids"])
from fluids.compressible import isentropic_work_compression as fluids_isentropic_work
def isentropic_work(temp_init, k_isentropic, p_inlet, p_outlet, comp_factor=1, efficiency=1):
"""
Calculate work of compression or expansion for a gas in an isentropic process.
See: https://fluids.readthedocs.io/fluids.compressible.html#fluids.compressible.isentropic_work_compression
This example function is provided as-is without any representation of accuracy.
Args:
temp_init (float): Initial temperature of the gas [K]
k_isentropic (float): Isentropic exponent of the gas (Cp/Cv) [-]
p_inlet (float): Inlet pressure [Pa]
p_outlet (float): Outlet pressure [Pa]
comp_factor (float, optional): Compressibility factor of the gas [-] Default is 1.
efficiency (float, optional): Isentropic efficiency of the process [-] Default is 1.
Returns:
float: Work performed per mole of gas compressed/expanded [J/mol]
"""
# Validate and convert inputs
try:
temp_init = float(temp_init)
except (ValueError, TypeError):
return "Invalid input: temp_init must be a number."
try:
k_isentropic = float(k_isentropic)
except (ValueError, TypeError):
return "Invalid input: k_isentropic must be a number."
try:
p_inlet = float(p_inlet)
except (ValueError, TypeError):
return "Invalid input: p_inlet must be a number."
try:
p_outlet = float(p_outlet)
except (ValueError, TypeError):
return "Invalid input: p_outlet must be a number."
try:
comp_factor = float(comp_factor)
except (ValueError, TypeError):
return "Invalid input: comp_factor must be a number."
try:
efficiency = float(efficiency)
except (ValueError, TypeError):
return "Invalid input: efficiency must be a number."
# Validation
if temp_init <= 0:
return "Invalid input: temp_init must be positive."
if k_isentropic <= 1:
return "Invalid input: k_isentropic must be greater than 1."
if p_inlet <= 0:
return "Invalid input: p_inlet must be positive."
if p_outlet <= 0:
return "Invalid input: p_outlet must be positive."
if comp_factor <= 0:
return "Invalid input: comp_factor must be positive."
if efficiency <= 0 or efficiency > 1:
return "Invalid input: efficiency must be between 0 and 1."
try:
result = fluids_isentropic_work(T1=temp_init, k=k_isentropic, P1=p_inlet, P2=p_outlet, Z=comp_factor, eta=efficiency)
return float(result)
except Exception as e:
return f"Error: Failed to compute isentropic work: {str(e)}"