# Variables
v=0.01283; #[m**3] - volume of tank in m**3
v=0.4531; #[ft**3] - volume of tank in ft**3
p=2; #[atm] - pressure
T=1.8*300; #[degR] - temperature
R=0.73; #[(atm*ft**3)/(lbmol*degR)] - gas constant
# Calculations
# usin the equation of state for an ideal gas pv=nRT
n=(p*v)/(R*T);
xN2=0.5; # fractiom of N2 in math.tank
nN2=xN2*n;
Ca=nN2/v;
# Results
print "no. of moles , n = %.3e"%n
print "Ca = %.2e lb*mol/ft**3"%(Ca);
from numpy import *
# the three unknowns are x,y,z
# the three equations are-
# x+y+z = 1500
# (1) 0.05*x+0.15*y+0.40*z = 1500*0.25
# (2) 0.95*x+0.00*y+0.452*z = 1500*0.50
# Variables
a = array([[1, 1, 1],[0.05, 0.15, 0.40],[0.95, 0 ,0.452]])
d = array([[1500.],[1500.*0.25],[1500.*0.50]])
# Calculations
#ainv = linalg.inv(a);
#sol = ainv * d;
sol = linalg.solve(a,d)
# Results
print "the amount of concentrated HNO3 is %.0fkg \
\nthe amount of concentrated H2SO4 is %.0fkg \
\nthe amount of waste acids is %.0fkg"%(sol[1],sol[0],round(sol[2],-1));
# Answer may be different because of rounding error and inbuilt function solve.