import math
# Variables
T0 = 293.; #K
T1 = 300.; #K
T2 = 370.; #K
cv = 0.716;
cp = 1.005;
R = 0.287;
p1 = 1.; #bar
p2 = 6.8; #bar
m = 1.; #kg
# Calculations
Wmax = -(cv*(T2-T1) - T0*(cp*math.log(T2/T1)-R*math.log(p2/p1)));
n = 1/(1-(math.log(T2/T1)/math.log(p2/p1)));
Wact = m*R*(T1-T2)/(n-1);
I = Wmax - Wact;
# Results
print ("Irreversibility = %.3f")%(I),("kJ/kg")
# Variables
T1 = 1000.; #K
T2 = 500.; #K
T0 = 300.; #K
Q = 7200.; #kJ/min
# Calculations and Results
print ("(i) Net change of entropy :")
dS_source = -Q/T1;
dS_system = Q/T2;
dS_net = dS_source+dS_system;
print ("dS_net = "), (dS_net), ("kJ/min.K")
print ("(ii) Decrease in available energy :")
AE_source = (T1-T0)*(-dS_source); #Available energy with the source
AE_system = (T2-T0)*dS_system; #Available energy with the system
dAE = AE_source - AE_system; #Decrease in available energy
print ("dAE = "), (dAE), ("kJ")
import math
# Variables
m = 8.; #kg
T1 = 650.; #K
p1 = 5.5*10**5; #Pa
p0 = 1*10.**5; #Pa
T0 = 300.; #K
cp = 1.005; #kJ/kg.K
cv = 0.718;
R = 0.287;
#p1*v1/T1 = p0*v0/T0
#Let r = v1/v0 = 1/2.54
r = 1/2.54;
# Calculations and Results
print ("(i) Change in available energy(for bringing the system to dead state) = ")
ds = cv*math.log(T1/T0) + R*math.log(r);
dAE = m*(cv*(T1-T0) - T0*ds);
#dAE is the change in available energy in kJ
V1 = m*R*10**3*T1/p1;
V0 = V1/r;
L = p0*(V0 - V1)/10**3;
print ("Loss of availability, L = "), (L), ("kJ")
print ("(ii) Available Energy and Effectiveness")
Q = m*cp*(T1-T0);
ds = m*cp*math.log(T1/T0);
Unavailable_energy = T0*ds;
Available_energy = Q - Unavailable_energy;
print ("Available energy = %.3f")% (Available_energy), ("kJ")
Effectiveness = Available_energy/dAE;
print ("Effectiveness = %.3f")% (Effectiveness)
import math
# Variables
c_pg = 1.; #kJ/kgK
h_fg = 1940.7; #kJ/kg
Ts = 473.; #K ; Temperature of saturation of steam
T1 = 1273.; #K ; Initial temperature of gases
T2 = 773.; #K ; Final temperature of gases
T0 = 293.; #K ; atmospheric temperature
# Calculations
#Heat lost by gases = Heat gained by 1 kg saturated water when it is converted to steam at 200 0C
m_g = h_fg/c_pg/(T1-T2);
dS_g = m_g*c_pg*math.log(T2/T1);
dS_w = h_fg/Ts;
dS_net = dS_g + dS_w;
# Results
print ("Net change in entropy = %.3f")% (dS_net), ("kJ/K")
E = T0*dS_net; #Increase in unavailable energy due to hea transfer
print ("Increase in unavailable energy = %.3f")%(E), ("kJ per kg of steam formed")
import math
# Variables
m_g = 3.; #kg
p1 = 2.5; #bar
T1 = 1200.; #K; Temperature of infinite source
T1a = 400.; #K; Initial temperature
Q = 600.; #kJ
cv = 0.81; #kJ/kg.K
T0 = 290.; #K; Surrounding Temperature
# Calculations
#final temperature = T2a
T2a = Q/m_g/cv + T1a;
AE = (T1-T0)*Q/T1; #Available energy with the source
dS = m_g*cv*math.log(T2a/T1a); #Change in entropy of the gas
UAE = T0*dS; #Unavailability of the gas
A = Q-UAE; #Available energy with the gas
loss = AE-A;
# Results
print ("Loss in available energy due to heat transfer = %.3f")%(loss),("kJ")
import math
from scipy.integrate import quad
# Variables
m = 60.; #kg
T1 = 333.; #K
T0 = 279.; #K
p = 1.; #atm
cp = 4.187;
# Calculations
def f16( T):
return m*cp*(1-T0/T)
Wmax = quad(f16, T0, T1)[0]
Q1 = m*cp*(T1-T0);
#Let unavailable energy = E
E = Q1-Wmax;
# Results
print ("unavailable energy = %.3f")%(E), ("kJ")
import math
# Variables
m = 15.; #kg
T1 = 340.; #K
T0 = 300.; #K
cp = 4.187; #kJ/kgK
# Calculations
#Work added during churning = Increase in enthalpy of water
W = m*cp*(T1-T0);
ds = cp*math.log(T1/T0);
AE = m*(cp*(T1-T0)-T0*ds);
AE_loss = W-AE; #Loss in availability
# Results
print ("Loss in availability %.3f")% (AE_loss), ("kJ")
import math
# Variables
m = 5.; #kg
T1 = 550.; #K
p1 = 4*10.**5; #Pa
T2 = 290.; #K
T0 = T2;
p2 = 1.*10**5; #Pa
p0 = p2;
cp = 1.005; #kJ/kg K
cv = 0.718; #kJ/kg K
R = 0.287; #kJ/kg K
# Calculations and Results
print ("(i) Availability of the system :")
ds = cp*math.log(T1/T0) - R*math.log(p1/p0);
Availability = m*(cv*(T1-T0) - T0*ds);
print ("Availability of the system = %.3f")% (Availability), ("kJ")
print ("(ii) Available energy and Effectiveness")
Q = m*cp*(T1-T0);
dS = m*cp*math.log(T1/T0);
E = T0*dS; #Unavailable energy
AE = Q-E;
print ("Available Energy = %.3f")%(AE), ("kJ")
Effectiveness = AE/Availability;
print ("Effectiveness = %.3f")%(Effectiveness)
import math
# Variables
R = 0.287; #kJ/kgK
cp = 1.005; #kJ/kgK
m = 25./60; #kg/s
p1 = 1.; #bar
p2 = 2.; #bar
T1 = 288.; #K
T0 = T1;
T2 = 373.; #K
# Calculations and Results
W_act = cp*(T2-T1); #W_actual
W_total = m*W_act;
print ("Total actual power required = %.3f")%(W_total), ("kW")
ds = cp*math.log(T2/T1) - R*math.log(p2/p1);
Wmin = cp*(T2-T1) - T0*(ds);
W = m*Wmin;
print ("Minimuumm work required = %.3f")%(W), ("kW")
import math
# Variables
m_O2 = 1.; #kg
m_H2 = 1.; #kg
p = 1*10.**5; #Pa
T_O2 = 450.; #K
T_H2 = 450.; #K
T0 = 290.; #K
R0 = 8.314;
M_O2 = 32.;
M_H2 = 2.;
# Calculations
R_O2 = R0/M_O2;
v_O2 = m_O2*R_O2*T_O2/p;
R_H2 = R0/M_H2;
v_H2 = m_H2*R_H2*T_H2/p;
v_f = v_O2 + v_H2; #total volume after mixing
dS_O2 = R_O2*math.log(v_f/v_O2);
dS_H2 = R_H2*math.log(v_f/v_H2);
dS_net = dS_O2 + dS_H2;
#Let E be the loss in availability
E = T0*dS_net;
# Results
print ("Loss in availability = %.3f")% (E), ("kJ")
import math
from scipy.integrate import quad
# Variables
T0 = 283.; #K
cp = 4.18; #kJ/kgK
m1 = 20.; #kg
T1 = 363.; #K
m2 = 30.; #kg
T2 = 303.; #K
T3 = 327.; #K
# Calculations
def f13( T):
return m1*cp*(1-T0/T)
AE1 = quad(f13, T0, T1)[0]
def f14( T):
return m2*cp*(1-T0/T)
AE2 = quad(f14, T0, T2)[0]
AE_total = AE1 + AE2; #before mixing
#If T K is the final temperature after mixing
T = (m1*T1+m2*T2)/(m1+m2);
m_total = m1+m2;
#Available energy of 50kg of water at 54 0C
AE3 = m_total*cp*((T3-T0) - T0*math.log(T3/T0));
#Decrease in available energy due to mixing dAE
dAE = AE_total - AE3;
# Results
print ("Decrease in avialble energy = %.3f")% (dAE), ("kJ")
import math
# Variables
T_w1 = 323.; #K
T_w2 = 343.; #K
T_o1 = 513.; #K
T_o2 = 363.; #K
SG_oil = 0.82;
c_po = 2.6; #kJ/kg K
c_pw = 4.18; #kJ/kg K
T0 = 300.; #K
m_o = 1.; #kg
# Calculations
#Heat lost by oil = Heat gained by water
m_w = (m_o*c_po*(T_o1-T_o2))/(c_pw*(T_w2-T_w1));
dS_w = m_w*c_pw*math.log(T_w2/T_w1);
dS_o = m_o*c_po*math.log(T_o2/T_o1);
dAE_w = m_w*(c_pw*(T_w2-T_w1))-T0*dS_w;
dAE_o = m_o*(c_po*(T_o2-T_o1))-T0*dS_o;
# Loss in availability E =
E = dAE_w+dAE_o;
# Results
print ("Loss in availability = %.3f")%(E),("kJ")
import math
# Variables
m_i = 1.; #kg
T_i = 273.; #K
m_w = 12.; #kg
T_w = 300.; #K
T0 = 288.; #K
c_pw = 4.18; #kJ/kg K
c_pi = 2.1; #kJ/kg K
L_i = 333.5; #kJ/kg
# Calculations
Tc = (m_w*c_pw*T_w + m_i*c_pw*T_i - L_i)/(m_w*c_pw + m_i*c_pw);
dS_w = m_w*c_pw*math.log(Tc/T_w);
dS_i = m_i*c_pw*math.log(Tc/T_i) + L_i/T_i;
dS_net = dS_w+dS_i;
# Results
print ("Increase in entropy = %.3f")% (dS_net), ("kJ/K")
dAE = T0*dS_net;
print ("Increase in unavailable energy = %.3f")% (dAE),("kJ")
# Variables
T1 = 673.; #K
T2 = 473.; #K
T0 = 303.; #K
T1a = T2;
# Calculations
UAE = T0*(T1-T1a)/T1a/(T1-T0);
# Results
print ("the fraction of energy that becomes unavailable = %.3f")%(UAE)
import math
# Variables
T1 = 293.; #K
T2 = 353.; #K
Tf = 1773.; #K
T0 = 288.; #K
c_pl = 6.3; #kJ/kg K
# Calculations
dAE = c_pl*(T2-T1) - T0*c_pl*math.log(T2/T1);
n = (1-T0/Tf); #efficiency
E = c_pl*(T2-T1)*n;
Effectiveness = dAE/E;
# Results
print ("Effectiveness of the heating process = %.3f")%(Effectiveness)
import math
# Variables
T0 = 293.; #K
T1 = 293.; #K
T2 = 373.; #K
T3 = 323.; #K
cp = 1.005;
# Calculations and Results
print ("(i) The ratio of mass flow")
x = (T3-T1)/(T2-T3);
print ("x = "), (x)
ds_13 = cp*math.log(T3/T1);
ds_32 = cp*math.log(T2/T3);
A = cp*(T3-T1) - T1*ds_13; #Increase of availability of system
B = x*(cp*(T2-T3)-T0*(ds_32)); # Loss of availability of surroundings
Effectiveness = A/B;
print ("Effectiveness of heating process = %.3f")%(Effectiveness)
import math
# Variables
m = 2.5; #kg
p1 = 6.*10**5; #Pa
r = 2.; #r = V2/V1
cv = 0.718; #kJ/kg K
R = 0.287; #kJ/kg K
T1 = 363.; #K
p2 = 1.*10**5; #Pa
T2 = 278.; #K
V1 = m*R*T1/p1;
V2 = 2*V1;
T0 = 278.; #K
p0 = 1.*10**5; #Pa
Q = 0.; #adiabatic process
# Calculations and Results
dS = m*cv*math.log(T2/T1) + m*R*math.log(V2/V1);
Wmax = m*(cv*(T1-T2)) + T0*(cv*math.log(T2/T1) + R*math.log(V2/V1));
print ("(i)The maximum work"),("Wmax = %.3f")% (Wmax), ("kJ")
dA = Wmax+p0*(V1-V2);
print ("(ii)Change in availability = %.3f")%(dA), ("kJ")
I = T0*m*(cv*math.log(T2/T1)+R*math.log(V2/V1));
print ("(iii)Irreversibility = %.3f")% (I),("kJ")
import math
# Variables
m = 1.; #kg
p1 = 7.*10**5; #Pa
T1 = 873.; #K
p2 = 1.*10**5; #Pa
T2 = 523.; #K
T0 = 288.; #K
Q = -9.; #kJ/kg
cp = 1.005; #kJ/kg K
R = 0.287; #kJ/kg K
# Calculations and Results
print ("(i) The decrease in availability ")
dA = cp*(T1-T2) - T0*(R*math.log(p2/p1) - cp*math.log(T2/T1));
print ("dA = %.3f")%(dA), ("kJ/kg")
print ("(ii) The maximum work")
Wmax = dA; #change in availability
print ("Wmax %.3f")% (Wmax), ("kJ/kg")
W = cp*(T1-T2) + Q;
I = Wmax - W;
print ("(iii)Irreversibility = %.3f")%(I), ("kJ/kg")
import math
# Variables
cp = 1.005; #kJ/kg K
cv = 0.718; #kJ/kg K
R = 0.287; #kJ/kg K
m = 1.; #kg
T1 = 290.; #K
T0 = 290.; #K
T2 = 400.; #K
p1 = 1.; #bar
p0 = 1.; #bar
p2 = 6.; #bar
# Calculations and Results
#Wrev = change in internal energy - T0*change in entropy
Wrev = -(cv*(T2-T1) - T0*(cp*math.log(T2/T1) - R*math.log(p2/p1)));
n = (1./(1-math.log(T2/T1)/math.log(p2/p1)));
Wact = m*R*(T1-T2)/(n-1);
I = Wrev-Wact;
print ("(i)Irreversibility = %.3f")% (I), ("kJ")
effectiveness = Wrev/Wact*100;
print ("(ii)The effectiveness = %.3f")%(effectiveness), ("%")
import math
from scipy.integrate import quad
# Variables
I = 0.62; #kg/m**2
N1 = 2500.; #rpm
w1 = 2*math.pi*N1/60; #rad/s
m = 1.9; #kg; Water equivalent of shaft bearings
cp = 4.18;
T0 = 293.; #K
t0 = 20.; #0C
# Calculations and Results
print ("(i)Rise in temperature of bearings")
KE = 1./2*I*w1**2/1000; #kJ
dT = KE/(m*cp); #rise in temperature of bearings
print ("dT = %.3f")% (dT), ("0C")
t2 = t0+dT;
print ("Final temperature of the bearings = %.3f")% (t2), ("0C")
T2 = t2+273;
print ("(ii)Final r.p.m. of the flywheel")
def f15( T):
return m*cp*(1-T0/T)
AE = quad(f15, T0, T2)[0]
UE = KE - AE;
print ("Available energy = %.3f")% (AE), ("kJ")
UAE = KE-AE;
print ("Unavailable energy = %.3f")%(UAE), ("kJ")
w2 = math.sqrt(AE*10**3*2/I);
N2 = w2*60/2/math.pi;
print ("Final rpm of the flywheel = %.3f")%(N2), ("rpm")
import math
# Variables
p1 = 8.; #bar
T1 = 453.; #K
p2 = 1.4; #bar
T2 = 293.; #K
T0 = T2;
p0 = 1.; #bar
m = 1.; #kg
C1 = 80.; #m/s
C2 = 40.; #m/s
cp = 1.005; #kJ/kg K
R = 0.287; #kJ/kg K
# Calculations and Results
print ("(i) Reversible work and actual work ")
A1 = cp*(T1-T0)-T0*(cp*math.log(T1/T0)-R*math.log(p1/p0))+C1**2/2/10**3; #Availability at the inlet
A2 = cp*(T2-T0)-T0*(cp*math.log(T2/T0)-R*math.log(p2/p0))+C2**2/2/10**3; #Availability at the exit
W_rev = A1-A2;
print ("W_rev = %.3f")%(W_rev), ("kJ/kg")
W_act = cp*(T1-T2) + (C1**2-C2**2)/2/10**3;
print ("W_act = %.3f")%(W_act),("kJ/kg")
print ("(ii) Irreversibilty and effectiveness = ")
I = W_rev-W_act;
print ("Irreversibilty = %.3f")% (I), ("kJ/kg")
Effectiveness = W_act/W_rev*100;
print ("Effectiveness = %.3f")%(Effectiveness),("%")
# Variables
p1 = 20.; #bar
t1 = 400.; #0C
p2 = 4.; #bar
t2 = 250.; #0C
t0 = 20.; #0C
T0 = t0+273;
h1 = 3247.6; #kJ/kg
s1 = 7.127; #kJ/kg K
#let h2' = h2a and s2' = s2a
h2a = 2964.3; #kJ/kg
s2a = 7.379; #kJ/kg K
s2 = s1;
s1a = s1;
#By interpolation, we get
h2 = 2840.8; #kJ/kg
# Calculations and Results
n_isen = (h1-h2a)/(h1-h2);
print ("(i)Isentropic efficiency = %.3f")%(n_isen)
A = h1-h2a + T0*(s2a-s1a);
print ("(ii)Loss of availability = %.3f")%(A), ("kJ/kg")
Effectiveness = (h1-h2a)/A;
print ("(iii)Effectiveness = %.3f")% (Effectiveness)