Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The ideal gas equation states that P= nRT V , where P is the pressure, V is the volume, T is the temperature, R =
The ideal gas equation states that P=nRTV, where P is the pressure, V is the volume, T is the temperature, R = 0.08206 (L.atm/mol.K) is the gas constant, and n is the number of moles. Real gases, especially at higher pressure, deviate from this behavior. Their response can be modeled with the van der Waals equation
where a and b are material constants. Write a script M-file which performs the following for given values of n, a, b and T:
- creates a vector V, for volume in L, with 10 uniformly distributed random numbers between 1 and 2;
- sorts the elements of vector V is ascending order to obtain a new vector, named Vs;
- calculates P twice for each value of Vs, once using the ideal gas equation of state and once with the van der Waals equation of state;
- using the two sets of values for P, calculates the percentage of error () for each value of Vs;*100%
- determines and displays the maximum error and the corresponding volume;
- finally, saves the percentage errors, the maximum error and the corresponding volume variables in a text file named variables. Consider 1 mole of nitrogen gas at 300 K, with a = 1.39 L2.atm/mol2, and b = 0.0391 L/mol. Use your program to find and display the maximum percent error in P and the corresponding value of the volume. Assign values for n, a, b and T in the Command Window. Make sure that your results are displayed based on Octaves choice among the fixed-point or scientific format with 5 digits.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started