# Variables :
mc = 10.; #Kg
Cpc = 0.4; #KJ/KgK
Cpw = 4.187; #KJ/KgK(Specific heat of water)
tc = 90.; #degree_centigrade
Vw = 0.35; #m**3
tw = 30.; #degree_centigrade
density_water = 1000; #Kg/m**3
mw = Vw*density_water; #Kg
# Calculations
#mc*Cpc*(tc-t) = mw*Cpw*(t-tw)
t = (mw*Cpw*tw+mc*Cpc*tc)/(mw*Cpw+mc*Cpc); #degree_centigrade
# Results
print "Equillibrium temperature in degree_centigrade : %.4f"%t
# Variables
Q1 = 2500.; #KJ/Kg
Q2 = 1800.; #KJ/Kg
Pdev = 210.; #MW
# Calculations
#Power developed = Heat transfered: Pdev = m*(Q1-Q2)
m = Pdev*1000/(Q1-Q2); #mass flow rate of steam in Kg/s
# Results
print "Mass flow rate of steam in Kg/s : ",m
# Variables
WA = 20; #KJ
QA = 15; #KJ
QB = 10; #KJ
# Calculations
U2subU1 = QA-WA; #change in internal energy in KJ
WB = QB - U2subU1
QB = -10
WB = -15
QA = 15
WA = 20
dQ = QA + QB
dW = WA + WB
# Results
print "Change in internal energy in KJ : ",U2subU1
print "Workdone in process : %d KJ"%WB
print "d'Q = Qa + Qb = %d kJ"%dQ
print "d'W = Wa + Wb = %d kJ"%dW
# Variables
Q1 = 120.; #KJ
Q2 = -16; #KJ
Q3 = -48; #KJ
Q4 = 12; #KJ
W1 = 60000; #N-m
W2 = 68000; #N-m
W3 = 120000; #N-m
W4 = 44000; #N-m
# Calculations
Net_work = Q1+Q2+Q3+Q4; #KJ
# Results
print "Net Work in N-m : ",Net_work*1000
print ("Option (ii) is true.")
import scipy
from scipy.integrate import quad
# Variables
T1 = 100; #degree_centigrade
T1 = T1+273; #kelvin
T2 = 200; #degree_centigrade
T2 = T2+273; #kelvin
delQbydelT = 1.005; #KJ/k
# Calculations
#delWbydelT = (4-0.12*T); #KJ/k
def f12(T):
return 1.005
Q = quad(f12,T1,T2)[0]
def f13(T):
return 4-0.12*T
W = quad(f13,T1,T2)[0]
U2subU1 = Q-W; #change in internal energy in KJ
# Results
print "Change in internal energy in KJ : ",U2subU1
# Variables
m = 20.; #Kg
mw = 200.; #Kg
Z1 = 15.; #m
Z2 = 0.; #m
g = 9.81; #gravity consmath.tant
print ("(i) Stone is about to enter the water");
deltaPE = m*g*(Z2-Z1)/1000; #KJ
Q = 0; #Heat Transfer
W = 0; #Work Transfer
deltaE = Q-W; #Energy Transfer
#deltaE = deltaU+deltaKE+deltaPE
deltaU = 0; #no change in temperature
deltaKE = deltaE-deltaU-deltaPE; #KJ
print "deltaU in KJ : ",deltaU
print "deltaPE in KJ : ",deltaPE
print "deltaKE in KJ : ",deltaKE
print "Q in KJ : ",Q
print "W in KJ : ",W
print ("(ii) Stone has come to rest near the math.tank.");
Q = 0; #Heat Transfer
W = 0; #Work Transfer
deltaE = Q-W; #Energy Transfer
deltaKE = 0; #rest condition
#deltaE = deltaU+deltaKE+deltaPE
deltaU = deltaE-deltaKE-deltaPE; #KJ
print "deltaU in KJ : ",deltaU
print "deltaPE in KJ : ",deltaPE
print "deltaKE in KJ : ",deltaKE
print "Q in KJ : ",Q
print "W in KJ : ",W
print ("(iii) Heat is transfered to surroundings.");
deltaKE = 0; #Energy Transfered to water
deltaPE = 0;
W = 0;
deltaE = deltaU+deltaKE+deltaPE
Q = deltaE+W; #KJ
print "deltaU in KJ : ",deltaU
print "deltaPE in KJ : ",deltaPE
print "deltaKE in KJ : ",deltaKE
print "Q in KJ : ",Q
print "W in KJ : ",W
# Variables
SigmaW = 30; #KJ
n = 10; #cycles/min
Q1_2 = 50; #KJ
#Q2_3 = 0; #KJ
#Q3_1 = 0; #KJ
#W1_2 = 0; #KJ
W2_3 = 30; #KJ
#W3_1 = 0; #KJ
deltaU1_2 = 20; #KJ
deltaU2_3 = -10; #KJ
# Calculations and Results
#deltaU3_1 = 0; #KJ
#Q-W = deltaU
#For Proess 1-2 :
W1_2 = Q1_2-deltaU1_2; #KJ
print "W1-2 in KJ : ",W1_2
#For Proess 2-3
Q2_3 = W2_3+deltaU2_3; #KJ
print "Q2-3 in KJ : ",Q2_3
#For Proess 3-1
W3_1 = SigmaW-W1_2-W2_3; #KJ
print "-1 in KJ : ",W3_1
SigmaQ = SigmaW; #KJ
Q3_1 = SigmaQ-Q1_2-Q2_3; #KJ
print "Q3-1 in KJ : ",Q3_1
deltaU3_1 = Q3_1-W3_1; #KJ
print "U1-U3 or deltaU3-1 in KJ : ",deltaU3_1
RateOfWork = SigmaW*n; #KJ/min
RateOfWork = RateOfWork/60; #KJ/sec or KW
print "Rate of work in KW : ",RateOfWork
# Variables :
m = 50.; #Kg
C1 = 10.; #m/s
C2 = 30.; #m/s
Z2subZ1 = 40.; #m
Q = 30000.; #J
W1 = -4500.; #J
W2 = 0.002; #KWh
g = 9.81; #gravity constant
W2 = W2*3600.*1000; #J
# Calculations
#sigmaQ-sigmaW = E2-E1 = (U2-U1)+(C2**2-C1**2)/2+g*(Z2-Z1)
U2subU1 = Q-(W1+W2)-(C2**2-C1**2)/2-g*(Z2subZ1); #J
# Results
print "Change in Internal energy in J : ",U2subU1
# Variables
deltaU = -4000.; #KJ
W = -1.2; #KWh
# Calculations
W = W*3600.; #KJ
Q = W+deltaU; #KJ/hr
# Results
print "Net heat transfer in KJ/hr : ",Q
# Variables
mw = 100; #Kg
T = 30; #min
T = T*60; #sec
P = 1; #KW
Q = -50; #KJ
Sw = 4.19; #KJ/KgK(Specific heat of water)
W = -P*T; #KJ
# Calculations and Results
#Q = W+deltaU
deltaU = Q-W; #KJ
print "Chnge in internal energy in kJ : ",deltaU
delta_t = deltaU/mw/Sw; #sec
print "Rise in temperature in degree C : %.3f"%delta_t
# Variables
V = 12.; #Volt
I = 6.; #Ampere
t = 1.5; #hr
t = t*3600.; #sec
deltaU = -750.; #KJ
# Calculations
W = V*I*t/1000; #KJ
Q = W+deltaU; #KJ
# Results
print "Heat transfer in KJ : ",Q
# Variables
Q = 82.; #KJ
p1 = 4.; #bar
m = 1.; #Kg
V1 = 0.21; #m**3
T2 = 127.; #degree Centigrade
R = 300.; #Nm/KgK
W = 0.; #because V is consmath.tant.
# Calculations and Results
print "Work done in KJ : ",W
#Q-W = deltaU
deltaU = Q-W; #KJ
print "Change in internal energy in KJ : ",deltaU
#p1*V1 = m*R*T1
T1 = p1*10**5*V1/m/R; #kelvin
T1 = T1-273; #degree centigrade
delta_t = T2-T1; #degree centigrade
Cv = deltaU/delta_t; #KJ/KgK
print "Specific Heat in KJ/KgK : %.3f"%Cv
# Variables :
V1 = 250.; #litres
V2 = 250.; #litres
p1 = 3.; #Mpa
t1 = 20.; #degree_centigrade
p2 = 1.8; #Mpa
t2 = 16.; #degree_centigrade
Gamma = 1.4; #
rho = 1.43; #Kg/m**3
p = 0.1013; #Mpa
# Calculations and Results
V1 = V1/1000; #m**3
V2 = V2/1000; #m**3
T1 = t1+273; #Kelvin
T2 = t2+273; #Kelvin
#p = rho*R*T
T = 0+273; #Kelvin
R = p*10**6/rho/T; #Nm/KgK
#p*V = m*R*T
m1 = p1*10**6*V1/R/T1; #Kg
m2 = p2*10**6*V2/R/T2; #Kg
Mass_oxygen = m1-m2; #Kg
print "Mass of oxygen used in Kg : %.3f"%Mass_oxygen
#Cv*(Gamma-1) = R
Cv = R/(Gamma-1); #Nm/KgK
Q = m2*Cv*(t1-t2); #J
print "Heat transfered in J : %.1f"%Q
# Variables :
m = 50./1000; #Kg
t1 = 14.; #degree_centigrade
t2 = 74.; #degree_centigrade
t_heating = 300.; #sec
Pheater = 10.04; #Watts
Gamma = 1.4;
Q = Pheater*t_heating; #J
#Q = m*Cp*(t2-t1)
Cp = Q/m/(t2-t1); #J/KgK
print "Specific heat of air in J/KgK : ",Cp
#Cp*(1-1/Gamma) = R
R = Cp*(1-1/Gamma); #Gas Constant in Nm/KgK
print "Gas constant of air in Nm/KgK : %.2f"%R
#p = rho*R*T
p = 0.1; #Mpa
T = 0+273; #kelvin
rho = p*10**6/R/T; #Kg/m**3
print "Density of air in Kg/m**3 : %.4f"%rho
# Variables :
m = 1.; #Kg
V1 = 0.3; #m**3
p = 3.2*100; #Kpa
p1 = 3.2*100; #Kpa
p2 = 3.2*100; #Kpa
V2 = 2.*V1; #m**3
Cp = 1.003; #KJ/KgK
R = 0.2927; #KJ/kgK
# Calculations and Results
#p*V = m*R*T
T1 = p1*V1/m/R; #kelvin
T2 = p2*V2/m/R; #kelvin
Q = m*Cp*(T2-T1); #KJ
print "Heat Added in KJ : %.2f"%Q
W = p*(V2-V1); #KJ
print "Work done in KJ : ",W
print "Initial temperature of air in kelvin : ",round(T1)
print "Final temperature of air in kelvin : ",round(T2)
import scipy
from scipy.integrate import quad
# Variables :
p = 105; #Kpa
p1 = 105; #Kpa
p2 = 105; #Kpa
V1 = 0.25; #m**3
V2 = 0.45; #m**3
T1 = 10+273; #kelvin
T2 = 240+273; #kelvin
# Calculations and Results
def f5(T):
return 0.4+18/(T+40)
Q = quad(f5,T1,T2)[0]
print "Heat Transfer in KJ : %.2f"%Q
W = p*(V2-V1); #KJ
print "Work Transfer in KJ : ",W
deltaU = Q-W; #KJ
print "in internal energy in KJ L : %.2f"%deltaU
deltaH = Q; #KJ
print "Change in enthalpy in KJ : %.2f"%deltaH
import math
# Variables :
N = 250.; #rpm
tau = 10.; #min
Q1 = -5.; #KJ
deltaU = 2.; #KJ
p = 1.2; #bar
p = p*100.; #KJ
E = 24.; #volt
I = 0.45; #Ampere
A = 0.1; #m**2
T = 0.5; #Nm
Q2 = E*I*tau*60./1000; #KJ
Q = Q1+Q2; #KJ
# Calculations
#Consider piston moves through a distance y
#Q-(W1+W2) = deltaU where W1 = p*A*y
W2 = -T*2*math.pi*N*tau; #Nm
W2 = W2/1000; #KJ
y = (Q-W2-deltaU)/A/p; #meter
# Results
print "Distance in cm : %.2f"%(y*100)
#Ans is wrong in the book.
import math
# Variables :
m = 0.8; #Kg
p1 = 1.; #bar
p2 = 5.; #bar
T1 = 25.+273; #kelvin
R = 287.; #KJ/kgK
# Calculations and Results
W = m*R*T1*math.log(p1/p2); #J
print "Work done in KJ : %.3f"%(W/1000)
U2subU1 = 0; #change in internal energy
Q = W+U2subU1; #J
print "Heat Transfer in KJ : %.3f"%(Q/1000)
import math
# Variables :
m = 1.; #Kg
p1 = 100.; #Kpa
T1 = 300.; #kelvin
V_ratio = 1./2; #V2/V1
T = 1.; #Nm
tau = 1.; #hr
tau = tau*60; #min
N = 400.; #rpm
R = 0.287; #KJ/kgK
# Calculations
W1 = m*R*T1*math.log(V_ratio); #KJ
W2 = -T*2*math.pi*N*tau/1000; #KJ
W = W1+W2; #KJ
# Results
print "Net work transfer in KJ : %.2f"%W
# Variables :
m = 2.; #Kg
T1 = 125.+273; #kelvin
T2 = 30.+273; #kelvin
W = 152.; #KJ
deltaH = -212.8; #KJ
Q = 0; #KJ(For adiabatic process)
# Calculations and Results
#Q = W+m*Cv*(T2-T!)
Cv = (Q-W)/m/(T2-T1); #KJ/KgK
print "Specific heat at constant volume in KJ/KgK : %.1f"%Cv
#deltaH = m*Cp*(T2-T1);
Cp = deltaH/m/(T2-T1); #KJ/KgK
print "Specific heat at cinstant pressure in KJ/KgK : ",Cp
R = Cp-Cv; #KJ/KgK
print "Characteristic gas constant in KJ/KgK : ",R
import math
# Variables :
V1 = 0.5; #m**3
p1 = 1.5; #bar
T1 = 100+273; #kelvin
V2 = 0.125; #m**3
p2 = 9; #bar
R = 287; #KJ/KgK
# Calculations and Results
m = p1*10**5*V1/R/T1; #Kg
print "Mass of air in Kg : %.4f"%m
#p1*V1**n = p2*V2**n
n = math.log(p2/p1)/math.log(V1/V2); #
print "Value of index : %.4f"%n
W = (p1*V1-p2*V2)*10**5/(n-1); #Nm
print "Work done in KJ : %.4f"%(W/1000)
import scipy
from scipy.integrate import quad
# Variables :
p1 = 1.; #bar
V1 = 0.14; #m**3
V2 = 0.07; #m**3
R = 287.; #KJ/KgK
# Calculations and Results
#p*V = R*k1*V**(-2/5) or p*V**(7/5) = K
K = p1*10**5*V1**(7./5); #Nm/Kg
def f17(V):
return K*V**(-7./5)
W = quad(f17,V1,V2)[0]
print "Work done in Nm : %.1f"%W
p2 = K*V2**(-7./5); #N/m**2
p2 = p2/10**5; #bar
print "Final pressure in bar : %.2f"%p2
#Ans in the book is wrong.
# Variables :
m = 2.; #Kg
Q = 0.; #KJ(because of adiabatic process)
p1 = 1.; #Mpa
p1 = p1*10.**6/1000; #Kpa
t1 = 200.; #degree centigrade
T1 = t1+273; #kelvin
p2 = 100.; #Kpa
n = 1.2;
R = 0.196; #KJ/KgK
# Calculations and Results
T2 = T1*(p2/p1)**((n-1)/n); #kelvin
t2 = T2-273; #degree centigrade
u1 = 196+0.718*t1; #KJ
u2 = 196+0.718*t2; #KJ
deltau = u2-u1; #KJ
deltaU = m*deltau; #KJ
print "Change in internal energy in KJ : %.1f"%deltaU
W = Q-deltaU; #KJ
print "Work transfer in KJ : %.1f"%W
W1 = m*R*(T1-T2)/(n-1); #KJ
print "Displacement work in KJ : %.2f"%W1
import scipy
from scipy.integrate import quad
# Variables :
m = 1.5; #Kg
V1 = 0.06; #m**3
p1 = 5.6*10; #Kpa
t2 = 240.; #degree centigrade
T2 = t2+273; #kelvin
a = 0.946;
b = 0.662;
K = 10.**-4;
# Calculations
#p*V = m*R*T = m*(a-b)*T
T1 = p1*10**5*V1/m/(a-b)/1000; #Kelvin
def f28(T):
return m*(b+K*T)
U2subU1 = quad(f28,T1,T2)[0]
Q = 0; #isentropic process
W = Q-U2subU1; #KJ
# Results
print "Work done in KJ : %.1f"%W
#Answer in the book is wrong.
import math
from scipy.integrate import quad
from numpy import *
# Variables :
m = 1.5; #Kg
p1 = 1000; #Kpa
p2 = 200; #Kpa
V1 = 0.2; #m**3
V2 = 1.2; #m**3
#p = a+b*v
#solving for a and b by matrix
A = array([[1, V1],[1, V2]]);
B = array([p1,p2]);
X = linalg.solve(A,B)
a = X[0]
b = X[1]
def f16(V):
return a+b*V
W = quad(f16,V1,V2)[0]
print "Work transfer in KJ/Kg : ",W
u2SUBu1 = (1.5*p2*V2+35)-(1.5*p1*V1+35); #KJ/Kg
print "Change in internal energy in KJ/Kg : ",u2SUBu1
q = W+u2SUBu1; #KJ/Kg
print "Heat transfer in KJ/Kg : ",q
#u = 1.5*(a+b*V)*V+35;
#1.5*a+2*V*1.5*b = 0; #for max value putting du/dV = 0
V = -1.5*a/2/1.5/b; #m**3/Kg
p = a+b*V; #KPa
u_max = 1.5*p*V+35; #KJ/Kg
print "Maximum internal energy in KJ/Kg : ",u_max
#Answer in the book is wrong because a is 1160 instead of 1260.
import math
# Variables :
V1 = 5.; #m**3
p1 = 2.; #bar
t1 = 27.; #degree centigrade
T1 = t1+273; #kelvin
p2 = 6.; #bar
p3 = p1; #bar
R = 287.; #KJ/KgK
n = 1.3;
# Calculations
#p*V**(1/3) = C
V2 = V1*(p1/p2)**(1/1.3); #m**3
#p*V = m*R*T1
m = p1*10**5*V1/R/T1; #Kg
W1_2 = 10**5*(p1*V1-p2*V2)/(n-1); #Nm
W1_2 = W1_2/1000; #KJ
Gamma = 1.4; #for air
#p*V**Gamma = C
V3 = (p2/p3)**(1/Gamma)*V2; #m**3
W2_3 = 10**5*(p2*V2-p3*V3)/(Gamma-1); #Nm
W2_3 = W2_3/1000; #KJ
W = W1_2+W2_3; #KJ
# Results
print "Net work done in KJ : %.2f"%W
# Variables :
Q1_2 = 85; #KJ
Q2_3 = -90; #KJ
W2_3 = -20; #KJ
Q3_1 = 0; #Adiabatic process
W1_2 = 0; #consmath.tant volume process
# Calculations
W3_1 = Q1_2+Q2_3+Q3_1-W1_2-W2_3; #KJ
# Results
print "Direction is 3-1 and work in KJ : ",W3_1
# Variables :
V1 = 200./1000; #m**3
p1 = 4.; #bar
T1 = 400.; #K
p2 = 1.; #bar
H3subH2 = 72.; #KJ
Cp = 1. #KJ/KgK
Cv = 0.714; #KJ/KgK
# Calculations and Results
Gamma = Cp/Cv;
R = Cp-Cv; #KJ/KgK
#p*V = m*R*T
m = p1*10**5*V1/R/1000/T1 #Kg
T2 = T1*(p2/p1)**((Gamma-1)/Gamma); #K
V2 = p1*V1/T1*T2/p2; #m**3
W1_2 = m*R*(T1-T2)/(Gamma-1); #KJ
print "Work done W1-2 in KJ : %.1f"%W1_2
#H3subH2 = m*Cp(T3-T2);
T3 = (H3subH2+m*Cp*T2)/m/Cp; #K
W2_3 = m*R*(T3-T2); #KJ
W = W1_2+W2_3; #KJ
print "Workdone in KJ : %.0f"%W
#W = m*R*(T1-T3)/(n-1)
n = m*R*(T1-T3)/W+1; #
print "Index of expansion : %.5f"%n
from scipy.integrate import quad
from numpy import *
# Variables :
p1 = 10.; #bar
p2 = 2.; #bar
V1 = 0.1; #m**3
V2 = 0.9; #m**3
R = 300.; #Nm/Kg-K
m = 1.; #Kg
# Calculations
#p = a*v+b
#solving for a and b by matrix
A = array([[V1, 1],[V2, 1]]);
B = array([p1,p2]);
X = linalg.solve(A,B);
a = X[0]
b = X[1]
#p = a*v+b = a*R*T/p+b
#2*p-b = 0; #on differentiating
p = b/2; #bar
#p = a*v+b
v = (p-b)/a; #m**3/Kg
T = p*10**5*v/R; #K
print "Maximum temperature in K : %.2f"%T
def f23(v):
return (a*v+b)*10**5
W = quad(f23,V1,V2)[0]
W = W/10**3; #KJ/KgK
print "Work done in KJ : %.2f"%W
T1 = p1*10**5*V1/R; #K
T2 = p2*10**5*V2/R; #K
Gamma = 1.4;
Cv = R/(Gamma-1); #Nm/KgK
Cv = Cv/1000; #KJ/KgK
deltaU = m*Cv*(T2-T1); #KJ/Kg
Q = W+deltaU; #KJ
print "Net Heat transfer in KJ : %.2f"%-Q
# Variables :
m = 5.; #Kg
#u = 3.62*p*v
p1 = 550.; #KPa
p2 = 125.; #KPa
V1 = 0.25; #m**3
# Calculations and Results
#p*V**(1/2) = C
n = 1.2;
V2 = (p1/p2)**(1/n)*V1; #m**3/Kg
W = (p1*V1-p2*V2)*10**5/(n-1)/1000; #KJ
delta_u = (3.62*p2*V2)-(3.62*p1*V1); #KJ/Kg
deltaU = m*delta_u; #KJ
print "Change in internal energy in KJ : %.4f"%deltaU
Q = W+deltaU; #KJ
Q = Q/1000; #MJ
print "Heat transfer in MJ : %.3f"%Q
import math
# Variables :
Vdot = 0.032; #m**3/s
d = 1.5; #m
L = 4.2; #m
m = 3500.; #Kg
# Calculations and Results
V = math.pi/4*d**2*L; #m**3
rho = m/V; #Kg/m**3
print "Density of liquid in Kg/m**3 : %.1f"%rho
m_dot = rho*Vdot; #Kg/s
print "Mass flow rate in Kg/s : %.2f"%m_dot
import math
# Variables :
p1 = 1.; #bar
T1 = 20.+273; #K
p2 = 6.; #bar
m = 1.; #Kg
R = 287.; #Nm/Kg
Gamma = 1.4;
Cp = 1.005; #KJ/KgK
Cv = 0.7175; #KJ/KgK
#T2 = T1 : Isothermal compression
T2subT1 = 0;
deltaU = m*Cv*(T2subT1); #KJ
print ("Isothermal :");
print "Change in internal energy in KJ : ",deltaU
Wsf = m*R/1000*T1*math.log(p1/p2); #KJ/Kg
print "Work done in KJ/Kg : %.2f"%Wsf
p2V2subp1V1 = 0; #isothermal process
Q = Wsf+deltaU+p2V2subp1V1; #KJ/Kg
print "Heat transfer in KJ/Kg : %.2f"%Q
print ("Isentropic :");
T2 = T1*(p2/p1)**((Gamma-1)/Gamma); #K
U2subU1 = m*Cv*(T2-T1); #KJ/Kg
print "Change in internal energy in KJ/Kg : %.2f"%U2subU1
H2subH1 = m*Cp*(T2-T1); #KJ/Kg
print "Change in heat in KJ/Kg : %.2f"%H2subH1
Q = 0; #adiabatic process
print "Heat transfer in KJ/Kg : %.2f"%Q
Wsf = Q-H2subH1; #KJ/Kg
print "Work done in KJ/Kg : %.2f"%Wsf
print ("Polytropic : ");
n = 1.25; #index
T2 = T1*(p2/p1)**((n-1)/n); #K
deltaU = m*Cv*(T2-T1); #KJ/Kg
print "Change in internal energy in KJ/Kg : %.2f"%deltaU
H2subH1 = m*Cp*(T2-T1); #KJ/Kg
Wsf = (n/(n-1))*m*R/1000*(T1-T2); #KJ/Kg
print "Work done in KJ/Kg : %.2f"%Wsf
Q = Wsf+H2subH1; #KJ/Kg
print "Heat transfer in KJ/Kg : %.2f"%Q
#Answer of chane in internal energy for last part is wrong in the book.
import scipy
from scipy.integrate import quad
# Variables :
p1 = 5.; #bar
p2 = 50.; #bar
V = 0.001; #m**3/Kg
m_dot = 10.; #Kg/s
# Calculations
def f20(p):
return -V
wsf = quad(f20,p1*10**5,p2*10**5)[0]
wsf = wsf/1000 #KJ/Kg
Wsf = abs(wsf)*m_dot; #KW(leaving -ve sign as it is to indiacte heat is supplied)
# Results
print "Power required in KW : ",Wsf
import math
# Variables :
p1 = 10.**5; #Pa
p2 = 5.*10**5; #Pa
T1 = 25.+273; #K
V1 = 1.8; #m**3/Kg
# Calculations and Results
V2 = p1/p2*V1; #m**3/Kg
W = -p1*V1*math.log(p2/p1); #J/kg
W = W/1000.; #KJ/Kg
print "Workdone in KJ : %.1f"%W
deltaU = 0; #As in a isothermal process T2-T1 = 0
print "Change in internal energy in KJ : ",deltaU
Q = -W; #KJ/Kg(As in a isothermal process T2-T1 = 0 )
print "Heat Transfered in KJ/Kg : %.1f"%Q
# Variables :
p = 6.; #bar
m = 18.; #Kg
v = 260.; #m/s
rho = 4.; #Kg/m**3
Q = 42.; #KJ/Kg
W = 261.; #KW
Cv = 0.715; #KJ/KgK
pA = 1.; #bar
vA = 60.; #m/s
mdotA = 14.; #Kg/s
CvA = 0.835; #m**3/Kg
TA = 115.+273; #K
pB = 5.5; #bar
vB = 15.; #m/s
mdotB = 4.; #Kg/s
CvB = 0.46; #m**3/Kg
TB = 600.+273; #K
v1 = 1./rho; #m**3/Kg
# Calculations
#m*(Cv*T+p*10**5*v1/1000+v**2/2000)+Q*rho-W = mdotA*(Cv*TA+pA*10**5*CvA/1000+vA**2/2000)+m_dotB*(Cv*TB+pB*10**5*CvB/1000+vB**2/2000);
T = (((mdotA*(Cv*TA+pA*10**5*CvA/1000+vA**2/2000)+mdotB*(Cv*TB+pB*10**5*CvB/1000+vB**2/2000))+W-Q*rho)/m-v**2/2000-p*10**5*v1/1000)/Cv; #K
# Results
print "Temperature of air at inlet in K : %.2f"%T
#Answer in the book is wrong.
import math
# Variables :
h1 = 3000.; #KJ/Kg
C1 = 60.; #m/s
h2 = 2762.; #KJ/Kg
Q = 0.; #KJ
m = 1.; #Kg
W = 0.; #in case of nozzle
# Calculations and Results
#Q-W = m*[(h2-h1)+(C2**2-C1**2)/2/1000+g*(Z2-Z1)/1000]
Z2subZ1 = 0; #as Z1 = Z2 for horizontal nozzle
C2 = math.sqrt(-(h2-h1)*2*1000+C1**2); #m/s
print "Velocity at exit of nozzle in m/s : %.2f"%C2
A1 = 0.1; #m**3
v1 = 0.187; #m**3/Kg
mdot = A1*C1/v1; #Kg/s
print "Mass flow rate through the nozzle in Kg/s : %.4f"%mdot
v2 = 0.498; #m**3/Kg
#mdot = A2*C2/v2 = math.pi/4*d**2*C2/v2
d2 = math.sqrt(mdot/math.pi*4*v2/C2); #m
print "Diameter of nozzle at exit in meter : %.4f"%d2
# Variables :
p1 = 4.; #bar
p2 = 1.; #bar
T1 = 40.+273; #K
T2 = 2.5+273; #K
C1 = 40.; #m/s
C2 = 200.; #m/s
W = 52.; #KJKg
m = 1.; #Kg
Cp = 1.005; #KJ/KgK
Z2subZ1 = 0.; #as Z1 = Z2
# Calculations
Q = W+m*(Cp*(T2-T1)+(C2**2-C1**2)/2/1000) #KJ/Kg
# Results
print "Heat transfered per Kg of air in KJ/Kg : %.1f"%Q
# Variables :
m1dot = 0.01; #Kg/s
h1 = 2950. #KJ/Kg
C1 = 20. #m/s
m2dot = 0.1; #Kg/s
h2 = 2565. #KJ/Kg
C2 = 120. #m/s
m3dot = 0.001; #Kg/s
h3 = 421. #KJ/Kg
C3 = 0. #m/s
C4 = 0. #m/s
Wsf_dot = 25. #KW
Qdot = 0. #KJ
# Calculations
#m1dot+m2dot = m3dot+m4dot
m4dot = m1dot+m2dot-m3dot; #Kg/s
#m1dot*(h1+C1**2/2/1000)+m2dot*(h2+C2**2/2/1000) = m3dot*(h3+C3**2/2/1000)+m4dot*(h4+C4**2/2/1000)+Wsf_dot
h4 = (m1dot*(h1+C1**2/2/1000)+m2dot*(h2+C2**2/2/1000)-m3dot*(h3+C3**2/2/1000)-Wsf_dot)/m4dot-C4**2/2/1000; #KJ/Kg
# Results
print "Enthalpy of 2nd exit stream in KJ/Kg : %.2f"%h4
# Variables :
mdot = 0.5; #kg/s
p1 = 1.4; #bar
rho1 = 2.5; #kg/m**3
u1 = 920.; #kJ/kg
C1 = 200.; #m/s
p2 = 5.6; #bar
rho2 = 5.; #kg/m**3
u2 = 720.; #kJ/kg
C2 = 180.; #m/s
Qdot = -60.; #kW
Z21 = 60.; #m
g = 9.81; #gravity consmath.tant
# Calculations and Results
h21 = u2-u1+(p2*10**5/(rho2*1000)-p1*10**5/(rho1*1000)); #kJ/kg(change in enthalpy)
H21 = mdot*h21; #kW(total change in enthalpy)
print "Change in enthalpy, H2-H1 in kW : ",H21
Wsf = Qdot-mdot*(h21+(C2**2-C1**2)/2/1000+g*(Z21)/1000); #kW
print "Rate of workdone, Wsf in kW : %.3f"%Wsf
# Variables :
mdot = 0.4; #Kg/s
C1 = 6.; #m/s
p1 = 1.; #bar
p1 = p1*100; #KPa
V1 = 0.16; #m**3/Kg
u2subu1 = 88.; #KJ/Kg
Qdot = -59.; #W
Qdot = Qdot/1000.; #KJ/s
W = 0.059; #KJ/
Gamma = 1.4;
Z2subZ1 = 0;
# Calculations
h2subh1 = Gamma*u2subu1; #KJ
Wdot = Qdot-mdot*(h2subh1); #As C1 = C2, C2**2-C1**2 = 0 & Z2-Zi = 0
# Results
print "Power in KW : ",Wdot
# Variables :
mdot = 1; #Kg/s
p1 = 40.; #bar
T1 = 1047.+273; #K
C1 = 200.; #m/s
C2 = 100.; #m/s
p2 = 1.; #bar
Qdot = 0.; #W
Cp = 1.05; #KJ/KgK
R = 300.; #Nm/KgK
Gamma = 1.4;
# Calculations
#p*v = m*R*T
v1dot = mdot*R*T1/p1/10**5; #m**3/s
v2dot = (p1/p2)**(1/Gamma)*v1dot; #m**3/s
T2 = p2*v2dot/p1/v1dot*T1; #K
Wsf_dot = Qdot-mdot*(Cp*(T2-T1)+(C2**2-C1**2)/2/1000); #KJ/s or KW
# Results
print "Output of turbine in KJ/s or KW : %.0f"%Wsf_dot
import math
# Variables :
A1C1 = 0.7; #m**3/s
p1 = 85.; #KPa
p2 = 650.; #KPa
v1 = 0.35; #m**3/Kg
v2 = 0.1; #m**3/Kg
d1 = 10./100; #m
d2 = 6.25/100; #m
# Calculations and Results
mdot = A1C1/v1; #Kg/s
p2v2SUBp1v1 = mdot*(p2*v2-p1*v1); #KJ/s
print "Change in flow work in KJ/s : %.1f"%p2v2SUBp1v1
print "Mass flow rate in Kg/s : %.0f"%mdot
C1 = A1C1/(math.pi/4*d1**2); #m/s
A2C2 = mdot*v2; #m**3/s
C2 = A2C2/(math.pi/4*d2**2); #m/s
C2subC1 = C2-C1; #m/s
print "Velocity change in m/s : %.3f"%C2subC1
import math
# Variables :
m = 12./60; #Kg/s
C1 = 12.; #m/s
p1 = 1.*100; #KPa
v1 = 0.5; #m**3/Kg
C2 = 90.; #m/s
p2 = 8.*100; #KPa
v2 = 0.14; #m**3/Kg
deltah = 150.; #KJ/Kg
Qdot = -700./60; #KJ/s
# Calculations and Results
#Assuming deltaPE = 0 = g*(Z2-Z1)
#Qdot-Wdot = mdot*(deltah+(C2**2-C1**2)/2/1000+g*(Z2-Z1)/1000)
Wdot = Qdot-m*(deltah+(C2**2-C1**2)/2/1000); #KW
print "Power required to drive the compressor in KW : %.3f"%abs(Wdot)
#A1C1/v1 = A2C2/v2
d1BYd2 = math.sqrt(C2/v2*v1/C1);
print "Ratio of inlet to outlet pipe diameter : %.4f"%d1BYd2
# Variables :
h1 = 160.; #KJ/Kg
h2 = 2380.; #KJ/Kg
m1dot = 10.; #Kg/s
m2dot = 0.8; #Kg/s
Qdot = 10.; #KJ/s
Wdot = 0.; #KJ
deltaKE = 0.;
deltaPE = 0.;
m3dot = m1dot+m2dot; #Kg/s
print "Mass flow of heated water in Kg/s : ",m3dot
#m1dot*h1+m2dot*h2 = m3dot*h3+Qdot
h3 = (m1dot*h1+m2dot*h2-Qdot)/m3dot; #KJ/Kg
print "Specific enthalpy of heated water in KJ/Kg : %.3f"%h3
import math
# Variables :
v = 0.001; #m**3/Kg
DisRate = 10./60; #m**3/s
p1 = 100.; #KN/m**2
p2 = 300.; #KN/m**2
Z1 = 3.; #m
Z2 = 9.; #m
d1 = 0.25; #m
d2 = 0.17; #m
Qdot = 0.; #KJ/s(Adiabatic process)
# Calculations
#A1*C1 = A2*C2 = DisRate
C1 = DisRate/(math.pi/4*d1**2); #m/s
C2 = DisRate/(math.pi/4*d2**2); #m/s
mdot = DisRate/v; #Kg/s
g = 9.81; #gravity consmath.tant
delta_u = 0;
#Qdot-Wdot = mdot*(delta_u+p2*v2-p1*v1+C2**2-C1**2+g*(Z2-Z1))
Wdot = mdot*(delta_u+p2*10**3*v-p1*10**3*v+(C2**2-C1**2)/2+g*(Z2-Z1))-Qdot; #J/s
Wdot = Wdot/1000; #KJ/s or KW
# Results
print "Power required to drive the pump in KW : %.3f"%Wdot
# Variables :
mdot = 5.; #Kg/s
T1 = 27.+273; #K
#Z1 = Z2
deltaPE = 0.;
Wdot = -100.; #KW
C1 = 60.; #m/s
C2 = 150.; #m/s
q = -2.; #KJ/Kg
Cp = 1.05; #KJ/Kg
Qdot = mdot*q; #KJ/s
delta_h = Cp; #KJ/Kg
# Calculations
#Qdot-Wdot = mdot*(delta_h*(T2-T1)+(C2**2-C1**2)/2/1000+g*(Z2-Z1))/1000)
T2 = ((Qdot-Wdot)/mdot-(C2**2-C1**2)/2/1000)/delta_h+T1; #K
# Results
print "Exit temperature in K : %.3f"%T2
import math
# Variables :
t1 = 90.; #degreeC
t2 = 30.; #degreeC
modot = 3.; #Kg/s
# Calculations
#h = 1.7*t+11*10**-4*t**2
h1 = 1.7*t1+11*10**-4*t1**2; #KJ/Kg
h2 = 1.7*t2+11*10**-4*t2**2; #KJ/Kg
tw1 = 27.; #degreeC
tw2 = 67.; #degreeC
Cp = 4.2; #KJ/KgK
#h = Cp*tw; #KJ/Kg
hw1 = Cp*tw1; #KJ/Kg
hw2 = Cp*tw2; #KJ/Kg
#modot*(h1-h2) = mwdot*(hw2-hw1)
mwdot = modot*(h1-h2)/(hw2-hw1); #Kg/s
# Results
print "Rate of flow of water in Kg/s : %.4f"%mwdot
import math
# Variables :
V1 = 6.; #m**3
p1 = 20.*100; #Kpa
T1 = 37.+273; #K
p2 = 10.*100; #Kpa
V2 = V1; #m**3
R = 0.287; #KJ/KgK
m1 = p1*V1/R/T1; #Kg
# Calculations
#T2 = T1*(p2/p1)**((Gamma-1)/Gamma)
Gamma = 1.4;
T2 = T1*(p2/p1)**((Gamma-1)/Gamma); #K
m2 = p2*V2/R/T2; #Kg
m = m1-m2; #mass of air discharged in Kg
# Results
print "Mass of air discharged in Kg : %.2f"%m
import scipy
from scipy.integrate import quad
# Variables :
V1 = 1.5; #m**3
V2 = 0.; #m**3
p = 1.02; #bar
def f21(V):
return 1
W = p*10**5* quad(f21,V1,V2)[0]
print "Work done by the air in KJ : %.0f"%(W/1000)