# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3.8.5 64-bit
#     name: python385jvsc74a57bd0916dbcbb3f70747c44a77c7bcd40155683ae19c65e1c03b4aa3499c5328201f1
# ---

# # Example 9.1: Isentropic Compression (Cold-Air-Standard)
#
# *<NAME>, Ph.D., P.E.<br>
# University of Kentucky - Paducah Campus<br>
# ME 321: Engineering Thermodynamics II<br>*

# ## Problem Statement
# Air is compressed isentropically form $T_1=250\ \text{K}$, $p_1=1\ \text{bar}$ to $T_2=400\ \text{K}$
# * (a) What is the compression ratio
# * (b) What is the final pressure

# ## Solution
#
# __[Video Explanation](https://uky.yuja.com/V/Video?v=3074239&node=10465156&a=1753145453&autoplay=1)__

# ### Python Initialization
# We'll start by importing the libraries we will use for our analysis and initializing dictionaries to hold the properties we will be usings.

# + jupyter={"outputs_hidden": false}
from kilojoule.templates.kSI import *
air = idealgas.Properties('Air', unit_system='kSI')
# -

# ### Given Parameters
# We now define variables to hold our known values.

# + jupyter={"outputs_hidden": false}
# %%showcalc
T[1] = Quantity(250,'K')
p[1] = Quantity(1,'bar')
T[2] = Quantity(400,'K')
# -

# #### Assumptions (Cold-Air-Standard)
# * Ideal gas
# * Constant specific heat
# * Adiabatic
# * Negligible changes in kinetic and potential energy

# + jupyter={"outputs_hidden": false}
# %%showcalc
# Ideal Gas
R = air.R

# Constant thermal properties evaluated at room temperature
T_room = Quantity(25,'degC')
c_v = air.Cv(T=T_room)
c_p = air.Cp(T=T_room)
k = air.k(T=T_room)
# -

# #### (a) Compression Ratio

# + jupyter={"outputs_hidden": false}
# %%showcalc
# Specific volume at inlet: Ideal Gas Law (IGL)
v[1] = R*T[1]/p[1]

# Isentropic compression from $1\to2$
v[2] = v[1]*(T[1]/T[2])**(1/(k-1))

# Compression ratio 
r = v[1]/v[2]

Calculations();
# -

# #### (b) Final Pressure

# + jupyter={"outputs_hidden": false}
# %%showcalc
# Pressure at exit (IGL)
p[2] = R*T[2]/v[2]

# Pressure ratio
r_p = p[2]/p[1]

# + jupyter={"outputs_hidden": false}
Summary();

# + jupyter={"outputs_hidden": false}
Summary(['r','r_p']);

StarcoderdataJupyterScriptsDedupFiltered