I want the math lab code for this qeasution _ ( Numerical mathods coruse ), Any
ID: 702631 • Letter: I
Question
I want the math lab code for this qeasution _ ( Numerical mathods coruse ), Any one could help me ?
Project la for Chemical Engineering Students Ideal Gas Law: pV = nRT, where p is the absolute pressure. V is the volume, n is the number of moles, R is the universal gas constant, and T is the absolute temperature. der Won-RT,wheris the molai where u =-s t volume and a and b are empirical constants that depend on the particular gas. Using the value of the universal gas constant R= 0.082054 L atm /(mol K), compute the molal volume for Oxygen (a 1.360 and b-0.03183 at the following temperatures and pressures. Compare your results w Tolerance Tol 10-5 For each case, compute the relative error of molal volume obtained by the van der Waals equation from the Ideal gas law. Use Newton's method to solve this problem and complete the table. ith the ideal gas law and van der Waals equation. Use Table using Newton's method Temp PressureMolal Volume (IdeaMolal Volume (vanRelativeNumber Gas Law) L/Mol der Waals) L/Mol Oxygen Error Oxygen Iterations atm 200 50 75 400 50 75 Define a suitable equation as vg(v) and use fixed point method to solve van der Waals equation for the above mentioned data Tale using Fixed points method Temp Pressure Molal Volume (IdeaMolal Volume (van Relative Number Gas Law) L/Mol der Waals) L/Mol Oxvgen Error Oxygen Iterations atm 200 75 400 50 75 For K-200 and pressure 5 and 50, chose a suitable interval for v to sketch the graphs of fv)Explanation / Answer
[1] Matlab code for Neton's method [You have to copy this code on m_file, save it asnwtnvdw and type following in command window: nwtnpvdw(3,10,300,0.001,1000,3.5). For other pressure and temperature you should change them accordingly.
function Volume = nwtnvdw(v0,P, T,es,imax,vr)
% P = pressure in atm, T = Temp in K, es = 0.001, iter=1, itermax = 1000
% P and T should be provided by user while running the code
iter = 0;
% a and b are van der Waal parameters for oxygen
a= 1.360;
b= 0.03183;
R = 0.082054; % universal gas constant in L atm/mol.K
vr=v0;
iter=0;
while(1)
vrold = vr;
fv0= (P+(a/vr^2))*(vr-b)/(R*T); % van der Waal equation f(v)
dfv0= (P+(a/vr^2))+(vr-b)*(-2*a/vr^2);% first derivative of van der Waal equation f'(v)
vr = vr - fv0/dfv0;
iter=iter+1;
if vr~=0 & dfv0~=0
end
ea=abs((vr-vrold)*100/vr);
if ea<es | iter>imax, break, end
end
vroot = vr;
disp(vr);
disp(iter);
end
[2] Matlab code for fixed point method [You have to copy this code on m_file, save it asfixedvdw and type following in command window: fixedpvdw(3,5,200,0.001,1,1000). For other pressure and temperature you should change them accordingly.
function fixedpvdw(v0,P,T,es,iter,itermax)
% P = pressure in atm, T = Temp in K, es = 10^-5, iter=1, itermax = 1000
% P and T should be provided by user while running the code
while(1)
% a and b are van der Waal parameters for oxygen
a= 1.360;
b= 0.03183;
R = 0.082054; % universal gas constant in L atm/mol.K
vr0=v0;
vrn=(R*T)/(P+a/vr0^2)+b;% This is modified form of van der Wall equation as (RT)/(P+a/v^2)+b =v [Fixed point method form of writing f(x) =0 as x=g(x)
ea=abs((vrn-vr0)*100/vrn);
v0=vrn;
iter=iter+1;
if ea<es | iter>itermax
break,end
end
root=v0;
disp(root); % To display final answer for molar volume
disp(iter); % To display no. of iteration
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.