#Variable declaration
Q12=-250; # Heat transfer during Discharging of battery in kcal
W21=-0.53; # Consumption of electricity dring Charging process in kWh
#Calculation
Q21=(W21*3600)-(Q12*4.1868); # First law of thermodynamics
#Result
print "Heat loss from battery during charging process = ",Q21,"kJ"
#Variable declaration
m=5; # Mass of water in a tank in kg
T1=30; # Temperature of water at initial state (1) in degree celcius
T2=95; # Temperature of water at final state (2) in degree celcius
Qout=70; # Heat transfer from the water tank to the surrounding air in kJ
W=75; #Electric energy input to a stirrer inside water in kJ
mf=32.3; # Mass of fel in bomb in grams
u1=125.78; # Internal energy of water from steam table (uf at T1) in kJ/kg
u2=397.88; # Internal energy of water from steam table (uf at T2) in kJ/kg
#Calculation
Qf=m*(u2-u1)-W+Qout; # From First law of thermodynamics
qf=Qf/(mf*10**-3); # Heat consumption per unit mass of fuel
#Result
print "Heat consumption per unit mass of fuel =",round(qf,0),"kJ/kg"
#Variable declaration
V=50; # Volume of water in a tank in litres
T1=120; # Temperature of water at initial state (1) in degree celcius
x1=0.6; # Dryness fraction at initial state (1)
T2=-10; # Temperature of water at final state (2) in degree celcius
vf1=0.00106; # specific volume of water from steam tables at T1 in m^3/kg
vg1=0.8919; # specific volume of water from steam tables at T1 in m^3/kg
v1=(1-x1)*vf1+x1*vg1; # Specific volume of misture of liquid and water at state (1)
m=(V*10**-3)/v1; # Mass of water in the tank
vs2=0.0010891; # Specific volume of saturated ice at T2 in m^3/kg
vg2=466.7; # Specific volume of water vapour at T2 in m^3/kg
v2=v1; # constant specific volume during cooling process
x2=(v2-vs2)/(vg2-vs2); # Dryness fraction at state (2)
uf1=503.5; # Specific internal energy at state (1) in kJ/kg
ug1=2529.3; # Specific internal energy at state (1) in kJ/kg
us2=-354.09; # Specific internal energy at state (2) in kJ/kg
ug2=2361.4; # Specific internal energy at state (2) in kJ/kg
#Calculation
u1=(1-x1)*uf1+x1*ug1; # Total Specific internal energy at state (1) in kJ/kg
u2=(1-x2)*us2+x2*ug2; # Total Specific internal energy at state (2) in kJ/kg
Q12=m*(u2-u1); # Heat transfer during cooling pocess
#Result
print "Heat transfer during cooling pocess = ",round(Q12,1),"kJ (round off error)"
#Variable declaration
V1=0.3; # Initial volume of water upto stop 1 in m^3
p1=1; # Initial pressure of water in bar
x1=0.2; # Dryness fraction at initial state (1)
p2=3; # Pressur required to lift the piston in bar
V4=0.45; # Volume of water upto stop 2 in m^3
vf1=0.001043; # Specific volume at state (1) from steam table in m^3/kg
vg1=1.694; # Specific volume at state (1) from steam table in m^3/kg
#Calculation for (a)
v1=vf1+x1*(vg1-vf1); # Total Specific volume at state (1) from steam table in m^3/kg
m=V1/v1; # Mass of water
v3=V4/m; # Specific volume at stop 2
v2=v1; p3=p2; v4=v3; V3=V4; V2=V1; # From process diagram
# (a)
p4=0.361; # Final Pressure at v4 from steam table in Mpa
#Result for (a)
print "(a)","\nFianl pressure = ",p4,"MPa"
#Calculation for (b)
# (b)
W14=p2*10**2*(V3-V2); # Work done in process
uf1=417.36; # Specific internal energ at initial state in kJ/kg
ufg1=2088.7; # Specific internal energ at initial state in kJ/kg
u1=uf1+x1*ufg1; # Total Specific internal energr at initial state in kJ.kg
u4=2550.2; # Specific internal energ at final state in kJ/kg
Q14=m*(u4-u1)+W14; # From first law of thermodynamics
#Result for (b)
print "\n\n(b)","\nWork done during the process = ",W14,"kJ","\nHeat transfer during the process = ",round(Q14,1),"kJ"
#Variable declaration
V1=0.01; # Initial Volume of Freon 12 vapour in cylinder in m^3
T1=15; # Initial Temperature of Freon 12 vapour in degree celcius
p1=4.914; # Initial pressure (Psat at T1) in bar
p2=9; # Final pressure of Freon 12 vapour after compression in bar
T2=65; # Final temperature of Freon 12 vapour after compression in degree celcius
Q=-0.5; # Heat lost to surroundings during compresson process in kJ
v1=0.035413; # Initial specific volume of Freon 12 vapour from table in m^3/kg
#Calculation
m=V1/v1; # Mass of vapour
hg1=193.644; # specific enthalpy of Freon 12 vopour at state 1 in kJ/kg
u1=hg1-(p1*10**2*v1); # Total Specific internal energy at state 1
h2=222.9; # specific enthalpy of Freon 12 vapour at state 2 in kJ/kg
v2=0.022537; # specific volume of Freon 12 vapour at state 2 in m^3/kg
u2=h2-(p2*10**2*v2); # Total Specific internal energy at state 2
W=-m*(u2-u1)+Q; # From first law of thermodynamics
#Result
print "Work of compression = ",round(W,2),"kJ"
#Variable declaration
tS=-10; # initial temperature of ice in degree celcius
ts=0; # Melting temperature of ice in degree celcius
Cs=1.94; # Specific heat of ice in kJ/kg k
m=1000; # Mass of ice in kg
tF=10; # Temperature of water after 24 hours in degree celcius
tf=0; # Freezing temperature of water in degree celcius
Cf=4.1868; # Specific heat of water in kJ/kg K
hsg=335; # Latent heat of fusion of ice in kJ/kg
#Calculation
Q=m*(Cs*(ts-tS)+hsg+Cf*(tF-tf)); # Heat gain of water
Q_dot=Q/(24*3600); # Rate of cooling
#Result
print "Rate of cooling = ",round(Q_dot,3),"kW"
#Variable declaration
T1=300; # Temperature of air at state 1 in Kelvin
T2=500; # Temperature of air at state 2 in Kelvin
m_=28.966; # Molecular weight oh air in kg
Cpoav=1.017; # Average value of specific heat of air in kJ/kg K
#Calculation for (a)
# (a). change in enthalpy
h_=27.43*(T2-T1)+3.09*10**-3*(T2**2-T1**2)-0.2296*10**-6*(T2**3-T1**3); #change in enthalpy during process in kJ/kmol
h=h_/m_; # change in enthalpy during process in kJ/kg
#Result for (a)
print "(a).change in enthalpy during process = ",round(h,2),"kJ/kg"
#Calculation for (b)
# (b).change in enthalpy
h=Cpoav*(T2-T1); # change in enthalpy in kJ/kg
#Result for (b)
print "(b).change in enthalpy during process with average specfic heat = ",h,"kJ/kg"
#Variable declaration
m=0.1; # mass of nitrogen gas in kg
V1=0.1; # Initial volme of nitrogen gas in m^3
p1=1.2; # Initial pressure of nitrogen gas in bar
V2=0.075; # Final volume of nitrogen gas in m^3
Cpo=1.041; # Specific heat at constant pressure of nitrogen in kJ/kg K
R=0.2969393; # Characteristic gas constant of nitrogen in Kj/kg K
#Calculation
T1=(p1*10**2*V1)/(m*R); # Initial temperature of nitrogen gas
T2=T1*(V2/V1); # Final temperature of nitrogen gas (constant pressure process)
Q=m*Cpo*(T2-T1); # Heat transfer to surroundings
W=p1*10**2*(V2-V1); # Work done
#Result
print "Final Temperature of nitrogen gas = ",round(T2,0),"K","\nHeat transfer to surroundings = ",round(Q,1),"kJ"
print "Work done = ",W,"kJ"," The Work is done on the gas"
#Variable declaration
p=1; # pressure inside piston cylinder arrangement in MPa
# stae 1 = saturated liquid
# state 2 = saturated vapour
# state 3 = superheated vapour
v1=0.001127; # specific volume at state 1 in m^3/kg
v2=0.19444; # specific volume at state 2 in m^3/kg
v3=0.4011; # specific volume at state 3 in m^3/kg
u1=761.68; # specific internal energy at state 1 in kK/kg
u2=2583.6; # specific internal energy at state 2 in kK/kg
u3=3296.8; # specific internal energy at state 3 in kK/kg
h1=762.81; # specific enthalpy at state 1 in kJ/kg
h2=2778.1; # specific enthalpy at state 2 in kJ/kg
h3=3697.9; # specific enthalpy at state 3 in kJ/kg
#Calculation for (Method I)
w12=p*10**3*(v2-v1); # Work done during process 1-2
w23=p*10**3*(v3-v2); # Work done during process 2-3
wtotal=w12+w23; # Total work done
# Calculation of heat transfer
# Method I
q12=(u2-u1)+w12; # Heat transfer during process 1-2
q23=(u3-u2)+w23; # Heat transfer during process 2-3
qtotal=q12+q23; # Total Heat transfer
#Results for (Method I)
print "Work done = ",round(wtotal,0),"kJ/kg"
print "\n\nCalculation of Heat Transfer","\nMethod I","\nHeat Transfer = ",round(qtotal,1),"kJ/kg"
#Calculation for (Method II)
# Method II
q12=h2-h1; # Heat transfer during process 1-2
q23=h3-h2; # Heat transfer during process 2-3
qtotal=q12+q23; # Total Heat transfer
#Result for (Method II)
print "\nMethod II","\nHeat Transfer = ",round(qtotal,1),"kJ/kg"
import math
from __future__ import division
#Variable declaration
p1=1; # initial pressure of air in piston cylinder arrangement in bar
T=300; # Temperature of air in piston cylinder arrangement in kelvin
p2=10; # Final pressure of air in piston cylinder arrangement in bar
R=0.287; # Characteristic gas constant of air in kJ/kg K
#Calculation
w=R*T*math.log(p1/p2); # Work done
q=w; # From first law of thermodynamics
#Results
print "The change in internal energy during the isothermal process is zero"
print "Work done = ",round(w,1),"kJ/kg","\nHeat transfer = ",round(q,1),"kJ/kg"
import math
from __future__ import division
#Variable declaration
p1=65;# (Error in textbook) # Pressure of air at state 1 in bar
v1=0.0135; # Volume of air at state 1 in m^3
v2=0.1; # Volume of air at state 2 in m^3
R=0.287; # Characteristic gas constant of air in kJ/kg K
Cvo=0.7165; # Specific heat at constant volume in kJ/kg K
#Calculation for (a)
# (a).Adiabatic process
k=1.4; # Index of adiabatic process
p2=p1*(v1/v2)**k; # Pressure of air at state 2
T1=p1*10**2*v1/R;# Tempewrature of air at state 1
T2=p2*10**2*v2/R;# Tempewrature of air at state 2
w=R*(T2-T1)/(1-k); # work done
q=0; # Adiabatic expansion process
delta_u=Cvo*(T2-T1); # Change in internal energy of air
#Result for (a)
print "(a).Adiabatic Process","\nFinal Temperature = ",round(T2,1),"K","\nWork done = ",round(w,1),"kJ"
print "Change in internal energy of air = ",round(delta_u,1),"kJ","\nHeat Ineraction = ",round(q,1),"kJ"
#Calculation for (b)
# (b).Polytropic process
n=1.3; # Index of adiabatic process
p2=p1*(v1/v2)**n; # Pressure of air at state 2
T1=p1*10**2*v1/R;# Tempewrature of air at state 1
T2=p2*10**2*v2/R;# Tempewrature of air at state 2
w=R*(T2-T1)/(1-n); # work done
delta_u=Cvo*(T2-T1); # Change in internal energy of air
q=delta_u+w; # Adiabatic expansion process
#Result for (b)
print "\n\n(b).Polytropic Process","\nFinal Temperature = ",round(T2,1),"K","\nWork done = ",round(w,1),"kJ"
print "Change in internal energy of air = ",round(delta_u,1),"kJ","\nHeat Ineraction = ",round(q,1),"kJ"
#Calculation for (c)
# (c).Isothermal process
T1=p1*10**2*v1/R;# Tempewrature of air at state 1
T2=T1; # Tempewrature of air at state 2
p2=p1*(v1/v2); # Pressure of air at state 2
w=R*T1*math.log (v2/v1); # work done
delta_u=Cvo*(T2-T1); # Change in internal energy of air
q=delta_u+w; # Adiabatic expansion process
#Result for (c)
print "\n\n(c).Isothermal Process","\nFinal Temperature = ",round(T2,1),"K","\nWork done = ",round(w,1),"kJ"
print "Change in internal energy of air = ",round(delta_u,1),"kJ","\nHeat Ineraction = ",round(q,1),"kJ"
#Variable declaration
m=10; # mass flow rate of chilled water in kg/s
V1=50; #velocity of chilled water at section 1 in m/s
z1=30; # Elevation of section 1 in m
V2=10; #velocity of chilled water at section 2 in m/s
z2=60; # Elevation of section 2 in m
h1=21; # Enthalpy of chilled water at section 1 in kJ/kg
h2=43; # Enthalpy of chilled water at section 2 in kJ/kg
W=35; # Rate of work done by pump in kW
g=9.80665; # Acceleration due to gravity in m/s^2
#Calculation
Q=m*(h2-h1)+(m*(V2**2-V1**2)/2000)+(m*g*(z2-z1)/1000)-W; # Steady flow energy equation
#Result
print "The rate of Heat Transfer From Building (Error in textbook)= ",round(Q,2),"kW"
import math
from __future__ import division
#Variable declaration
p1=1; # Suction pressure of air in bar
p2=5; # Delivery pressure of air in bar
T1=310; # Suction Temperature of air in kelvin
Cpo=1.0035; # Specific heat at constant pressure in kJ/kg K
# (a) Polytropic compression
T2=475; # Delivery Temperature of air in kelvin
Q=-0.15; # Heat loss to the cooling water in kW
Wpoly=-5.3; # Power consumption of compressor in kW
#Calculation for (a)
m=(-Wpoly+Q)/(Cpo*(T2-T1)); # mass flow rate of air from SSSF energy equation
n=1/((1-((math.log (T2/T1))/(math.log (p2/p1))))); # Index of polytropic process
#Result for (a)
print "(a).Polytropic compression","\nmass flow rate of air = ",round(m,3),"kg/s","\nIndex of polytropic process = ",round(n,4)
#Calculation for (b)
# (b) Adiabatic compression
k=1.4; # Index of adiabatic process
Wad=-m*Cpo*T1*((p2/p1)**((k-1)/k)-1); # power consumption of compressor
#Result for (b)
print "\n(b).Adiabatic compression","\nPower consumption of compressor = ",round(Wad,2),"kW"
#Calculation for (c)
# (c).Difference between specific work
wdiff=(abs(Wad)-abs(Wpoly))/m; # Difference between specific work
#Result for (c)
print "\n(c).Difference between specific work","\nDifference between specific work = ",round(wdiff,2),"kJ/kg (roundoff error)"
#Variable declaration
W=500; # Power output from steam turbine in MW
Q=10; # Heat loss to surroundings in MW
p1=12.5; # Pressure of staem at steam turbine inlet in MPa
p2=10; # Pressure of staem at steam turbine outlet in kPa
V1=50; # Velocity of steam at steam turbine inlet in m/s
V2=100; # Velocity of steam at steam turbine outlet in m/s
x2=0.85; # Quality of steam at steam turbine outlet
h1=3341.8; # Specific enthalpy of staem at inlet from steam table in kJ/kg
hf2=191.83; hg2=2584.7;# Specific enthalpies of fluid and steam at outlet from steam table in kJ/kg
#Calculation
h2=(1-x2)*hf2+x2*hg2;# Specific enthalpy of staem at outlet in kJ/kg
m=(W-Q)*10**3/((h1-h2)+(V1**2-V2**2)/2000); # Mass flow rate of steam
#Result
print "Mass flow rate of steam = ",round(m,0),"kg/s"
import math
from __future__ import division
#Variable declaration
p1=3; # Pressre of air at state 1 in bar
p2=p1; # constant pressure process
T1=450; # Temperature of air at state 1 in kelvin
T2=1250; # Temperature of air at state 2 in kelvin
T3=1000; # Temperature of air at state 3 in kelvin
V3=50; # Velocity of air at state 3 in m/s
T4=800; # Temperature of air at state 4 in kelvin
Cpo=1.0035; # Specific heat at constant pressure in kJ/kg K
#Calculation for (a)
# (a).Combustion chamber
q=Cpo*(T2-T1); # Heat added to air
#Result for (a)
print "(a).Combustion chamber","\nHeat added to air = ",q,"kJ/kg (round off error)"
#Calculation for (b)
# (b).Turbine
k=1.4; # Index of adiabatic process
w=Cpo*(T2-T3)-V3**2/2000; # Work done
#Result for (b)
print "\n(b).Turbine","\nWork done = ",w,"kJ/kg (round off error)"
#Calculation for (c)
# (c).Nozzle
V4=math.sqrt (2*Cpo*10**3*(T3-T4)+V3**2); # Velocity of air leaving the nozzle
#Result for (c)
print "\n(c).Nozzle","\nVelocity of air leaving the nozzle = ",round(V4,0),"m/s (round off error)"
#Calculation for (d)
# (d).Pressure drop
p3=p2*(T3/T2)**(k/(k-1)); # Pressure of air leaving turbine
p4=p3*(T4/T3)**(k/(k-1)); # Pressure of air leaving nozzle
#Result for (d)
print "\n(d).Pressure drop","\nPressure of air leaving turbine = ",round(p3,3),"bar"
print "Pressure of air leaving nozzle = ",round(p4,2),"bar"
#Variable declaration
V=1000; # Speed of aircraft in kmph
p1=0.35; # Ambient pressure in bar
T1=258; # Ambient temperature in kelvin
V1=V*1000/3600; # unit conversion kmph into m/s
p=1.01325; # Atmospheric pressure in bar
Cpo=1.0035; # Specific heat at constant pressure in kJ/kg K
k=1.4; # Index of compression process
#Calculation
T2=T1+(V1**2)/(2*Cpo*10**3); # The temperature after leaving inlet diffuser
p2=p1*(T2/T1)**(k/(k-1)); # Pressure after leaving inlet diffuser
r=p/p2; # Pressre ratio of compressor required for pressurization
#Result
print "The temperature after leaving inlet diffuser = ",round(T2,1),"K"
print "Pressre ratio of compressor required for pressurization = ",round(r,2)
#Variable declaration
p1=50; # Pressre of steam at diffuser inlet in kPa
T1=150; # Temperature of steam at diffuser inlet in degree celcius
V1=180; # Velocity of steam at diffuser inlet in m/s
A1=1000; # area of diffuser inlet in cm^2
V2=90; # Velocity of steam at diffuser outlet in m/s
p2=1; # Pressre of steam at diffuser outlet in bar
Q=120; # Heat loss to the surroundings in kW
v1=3.24; # Specific volume of steam from superheated steam table in m^3/kg at inlet
h1=2645.9; # # Specific enthalpy of steam from superheated steam table in m^3/kg at inlet
#Calculation
m=V1*A1*10**-4/v1; # Mass flow rate of steam
q=Q/m; # Heat transfer per unit mass of steam
h2=q+h1+(V1**2-V2**2)/2000; # Specific enthalpy of steam from SSSF energy equationat outlet
v2=1.704; # Specific volume of steam from superheated steam table in m^3/kg at outlet
A2=m*v2/V2; # Area of diffuser exit and Answer given in the textbook is wrong
#Result
print "Area of diffuser exit = ",round(A2*10**4,0),"cm^2 (Answer was wrong in textbook because that"
print "the value considered in the textbook for V2 is incorrect. So there is a difference in solution.)"
from numpy import matrix
from numpy import linalg
#Variable declaration
p=0.15; # Pressure of Freon-12 gas in MPa
T1=10; # Temperature of Freon-12 gas in degree celcius
T2=35; # Temperature of Freon-12 gas in degree celcius
h1=196.762; # Specific enthalpy of Freon-12 from table at 1 in kJ/kg
h2=69.49; # Specific enthalpy of Freon-12 from table at 2 in kJ/kg
h3=178.54; # Specific enthalpy of Freon-12 from table at 3 in kJ/kg
#Calculation
# For solving Conservation of mass and SSSF energy equations
A=[[1,-1],[h3,-h2]];
B=[[1] ,[h1]];
M=linalg.solve(A, B)
#Result
print "Mass of saturated liquid at 35 oC = ",round(M.item(1),3),"kg/s"
print "Mass of saturated vapour at 0.15 MPa = ",round(M.item(0),3),"kg/s"
#Variable declaration
p1=15;# Inlet pressure of condenser in kPa
x=0.92; # Quality of steam
ms=25; # mass flow rate of steam in kg/s
d_t=12; # temperature rise of water
Cpw=4.1868; # Specific heat of water in kJ/kg K
hfg=225.94; h4_3=2599.1; # specific enthalpy in kJ/kg
#Calculation
h1=(1-x)*hfg+x*h4_3; # specific enthalpy
h2=225.94; # specific enthalpy in kJ/kg
Q=ms*(h1-h2); # Heat transfer rate in condenser
mw=Q/(Cpw*d_t); # Mass flow rate of water
#Result
print "Heat transfer rate in condenser = ",round(Q,0),"kW","\nMass flow rate of water = ",round(mw,1),"kg/s"