import math
# Variables
T0 = 308.;
T1 = 693.;
T1_ = 523.; # T1_ = T1'
T1_ = 523.; # ""
# Calculation
f = (T0*(T1-T1_))/(T1_*(T1-T0));
# Results
print "The fraction of energy that becomes unavailable due to irreversible heat transfer is %.2f"%f
import math
from scipy.integrate import quad
# Variables
lhw = 1858.5; # Latent heat of water
Tew = 220+273.;
Sw = lhw/Tew;
Tig = 1100.; # Initial temperature of the gas
Tfg = 550.; # Final ""
# Calculation
k = 1*lhw/(Tig-Tfg); # k = mg_dot*cpg
Tg2 = 823.
Tg1 = 1373.
T0 = 303.;
def f2(T):
return k/T
Sg = quad(f2,Tg1,Tg2)[0]
St = Sg+Sw;
print "Total change in entropy is %.3f kJ/K"%St
print "Increase in unavailable energy is %.0f Kj"%(round(T0*St,-1))
import math
from scipy.integrate import quad
# Variables
Tw = 75. + 273;
Ts = 5. + 273; # Ts = T0
m = 40.;
cp = 4.2;
# Calculation
def f9(T):
return m*cp*(1-(Tw/T))
W = -quad(f9,Ts,Tw)[0]
Q1 = m*cp*(Tw-Ts);
UE = Q1-W;
# Results
print "Total work %.0f kJ"%W
print "Heat released",Q1,"kJ"
print "Internal energy change %.0f kJ"%UE
# quad gives slightly different answer than book has. pLease check.
import math
from scipy.integrate import quad
# Variables
Ts = 273+15. #temperature
Tw1 = 95+273. #Water
Tw2 = 35+273. #water
m1 = 25. #energy
m2 = 35.
cp = 4.2 #Water
# Calculation
def f3(T):
return m1*cp*(1-(Ts/T))
AE25 = quad(f3,Ts,Tw1)[0]
def f4(T):
return m2*cp*(1-(Ts/T))
AE35 = quad(f4,Ts,Tw2)[0]
AEt = AE25 + AE35;
Tm = (m1*Tw1+m2*Tw2)/(m1+m2); # Temperature after mixing
def f5(T):
return (m1+m2)*cp*(1-(Ts/T))
AE60 = quad(f5,Ts,Tm)[0]
AE = AEt - AE60;
print "The decrease in the totla energy is %.2f kJ"%AE
import math
from scipy.integrate import quad
# Variables
N1 = 3000.; #RPM
w1 = (2*math.pi*N1)/60.;
I = 0.54;
Ei = 0.5*I*w1**2;
ti = 15.+273; #temperature
m = 2.; #water equivalent
# Calculation
dt = Ei/(1000*2*4.187);
tf = ti+dt;
def f6(T):
return m*4.187*(1-(ti/T))
AE = quad(f6,ti,tf)[0]
UE = Ei/1000 - AE;
w2 = math.sqrt(AE*1000*2/I);
N2 = (w2*60)/(2*math.pi);
# Results
print "The final RPM of the flywheel would be %.0f"%N2
import math
from scipy.integrate import quad
# Variables
T1 = 353.
T2 = 278.
V2 = 2.
V1 = 1.
P0 = 100. #tempareture
P1 = 500. #air
R = 0.287
cv = 0.718; #air
m = 2.
# Calculation
def f7(T):
return (m*cv)/T
def f8(V):
return m*R/V
S = quad(f7,T1,T2)[0] + quad(f8,V1,V2)[0]
U = m*cv*(T1-T2);
Wmax = U-(T2*(-S));
V1_ = (m*R*T1)/P1;
CA = Wmax-P0*(V1_); # Change in availability
I = T2*S;
# Results
print "The maximum work is %.2f kJ"%Wmax
print "Change in availability is %.2f kJ"%CA
print "Irreversibility is %.1f kJ"%I
# rounding off error. please check.
import math
# Variables
P1 = 500. # air
P2 = 100.; # kPa
T1 = 793.
T2 = 573.
cp = 1.005 # air
T0 = 293.
R = 0.287;
# Calculation and Results
S21 = (R*math.log(P2/P1))-(cp*math.log(T2/T1))
CA = cp*(T1-T2)-T0*S21; # Change in v=availability
print "The decrease in availability is %.1f kJ/Kg"%CA
Wmax = CA;
print "The maximum work is %.1f kJ/Kg"%Wmax
Q = -10.;
W = cp*(T1-T2)+Q ;
I = Wmax-W;
print "The irreversibility is %.1f kJ/Kg"%I
# rounding off error.
import math
# Variables
T0 = 300. # cooled
Tg1 = 573.
Tg2 = 473.;
Ta1 = 313.;
cpg = 1.09 # tempareture
cpa = 1.005; # air
mg = 12.5
ma = 11.15;
# Calculation and Results
f1 = cpg*(Tg1-T0)-T0*cpg*(math.log(Tg1/T0));
f2 = cpg*(Tg2-T0)-T0*cpg*(math.log(Tg2/T0));
print "The initial and final availbility of the products are %.2f and %.2f kJ/Kg respectively"%(f1,f2)
# Part (b)
Dfg = f1-f2;
Ta2 = Ta1 + (mg/ma)*(cpg/cpa)*(Tg1-Tg2);
Ifa = cpa*(Ta2-Ta1)-T0*cpa*(math.log(Ta2/Ta1));
I = mg*Dfg-ma*Ifa;
print "The irreversibility of the process is %.2f kW"%I
# Part (c)
Ta2_ = Ta1*(math.e**(-(mg/ma)*(cpg/cpa)*math.log(Tg2/Tg1)));
Q1 = mg*cpg*(Tg1-Tg2);
Q2 = ma*cpa*(Ta2_-Ta1);
W = Q1-Q2;
print "Tota power generated by the heat engine %.2f kW"%W
# rounding off error. please check.
import math
# Variables
T2 = 1063.;
T1 = 1073.;
m = 2.; # pipe
cp = 1.1;
# Calculation and Results
I = m*cp*((T1-T2)-T0*(math.log(T1/T2)));
print "The irrevesibility rate is %.3f kW"%I
# At lower temperature
T1_ = 353.
T2_ = 343.
I_ = m*cp*((T1_-T2_)-T0*(math.log(T1_/T2_)));
print "The irrevesibility rate at lower temperature is %.3f kW"%I_
# Variables
m = 3.; # insulated pipe
R = 0.287;
T0 = 300.
k = 0.10; # k = dP/P1
# Calculation
Sgen = m*R*k;
I = Sgen*T0;
# Results
print "The rate of energy loss because of the pressure drop due to friction",I,"kW"
import math
# Variables
m1 = 2.; # m1_dot
m2 = 1.;
T1 = 90.+273;
T2 = 30.+273;
T0 =300.;
# Calculation
m = m1+m2;
x = m1/m;
t = T2/T1; # Tau
cp = 4.187;
Sgen = m*cp*math.log((x+t*(1-x))/(t**(1-x)));
I = T0*Sgen;
print "The rate of entropy generation is %.4f kW/K"%Sgen
print "The rate of energy loss due to mixing is %.1f kW"%I
# rounding off error.
# Variables
Qr = 500.; # Heat release in kW
Tr = 2000.;
T0 = 300.; # chemical process
# Calculation and Results
# Part (a)
Qa = 480.
Ta = 1000.;
n1a = (Qa/Qr);
n2a = n1a*(1-(T0/Ta))/(1-(T0/Tr));
print ("PART (A)")
print "The first law efficiency is",n1a*100,"%"
print "The Second law efficiency is %.0f %%"%(n2a*100)
# Part (b)
Qb = 450.
Tb = 500.
n1b = (Qb/Qr);
n2b = n1b*(1-(T0/Tb))/(1-(T0/Tr));
print ("PART (B)")
print "The first law efficiency is",n1b*100,"%"
print "The Second law efficiency is %.1f %%"%(n2b*100)
# Part (c)
Qc = 300.
Tc = 320.
n1c = (Qc/Qr);
n2c = n1c*(1-(T0/Tc))/(1-(T0/Tr));
print ("PART (C)")
print "The first law efficiency is",n1c*100,"%"
print "The Second law efficiency is %.2f %%"%(n2c*100)
# Part (d)
Qd = 450.;
n1d = (Qd/Qr);
n2a_= n1d*(1-(T0/Ta))/(1-(T0/Tr));
n2b_= n1d*(1-(T0/Tb))/(1-(T0/Tr));
n2c_= n1d*(1-(T0/Tc))/(1-(T0/Tr));
print ("Part (D)")
print "The first law efficiency is",n1d
print "The Second law efficiency of part (a) is %.2f %%"%(n2a_*100)
print "The Second law efficiency of part (b) is %.1f %%"%(n2b_*100)
print "The Second law efficiency of part (c) is %.2f %%"%(n2c_*100)
import math
# Variables
cp = 1.005
T2 = 433.
T1 = 298.;
T0 = 298.
R = 0.287
P2 = 8.
P1 = 1.
Q = -100.
m = 1.
# Calculation
W = Q + m*cp*(T1-T2);
AF = cp*(T2-T1)-T0*((cp*math.log(T2/T1))-(R*math.log(P2/P1))) ; # AF = af2-af1
e = AF/-W # efficiency
# Results
print "The power input is %.1f kW"%W
print "The second law efficiency of the compressor is %.3f"%e
import math
# Variables
U = 0
H0 = 0
S = 0;
# If the vaccume ha reduced to dead state
U0 = 0
H0 = 0
S0 = H0
V0 = 0;
P0 = 100
V = 1;
# Calculation
fi = P0*V;
# Results
print "The energy of the complete vaccume is",fi,"kJ"
import math
# Variables
m = 1000. # mass in kg
T0 = 300.
P0 = 1.
T1 = 300.;
T2 = 273-20.
Tf = 273-2.2; # freezing point in C
Cb = 1.7
Ca = 3.2;
Lh = 235. # latent heat
# Calculation
H12 = m*((Cb*(Tf-T2))+Lh+(Ca*(T1-Tf)));
H21 = -H12;
S12 = m*((Cb*math.log(Tf/T2))+(Lh/Tf)+(Ca*math.log(T1/Tf)));
S21 = -S12;
E = H21-T0*S21;
# Results
print "Energy produced is %.1f MJ"%(E/1000)
import math
# Variables
cv = 0.718
T2 = 500. # tempareture
T1 = 300.
m = 1.
T0 = 300.
# Case (a)
Sua = cv*math.log(T2/T1);
Ia = T0*Sua;
print "The irreversibility in case a is %.1f kJ/Kg"%Ia
# Case (b)
Q = m*cv*(T2-T1);
T = 600.
Sub = Sua-(Q/T);
Ib = T0*Sub;
print "The irreversibility in case b is %.2f kJ/Kg"%Ib
# rounding off error
import math
# Variables
h1 = 3230.9
s1 = 6.69212
V1 = 160. # velocity
T1 = 273.+400; # Steam
h2 = 2676.1
s2 = 7.3549
V2 = 100.
T2 = 273. + 100;
T0 = 298.
W = 540. # water
Tb = 500. # tempareture
# Calculation
Q = (h1-h2)+((V1**2-V2**2)/2)*1e-03-W;
I = 151.84-Q*(0.404);
AF = W + Q*(1-(T0/Tb)) + I; # AF = af1-af2
n2 = W/AF;
# Results
print "Irreversibility per unit mass is %.2f kJ/Kg"%I
print "The second law effiency of the turbine is %.2f"%n2
# Variables
T0 = 300.
T = 1500. # resistor
Q = -8.5
W = 8.5;
# Calculation and Results
# Case (a)
I = Q*(1-T0/T) + W;
R = Q*(1-T0/T);
print "Rate of availability transfer with heat and the irreversibility rate are",R,"and",I,"kW"
# Case (b)
T1 = 500.;
Ib = - Q*(1-T0/T) + Q*(1-T0/T1);
print "Rate of availability in case b is",Ib,"kW"
import math
# Variables
P1 = 1.
T1 = 273.+30;
P2 = 3.5
T2 = 141.+273 ;
V = 90.;
T0 = 303.;
# Calculation and Results
# Part (a)
g = 1.4;
T2s = T1*((P2/P1)**((g-1)/g));
print "As T2s> T2 so the process must be polytropic"
# Part (b)
p = math.log(P2/P1); q = math.log(T2/T1);
n = p/(p-q);
print "The polytropic index is %.2f"%n
# Part (c)
cp = 1.0035; R = 0.287;
Wa = cp*(T1-T2)-(V2**2/2)*1e-03 ;
Wt = -R*T0*math.log(P2/P1)-(V2**2/2)*1e-03;
Nt = Wt/Wa;
print "The isothermal effiency is %.3f"%Nt
# Part (d)
f12 = cp*(T1-T2) + T0*((R*math.log(P2/P1))-(cp*math.log(T2/T1))) - (V2**2/2)*1e-03 ;
I = f12-Wa ;
print "The minimum work input and irreversibility are %.1f and %.1f kJ/Kg "%(f12,I)
# Part (e)
n2 = (f12/Wa);
print "Second law efficiency is %.2f"%n2
# note : answer are slightly different because of rounding off error. please check.