# Variables :
T1 = 400.; #Kelvin
T2 = 300.; #Kelvin
Q1 = 4800.; #KJ
Q2 = -4800.; #KJ
# Calculations
#Q1/T1+Q2/T2< = 0
LHS = Q1/T1+Q2/T2; #
# Results
print "/T1+Q2/T2 = ",LHS
print ("It is less than zero. Process is irreversible")
# Variables :
T1 = 290.+273; #Kelvin
T2 = 8.5+273; #Kelvin
Q1 = 300.; #KJ
#Case 1 :
Q2 = -215.; #KJ
# Calculations and Results
sigmaQbyT = Q1/T1+Q2/T2
print "(i) Q1/T1+Q2/T2 = %.4f"%sigmaQbyT
print ("It is less than zero. Cycle is irreversible")
#Case 2 :
Q2 = -150.; #KJ
sigmaQbyT = Q1/T1+Q2/T2
print "(ii) Q1/T1+Q2/T2 = %.0f"%sigmaQbyT
print ("It is equal to zero. Cycle is reversible");
#Case 3 :
Q2 = -75.; #KJ
sigmaQbyT = Q1/T1+Q2/T2
print "(iii) Q1/T1+Q2/T2 = %.4f"%sigmaQbyT
print ("It is greater than zero. Cycle is impossible.");
import math
# Variables :
V1 = 10.; #m**3
T1 = 175.+273; #Kelvin
T2 = 36.+273; #Kelvin
p1 = 5.; #bar
p2 = 1.; #bar
R = 287.; #KJ/KgK
Cp = 1.005; #KJ/KgK
# Calculations
#p*V = m*R*T
m = p1*10**5*V1/R/T1; #Kg
deltaS = m*Cp*math.log(T2/T1)+m*R/1000*math.log(p1/p2); #KJ/K
# Results
print "Entropy change in KJ/K : %.3f"%deltaS
# Variables :
deltaS = 5.; #KJ/KgK
W = 2000.; #KJ/Kg
T1 = 327.+273; #Kelvin
# Calculations and Results
Q1 = deltaS*T1; #KJ/Kg
Q2 = Q1-W; #KJ/Kg
Eta = W/Q1*100; #%
print "Efficiency in %% : %.1f"%Eta
T2 = Q2/Q1*T1; #K
print "Lowest temperature in Kelvin : ",T2
import scipy
from scipy.integrate import quad
# Variables :
mc = 0.5; #Kg
Tc = 100.+273; #K
Cpc = 0.393; #KJ/KgK
Tw = 10.+273; #K
Cpw = 4.2; #KJ/KgK
# Calculations and Results
def f0(T):
return mc*Cpc
Q = quad(f0,Tc,Tw)[0]
def f1(T):
return mc*Cpc/T
deltaSc = quad(f1,Tc,Tw)[0]
deltaSw = abs(Q)/Tw; #KJ/K
deltaSuniverse = deltaSc+deltaSw; #Kj/K
print "Part (i) Chane in entropy in KJ/K : %.4f"%deltaSuniverse
T1 = 383.; #K
T2 = 283.; #K
T = (T1+T2)/2; #K
def f2(T):
return 1/T
a = quad(f2,T1,T)[0]
deltaSuniverse = mc*Cpc*( a + 0.1627)
print "Part (ii) Chane in entropy in KJ/K : %.5f"%deltaSuniverse
# Variables :
Tc = 35.+273; #K
W = 500.; #KJ
T1 = 308.; #K
T2 = 308.; #K
T0 = 15.+273; #K
Q = W; #KJ
deltaS1 = 0; #as heat supplied is zero
# Calculations
deltaS2 = Q/T0; #KJ/K
# Results
print "Change in entropy in KJ/K : %.4f"%deltaS2
import math
# Variables :
mi = 0.5; #Kg
Ti = -10.+273; #K
Cpi = 2.; #KJ/KgK
Cpw = 4.2; #KJ/KgK
Li = 334.; #KJ/Kg
mc = 5.; #Kg
Tc = 80.+273; #K
Cpc = 0.5; #KJ/KgK
T0 = 0.+273; #K
# Calculations and Results
#mi*[Cpi*(T0-Ti)+Li+Cpw*(T-T0)] = mc*Cpc*(Tc-T)
T = (mc*Cpc*Tc-mi*Cpi*(T0-Ti)-mi*Li+mi*Cpw*T0)/(mi*Cpw+mc*Cpc); #K
deltaSi = mi*Cpi*math.log(T0/Ti)+Li/T0+mi*Cpw*math.log(T/T0); #KJ/K
print "Entropy chane of Ice in KJ/K : %.4f"%deltaSi
deltaSc = mc*Cpc*math.log(T/Tc); #KJ/K
print "Entropy chane of Copper in KJ/K : %.4f"%deltaSc
deltaSsurr = 0; #No heat transfer between system & Surrounding
deltaSuniverse = deltaSi+deltaSc+deltaSsurr; #KJ/K
print "Entropy chane of universe in KJ/K : %.4f"%deltaSuniverse
import scipy
from scipy.integrate import quad
# Variables :
m1 = 5.; #Kg
T1 = 200.+273; #K
Cp1 = 0.4; #KJ/KgK
m2 = 100.; #Kg
T2 = 30.+273; #K
Cp2 = 2.1; #KJ/KgK
# Calculations
#m1*Cp1*(T1-T) = m2*Cp2*(T-T2)
T = (m1*Cp1*T1+T2*m2*Cp2)/(m2*Cp2+m1*Cp1); #K
def f8(T):
return m1*Cp1/T
deltaS1 = quad(f8,T1,T)[0]
def f9(T):
return m2*Cp2/T
deltaS2 = quad(f9,T2,T)[0]
deltaSsurr = 0; #No heat transfer neglected
deltaSuniverse = deltaS1+deltaS2+deltaSsurr; #KJ/K
# Results
print "Increase in Entropy of universe in KJ/K : %.4f"%deltaSuniverse
import scipy
from scipy.integrate import quad
# Variables :
HeatTransfer = 2; #KJ/degreeCentigrade(it is d'Q/dT)
T1 = 27+273; #K
T2 = 127+273; #K
# Calculations
def f22(T):
return HeatTransfer/T
deltaS = quad(f22,T1,T2)[0]
# Results
print "Entropy change when heat is transfered to system in KJ/K : %.4f"%deltaS
print "change when end states are achieved by stirring action in KJ/K : %.4f"%deltaS
import scipy
from scipy.integrate import quad
# Variables :
m1 = 2.; #Kg
T1 = 80.+273; #K
m2 = 3.; #Kg
T2 = 30.+273; #K
Cp = 4.187; #KJ/KgK
# Calculations
#m1*Cp1*(T1-T) = m2*Cp2*(T-T2)
T = (m1*Cp*T1+T2*m2*Cp)/(m2*Cp+m1*Cp); #K
def f26(T):
return m1*Cp/T
deltaS = quad(f26,T1,T)[0] + 0.8029
print "Total Entropy change due to mixing process in KJ/K : %.4f"%deltaS
from scipy.integrate import quad
# Variables :
V1 = 4.; #m**3
V2 = 4.; #m**3
m = 20.; #Kg
p1 = 4.*100; #KPa
p2 = 8.*100; #KPa
Cp = 1.005; #KJ/KgK
Cv = 0.718; #KJ/KgK
# Calculations and Results
R = Cp-Cv; #KJ/KgK
T1 = p1*V1/m/R; #K
T2 = p2*V2/m/R; #K
deltaU = m*Cv*(T2-T1); #KJ
print "Change in internal energy in KJ : %.2f"%deltaU
W = 0; #KJ
print "no movement, Work done in KJ : ",W
Q = W+deltaU; #KJ
print "Heat transfered in KJ : %.2f"%Q
def f19(T):
return m*Cv/T
deltaS = quad(f19,T1,T2)[0]
print "Entropy change in KJ/K : %.4f"%deltaS
import scipy
from scipy.integrate import quad
# Variables :
V1 = 4.; #m**3
V2 = 4.; #m**3
m = 600./1000; #Kg
C = 150.; #J/K
T1 = 100.+273; #K
T0 = 8.+273; #K
Cp = C/1000; #KJ/K
# Calculations and Results
def f10(T):
return Cp/T
deltaSblock = quad(f10,T1,T0)[0]
Q = Cp*(T1-T0); #KJ
deltaSlake = Q/T0; #KJ/K
deltaSuniverse = deltaSblock+deltaSlake; #KJ/K
print "Part (i) Entropy change of universe in KJ/K : %.4f"%deltaSuniverse
T1 = 8.+273; #K
Z = 100.; #meter
g = 9.81; #gravity constant
PE = m*g*Z/1000.; #KJ
deltaT = PE/Cp; #degree centigrade
T2 = T1+deltaT; #K
def f11(T):
return Cp/T
deltaSblock = - quad(f11,T1,T2)[0]
deltaSlake = PE/T0; #KJ/K
deltaSuniverse = deltaSblock+deltaSlake; #KJ/K
print "Part (ii) Entropy change of universe in %f KJ/K : "%deltaSuniverse
import math
# Variables :
m = 1.; #Kg
p1 = 1.; #bar
T1 = 290.; #K
p2 = 30.; #bar
T2 = 290.; #K
n = 1.3; #consmath.tant
R = 300.; #Nm/KgK
Cv = 0.72; #KJ/KgK
# Calculations and Results
print ("part (a) Isothermally")
V1 = R*T1/p1/10**5; #m**3/Kg
V2 = p1*V1/p2; #m**3/Kg
w = p1*10**5*V1*math.log(V2/V1)/1000; #KJ/Kg
print "Workdone in KJ/Kg : %.1f"%w
deltaU = m*Cv*(T2-T1); #KJ(as T1 = T2)
print "Change in internal energy in KJ : ",deltaU
q = w+deltaU; #KJ/Kg
print "Heat transfer in KJ/Kg : %.1f"%q
S2subS1 = m*R/1000*math.log(V2/V1)+m*Cv*math.log(T2/T1); #KJ/KgK
print "Change in entropy in KJ/KgK : %.4f"%S2subS1
print ("\npart (b) Polytropically")
T2 = T1*(p2/p1)**((n-1)/n); #K
print "Temperature T2 in K : %.1f"%T2
V1 = R*T1/p1/10**5; #m**3/Kg
V2 = (p1/p2)**(1/n)*V1; #m**3/Kg
w = m*R/1000*(T1-T2)/(n-1); #KJ/Kg
print "Workdone in KJ/Kg : %.1f"%w
deltaU = m*Cv*(T2-T1); #KJ(as T1 = T2)
q = w+deltaU; #KJ/Kg
print "Heat transfer in KJ/Kg : %.1f"%q
S2subS1 = m*R/1000*math.log(V2/V1)+m*Cv*math.log(T2/T1); #KJ/KgK
print "Change in entropy in KJ/KgK : %.4f"%S2subS1
import math
# Variables :
P1 = 480.; #kPa
T1 = 190.+273; #K
T3 = 190.+273; #K
P2 = 94.; #kPa
P3 = 150.; #kPa
T2 = T3*P2/P3; #K
R = 0.29; #KJ/KgK
m = 1.; #Kg
Cp = 1.011; #KJ/KgK
#T2/T1 = (P2/P1)**((Gamma-1)/Gamma)
#((Gamma-1)/Gamma) = math.log(T2/T1)/math.log(P2/P1); #
Gamma = 1.402; #by trial method
print "Index of adiabatic expansion : %.2f"%Gamma
Cv = R/(Gamma-1); #KJ/KgK
W1_2 = m*R*(T1-T2)/(Gamma-1); #KJ/Kg
print "Work done, W1-2 per Kg of air in KJ/Kg : %.2f"%W1_2
W2_3 = 0; #Consmath.tant volume process
print "Work done, W2-3 per Kg of air in KJ/Kg : %.0f"%W2_3
W3_1 = m*R*T2*math.log(P3/P1); #KJ/Kg
print "Work done, W1-2 per Kg of air in KJ/Kg : %.2f"%W3_1
W = W1_2+W2_3+W3_1; #KJ/Kg
print "Total Work done in KJ/Kg : %.2f"%W
S2subS1 = 0; #adiabatic process
S3subS2 = m*R*math.log(P2/P3)+m*Cp*math.log(T3/T2); #KJ/KgK
print "Change in specific entropy, S1-2 in KJ/KgK ; %.3f"%S3subS2
S1subS3 = -S2subS1-S3subS2; #KJ/KgK
print "Change in specific entropy, S3-1 in KJ/KgK ; %.3f"%S1subS3
import math
# Variables :
p1 = 5.; #bar
T1 = 30.+273; #K
p2 = 4.; #bar
m = 1.; #Kg
R = 0.287; #KJ/KgK
# Calculations
#deltaS = m*R*math.log(p1/p2)+m*Cp*math.log(T2/T1); #KJ/kgK
deltaS = m*R*math.log(p1/p2); #KJ/kgK(T2/T1 leads to 2nd term zero)
# Results
print "Entropy Change in KJ/KgK : %.5f"%deltaS
import scipy
from scipy.integrate import quad
# Variables :
Cpg = 1.05; #KJ/KgK
t1 = 400.; #degree centigrade
t2 = 360.; #degree centigrade
T = 30.+273; #K
# Calculations
Q = Cpg*(t1-t2); #KJ/Kg
deltaSsurr = Q/T; #KJ/KgK
def f25(T):
return Cpg/T
deltaSsystem = quad(f25,t1+273,t2+273)[0]
deltaSuniverse = deltaSsystem+deltaSsurr; #KJ/KgK
# Results
print "Change in entropy of the universe in KJ/KgK : %.4f"%deltaSuniverse