0% found this document useful (0 votes)
148 views7 pages

EES Codes

1) Defines a function to look up thermal conductivity values for various materials. Calculates heat loss through a glass wall. 2) Calculates heat transfer by convection and radiation from a heated sphere. 3) Performs thermodynamic calculations for a constant-volume process involving R134a. 4) Performs calculations for a constant-volume mixing process involving steam.

Uploaded by

qq99xyhqm4
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
148 views7 pages

EES Codes

1) Defines a function to look up thermal conductivity values for various materials. Calculates heat loss through a glass wall. 2) Calculates heat transfer by convection and radiation from a heated sphere. 3) Performs thermodynamic calculations for a constant-volume process involving R134a. 4) Performs calculations for a constant-volume mixing process involving steam.

Uploaded by

qq99xyhqm4
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

1)

FUNCTION klookup(material$)
If material$='Glass' then klookup:=0.78
If material$='Brick' then klookup:=0.72
If material$='Fiber Glass' then klookup:=0.043
If material$='Air' then klookup:=0.026
If material$='Wood(oak)' then klookup:=0.17
END
L=2"[m]"
W=2"[m]"
{material$='Glass'
T_in=10"[C]"
T_out=3"[C]"
k=0.78"[W/m-C]"
t=5"[hr]"
thickness=0.5"[cm]"}
k=klookup(material$)"[W/m-K]"
A=L*W"[m^2]"
Q_dot_loss=A*k*(T_in-T_out)/(thickness*convert(cm,m))"[W]"
Q_loss_total=Q_dot_loss*t*convert(hr,s)*convert(J,kJ)"[kJ]"

2)

sigma = 5.67e-8"[W/m^2-K^4]"
{T_sphere = 70"[C]"
T_room = 20"[C]"
D_sphere = 5"[cm]"
epsilon = 0.1
h_c = 15"[W/m^2-K]"}
A = 4 * pi * (D_sphere / 2)^2 * convert(cm^2,m^2)"[m^2]"
Q_dot_conv = A * h_c * (T_sphere - T_room)"[W]"
Q_dot_rad = A * epsilon * sigma * ((T_sphere + 273)^4 - (T_room + 273)^4)"[W]"
Q_dot_total = Q_dot_conv + Q_dot_rad"[W]"

3)

"Given Data"
x_1=0.0
Vol_1=0.01[m^3]
P_1=800 [kPa]
T_2=20 [C]
P_2=400 [kPa]
"Solution"
v_1=volume(R134a,P=P_1,x=x_1)
Vol_1=m*v_1
v_2=volume(R134a,P=P_2,T=T_2)
Vol_2=m*v_2
4)

"Given Data"
V_A=0.5 [m^3]
T_A=20 [C]
P_A=600 [kPa]
V_B=0.5 [m^3]
T_B=30 [C]
P_B=150 [kPa]
T_2=15 [C]

"Solution"
R=R_u/molarmass(H2)
R_u=8.314 [kJ/kmol-K]
V_total=V_A+V_B
m_total=m_A+m_B
P_A*V_A=m_A*R*(T_A+273)
P_B*V_B=m_B*R*(T_B+273)
P_2*V_total=m_total*R*(T_2+273)

5)

P = 10 [MPa]*convert(MPa,kPa)
T_Celsius = 400 [C]
T = T_Celsius + 273 "[K]"
T_critical = t_crit(Steam_iapws)
P_critical = p_crit(Steam_iapws)
{v = Vol/m}
P_table = P; P_comp = P; P_idealgas = P
T_table = T; T_comp = T; T_idealgas = T
v_table = volume(Steam_IAPWS, P = P_table, T = T_table) "EES data for steam as a
real gas"
{P_table = pressure(Steam_iapws, T = T_table, v = v)}
{T_sat = temperature(Steam_iapws, P = P_table, v = v)}
MM = molarmass(water)
R_u = 8.314 [kJ/kmol-K] "Universal gas constant"
R = R_u / MM "[kJ/kg-K], Particular gas constant"
P_idealgas * v_idealgas = R * T_idealgas "Ideal gas equation"
z = COMPRESS(T_comp/T_critical, P_comp/P_critical)
P_comp * v_comp = z * R * T_comp "generalized Compressibility factor"
Error_idealgas = abs(v_table - v_idealgas) / v_table * convert(, %)
Error_comp = abs(v_table - v_comp) / v_table * convert(, %)

6)

"Given Data"
D=6 [m]
P=200 [kPa]
T=20 [C]
R_u=8.314 [kJ/kmol-K]
"Solution"
P*V=N*R_u*(T+273)
V=4*pi*(D/2)^3/3
m=N*molarmass(Helium)

7)

Function vanderwaals(T,v,M,R_u,T_cr,P_cr)
v_bar=v*M "Conversion from m^3/kg to m^3/kmol"
"The constants for the van der Waals equation of state are given by equation 3-24"
a=27*R_u^2*T_cr^2/(64*P_cr)
b=R_u*T_cr/(8*P_cr)
"The van der Waals equation of state gives the pressure as"
vanderwaals:=R_u*T/(v_bar-b)-a/v_bar**2
End
m=2.841[kg]
Vol=1 [m^3]
P=6*convert(MPa,kPa)
T_cr=t_crit(Steam_iapws)
P_cr=p_crit(Steam_iapws)
v=Vol/m
P_table=P; P_vdW=P;P_idealgas=P
T_table=temperature(Steam_IAPWS,P=P_table,v=v) "EES data for steam as a real gas"
{P_table=pressure(Steam_iapws, T=T_table,v=v)}
{T_sat=temperature(Steam_iapws,P=P_table,v=v)}
MM=molarmass(water)
R_u=8.314 [kJ/kmol-K] "Universal gas constant"
R=R_u/MM "Particular gas constant"
P_idealgas=R*T_idealgas/v "Ideal gas equation"
"The value of P_vdW is found from van der Waals equation of state Function"
P_vdW=vanderwaals(T_vdW,v,MM,R_u,T_cr,P_cr)
Error_idealgas=abs(T_table-T_idealgas)/T_table*convert(, %)
Error_vdW=abs(T_table-T_vdW)/T_table*convert(, %)

8)

"Knowns"
Vol_1L=200 [L]
x_1=0 "saturated liquid state"
P=900 [kPa]
T_2=70 [C]
"Solution"
Vol_1=Vol_1L*convert(L,m^3)
"The work is the boundary work done by the R-134a during the constant pressure
process."
W_boundary=P*(Vol_2-Vol_1)
"The mass is:"
Vol_1=m*v_1
v_1=volume(R134a,P=P,x=x_1)
Vol_2=m*v_2
v_2=volume(R134a,P=P,T=T_2)
"Plot information:"
v[1]=v_1
v[2]=v_2
P[1]=P
P[2]=P
T[1]=temperature(R134a,P=P,x=x_1)
T[2]=T_2

9)

P[3]=P[2]+(Spring_const)*(V[3] - V[2]) "P[3] is a linear function of V[3]"


"where Spring_const = k/A^2, the actual spring constant divided by the piston face
area squared"
"Input Data"
P[1]=150 [kPa]
m=50 [kg]
T[1]=25 [C]
P[2]=P[1]
V[2]=0.2 [m^3]
A=0.1[m^2]
k=100 [kN/m]
DELTAx=20 [cm]
Spring_const=k/A^2 "[kN/m^5]"
V[1]=m*spvol[1]
spvol[1]=volume(Steam_IAPWS,P=P[1],T=T[1])
V[2]=m*spvol[2]
V[3]=V[2]+A*DELTAx*convert(cm,m)
V[3]=m*spvol[3]
"The temperature at state 2 is:"
T[2]=temperature(Steam_IAPWS,P=P[2],v=spvol[2])
"The temperature at state 3 is:"
T[3]=temperature(Steam_IAPWS,P=P[3],v=spvol[3])
Wnet_other = 0
W_out=Wnet_other + W_b12+W_b23
W_b12=P[1]*(V[2]-V[1])
"W_b23 = integral of P[3]*dV[3] for Deltax = 20 cm and is given by:"
W_b23=P[2]*(V[3]-V[2])+Spring_const/2*(V[3]-V[2])^2

10)

Function hcal(WorkFluid$, Tx, Px)


"Function to calculate the enthalpy of an ideal gas or real gas"
If 'Air' = WorkFluid$ Then
hcal:=enthalpy('Air',T=Tx) "Ideal gas equ."
Else
hcal:=enthalpy(WorkFluid$,T=Tx, P=Px)"Real gas equ."
Endif
End HCal
"System: control volume for the nozzle"
"Property relation: Air is an ideal gas"
"Process: Steady state, steady flow, adiabatic, no work"
"Knowns - obtain from the input diagram"
WorkFluid$ = 'Air'
T[1] = 200 [C]
P[1] = 300 [kPa]
Vel[1] = 30 [m/s]
P[2] = 100 [kPa]
Vel[2] = 180 [m/s]
A[1]=80 [cm^2]
Am[1]=A[1]*convert(cm^2,m^2)
"Property Data - since the Enthalpy function has different parameters
for ideal gas and real fluids, a function was used to determine h."
h[1]=hcal(WorkFluid$,T[1],P[1])
h[2]=hcal(WorkFluid$,T[2],P[2])
"The Volume function has the same form for an ideal gas as for a real fluid."
v[1]=volume(workFluid$,T=T[1],P=P[1])
v[2]=volume(WorkFluid$,T=T[2],P=P[2])
"Conservation of mass: "
m_dot[1]= m_dot[2]
"Mass flow rate"
m_dot[1]=Am[1]*Vel[1]/v[1]
m_dot[2]= Am[2]*Vel[2]/v[2]
"Conservation of Energy - SSSF energy balance"
h[1]+Vel[1]^2/(2*1000) = h[2]+Vel[2]^2/(2*1000)
"Definition"
A_ratio=A[1]/A[2]
A[2]=Am[2]*convert(m^2,cm^2)

11)

"Knowns"
T[1] = 450 [C]
P[1] = 10000 [kPa]
Vel[1] = 80 [m/s]
P[2] = 10 [kPa]
X_2 = 0.92
Vel[2] = 50 [m/s]
m_dot[1] = 12 [kg/s]
Fluid$ = 'Steam_IAPWS'

"Property Data"
h[1] = enthalpy(Fluid$, T = T[1], P = P[1])
h[2] = enthalpy(Fluid$, P = P[2], x = X_2)
T[2] = temperature(Fluid$, P = P[2], x = X_2)
v[1] = volume(Fluid$, T = T[1], P = P[1])
v[2] = volume(Fluid$, P = P[2], x = X_2)

"Conservation of Mass"
m_dot[1] = m_dot[2]

"Mass Flow Rate"


m_dot[1] = A[1] * Vel[1] / v[1]
m_dot[2] = A[2] * Vel[2] / v[2]

"Conservation of Energy - Steady Flow Energy Balance"


m_dot[1] * (h[1] + Vel[1]^2 / 2 * Convert(m^2/s^2, kJ/kg)) =
m_dot[2] * (h[2] + Vel[2]^2 / 2 * Convert(m^2/s^2, kJ/kg)) + W_dot_turb *
Convert(MW, kJ/s)

DELTAke = Vel[2]^2 / 2 * Convert(m^2/s^2, kJ/kg) - Vel[1]^2 / 2 * Convert(m^2/s^2,


kJ/kg)

12)

"Input Data from the Diagram Window"


T_H = 550 [C]
T_L = 25 [C]
Q_dot_H = 1200 [kJ/min]
"First Law applied to the heat engine"
Q_dot_H - Q_dot_L- W_dot_net = 0
W_dot_net_KW=W_dot_net*convert(kJ/min,kW)
"Cycle Thermal Efficiency - Temperatures must be absolute"
eta_th = 1 - (T_L + 273)/(T_H + 273)
"Definition of cycle efficiency"
eta_th=W_dot_net / Q_dot_H

14)

"Knowns:"
T_H = 400 [C]
Q_H = 1300 [kJ]
T_Sys = T_H
"Analysis:
(a) & (b) This is a reversible isothermal process, and the entropy change during
such a process
is given by
DELTAS = Q/T"
"Noting that heat transferred from the source is equal to the heat transferred to
the working fluid,
the entropy changes of the fluid and of the source become "
DELTAS_source = -Q_H/(T_H+273)
DELTAS_fluid = +Q_H/(T_Sys+273)
"(c) entropy generation for the process:"
S_gen = DELTAS_source + DELTAS_fluid

15)

"Knowns:"
T_1_iron = 100 [C]
m_iron = 20 [kg]
T_1_al = 200 [C]
m_al = 20 [kg]
C_al = 0.973 [kJ/kg-K] "FromTable A-3
at the anticipated average temperature of
450 K."
C_iron= 0.45 [kJ/kg-K] "FromTable A-3
at room temperature, the only value
available."
"Analysis: "
" Treat the iron plus aluminum as a
closed system, with no heat transfer in,
no work out, neglect changes in KE and
PE of the system. "
"The final temperature is found from the
energy balance."
E_in - E_out = DELTAE_sys
E_out = 0
E_in = 0
DELTAE_sys = m_iron*DELTAu_iron + m_al*DELTAu_al
DELTAu_iron = C_iron*(T_2_iron - T_1_iron)
DELTAu_al = C_al*(T_2_al - T_1_al)
"the iron and aluminum reach thermal equilibrium:"
T_2_iron = T_2
T_2_al = T_2
DELTAS_iron = m_iron*C_iron*ln((T_2_iron+273) / (T_1_iron+273))
DELTAS_al = m_al*C_al*ln((T_2_al+273) / (T_1_al+273))
DELTAS_total = DELTAS_iron + DELTAS_al

You might also like