#intiation of all variables
# Chapter 6
print"Example 6.1, Page:174 \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 6 Example 1")
print("NOTE=>In question no. 1 expression for various quantities is derived which cannot be solve using python software.")
#cal of dryness fraction
#intiation of all variables
# Chapter 6
print"Example 6.2, Page:175 \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 6 Example 2")
print("during throttling,h1=h2")
print("at state 2,enthalpy can be seen for superheated steam using Table 4 at 0.05 Mpa and 100 degree celcius")
print("thus h2=2682.5 KJ/kg")
h2=2682.5;
print("at state 1,before throttling")
print("hf_10Mpa=1407.56 KJ/kg")
hf_10Mpa=1407.56;
print("hfg_10Mpa=1317.1 KJ/kg")
hfg_10Mpa=1317.1;
print("h1=hf_10Mpa+x1*hfg_10Mpa")
h1=h2;#during throttling
print("dryness fraction(x1)may be given as")
x1=(h1-hf_10Mpa)/hfg_10Mpa
print("x1="),round(x1,2)
#cal of internal energy
#intiation of all variables
# Chapter 6
print"Example 6.3, Page:176 \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 6 Example 3")
h=2848;#enthalpy in KJ/kg
p=12*1000;#pressure in Kpa
v=0.017;#specific volume in m^3/kg
u=h-p*v
print("internal energy(u)=in KJ/kg"),round(u,2)
#cal of entropy of 5 kg of steam
#intiation of all variables
# Chapter 6
import math
print"Example 6.4, Page:176 \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 6 Example 4")
m=5;#mass of steam in kg
p=2;#pressure of steam in Mpa
T_superheat=(300+273.15);#temperature of superheat steam in K
Cp_water=4.18;#specific heat of water at constant pressure in KJ/kg K
Cp_superheat=2.1;#specific heat of superheat steam at constant pressure in KJ/kg K
print("steam state 2 Mpa and 300 degree celcius lies in superheated region as saturation temperature at 2 Mpa is 212.42 degree celcius and hfg=1890.7 KJ/kg")
T_sat=(212.42+273.15);#saturation temperature at 2 Mpa in K
hfg_2Mpa=1890.7;
print("entropy of unit mass of superheated steam with reference to absolute zero(S)in KJ/kg K")
S=Cp_water*math.log(T_sat/273.15)+(hfg_2Mpa/T_sat)+(Cp_superheat*math.log(T_superheat/T_sat))
print("S="),round(S,2)
print("entropy of 5 kg of steam(S)in KJ/K")
S=m*S
print("S=m*S"),round(S,2)
#cal of boiling point
#intiation of all variables
# Chapter 6
print"Example 6.5, Page:176 \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 6 Example 5")
rho=1000;#density of water in kg/m^3
g=9.81;#acceleration due to gravity in m/s^2
h=0.50;#depth from above mentioned level in m
print("boiling point =110 degree celcius,pressure at which it boils=143.27 Kpa(from steam table,sat. pressure for 110 degree celcius)")
p_boil=143.27;#pressure at which pond water boils in Kpa
print("at further depth of 50 cm the pressure(p)in Kpa")
p=p_boil-((rho*g*h)*10**-3)
print("p="),round(p,2)
print("boiling point at this depth=Tsat_138.365")
print("from steam table this temperature=108.866=108.87 degree celcius")
print("so boiling point = 108.87 degree celcius")
#cal of mass and volume of water
#intiation of all variables
# Chapter 6
print"Example 6.6, Page:177 \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 6 Example 6")
V=0.5;#capacity of rigid vessel in m^3
print("in a rigid vessel it can be treated as constant volume process.")
print("so v1=v2")
print("since final state is given to be critical state,then specific volume at critical point,")
print("v2=0.003155 m^3/kg")
v2=0.003155;#specific volume at critical point in m^3/kg
print("at 100 degree celcius saturation temperature,from steam table")
print("vf_100=0.001044 m^3/kg,vg_100=1.6729 m^3/kg")
vf_100=0.001044;
vg_100=1.6729;
vfg_100=vg_100-vf_100
print("and vfg_100=in m^3/kg="),round(vfg_100,2)
print("thus for initial quality being x1")
v1=v2;#rigid vessel
x1=(v1-vf_100)/vfg_100
print("v1=vf_100+x1*vfg_100")
print("so x1="),round(x1,3)
print("mass of water initially=total mass*(1-x1)")
m=V/v2
print("total mass of fluid/water(m) in kg="),round(m,2)
v=m*vf_100
print("volume of water(v) in m^3="),round(v,4)
#cal of slope
#intiation of all variables
# Chapter 6
print"Example 6.7, Page:177 \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 6 Example 7")
print("on mollier diadram(h-s diagram)the slope of isobaric line may be given as")
print("(dh/ds)_p=cons =slope of isobar")
print("from 1st and 2nd law combined;")
print("T*ds=dh-v*dp")
print("(dh/ds)_p=cons = T")
print("here temperature,T=773.15 K")
print("here slope=(dh/ds))p=cons = 773.15")
#cal of entropy
#intiation of all variables
# Chapter 6
print"Example 6.8, Page:178 \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 6 Example 8")
x=.10;#quality is 10%
print("at 0.15Mpa,from steam table;")
print("hf=467.11 KJ/kg,hg=2693.6 KJ/kg")
hf=467.11;
hg=2693.6;
hfg=hg-hf
print("and hfg in KJ/kg="),round(hfg,2)
print("vf=0.001053 m^3/kg,vg=1.1593 m^3/kg")
vf=0.001053;
vg=1.1593;
vfg=vg-vf
print("and vfg in m^3/kg="),round(vfg,2)
print("sf=1.4336 KJ/kg,sg=7.2233 KJ/kg")
sf=1.4336;
sg=7.2233;
sfg=sg-sf
print("and sfg=in KJ/kg K="),round(sfg,2)
print("enthalpy at x=.10(h)in KJ/kg")
h=hf+x*hfg
print("h="),round(h,2)
print("specific volume,(v)in m^3/kg")
v=vf+x*vfg
print("v="),round(v,2)
print("entropy (s)in KJ/kg K")
s=sf+x*sfg
print("s="),round(s,2)
#cal of heat added
#intiation of all variables
# Chapter 6
print"Example 6.9, Page:178 \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 6 Example 9")
p1=1*1000;#initial pressure of steam in Kpa
V1=0.05;#initial volume of steam in m^3
x1=.8;#dryness fraction is 80%
V2=0.2;#final volume of steam in m^3
p2=p1;#constant pressure process
print("work done during constant pressure process(W)=p1*(V2-V1)in KJ")
W=p1*(V2-V1)
print("now from steam table at p1,vf=0.001127 m^3/kg,vg=0.19444 m^3/kg,uf=761.68 KJ/kg,ufg=1822 KJ/kg")
vf=0.001127;
vg=0.19444;
uf=761.68;
ufg=1822;
v1=vf+x1*vg
print("so v1 in m^3/kg=")
m=V1/v1
print("now mass of steam(m) in kg="),round(m,2)
m=0.32097;#take m=0.32097 approx.
print("specific volume at final state(v2)in m^3/kg")
v2=V2/m
print("v2="),round(v2,2)
print("corresponding to this specific volume the final state is to be located for getting the internal energy at final state at 1 Mpa")
print("v2>vg_1Mpa")
print("hence state lies in superheated region,from the steam table by interpolation we get temperature as;")
print("state lies between temperature of 1000 degree celcius and 1100 degree celcius")
T=1000+((100*(.62311-.5871))/(.6335-.5871))
print("so exact temperature at final state(T)in K="),round(T,2)
print("thus internal energy at final state,1 Mpa,1077.61 degree celcius;")
print("u2=4209.6 KJ/kg")
u2=4209.6;
print("internal energy at initial state(u1)in KJ/kg")
u1=uf+x1*ufg
print("u1="),round(u1,2)
print("from first law of thermodynamics,Q-W=deltaU")
Q=m*(u2-u1)+W
print("so heat added(Q)=(U2-U1)+W=m*(u2-u1)+W in KJ="),round(Q,2)
#cal of pressure
#intiation of all variables
# Chapter 6
print"Example 6.10, Page:179 \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 6 Example 10")
p1=800;#initial pressure of steam in Kpa
T1=200;#initial temperature of steam in degree celcius
print("here steam is kept in rigid vessel,therefore its specific volume shall remain constant")
print("it is superheated steam as Tsat=170.43 degree celcius at 800 Kpa")
print("from superheated steam table;v1=0.2404 m^3/kg")
print("at begining of condensation specific volume = 0.2404 m^3/kg")
print("v2=0.2404 m^3/kg")
v2=0.2404;
print("this v2 shall be specific volume corresponding to saturated vapour state for condensation.")
print("thus v2=vg=0.2404 m^3/kg")
vg=v2;
print("looking into steam table vg=0.2404 m^3/kg shall lie between temperature 175 degree celcius(vg=0.2168 m^3/kg)and 170 degree celcius(vg=0.2428 m^3/kg)and pressure 892 Kpa(175 degree celcius)and 791.7 Kpa(170 degree celcius).")
print("by interpolation,temperature at begining of condensation(T2)in K")
T2=175-((175-170)*(0.2404-0.2167))/(0.2428-.2168)
p=892-(((892-791.7)*(0.2404-0.2168))/(0.2428-0.2168))
print("similarily,pressure(p2)in Kpa="),round(p,2)
#cal of enthalpy change
#intiation of all variables
# Chapter 6
print"Example 6.11, Page:180 \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 6 Example 11")
p2=200;#feed water pump pressure in Kpa
print("from 1st and 2nd law;")
print("T*ds=dh-v*dp")
print("for isentropic process,ds=0")
print("hence dh=v*dp")
print("i.e (h2-h1)=v1*(p2-p1)")
print("corresponding to initial state of saturated liquid at 30 degree celcius;from steam table;")
print("p1=4.25 Kpa,vf=v1=0.001004 m^3/kg")
p1=4.25;
v1=0.001004;
deltah=v1*(p2-p1)
print("therefore enthalpy change(deltah)=(h2-h1) in KJ/kg="),round(deltah,2)
#cal of quality or dryness fraction
#intiation of all variables
# Chapter 6
print"Example 6.12, Page:180 \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 6 Example 12")
V=2.;#volume of vessel in m^3
print("from steam table at 150 degree celcius")
print("vf=0.001091 m^3/kg,vg=0.3928 m^3/kg")
Vf=0.001091;
Vg=0.3928;
Vw=3*V/(3+2)
print("so volume occupied by water(Vw)=3*V/(3+2) in m^3"),round(Vw,2)
Vs=2*V/(3+2)
print("and volume of steam(Vs) in m^3="),round(Vs,2)
mf=Vw/Vf
print("mass of water(mf)=Vw/Vf in kg"),round(mf,2)
mg=Vs/Vg
print("mass of steam(mg)=Vs/Vg in kg"),round(mg,2)
m=mf+mg
print("total mass in tank(m) in kg="),round(m,2)
print("quality or dryness fraction(x)")
x=mg/m
print("x="),round(x,3)
print("NOTE=>answer given in book for mass=1103.99 kg is incorrect and correct answer is 1101.945 which is calculated above.")
#cal of turbine output
#intiation of all variables
# Chapter 6
print"Example 6.13, Page:181 \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 6 Example 13")
print("fron S.F.S.E on steam turbine;")
print("W=h1-h2")
print("initially at 4Mpa,300 degree celcius the steam is super heated so enthalpy from superheated steam or mollier diagram")
print("h1=2886.2 KJ/kg,s1=6.2285 KJ/kg K")
h1=2886.2;
s1=6.2285;
print("reversible adiabatic expansion process has entropy remaining constant.on mollier diagram the state 2 can be simply located at intersection of constant temperature line for 50 degree celcius and isentropic expansion line.")
print("else from steam tables at 50 degree celcius saturation temperature;")
print("hf=209.33 KJ/kg,sf=0.7038 KJ/kg K")
hf=209.33;
sf=0.7038;
print("hfg=2382.7 KJ/kg,sfg=7.3725 KJ/kg K")
hfg=2382.7;
sfg=7.3725;
print("here s1=s2,let dryness fraction at 2 be x2")
x2=(s1-sf)/sfg
print("x2="),round(x2,2)
print("hence enthalpy at state 2")
h2=hf+x2*hfg
print("h2 in KJ/kg="),round(h2,2)
print("steam turbine work(W)in KJ/kg")
W=h1-h2
print("W=h1-h2")
print("so turbine output=W"),round(W,2)
#cal of quality of final mixture
#intiation of all variables
# Chapter 6
print"Example 6.14, Page:181 \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 6 Example 14")
x1=0.5;#dryness fraction
m1=100;#mass of steam in kg
v1=0.8475;#
print("it is constant volume process")
print("volume of vessel(V)=mass of vapour * specific volume of vapour")
print("initial specific volume,v1")
print("v1=vf_100Kpa+x1*vfg_100 in m^3/kg")
print("at 100 Kpa from steam table;")
print("hf_100Kpa=417.46 KJ/kg,uf_100Kpa=417.36 KJ/kg,vf_100Kpa=0.001043 m^3/kg,hfg_100Kpa=2258 KJ/kg,ufg_100Kpa=2088.7 KJ/kg,vg_100Kpa=1.6940 m^3/kg")
hf_100Kpa=417.46;
uf_100Kpa=417.36;
vf_100Kpa=0.001043;
hfg_100Kpa=2258;
ufg_100Kpa=2088.7;
vg_100Kpa=1.6940;
vfg_100Kpa=vg_100Kpa-vf_100Kpa
print(" here vfg_100Kpa= in m^3/kg="),round(vfg_100Kpa,2)
v1=vf_100Kpa+x1*vfg_100Kpa
print("so v1= in m^3/kg="),round(v1,2)
V=m1*x1*v1
print("and volume of vessel(V) in m^3="),round(V,2)
h1=hf_100Kpa+x1*hfg_100Kpa
print("enthalpy at 1,h1=hf_100Kpa+x1*hfg_100Kpa in KJ/kg"),round(h1,2)
U1=m1*(uf_100Kpa+x1*ufg_100Kpa)
print("internal energy in the beginning=U1=m1*u1 in KJ"),round(U1,2)
print("let the mass of dry steam added be m,final specific volume inside vessel,v2")
print("v2=vf_1000Kpa+x2*vfg_1000Kpa")
print("at 2000 Kpa,from steam table,")
print("vg_2000Kpa=0.09963 m^3/kg,ug_2000Kpa=2600.3 KJ/kg,hg_2000Kpa=2799.5 KJ/kg")
vg_2000Kpa=0.09963;
ug_2000Kpa=2600.3;
hg_2000Kpa=2799.5;
print("total mass inside vessel=mass of steam at2000 Kpa+mass of mixture at 100 Kpa")
print("V/v2=V/vg_2000Kpa+V/v1")
v2=1/((1/vg_2000Kpa)+(1/v1))
print("so v2 in m^3/kg="),round(v2,2)
print("here v2=vf_1000Kpa+x2*vfg_1000Kpa in m^3/kg")
print("at 1000 Kpa from steam table,")
print("hf_1000Kpa=762.81 KJ/kg,hfg_1000Kpa=2015.3 KJ/kg,vf_1000Kpa=0.001127 m^3/kg,vg_1000Kpa=0.19444 m^3/kg")
hf_1000Kpa=762.81;
hfg_1000Kpa=2015.3;
vf_1000Kpa=0.001127;
vg_1000Kpa=0.19444;
vfg_1000Kpa=vg_1000Kpa-vf_1000Kpa
print("here vfg_1000Kpa= in m^3/kg="),round(vfg_1000Kpa,2)
x2=(v2-vf_1000Kpa)/vfg_1000Kpa
print("so x2="),round(x2,2)
print("for adiabatic mixing,(100+m)*h2=100*h1+m*hg_2000Kpa")
print("so mass of dry steam at 2000 Kpa to be added(m)in kg")
m=(100*(h1-(hf_1000Kpa+x2*hfg_1000Kpa)))/((hf_1000Kpa+x2*hfg_1000Kpa)-hg_2000Kpa)
print("m=(100*(h1-h2))/(h2-hg_2000Kpa)="),round(m,2)
print("quality of final mixture x2="),round(x2,2)
#cal of dryness fraction of steam entering
#intiation of all variables
# Chapter 6
print"Example 6.15, Page:183 \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 6 Example 15")
p_vaccum=71.5;#recorded condenser vaccum in cm of mercury
p_barometer=76.8;#barometer reading in cm of mercury
T_cond=35;#temperature of condensation in degree celcius
T_hotwell=27.6;#temperature of hot well in degree celcius
m_cond=1930;#mass of condensate per hour
m_w=62000;#mass of cooling water per hour
Ti=8.51;#initial temperature in degree celcius
To=26.24;#outlet temperature in degree celcius
print("from dalton law of partial pressure the total pressure inside condenser will be sum of partial pressures of vapour and liquid inside.")
p_condenser=(p_barometer-p_vaccum)*101.325/73.55
print("condenser pressure(p_condenser) in Kpa="),round(p_condenser,2)
print("partial pressure of steam corresponding to35 degree celcius from steam table;")
print("p_steam=5.628 Kpa")
p_steam=5.628;#partial pressure of steam
print("enthalpy corresponding to 35 degree celcius from steam table,")
print("hf=146.68 KJ/kg,hfg=2418.6 KJ/kg")
hf=146.68;
hfg=2418.6;
print("let quality of steam entering be x")
print("from energy balance;")
print("mw*(To-Ti)*4.18=m_cond*(hf+x*hfg-4.18*T_hotwell)")
print("so dryness fraction of steam entering(x)is given as")
x=(((m_w*(To-Ti)*4.18)/m_cond)-hf+4.18*T_hotwell)/hfg
print("x="),round(x,2)
#cal of change in internal energy and work done
#intiation of all variables
# Chapter 6
import math
print"Example 6.16, Page:184 \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 6 Example 16")
F=10;#force applied externally upon piston in KN
d=.2;#diameter in m
h=0.02;#depth to which water filled in m
P_atm=101.3;#atmospheric pressure in Kpa
rho=1000;#density of water in kg/m^3
Q=600;#heat supplied to water in KJ
T=150;#temperature of water in degree celcius
print("heating of water in vessel as described above is a constant pressure heating. pressure at which process occurs(p)=F/A+P_atm in Kpa")
A=math.pi*d**2/4
print("area(A) in m^2="),round(A,2)
p1=F/A+P_atm
print("so p1=in Kpa="),round(p1,2)
print("now at 419.61 Kpa,hf=612.1 KJ/kg,hfg=2128.7 KJ/kg,vg=0.4435 m^3/kg")
hf=612.1;
hfg=2128.7;
vg=0.4435;
V1=math.pi*d**2*h/4
print("volume of water contained(V1) in m^3="),round(V1,3)
m=V1*rho
print("mass of water(m) in kg="),round(m,2)
print("heat supplied shall cause sensible heating and latent heating")
print("hence,enthalpy change=heat supplied")
print("Q=((hf+x*hfg)-(4.18*T)*m)")
print("so dryness fraction of steam produced(x)can be calculated as")
x=((Q/m)+4.18*T-hf)/hfg
print("so x="),round(x,2)
print("internal energy of water(U1)in KJ,initially")
h1=4.18*T;#enthalpy of water in KJ/kg
U1=m*h1-p1*V1
print("U1="),round(U1,2)
U1=393.5;#approx.
print("finally,internal energy of wet steam(U2)in KJ")
print("U2=m*h2-p2*V2")
V2=m*x*vg
print("here V2 in m^3="),round(V2,2)
p2=p1;#constant pressure process
U2=(m*(hf+x*hfg))-p2*V2
print("hence U2="),round(U2,2)
U2=940.71;#approx.
U=U2-U1
print("hence change in internal energy(U) in KJ="),round(U,2)
p=p1;
W=p*(V2-V1)
print("work done(W) in KJ="),round(W,2)
#cal of overall dryness fraction
#intiation of all variables
# Chapter 6
print"Example 6.17, Page:185 \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 6 Example 17")
ms=40;#mass of steam in kg
mw=2.2;#mass of water in kg
p1=1.47;#pressure before throttling in Mpa
T2=120;#temperature after throttling in degree celcius
p2=107.88;#pressure after throttling in Kpa
Cp_sup=2.09;#specific heat of superheated steam in KJ/kg K
print("consider throttling calorimeter alone,")
print("degree of superheat(T_sup)in degree celcius")
T_sup=T2-101.8
print("T_sup="),round(T_sup,2)
print("enthalpy of superheated steam(h_sup)in KJ/kg")
h=2673.95;
h_sup=h+T_sup*Cp_sup
print("h_sup="),round(h_sup,2)
print("at 120 degree celcius,h=2673.95 KJ/kg from steam table")
print("now enthalpy before throttling = enthalpy after throttling")
print("hf+x2*hfg=h_sup")
print("here at 1.47 Mpa,hf=840.513 KJ/kg,hfg=1951.02 KJ/kg from steam table")
hf=840.513;
hfg=1951.02;
x2=(h_sup-hf)/hfg
print("so x2="),round(x2,2)
print("for seperating calorimeter alone,dryness fraction,x1=(ms-mw)/ms")
x1=(ms-mw)/ms
x=x1*x2
print("overall dryness fraction(x)="),round(x,2)
#cal of heat added and initial quality
#intiation of all variables
# Chapter 6
print"Example 6.18, Page:185 \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 6 Example 18")
v=0.4;#volume of air in part A and part B in m^3
p1=10*10**5;#initial pressure of steam in pa
p2=15*10**5;#final pressure of steam in pa
print("here heat addition to part B shall cause evaporation of water and subsequently the rise in pressure.")
print("final,part B has dry steam at 15 bar.In order to have equilibrium the part A shall also have pressure of 15 bar.thus heat added")
Q=v*(p2-p1)/1000
print("Q in KJ="),round(Q,2)
print("final enthalpy of dry steam at 15 bar,h2=hg_15bar")
print("h2=2792.2 KJ/kg from steam table")
h2=2792.2;
print("let initial dryness fraction be x1,initial enthalpy,")
print("h1=hf_10bar+x1*hfg_10bar.........eq1")
print("here at 10 bar,hf_10bar=762.83 KJ/kg,hfg_10bar=2015.3 KJ/kg from steam table")
hf_10bar=762.83;
hfg_10bar=2015.3;
print("also heat balance yields,")
print("h1+Q=h2")
print("so h1=h2-Q in KJ/kg")
h1=h2-Q
x1=(h1-hf_10bar)/hfg_10bar
print("so by eq 1=>x1="),round(x1,2)
print("heat added(Q)in KJ="),round(Q,2)
print("and initial quality(x1)"),round(x1,2)
#cal of heat and work transfer
#intiation of all variables
# Chapter 6
print"Example 6.19, Page:186 \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 6 Example 19")
m=3;#mass of wet steam in kg
p=1.4;#pressure of wet steam in bar
V1=2.25;#initial volume in m^3
V2=4.65;#final volume in m^3
T=400;#temperature of steam in degreee celcius
print("from steam table,vg=1.2455 m^3/kg,hf=457.99 KJ/kg,hfg=2232.3 KJ/kg")
vg=1.2455;
hf=457.99;
hfg=2232.3;
v1=V1/m
print("specific volume of wet steam in cylinder,v1 in m^3/kg="),round(v1,2)
x1=v1/vg
print("dryness fraction of initial steam(x1)="),round(x1,2)
x1=0.602;#approx.
h1=hf+x1*hfg
print("initial enthalpy of wet steam,h1 in KJ/kg="),round(h1,2)
v2=V2/m
print("at 400 degree celcius specific volume of steam,v2 in m^3/kg="),round(v2,2)
print("for specific volume of 1.55 m^3/kg at 400 degree celcius the pressure can be seen from the steam table.From superheated steam tables the specific volume of 1.55 m^3/kg lies between the pressure of 0.10 Mpa (specific volume 3.103 m^3/kg at400 degree celcius)and 0.20 Mpa(specific volume 1.5493 m^3/kg at 400 degree celcius)")
print("actual pressure can be obtained by interpolation")
p2=.1+((0.20-0.10)/(1.5493-3.103))*(1.55-3.103)
print("p2=0.20 MPa(approx.)")
p2=0.20;
print("saturation temperature at 0.20 Mpa(t)=120.23 degree celcius from steam table")
t=120.23;
print("finally the degree of superheat(T_sup)in K")
print("T_sup=T-t")
T_sup=T-t
print("final enthalpy of steam at 0.20 Mpa and 400 degree celcius,h2=3276.6 KJ/kg from steam table")
h2=3276.6;
print("heat added during process(deltaQ)in KJ")
print("deltaQ=m*(h2-h1)")
deltaQ=m*(h2-h1)
print("internal energy of initial wet steam,u1=uf+x1*ufg in KJ/kg")
print("here at 1.4 bar,from steam table,uf=457.84 KJ/kg,ufg=2059.34 KJ/kg")
uf=457.84;
ufg=2059.34;
u1=uf+x1*ufg
print("internal energy of final state,u2=u at 0.2 Mpa,400 degree celcius")
print("u2=2966.7 KJ/kg")
u2=2966.7;
print("change in internal energy(deltaU)in KJ")
deltaU=m*(u2-u1)
print("deltaU="),round(deltaU,2)
print("form first law of thermodynamics,work done(deltaW)in KJ")
deltaW=deltaQ-deltaU
print("deltaW=deltaQ-deltaU"),round(deltaW,2)
print("so heat transfer(deltaQ)in KJ"),round(deltaQ,2)
print("and work transfer(deltaW)in KJ"),round(deltaW,2)
print("NOTE=>In book value of u1=1707.86 KJ/kg is calculated wrong taking x1=0.607,hence correct value of u1 using x1=0.602 is 1697.5627 KJ/kg")
print("and corresponding values of heat transfer= 4424.2962 KJ and work transfer=616.88424 KJ.")
#cal of percentage of vessel volume initially occupied by steam
#intiation of all variables
# Chapter 6
print"Example 6.20, Page:187 \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 6 Example 20")
print("here throttling process is occuring therefore enthalpy before and after expansion remains same.Let initial and final states be given by 1 and 2.Initial enthalpy,from steam table.")
print("at 500 degree celcius,h1_10bar_500oc=3478.5 KJ/kg,s1_10bar_500oc=7.7622 KJ/kg K,v1_10bar_500oc=0.3541 m^3/kg")
h1_10bar_500oc=3478.5;
s1_10bar_500oc=7.7622;
v1_10bar_500oc=0.3541;
print("finally pressure becomes 1 bar so finally enthalpy(h2) at this pressure(of 1 bar)is also 3478.5 KJ/kg which lies between superheat temperature of 400 degree celcius and 500 degree celcius at 1 bar.Let temperature be T2,")
h2=h1_10bar_500oc;
print("h_1bar_400oc=3278.2 KJ/kg,h_1bar_500oc=3488.1 KJ/kg from steam table")
h_1bar_400oc=3278.2;
h_1bar_500oc=3488.1;
print("h2=h_1bar_400oc+(h_1bar_500oc-h_1bar_400oc)*(T2-400)/(500-400)")
print("so final temperature(T2)in K")
T2=400+((h2-h_1bar_400oc)*(500-400)/(h_1bar_500oc-h_1bar_400oc))
print("T2="),round(T2,2)
print("entropy for final state(s2)in KJ/kg K")
s_1bar_400oc=8.5435;
s_1bar_500oc=8.8342;
s2=s_1bar_400oc+((s_1bar_500oc-s_1bar_400oc)*(495.43-400)/(500-400))
print("s2="),round(s2,2)
print("here from steam table,s_1bar_400oc=8.5435 KJ/kg K,s_1bar_500oc=8.8342 KJ/kg K")
print("so change in entropy(deltaS)in KJ/kg K")
deltaS=s2-s1_10bar_500oc
print("deltaS="),round(deltaS,2)
print("final specific volume,v2=v_1bar_400oc+((v_1bar_500oc-v_1bar_400oc)*(95.43)/(500-400)) in m^3/kg")
print("here from steam table,v_1bar_500oc=3.565 m^3/kg,v_1bar_400oc=3.103 m^3/kg")
v_1bar_500oc=3.565;
v_1bar_400oc=3.103;
v2=v_1bar_400oc+((v_1bar_500oc-v_1bar_400oc)*(95.43)/(500-400))
V=v1_10bar_500oc*100/v2
print("percentage of vessel volume initially occupied by steam(V)="),round(V,2)