#Initialization of variables
import math
import numpy
from numpy import linalg
mass=215.0 #kg
#Calculations and printing :
density=13.546*62.43
print '%s %.2f' %("density of mercury (lbm/ft^3) = ",density)
#the multiplication factor is to convert density from gm/cc to lbm/ft^3.
volume=mass/(.454*density) #ft^3
#the division by 0.454 is to convert mass in kg to lbm.
print '%s %.2f %s %.2f' %(" \n The volume of ",mass,"kg of mercury is(ft^3) = ",volume)
raw_input('press enter key to exit')
#Initialization of variables
import math
import numpy
from numpy import linalg
T1=20.0 # ˚C
T2=100.0 # ˚C
Vat20=0.560 #ft^3
D=0.0208333 #ft
#Calculations and printing :
print("we know that V(T)=Vo[1+0.math.pow(18182x10,()-3)xT +0.math.pow(0078x10,()-6)xTxT]")
Vat0=Vat20/(1+0.18182*math.pow(10,-3)*T1 +0.0078*math.pow(10,-6)*T1*T1)
#the function is defined with the variable as temperature
def volume(T):
volume=Vat0*(1+0.18182* math.pow(10,-3) *T +0.0078* math.pow(10,-6) *T*T)
return volume
print '%s %.3f' %(" vat20 (ft^3) = ",volume(T1))
print '%s %.3f' %(" \n vat100 (ft^3) =",volume(T2))
change=((volume(T2))-(volume(T1)))*4/(math.pi*D*D)
print '%s %.3f' %(" \n change in the height of mercury level (ft) = ",change)
#the answer is a bit different due to rounding off of volume(T2) in textbook
raw_input('press enter key to exit')
#Initialization of variables
import math
import numpy
from numpy import linalg
mass=100.0 #g of CO2
M=44.01 #molecular weight
#Calculations and print '%s %.3f' %ing :
moles=mass/M
print '%s %.3f' %("\n no.of moles=",moles)
lbmole=moles/453.6
print '%s %.3f' %("\n no.of lb moles=",lbmole)
Cmoles=moles
print '%s %.3f' %("\n no.of moles of carbon=",Cmoles)
Omoles=2*moles
print '%s %.3f' %("\n no.of moles of oxygen=",Omoles)
O2moles=moles
print '%s %.3f' %("\n no.of moles of dioxygen=",O2moles)
gramsO=Omoles*16
print '%s %.3f' %("\n no.of grams of oxygen=",gramsO)
gramsO2=O2moles*32
print '%s %.3f' %("\n no.of grams of oxygen=",gramsO2)
moleculesCO2=moles*6.02*math.pow(10,(23))
print '%s %.3E' %("\n no.of molecules of CO2 =",moleculesCO2)
raw_input('press enter key to exit')
#Initialization of variables
import math
import numpy
from numpy import linalg
xA=0.15 #mass fraction
yB=0.20 #mole fraction
mass=175.0 #kg of solution
flowrate1=53.0 #lbm/h
flowrate2=1000.0 #mol/min
massofA=300.0 #lbm
molarB=28.0 #kmolB/s
#Calculations and printing :
massA=mass*xA
print '%s %d %s %.3f'%(" \n Mass of A in",mass," kg of solution (kg A) =",massA)
flowrateA=flowrate1*xA
print '%s %d %s %.3f'%(" \n Mass flow rate of A in a stream flowing at",flowrate1," lbm/h (lbm A/h)=",flowrateA )
flowrateB=flowrate2*yB
print '%s %d %s %.3f'%(" \n Molar flowrate of B in a stream flowing at",flowrate2," mol/min (molB/min)= ",flowrateB)
Totalflowrate=molarB/yB
print '%s %d %s %.3f'%(" \n Total flow rate of a solution with",molarB,"kmolB/s=",Totalflowrate)
MassSolution=massofA/xA
print '%s %d %s %.3f'%(" \n Mass of solution that contains",massofA," lbm of A =",MassSolution)
raw_input('press enter key to exit')
#Initialization of variables
import math
import numpy
from numpy import linalg
#let the total mass be 100
massO2=16.0
massCO=4.0
massCO2=17.0
massN2=63.0
MO2=32.0
MCO=28.0
MCO2=44.0
MN2=28.0
#Calculations and print '%s %.3f' %ing :
molO2=massO2/MO2
molCO=massCO/MCO
molCO2=massCO2/MCO2
molN2=massN2/MN2
TotalMol=molO2+molCO+molCO2+molN2
print '%s %.3f' %(" \n molefraction of O2=",molO2/TotalMol)
print '%s %.3f' %(" \n molefraction of CO=",molCO/TotalMol)
print '%s %.3f' %(" \n molefraction of CO2=",molCO2/TotalMol)
print '%s %.3f' %(" \n molefraction of N2=",molN2/TotalMol)
raw_input('press enter key to exit')
#Initialization of variables
import math
import numpy
from numpy import linalg
yN2=0.79
MN2=28.0 #g/mol
MO2=32.0 g/mol
xN2=0.767
#Calculations and printing :
Mbar=yN2*MN2+(1-yN2)*MO2
print '%s %.3f' %(" \n average molecular weight of air from molar composition (g/mol) = ",Mbar)
InvMbar=xN2/28 + (1-xN2)/32
print '%s %.3f' %(" \n average molecular weight of air from mass composition (g/mol) = ",1./InvMbar)
raw_input('press enter key to exit')
#Initialization of variables
import math
import numpy
from numpy import linalg
conc=0.5 #molar
rate=1.25 #m^3/min
D=1.03 #no units
M=98.0
#Calculations and print '%s %.3f' %ing :
mass_conc=conc*98.
print '%s %.3f' %("mass concentration of sulfuric acid (kg/m^3) = ",mass_conc)
mass_flowrate=rate*mass_conc/60.
print '%s %.3f' %(" \n Mass flow rate of sulfuric acid (kg/s) = ",mass_flowrate)
massfraction=1/(rate*D*1000/60)
print '%s %.3f' %(" \n Mass fraction of sulfuric acid=",massfraction)
raw_input('press enter key to exit')
#Initialization of variables
import math
import numpy
from numpy import linalg
Pressure=2.00*100000. #Pa
#Calculations and printing :
Pressure=Pressure*1000./(13600.*9.807)
print '%s %.3E' %("Pressure (mm of Hg) = ",Pressure)
raw_input('press enter key to exit')
#Initialization of variables
import math
import numpy
from numpy import linalg
P0=10.4*1.013*100000. /10.33 #m H2O
D=1000.0 #kg/m^3
g=9.807 #m/s^2
h=30.0 #m
#Calculations and printing :
Ph=P0+D*g*h
print '%s %.3E' %("Pressure at the bottom of the lake (N/m^2) = ",Ph)
raw_input('press enter key to exit')
#Initilization of variables
import math
spg=1.05
h1=382. #mm of fluid
h2=374. #mm of fluid
reading= -2 #in of Hg
Patm=30. #in of Hg
#Calculations and printing:
deltaP=(spg-1)*980.7*(h1-h2)/10.
print '%s %.1f' %("Pressure drop between points 1 and 2 (dynes/cm^2) = ",deltaP)
P1=Patm+reading
print '%s %.1f' %("\n Absolute Pressure (in Hg) = ",P1)
raw_input("Press the Enter key to quit")
#Initialization of variables
import math
import numpy
from numpy import linalg
T1=20.0 #F
T2=80.0 #F
#Calculations and printing :
#In this code I used a function to achieve the conversion
def conversion(fahrenheit):
conversion=(fahrenheit-32)/1.8
return conversion;
difference=conversion(T2)-conversion(T1)
print '%s %.2f %s %.2f' %("Equivalent temperature of",T2-T1," temperature in C =",difference)
deltaTF=T2-T1
deltaTC=deltaTF/1.8
print '%s %.2f' %(" \n By second method, result=",deltaTC)
raw_input('press enter key to exit')
#Initilization of variables
import math
a=0.487
b=2.29*math.pow(10, -4)
print '%s %.2f %s %.1E %s' %("Given Cp(Btu/lbm.F) = ",a,"+",b,"T (F)")
print("\n Step 1")
af1=a+b*32
bf1=b*1.8
print("\n Step 2")
af2=af1*1.8/(454*9.486*math.pow(10, -4))
bf2=bf1*1.8/(454*9.486*math.pow(10, -4))
print '%s %.2f %s %.1E %s' %("Final Cp(J/g.C) = ",af2,"+",bf2,"T (C)")
raw_input("Press the Enter key to quit")