Answered step by step
Verified Expert Solution
Link Copied!

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:

  1. creates a vector V, for volume in L, with 10 uniformly distributed random numbers between 1 and 2;
  2. sorts the elements of vector V is ascending order to obtain a new vector, named Vs;
  3. 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;
  4. using the two sets of values for P, calculates the percentage of error () for each value of Vs;*100%
  5. determines and displays the maximum error and the corresponding volume;
  6. 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions