import math
#calculate diameter for given variable
##initialisation of variables
R= 8.314 ##J/mol K
M= 29 ##gms
T= 80 ##C
p= 104 ##/kPa
v= 30 ##m/sec
m= 8000 ##kg/h
##CALCULATIONS
V= R*(273.15+T)/(M*p)
A= m*V/(3600*v)
D=math.sqrt(4*A/math.pi)
##RESULTS
print'%s %.5f %s'%('diameter = ',D,'m^2')
import math
#calculate intial areas
##initialisation of variables
R= 8.314 ##J/mol K
M= 29. ##gms
T1= 230. ##C
p1= 30. ##/bar
k= 1.4
T2= 180. ##C
v1= 10. ##m/s
p2= 20. ##bar
m2= 0.84 ##kg/s
##CALCULATIONS
V1= R*(273.15+T1)/(M*p1*100)
cp= k*R/((k-1)*M)
A= m2*V1*10*10*10*10/v1
v2= math.sqrt(v1*v1+2*cp*10*10*10*(T1-T2))
V2= R*(273.15+T2)/(M*p2*100)
A2= m2*V2*10*10*10*10/v2
##RESULTS
print'%s %.1f %s'%('inlet area =',A,'cm^2')
print'%s %.2f %s'%('inlet area =',A2,'cm^2')
import math
#calculate quantity x and specific volume
##initialisation of variables
h= 2676.2 ##kJ/kg
hf= 721.11 ##kJ/kg
hg= 2679.1 ##kJ/kg
vf= 0.001115 ##m^3/kg
vg= 0.2404 ##m^3/kg
##CALCULATIONS
x= (h-hf)/(hg-hf)
v1= vf+x*(vg-vf)
##RESULTS
print'%s %.3f %s'%('quantity =',x,'')
print'%s %.2f %s'%('specific volume = ',v1,'m^3/kg')
import math
#calculate heat pump and reate heat interaction and work of the turbine and at another point rate of heat interaction and all four areas at given poin
##initialisation of variables
h4= 419.05 ##kJ/kg
h1= 434.92 ##kJ/kg
m= 2.5 ##kg/s
h2= 3272.4 ##kJ/kg
h3= 2601.7 ##kJ/kg
v1= 0.001401 ##m^3/kg
V1= 5. ##m/s
v2= 0.03817 ##m^3/kg
V2= 20. ##m/s
v3= 0.8415 ##m^3/kg
V3= 100. ##m/s
v4= 0.00104 ##m^3/kg
V4= 5. ##m/s
##CALCULATIONS
W41= m*(h4-h1)
Q12= m*(h2-h1)
W23= m*(h2-h3)
Q34= m*(h4-h3)
A1= m*v1*10.*10.*10.*10./V1
A2= m*v2*10.*10*10.*10./V2
A3= m*v3*10.*10*10.*10/V3
A4= m*v4*10.*10*10.*10/V4
##RESULTS
print'%s %.1f %s'%('rate of pump =',W41,'kW')
print'%s %.f %s'%('rate of heat ineraction =',Q12,'kW')
print'%s %.1f %s'%('rate of work of the turbine =',W23,'W')
print'%s %.f %s'%('rate of heat ineraction =',Q34,'kW')
print'%s %.2f %s'%('area =',A1,'cm^2')
print'%s %.2f %s'%('area =',A2,'cm^2')
print'%s %.2f %s'%('area =',A3,'cm^2')
print'%s %.2f %s'%('area =',A4,'cm^2')
import math
#calculate mass of helium and temperature of helium
##initialisation of variables
m1= 0.03 ##kg
R= 8.314 ##J/mol K
T1= 300. ##C
p1= 120. ##kPa
k= 5./3.
M=4. ##kg
p2= 600. ##kPa
##CALCULATIONS
V= m1*R*(273.15+T1)/(p1*M)
m2= m1*((p2/p1)+k-1)/k
T2= p2*V*M/(m2*R)
##RESULTS
print'%s %.3f %s'%('mass of helium =',m2,'kg')
print'%s %.1f %s'%('temperature of helium =',T2,'K')
import math
#calculate volume of container and pressure
##initialisation of variables
m1= 0.03 ##kg
v1= 2.1977 ##m^3/kg
h2= 3073.8 ##kJ/kg
h1= 3061.6 ##kJ/kg
p2= 600. ##kPa
p1= 120. ##kPa
##CALCULATIONS
V=m1*v1
r= ((h2-h1)/v1)+p2-p1
##RESULTS
print'%s %.5f %s'%('volume of container =',V,'m^3')
print'%s %.2f %s'%('pressure =',r,'kPa')