#A 15 ft^3 volume of an ideal gas has a mass of 20 lbm at 80F and 320 psia.
#What is the molecular weight of the gas?
#initialisation of variables
v= 15 #ft^3
m= 20 #lbm
T= 80 #lbf
P= 320 #psia
#CALCULATIONS
R= P*144*v/(m*(T+460.)) #Universal gas constant
M= 1545./R #Molecular weight
#RESULTS
print '%s %.2f' % ('Molecular weight of the gas (lbm/lbm mol) = ',M)
raw_input('press enter key to exit')
#A 50 ltr liter of oxygen is initially at 20 atm and 30C. A sufficient of
#amount of oxygen is removed to change the state to 6 atm and 10C.
#Determine (a) the initial mass of oxygen and (b) final mass of oxygen.
#initialisation of variables
V= 50 #lit
P= 20 #atm
T= 30 #C
P1= 6 #atm
T1= 10 #C
M= 32 #gm/gm mol
#CALCULATIONS
n= V*P/(0.082*(T+273.)) #No. of moles
m= n*M #Mass
n2= P1*V/(0.082*(T1+273.)) #No. of moles
m2= n2*M #Mass
#RESULTS
print '%s %.2f' % ('Initial Mass of Oxygen (gm) = ',m)
print '%s %.2f' % (' \n Final mass of oxygen (gm) = ',m2)
raw_input('press enter key to exit')
#If 0.75 ft^3 of a gas at 1 atm and 35F is compressed polytropically to a
#pressure of 3 atm, determine the final volume and temperature.
#The polytropic exponent is 1.3
import math
#initialisation of variables
V2= 0.75 #ft^3
P2= 1 #atm
P1= 3 #atm
T= 35 #F
e= 1.3
#CALCULATIONS
V1= math.pow(((P2*math.pow((V2),e))/P1),(1/e)) #Final volume
T2= P1*V1*(T+460.)/(P2*V2) #Final temperature
#RESULTS
print '%s %.2f' % ('Final volume (ft^3) = ',V1)
print '%s %.2f' % (' \n Final temperature (R) = ',T2)
raw_input('press enter key to exit')
#A rigid container holds a 0.45 kg mass of air with a volume of 0.03 m^3
#and an absolue pressure of 6.9x 10^5 pa. the air is expanded reversibly
#and adiabatically to 0.03 m^3. The air is then returned to its initial
#state by a rreversible constant volume process. Determine the pressure and
#temperature at each state
import math
#initialisation of variables
m= 0.45 #kg
v1= 0.03 #m^3
v2= 0.06 #m^3
P= 6.9*100000. #Pa
K= 1.4
R= 287.1 #J/Kg K
#CALCULATIONS
T1= (P*v1)/(m*R) #Temperature
T2= T1 #Temperature
P2= P*v1/v2 #Pressure
T3= T2*math.pow((v2/v1),(K-1)) #Temperature
P3= P2*math.pow((v2/v1),K) #Pressure
#RESULTS
print '%s %.2f' % ('T1 (K) = ',T1)
print '%s %.2f' % (' \n T2 (K) = ',T2)
print '%s %.2f' % (' \n T3 (K) = ',T3)
print '%s %.2e' % (' \n P2 (Pa) = ',P2)
print '%s %.2e' % (' \n P3 (Pa) = ',P3)
raw_input('press enter key to exit')
#Nitrogen is compressed in a reversible polytropic process from 1 atm and 60 F
#to 4 atm. Calculate the work associated with the process if the polytropic
#exponent is 1.3
import math
#initialisation of variables
P= 1 #atm
T= 60 #F
P1= 4 #atm
e= 1.3
R= 55.15 #lbf/lbm R
m= 778
#CALCULATIONS
T2= (T+460)*math.pow((P1/P),((e-1)/e)) #Temperature final
W= R*(T2-(T+460))/(1-e) #Work
W1= W/m #Work per unit mass
#RESLUTS
print '%s %.2f' % ('Work associated with the process (Btu/lbm) = ',W1)
raw_input('press enter key to exit')
#Determine the total pressure of a mixture of 10 lbm oxygen and
#15 lbm nitrogen at 120F in a rigid tank of 150 ft^3. Show that
#the total volume is the sum of the partial volumes?
import math
#initialisation of variables
m= 10 #lbm
R= 48.28 #lbf/lbm R
T= 120 #F
V= 150 #ft^3
m1= 15 #lbm
R1= 55.15 #lbf/lbm R
#CALCULATIONS
P1= (m*R*(T+460))/V #Pressure of Oxygen
P2= (m1*R1*(T+460))/V #Pressure of Nitrogen
Pm= P1+P2 #Total pressure
V1= (m*R*(T+460))/Pm #Volume of Oxygen
V2= (m1*R1*(T+460))/Pm #Volume of Nitrogen
Vm= V1+V2 #Total volume
#RESULTS
print '%s %.2f' % ('Total volume (ft^3) = ',Vm)
raw_input('press enter key to exit')