#Initialization of variables
import math
import numpy
from numpy import linalg
ID=2.0 #cm
Vdot=2.0 #m^3/h
#Calculations and printing :
print(" All the values in the textbook are Approximated hence the values in this code differ from those of Textbook")
u=Vdot*100*100 /(math.pi*math.pow(ID/2,2) *3600)
mdot=Vdot*math.pow(10,3) /3600.
Ek=mdot*math.pow(u,2) /2
print '%s %.3f' %(" \n Ek (J/s) = ",Ek)
raw_input('press enter key to exit')
#Initialization of variables
import math
import numpy
from numpy import linalg
g=9.81 #m/s^2
mdot=15.0 #Kg/s
z2=20.0 #m
z1=-220. #m
#Calculations and printing :
print(" All the values in the textbook are Approximated hence the values in this code differ from those of Textbook")
Power=mdot*g*(z2-z1)
print '%s %d' %(" \n Power (J/s) = ",Power)
raw_input('press enter key to exit')
#Initilization of variables
Q1=2. #Kcal
Ek1=0#System is stationary
Ep1=0#No vertical displacement
W1=0#No moving boundaries
deltaU1=Q1-W1-Ek1-Ep1
deltaU1J=deltaU1*1000./0.23901
print '%s %.2f' %("Energy gained by the gas in going from 25C to 100C is (J)",deltaU1J)
W2=100. #J
Ek2=0 #The system is stationary at the initial and final states
Ep2=0#Assumed negligible by hypothesis
deltaU2=0#U depends only on T for an ideal gas and T doesn't change
Q2=deltaU2+W2+Ek2+Ep2
print '%s %.1f' %("Heat transferred to the gas while it expands and reequilibrates at 100C is (J)",Q2)
raw_input("Press the Enter key to quit")
#Initialization of variables
import math
import numpy
from numpy import linalg
U=3800.0 #J/mol
P=1.0 #atm
Vcap=24.63 #L/mol
ndot=250.0 #Kmol/h
#Calculations and printing :
print(" All the values in the textbook are Approximated hence the values in this code differ from those of Textbook")
Hcap=U+P*Vcap*101.3
H=ndot*Hcap*math.pow(10,3)
print '%s %d' %(" \n Specific Enthalpy (J/mol) = ",Hcap)
print '%s %.3E' %("\n Enthalpy of Helium (J/h) = ",H)
raw_input('press enter key to exit')
#Initialization of variables
import math
import numpy
from numpy import linalg
mdot=500.0/3600.#Kg/s
u1=60.0 #m/s
u2=360.0 #m/s
deltaZ=-5. #m
g=9.81 #m/s^2
Qdot= -10000.#Kcal/h
Ws=70.0 #KW
#Calculations and printing :
print(" All the values in the textbook are Approximated hence the values in this code differ from those of Textbook")
Ek=mdot*math.pow(10,-3)*(math.pow(u2,2)-math.pow(u1,2))/2
Ep=mdot*g*deltaZ/math.pow(10,3)
Qdot=Qdot/(0.239*3600.)
Hdot=Qdot-Ws-Ek-Ep
print '%s %f' %(" \n DeltaH (KW) = ",Hdot)
Hcap=Hdot/mdot
print '%s %f' %("\n Specific Enthalpy (Kj/Kg) = ",Hcap)
raw_input('press enter key to exit')
#Initialization of variables
import math
import numpy
from numpy import linalg
H0=196.23 #Btu/lbm
H50=202.28 #Btu/lbm
Pfinal=51.99 #psia
Pinitial=18.90 #psia
Vfinal=1.920 #ft^3/lbm
Vinitial=4.969 #ft^3/lbm
#Calculations and printing :
print(" All the values in the textbook are Approximated hence the values in this code differ from those of Textbook")
deltaH=H0-H50
deltaU=deltaH+((Pfinal*Vfinal-Pinitial*Vinitial)*1.987/10.73)
print '%s %.3f' %(" \n change in Specific Enthalpy (Btu/lbm) = ",deltaH)
print '%s %.3f' %(" \n change in Specific Internal Energy (Btu/lbm) = ",deltaU)
raw_input('press enter key to exit')
#Initialization of variables
import math
import numpy
from numpy import linalg
mdot=2000.0 #Kg/h
P=10.0 #bar
#Calculations and printing :
print(" All the values in the textbook are Approximated hence the values in this code differ from those of Textbook")
print("From Steam tables, ")
Hin=3201. #Kj/Kg
Hout=2675. #Kj/Kg
Ws= -mdot*(Hout-Hin)/3600.
print '%s %d' %("Work delivered by Turbine to surroundings (Kw) = ",Ws)
raw_input('press enter key to exit')
#Initialization of variables
import math
import numpy
from numpy import linalg
m1=120.0 #kg
m2=175.0 #kg
m3=295.0 #kg
ID=6.0 #cm
P=17.0 #bar
H1=125.7 #Kj/Kg
H2=271.9 #Kj/Kg
H3=2793.0 #Kj/kg
#Calculations and printing :
print(" All the values in the textbook are Approximated hence the values in this code differ from those of Textbook")
deltaH=m3*H3-m1*H1-m2*H2
print("From tables, Vdot=0.1166 m^3/kg")
Vdot=0.1166
A=math.pi*math.pow(ID/2,2) /math.pow(10,4)
u=m3*Vdot/(A*60)
Ek=m3*math.pow(u,2) /(2*math.pow(10,3))
Qdot=deltaH+Ek
print '%s %.3E' %("Heat required (Kj/min) = ",Qdot)
raw_input('press enter key to exit')
#Initialization of variables
import math
import numpy
from numpy import linalg
basis=1.0 #Kg/s
x=0.6 #ethane
T1=150.0 #K
T2=250.0 #K
P=5.0 #bar
Hout1=434.5 #KJ/Kg
Hout2=130.2 #KJ/Kg
Hin1=314.3 #KJ/Kg
Hin2=30.0 #KJ/Kg
#Calculations and printing :
print(" All the values in the textbook are Approximated hence the values in this code differ from those of Textbook")
Qdot=basis*(x*Hout1+(1-x)*Hout2-x*Hin1-(1-x)*Hin2)
print '%s %.3f' %(" \n Heat required (KJ/Kg) = ",Qdot/basis)
raw_input('press enter key to exit')
#Initialization of variables
import math
import numpy
from numpy import linalg
m3=1150.0 #Kg/h
H3=2676.0 #KJ/Kg
H2=3074.0 #KJ/Kg
H1=3278.0 #KJ/Kg
#Calculations and printing :
print(" All the values in the textbook are Approximated hence the values in this code differ from those of Textbook")
print("Mass balance on Water,")
print("m3+m1=m2")
print("Energy balance,")
print("m3*H3+m1*H1=m2*H2")
A=([[1,-1],[H2,-H1]])
b=([[m3],[m3*H3]])
C=numpy.dot(linalg.inv(A),b)
#here we solved two linear equations simultaneously.
m2=C[0,0]
m1=C[1,0]
print '%s %.3f' %(" Input flowrate,m1 (Kg/h) = ",m1)
print '%s %.3f' %(" \n Output flowrate, m2 (Kg/h) = ",m2)
print("From tables,Vdot=3.11 m^3/Kg")
Vdot=3.11
print '%s %.3f' %(" Volumetric input flowrate (m^3/h) = ",m1*Vdot)
raw_input('press enter key to exit')
#Initialization of variables
import math
import numpy
from numpy import linalg
Vdot=20.0 #L/min
P2=1.01325*100000. #atm
ID1=0.5 #cm
ID2=1.0 #cm
g=9.81 #m/s^2
deltaZ=50.0 #m
#Calculations and printing :
print(" All the values in the textbook are Approximated hence the values in this code differ from those of Textbook")
u1=Vdot*math.pow(10,4) /(math.pow(10,3) *60*math.pi*math.pow(ID1/(2),2))
u2=Vdot*math.pow(10,4) /(math.pow(10,3) *60*math.pi*math.pow(ID2/(2),2))
deltaP=-((u2*u2-u1*u1)/2 +g*deltaZ)*1000.
P1=P2-deltaP
print '%s %.3f' %(" \n P1 (Pa) = ",P1)
raw_input('press enter key to exit')
#Initialization of variables
import math
import numpy
from numpy import linalg
deltaZ= -2.5 #ft
u1=0.0
D=50.0 #lbm/ft^3
F=0.80 #ft.lbf/lbm
V=5.0 #gal
g=32.174 #ft/s^2
ID=0.25 #in
#Calculations and printing :
print(" All the values in the textbook are Approximated hence the values in this code differ from those of Textbook")
u2=math.sqrt(2*32.174*(-F-g*deltaZ/32.174))
Vdot=u2*math.pi*math.pow(ID/(2),2) /144.
t=V*0.1337/(Vdot*60.)
print '%s %.3f' %("Total time taken (min) = ",t)
raw_input('press enter key to exit')
#Initialization of variables
import math
import numpy
from numpy import linalg
Ws=1000000. #N.m/s
deltaP= -83.*1000. #N/m^2
g=9.81 #m/s^2
deltaZ= -103 #m
D=1000. #kg/m^3
#Calculations and printing :
print(" All the values in the textbook are Approximated hence the values in this code differ from those of Textbook")
mdot= -Ws/(deltaP/D + g*deltaZ)
print'%s %.3f' %(" \n Water flow rate (kg/s) = ",mdot)
raw_input('press enter key to exit')