# Variables
Q1 = 1500./60; #kJ/s
W = 8.2; #kW
# Calculations and Results
print ("(i) Thermal efficiency")
n = W/Q1;
print ("n = "),(n)
print ("(ii) Rate of heat rejection")
Q2 = Q1-W;
print ("Q2 = "),(Q2), ("kW")
# Variables
Q_12 = 30.; #kJ
W_12 = 60; #kJ
# Calculations
dU_12 = Q_12-W_12;
Q_21 = 0;
W_21 = Q_21+dU_12;
# Results
print ("W_21 = "),(W_21)
print ("Thus 30 kJ work has to be done on the system to restore it to original state, by adiabatic process.")
# Variables
Q2 = 12000.; #kJ/h
W = 0.75*60*60; #kJ/h
# Calculations and Results
COP = Q2/W;
print ("Coefficient of performance %.3f")%(COP)
Q1 = Q2+W;
print ("heat transfer rate = %.3f")%(Q1), ("kJ/h")
# Variables
T2 = 261.; #K
T1 = 308.; #K
Q2 = 2.; #kJ/s
# Calculations
Q1 = Q2*(T1/T2);
W = Q1-Q2;
# Results
print ("Least power required to pump the heat continuosly %.3f")%(W),("kW")
import math
# Variables
Q1 = 2*10**5; #kJ/h
W = 3*10**4; #kJ/h
# Calculations and Results
Q2 = Q1-W;
print ("Heat abstracted from outside = "),(Q2), ("kJ/h")
COP_hp = Q1/(Q1-Q2);
print ("Co-efficient of performance = %.2f")%(COP_hp)
# Variables
T1 = 2373; #K
T2 = 288.; #K
# Calculations
n_max = 1-T2/T1;
# Results
print ("Highest possible theoritical efficiency = %.3f")% (n_max*100), ("%")
# Variables
T1 = 523.; #K
T2 = 258.; #K
Q1 = 90.; #kJ
# Calculations and Results
n = 1-T2/T1;
print ("(i) Efficiency of the system %.3f")%(n*100), ("%")
W = n*Q1;
print ("(ii) The net work transfer"),("W = %.3f")%(W),("kJ")
Q2 = Q1-W;
print ("(iii) Heat rejected to the math.sink"),("Q2 = %.3f")%(Q2),("kJ")
# Variables
T1 = 1023.; #K
T2 = 298.; #K
# Calculations
n_carnot = 1-T2/T1;
W = 75*1000*60*60;
Q = 3.9*74500*1000;
n_thermal = W/Q;
# Results
print ("n_carnot = %.3f")%(n_carnot)
print ("n_thermal = %.3f")%(n_thermal)
print ("Since ηthermal > ηcarnot, therefore claim of the inventor is not valid (or possible)")
# Variables
T1 = 1273.; #K
T2 = 313.; #K
n_max = 1-T2/T1;
Wnet = 1.;
# Calculations
Q1 = Wnet/n_max;
Q2 = Q1-Wnet;
# Results
print ("the least rate of heat rejection = %.3f")%(Q2), ("kW")
# Variables
one_ton_of_refrigeration = 210.; #kJ/min
Cooling_required = 40*(one_ton_of_refrigeration); #kJ/min
T1 = 303.; #K
T2 = 238.; #K
# Calculations
COP_refrigerator = T2/(T1-T2);
COP_actual = 0.20*COP_refrigerator;
W = Cooling_required/COP_actual/60;
# Results
print ("power required = %.1f")% (W), ("kW")
# Variables
E = 12000.; #kJ/min
T2 = 308.; #K
# Source 1
T1 = 593.; #K
# Calculations
n1 = 1-T2/T1;
# Source 2
T1 = 343.; #K
n2 = 1-T2/T1;
W1 = E*n1;
# Results
print ("W1 = %.3f")% (W1),("kJ/min")
W2 = E*n2;
print ("W2 = %.3f")% (W2),("kJ/min")
print ("Thus, choose source 2.")
print ("The source 2 is selected even though efficiency in this case is lower, because the criterion for selection is the larger output.")
# Variables
T1 = 973.; #K
T2 = 323.; #K
T3 = 248.; #K
Q1 = 2500.; #kJ
W = 400.; #kJ
# Calculations and Results
n_max = 1-T2/T1;
W1 = n_max*Q1;
COP_max = T3/(T2-T3);
W2 = W1-W;
Q4 = COP_max*W2;
COP1 = round(Q4/W2,3);
Q3 = Q4+W2;
Q2 = Q1-W1;
print ("Heat rejection to the 50°C reservoir = %.3f")%(Q2+Q3), ("kJ")
n = 0.45*n_max;
W1 = n*Q1;
W2 = W1-W;
COP2 = 0.45*COP1;
Q4 = W2*COP2;
Q3 = Q4+W2;
Q2 = Q1-W1;
print ("Heat rejected to 50°C reservoir = %.3f")% (Q2+Q3), ("kJ")
# Note : Answers are slightly different then book because of Rounding Error.
# Variables
T1 = 298.; #K
T2 = 273.; #K
Q1 = 24.; #kJ/s
T3 = 653.; #K
# Calculations and Results
COP = T1/(T1-T2);
print ("(i) determine COP and work input required")
print ("Coefficient of performance = "),(COP)
COP_ref = T2/(T1-T2);
W = Q1/COP_ref;
print ("Work input required = %.3f")%(W),("kW")
Q4 = T1*W/(T3-T1);
Q3 = Q4+W;
Q2 = Q1+W;
COP = Q1/Q3;
print ("(ii)Determine overall COP of the system "),("COP = %.3f")%(COP)
COP_overall = (Q2+Q4)/Q3;
print ("Overall COP = %.3f")%(COP_overall)
# Variables
T_e1 = 493.; #K
T_e2 = 298.; #K
T_p1 = 298.; #K
T_p2 = 273.; #K
Amt = 15.; #tonnes produced per day
h = 334.5; #kJ/kg
Q_abs = 44500.; #kJ/kg
# Calculations and Results
Q_p2 = Amt*10**3*h/24/60;
COP_hp = T_p2/(T_p1-T_p2);
W = Q_p2/COP_hp/60;
print ("(i)Power developed by the engine = %.3f")%(W),("kW")
print ("(ii) Fuel consumed per hour")
n_carnot = 1-(T_e2/T_e1);
Q_e1 = W/n_carnot*3600; #kJ/h
fuel_consumed = Q_e1/Q_abs;
print ("Quantity of fuel consumed/hour = %.3f")%(fuel_consumed),("kg/h")
# Variables
T1 = 550.; #K
T3 = 350.; #K
# Calculations
T2 = (T1+T3)/2;
# Results
print ("Intermediate temperature = "), (T2),("K")
# Variables
T1 = 600.; #K
T2 = 300.; #K
# Calculations and Results
T3 = 2*T1/(T1/T2+1);
print ("(i) When Q1 = Q2"),("T3 = "),(T3),("K")
print ("(ii) Efficiency of Carnot engine and COP of carnot refrigerator")
n = (T1-T3)/T1; #carnot engine
COP = T2/(T3-T2); #refrigerator
print ("Efficiency of carnot engine = %.3f")% (n)
print ("COP of carnot refrigerator = "), (COP)
# Variables
T3 = 278.; #K
T2 = 350.; #K
T4 = T2;
T1 = 1350.; #K
# Calculations
Q1 = 100/(((T4/T1)*(T1-T2)/(T4-T3))+T2/T1) #Q4+Q2 = 100; Q4 = Q1*((T4/T1)*(T1-T2)/(T4-T3)); Q2 = T2/T1*Q1;
# Results
print ("Q1 = %.3f")%(Q1),("kJ")
# Variables
Q1 = 300.; #kJ/s
T1 = 290.; #0C
T2 = 8.5; #0C
# Calculations and Results
print ("let ΣdQ/T = A")
print ("(i) 215 kJ/s are rejected")
Q2 = 215.; #kJ/s
A = Q1/(T1+273) - Q2/(T2+273)
print ("Since, A<0, Cycle is irreversible.")
print ("(ii) 150 kJ/s are rejected")
Q2 = 150; #kJ/s
A = Q1/(T1+273) - Q2/(T2+273)
print ("Since A = 0, cycle is reversible")
print ("(iii) 75 kJ/s are rejected.")
Q2 = 75; #kJ/s
A = Q1/(T1+273) - Q2/(T2+273)
print ("Since A>0, cycle is impossible")
# Variables
P1 = 0.124*10**5; #N/m**2
T1 = 433; #K
T2 = 323; #K
h_f1 = 687; #kJ/kg
h2 = 2760; #kJ/kg
h3 = 2160; #kJ/kg
h_f4 = 209; #kJ/kg
# Calculations and Results
Q1 = h2-h_f1;
Q2 = h_f4-h3;
print ("Let A = ΣdQ/T")
A = Q1/T1+Q2/T2;
print (A)
print ("A<0. Hence classius inequality is verified")
# Variables
T1 = 437.; #K
T2 = 324.; #K
h2 = 2760.; #kJ/kg
h1 = 690.; #kJ/kg
h3 = 2360.; #kJ/kg
h4 = 450.; #kJkg
# Calculations
Q1 = h2-h1;
Q2 = h4-h3;
# Results
print ("Let A = ΣdQ/T")
A = Q1/T1 + Q2/T2;
print "%.3f"%(A)
print ("Since A<0, Classius inequality is verified")
import math
# Variables
T0 = 273.; #K
T1 = 673.; #K
T2 = 298.; #K
m_w = 10.; #kg
T3 = 323.; #K
c_pw = 4186.; #kJ/kg.K
# Calculations and Results
print ("Let C = mi*cpi")
C = m_w*c_pw*(T3-T2)/(T1-T3);
S_iT1 = C*math.log(T1/T0); # Entropy of iron at 673 K
S_wT2 = m_w*c_pw*math.log(T2/T0); #Entropy of water at 298 K
S_iT3 = C*math.log(T3/T0); #Entropy of iron at 323 K
S_wT3 = m_w*c_pw*math.log(T3/T0); #Entropy of water at 323 K
dS_i = S_iT3 - S_iT1;
dS_w = S_wT3 - S_wT2;
dS_net = dS_i + dS_w
print ("Since dS>0, process is irreversible")
import math
# Variables
T1 = 293.; #K
V1 = 0.025; #m**3
V3 = V1;
p1 = 1.05*10**5; #N/m**2
p2 = 4.5*10**5; #N/m**2
R = 0.287*10**3;
cv = 0.718;
cp = 1.005;
T3 = 293.; #K
# Calculations and Results
m = p1*V1/R/T1;
T2 = p2/p1*T1;
Q_12 = m*cv*(T2-T1);
Q_23 = m*cp*(T3-T2)
Q_net = Q_12+Q_23;
print ("Net heat flow = "),(Q_net), ("kJ")
dS_32 = m*cp*math.log(T2/T1);
dS_12 = m*cv*math.log(T2/T1);
dS_31 = dS_32 - dS_12;
print ("Decrease in entropy = %.3f")% (dS_31), ("kJ/K")
%matplotlib inline
from matplotlib.pyplot import *
from numpy import *
import math
# Variables
p1 = 1.05*10**5; #N/m**2
V1 = 0.04; #m**3
T1 = 288.; #K
p2 = 4.8*10**5;
T2 = T1;
R0 = 8314.;
M = 28.;
# Calculations and Results
R = R0/M;
m = p1*V1/R/T1;
dS = m*R*math.log(p1/p2)
print ("Decrease in entropy = %.3f")% (-dS), ("J/K")
print
Q = T1*(-dS);
print ("(ii)Heat rejected = "),("Q = %.3f")%(Q),("J")
W = Q;
print ("Work done = %.3f")% (W), ("J")
V2 = p1*V1/p2;
v1 = V1/m; #specific volume
v2 = V2/m; #specific volume
v = linspace(v2,0.8081571,64);
def f(v):
return p1*v1/v
plot(v,f(v))
p = []
for i in range(len(v)):
p.append(p1)
plot(v,p,'--')
p = [0 ,p2]
v = [v2 ,v2]
plot(v,p,'--')
p = [0 ,p1]
v = [v1 ,v1]
plot(v,p,'--')
T = [288, 288]
s = [10 ,(10-dS)]
plot(s,T)
s = [10 ,10]
T = [0 ,288]
plot(s,T,'--')
s = [(10-dS), (10-dS)]
T = [0 ,288]
plot(s,T,'--')
import math
# Variables
R = 287.; #kJ/kg.K
dU = 0;
W = 0;
Q = dU+W;
# Calculations
dS = R*math.log(2); #v2/v1 = 2
# Results
print ("Change in entropy = %.3f")%(dS),("kJ/kg.K")
import math
# Variables
m = 0.04; #kg
p1 = 1*10.**5; #N/m**2
T1 = 293.; #K
p2 = 9*10.**5; #N/m**2
V2 = 0.003; #m**3
cp = 0.88; #kJ/kg.K
R0 = 8314.;
M = 44.;
# Calculations
R = R0/M;
T2 = p2*V2/m/R;
ds_2A = R/10**3*math.log(p2/p1);
ds_1A = cp*math.log(T2/T1);
ds_21 = ds_2A - ds_1A;
dS_21 = m*ds_21;
# Results
print ("Decrease in entropy = %.3f")% (dS_21),("kJ/K")
import math
# Variables
p1 = 7.*10**5; #N/m**2
T1 = 873.; #K
p2 = 1.05*10**5; #N/M62
n = 1.25;
m = 1.; #kg
R = 0.287;
cp = 1.005;
# Calculations
T2 = T1*(p2/p1)**((n-1)/n);
# At constant temperature from 1 to A
ds_1A = R*math.log(p1/p2);
# At constant pressure from A to 2
ds_2A = cp*math.log(T1/T2);
ds_12 = ds_1A - ds_2A;
# Results
print ("Increase in entropy = %.3f")% (ds_12), ("kJ/kg.K")
import math
# Variables
p1 = 7*10**5; #Pa
T1 = 733.; #K
p2 = 1.012*10**5; #Pa
T2a = 433.; #K
y = 1.4;
cp = 1.005;
# Calculations and Results
print ("(i) To prove that the process is irreversible")
T2 = T1*(p2/p1)**((y-1)/y);
print ("T2 = %.3f")% (T2)
print ("But the actual temperature is 433K at th epressure of 1.012 bar, Hence the process is irreversible. Proved.")
print ("(ii) Change of entropy per kg of air")
ds = cp*math.log(T2a/T2);
print ("Increase of entropy = %.3f")% (ds), ("kJ/kg.K")
import math
# Variables
V1 = 0.3; #m**3
p1 = 4*10**5; #N/m**2
V2 = 0.08; #m**3
n = 1.25;
# Calculations and Results
p2 = p1*(V1/V2)**n;
dH = n*(p2*V2-p1*V1)/(n-1)/10**3;
print ("(i) Change in enthalpy"), ("dH = %.3f")% (dH), ("kJ")
dU = dH-(p2*V2 - p1*V1)/10**3;
print ("(ii) Change in internal energy"),("dU = %.3f")% (dU), ("kJ")
dS = 0;
print ("(iii) Change in entropy"),("dS"), (dS)
Q = 0;
print ("(iv)Heat transfer"),("Q = "), (Q)
W = Q-dU;
print ("(v) Work transfer"),("W = %.3f")%(W),("kJ")
import math
# Variables
m = 20.; #kg
p1 = 4.*10**5; #Pa
p2 = 8.*10**5; #Pa
V1 = 4.; #m**3
V2 = V1;
cp = 1.04; #kJ/kg.K
cv = 0.7432; #kJ/kg.K
R = cp-cv;
T1 = p1*V1/R/1000.; #kg.K; T = mass*temperature
T2 = p2*V2/R/1000.; #kg.K
# Calculations and Results
dU = cv*(T2-T1);
print ("(i) Change in internal energy"),("dU = %.3f")% (dU), ("kJ")
Q = 0;
W = Q-dU;
print ("(ii) Work done"),("W %.3f")% (W), ("kJ")
print ("(iii) Heat transferred = "), (Q)
dS = m*cv*math.log(T2/T1);
print ("(iv) Change in entropy = %.3f")%(dS), ("kJ/K")
import math
from matplotlib.pyplot import *
%matplotlib inline
# Variables
V1 = 5.; #m**3
p1 = 2.*10**5; #Pa
T1 = 300.; #K
p2 = 6.*10**5; #Pa
p3 = 2.*10**5; #Pa
R = 287.;
n = 1.3;
y = 1.4;
# Calculations and Results
m = p1*V1/R/T1;
T2 = T1*(p2/p1)**((n-1)/n);
T3 = T2*(p3/p2)**((y-1)/y);
W_12 = m*R*(T1-T2)/(n-1)/1000; #polytropic compression
W_23 = m*R*(T2-T3)/(y-1)/1000; #Adiabatic expansion
W_net = W_12+W_23;
print ("Net work done on the air = %.3f")%(-W_net), ("kJ")
T = [T1, 310, 320, 330, 340, 350, 360, 370, 380, T2];
def f(T):
return (y-n)/(y-1)/(1-n)*R/10**3*math.log(T);
s = [f(T1), f(310), f(320), f(330), f(340), f(350), f(360), f(370), f(380), f(T2)]
plot(s,T)
T = [T2, T3];
s = [f(T2), f(T2)];
plot(s,T,'r')
# Answers are slightly diffferent because of rounding error.
# Variables
V1 = 0.004; #m**3
p1 = 1.*10**5; #Pa
T1 = 300.; #K
T2 = 400.; #K
y = 1.4;
M = 28.;
R0 = 8.314;
R = R0/M;
# Calculations and Results
print ("(i) The heat supplied")
m = p1*V1/R/1000/T1; #kg
cv = R/(y-1);
Q = m*cv*(T2-T1);
print ("Q %.3f")%(Q), ("kJ")
print ("(ii) The entropy change")
dS = m*cv*math.log(T2/T1);
print ("dS = %.8f")%(dS), ("kJ/kg.K")
import math
# Variables
V1 = 0.05; #m**3
p1 = 1.*10**5; #Pa
T1 = 280.; #K
p2 = 5.*10**5; #Pa
# Calculations
print ("(i) Change in entropy")
R0 = 8.314;
M = 28.;
R = R0/M;
m = p1*V1/R/T1/1000;
dS = m*R*math.log(p1/p2);
# Results
print ("dS = %.3f")%(dS), ("kJ/K")
print ("(ii)Work done")
Q = T1*dS;
print ("Q = %.3f")%(Q),("kJ")
import math
# Variables
R = 0.287; #kJ/kg.K
m = 1.; #kg
p1 = 8.*10**5; #Pa
p2 = 1.6*10**5; #Pa
T1 = 380.; #K
n = 1.2;
y = 1.4;
# Calculations and Results
print ("(i) Final specific volume and temperature")
v1 = R*T1/p1*10**3; #m**3/kg
v2 = v1*(p1/p2)**(1/n);
T2 = T1*(p2/p1)**((n-1)/n);
print ("v2 = %.3f")%(v2), ("m**3/kg")
print ("T2 = %.3f")% (T2),("K")
print ("(ii) Change of internal energy, work done and heat interaction")
dU = R/(y-1)*(T2-T1);
print ("dU = %.3f")%(dU), ("kJ/kg")
W = R*(T1-T2)/(n-1);
print ("W = %.3f")%(W), ("kJ/kg")
Q = dU + W;
print ("Q = %.3f")%(Q),("kJ/kg")
print ("(iii) Change in entropy")
dS = R/(y-1)*math.log(T2/T1) + R*math.log(v2/v1)
print ("dS = %.3f")%(dS),("kJ/kg.K")
%matplotlib inline
import math
from matplotlib.pyplot import *
# Variables
y = 1.4;
cv = 0.718; #kJ/kg.K
m = 1.; #kg
T1 = 290.; #K
n = 1.3;
r = 16.;
y = 1.4;
# Calculations and Results
T2 = T1*(r)**(n-1);
print ("(a)")
T = [T1, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500, 510, 520, 530, 540, 550, 560, 570, 580, 590, 600, 610, 620, 630, 640, 650, 660, T2];
def f(T):
return (y-n)*cv/(1-n)/10**3*math.log(T);
s = [f(T1),f(300),f(310),f(320),f(330),f(340),f(350),f(360),f(370),f(380),f(390),f(400),f(410),f(420),f(430),f(440),f(450),f(460),f(470),f(480),f(490),f(500),f(510),f(520),f(530),f(540),f(550),f(560),f(570),f(580),f(590),f(600),f(610),f(620),f(630),f(640),f(650),f(660), f(T2)];
plot(s,T)
T = [0, T2];
s = [f(T2), f(T2)];
plot(s,T,'r--')
T = [0 ,T1];
s = [f(T1),f(T1)];
plot(s,T,'r--')
T = [T1 ,T2];
s = [f(T1), f(T2)];
plot(s,T,'r--' )
suptitle("T-S diagram")
xlabel("S")
ylabel("T")
text(-0.00150,400,"pV**n = C")
print ("(b)Entropy change")
dS = cv*((n-y)/(n-1))*math.log(T2/T1);
print ("dS = %.3f")%(dS), ("kJ/kg.K")
print ("There is decrease in entropy")
Q = cv*((y-n)/(n-1))*(T1-T2);
Tmean = (T1+T2)/2;
dS_app = Q/Tmean;
error = ((-dS) - (-dS_app))/(-dS) * 100;
print ("age error = %.3f")%(error), ("%")
from matplotlib.pyplot import *
from numpy import *
# Variables
cp = 1.005; #kJ/kg.K
R = 0.287; #kJ/kg.K
V1 = 1.2; #m**3
p1 = 1.*10**5; #Pa
p2 = p1;
T1 = 300.; #K
T2 = 600.; #K
T3 = T1;
p1 = 1.*10**5; #Pa
cv = cp-R;
# Calculations and Results
print ("(i) The net heat flow")
m = p1*V1/R/1000/T1; #kg
Q = m*R*(T2-T1);
print ("Q = "), (Q), ("kJ")
print ("(ii) The overall change in entropy")
dS_12 = m*cp*math.log(T2/T1);
dS_23 = m*(cp-R)*math.log(T3/T2); #cv = cp-R
dS_overall = dS_12+dS_23;
print ("Overall change in entropy = %.3f")%(dS_overall),("kJ/K")
s = linspace(math.sqrt(300),math.sqrt(600),100);
T = s**2;
plot(s,T)
s = linspace(22.18,math.sqrt(600),100)
T = 10*(s-16.725)**2;
plot(s,T,'r')
s = [17, 25];
T = [600, 600];
plot(s,T,'--')
s = [17 ,25];
T = [300 ,300];
plot(s,T,'--')
suptitle("T-s diagram ")
xlabel("S")
ylabel("T")
text(24,400,"v = C")
text(20,450,"p = C")
import math
from matplotlib.pyplot import *
# Variables
cv = 0.718; #kJ/kg.K
R = 0.287 #kJ/kg.K
p1 = 1.*10**5; #Pa
T1 = 300. #K
V1 = 0.018; #m**3
p2 = 5.*10**5 #Pa
T3 = T1;
cp = cv+R;
p3 = p2;
# Calculations and Results
m = p1*V1/R/T1/1000; #kg
T2 = T1*p2/p1;
print ("(i) constant volume process")
dS_12 = m*cv*math.log(T2/T1);
print ("dS = %.3f")%(dS_12), ("kJ/K")
print ("(ii) Constant prssure process ")
dS_23 = m*cp*math.log(T3/T2);
print ("dS = %.3f")%(dS_23), ("kJ/K")
print ("(iii) Isothermal process")
dS_31 = m*R*math.log(p3/p1);
print ("dS = %.5f")%(dS_31),("kJ/K")
print ("T-s diagram")
s = linspace(math.sqrt(300),math.sqrt(600),72);
T = s**2;
#plot(s,T)
s = linspace(22.18,math.sqrt(600),24)
T = 10*(s-16.725)**2;
#plot(s,T,'r')
s = [math.sqrt(300), 22.18];
T = [300 ,300];
#plot(s,T,'g')
print ("p-V diagram")
V = [0.018, 0.018];
p = [1 ,5];
#plot(V,p)
p = [5 ,5];
V = [0.0036, 0.018];
#plot(V,p,'r')
V = linspace(0.0036,0.018,145)
def f():
return 1*0.018/V;
f1 = f()
plot(V,f1,'g')
suptitle("p-V diagram")
xlabel("V")
ylabel("p")
import math
from scipy.integrate import quad
# Variables
m = 4; #kg
T1 = 400; #K
T2 = 500; #K
# Calculations
def f12( T):
return m*(0.48+0.0096*T)/T
dS = quad(f12, T1,T2)[0]
# Results
print ("dS = %.3f")%(dS), ("kJ")
import math
from scipy.integrate import quad
# Variables
p1 = 1*10**5; #Pa
T1 = 273; #K
p2 = 25*10**5; #Pa
T2 = 750; #K
R = 0.29; #kJ/kg.K ; cp = 0.85+0.00025*T; cv = 0.56+0.00025*T; R = cp-cv;
# Calculations
v2 = R*T2/p2;
v1 = R*T1/p1;
def f8( T):
return (0.56+0.00025*T)/T
def f9(v):
return R/v
ds = quad(f8, T1, T2)[0] + quad(f9,v1,v2)[0]
# Results
print ("ds = %.3f")%(ds),("kJ/kg K")
import math
# Variables
cv = 0.715; #kJ/kg K
R = 0.287; #kJ/kg K
V_A = 0.25; #m**3
p_Ai = 1.4; #bar
T_Ai = 290; #K
V_B = 0.25; #m**3
p_Bi = 4.2; #bar
T_Bi = 440; #K
# Calculations and Results
print ("(i) Final equilibrium temperature")
m_A = p_Ai * 10**5 * V_A / R / 1000/ T_Ai; #kg
m_B = p_Bi * 10**5 * V_B / R / 1000/ T_Bi; #kg
T_f = (m_B * T_Bi + m_A * T_Ai)/(m_A + m_B);
print ("T_f = %.3f")% (T_f), ("K")
print ("(ii) Final pressure on each side of the diaphragm")
p_Af = p_Ai*T_f/T_Ai;
print ("p_Af = %.3f")%(p_Af),("bar")
p_Bf = p_Bi*T_f/T_Bi;
print ("p_Bf = %.3f")%(p_Bf),("bar")
print ("(iii) Entropy change of the system")
dS_A = m_A*cv*math.log(T_f/T_Ai);
dS_B = m_B*cv*math.log(T_f/T_Bi);
dS_net = dS_A+dS_B;
print ("Net change of entropy = %.3f")%(dS_net), ("kJ/K")
import math
# Variables
cv = 1.25; #kJ/kg.K
T1 = 530.; #K
v1 = 0.0624; #m**3/kg
v2 = 0.186; #m**3/kg
dT_31 = 25.; #K
T3 = T1-dT_31; #K
dT_21 = 165.; #K
# Calculations
T2 = T1-dT_21; #K
# Path 1-2 : Reversible adiabatic process
ds_12 = 0;
v3 = 0.186; #m**3/kg
v3 = v2;
ds_13 = cv*math.log(T3/T2);
# Results
print ("Chang in entropy = %.4f")%(ds_13), ("kJ/kgK")
import math
from numpy import *
# Variables
T1 = 500.; #K
T2 = 400.; #K
T3 = 300.; #K
Q1 = 1500.; #kJ/min
W = 200.; #kJ/min
# Calculations and Results
A = [[1,-1],[(1./400),(-1./300)]];
B = [(-1300),(-3)];
X = linalg.solve(A,B)
Q2 = X[0];
print ("Q2 = "), (Q2), ("kJ/min")
Q3 = X[1];
print ("Q3 = "), (Q3), ("kJ/min")
print ("(ii) Entropy change ")
dS1 = (-Q1)/T1;
print ("Entropy change of source 1 = "), (dS1), ("kJ/K")
dS2 = (-Q2)/T2;
print ("Entropy change of math.sink 2 = "), (dS2), ("kJ/K")
dS3 = Q3/T3;
print ("Entropy change of source 3 = "),(dS3), ("kJ/K")
print ("(iii) Net change of the entropy")
dSnet = dS1 + dS2 + dS3;
print ("dSnet = %d")% (dSnet)
import math
from scipy.integrate import quad
# Variables
T1 = 250; #K
T2 = 125; #K
# Calculations
#cv = 0.0045*T**2
def f10( T):
return 0.045*T**2
Q1 = quad(f10, T1, T2)[0]
def f11( T):
return 0.045*T
dS_system = quad(f11, T1, T2)[0]
dS_universe = 0;
W_max = ((-Q1) -T2*(dS_universe-dS_system))/1000;
# Results
print ("W_max = %.3f")%(W_max), ("kJ")
import math
from scipy.integrate import quad
# Variables
cp = 1.005; #kJ/kg K
T_A = 333.; #K
T_B = 288.; #K
p_A = 140.; #kPa
p_B = 110.; #kPa
#h = cp*T
#v/T = 0.287/p
# Calculations
def f9( T):
return cp/T
def f10(p):
return 0.287/p
ds_system = quad(f9, T_B, T_A)[0] + quad(f10,p_A,p_B)[0]
ds_surr = 0;
ds_universe = ds_system+ds_surr;
# Results
print ("change in entropy of universe = -%.4f")% (ds_universe), ("kJ/kgK")
print ("Since change in entropy of universe from A to B is -ve")
print ("The flow is from B to A")
import math
# Variables
m1 = 3.; #kg
m2 = 4.; #kg
T0 = 273.; #K
T1 = 80.+273; #K
T2 = 15.+273; #K
c_pw = 4.187; #kJ/kgK
# Calculations
tm = (m1*T1 + m2*T2)/(m1+m2);
Si = m1*c_pw*math.log(T1/T0) + m2*c_pw*math.log(T2/T0);
Sf = (m1+m2)*c_pw*math.log(tm/T0);
dS = Sf-Si;
# Results
print ("Net change in entropy = %.3f")%(dS),("kJ/K")
import math
# Variables
m = 1.; #kg
T1 = 273.; #K
T2 = 363.; #K
c = 4.187;
# Calculations and Results
print ("(a)")
ds_water = m*c*math.log(T2/T1);
print ("(i) Entropy of water = %.3f")%(ds_water), ("kJ/kgK")
print ("(ii) Entropy change of the reservoir ")
Q = m*c*(T2-T1);
ds_reservoir = -Q/T2;
print ("ds_reservoir = %.3f")% (ds_reservoir), ("kJ/K")
ds_universe = ds_water+ds_reservoir;
print ("(iii) Entropy change of universe = %.3f")% (ds_universe), ("kJ/K")
print ("(b)")
T3 = 313; #K
ds_water = m*c*(math.log(T3/T1) + math.log(T2/T3));
ds_res1 = -m*c*(T3-T1)/T3;
ds_res2 = -m*c*(T2-T3)/T2;
ds_universe = ds_water+ds_res1+ds_res2;
print ("(iii) Entropy change of universe = %.3f")%(ds_universe), ("kJ/K")
print ("(c) The entropy change of universe would be less and less, if the water is heated in more and more stages, by bringing")
print ("the water in contact successively with more and more heat reservoirs, each succeeding reservoir being at a higher temperature")
print ("than the preceding one.")
print ("When water is heated in infinite steps, by bringing in contact with an infinite number of reservoirs in succession, so that")
print ("at any insmath.tant the temperature difference between the water and the reservoir in contact is infinitesimally small, then")
print ("the entropy change of the universe would be zero and the water would be reversibly heated.")
import math
# Variables
cp = 2.093; #kJ/kg0C
c = 4.187;
Lf = 333.33; #kJ/kg
m = 1.; #kg
T0 = 273.; #K
T1 = 268.; #K
T2 = 298.; #K
# Calculations and Results
Q_s = m*cp*(T0-T1);
Q_f = m*Lf;
Q_l = m*c*(T2-T0);
Q = Q_s+Q_f+Q_l;
print ("(i) Entropy increase of the universe")
ds_atm = -Q/T2;
ds_sys1 = m*cp*math.log(T0/T1);
ds_sys2 = Lf/T0;
ds_sys3 = m*c*math.log(T2/T0);
ds_total = ds_sys1+ds_sys2+ds_sys3;
ds_universe = ds_total+ds_atm;
print ("Entropy increase of universe = %.3f")%(ds_universe), ("kJ/K")
print ("(ii) Minimum amount of work necessary to convert the water back into ice at – 5°C, Wmin.")
dS_refrigerator = 0;
dS_system = -1.6263; #kJ/kg K
T = 298; #K
#For minimum work
W_min = T*(-dS_system)-Q;
print ("Minimum work done = %.3f")% (W_min), ("kJ")