You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Buy here:<br />
http://homework.plus/cmpsc-<strong>201</strong>-fa16-project-1/<br />
Objective: Write a C++ program that solves the Van der Waals equation of state using the<br />
Newton-Raphson method.<br />
Program Description:<br />
A more realistic equation of state than the ideal gas law is the Van der Waals equation:<br />
gas constant, P = pressure, T = temperature, and Vˆ is the volume per unit mole of<br />
material (molar volume).<br />
The values of the Van der Waals constants for air are:<br />
liter 2 a 1.33 atm mole<br />
b 0.0366 liter mole<br />
a<br />
V b R T<br />
where a and b are parameters for a given gas, R = 0.08206 (liter atm/(mole K)) is the<br />
universal<br />
P V2<br />
ˆ
ˆ<br />
<strong>CMPSC</strong> <strong>201</strong> <strong>–</strong> <strong>FA16</strong><br />
Air is contained in a vessel at T = 170 K and P = 50 atm. Compute the molar volume of the<br />
air Vˆ ˆ<br />
using the Van der Waals equation. You can use the ideal gas law PV RT to obtain an<br />
initial estimate for Vˆ with which to start the iteration.<br />
To implement the Newton-Raphson method for this problem, rewrite the equation as a<br />
function of the volume:<br />
a<br />
P V2<br />
'ˆ<br />
f (Vn)<br />
'ˆˆ where f (V ) is the derivative of the function with respect to V :<br />
ˆ<br />
f'VP a 2ab<br />
ˆ<br />
ˆˆ V b R T 0 f ( V )<br />
The each successive iteration will be obtained by using:<br />
ˆ
f (V )<br />
ˆˆ<br />
VV n1 n<br />
n<br />
ˆ2 ˆ3<br />
VV<br />
Continue iterations until the value of Vˆ changes by less than 1% from one iteration to the<br />
next. Test Data: The above values should give you a Vˆ of 0.2101<br />
Notes:<br />
● You will need to have 2 variables to represent the volume.<br />
● Read the problem very carefully to make sure you fully understand what you<br />
are solving<br />
●<br />
for.<br />
● Your program should prompt for a, b, T and P.<br />
● All data should be 4 decimal points of precision.<br />
●<br />
What are you turning in:<br />
1. A printout of your original source code<br />
2. A printout of your output with your program run with ONE of the following<br />
sets of data:<br />
3. Upload your source to the Angel drop box. Be sure you have followed the<br />
rules for naming your cpp file.<br />
4. If you neglect to either upload your file or turn in your paperwork, I will not<br />
grade your project and you will get a zero for the assignment. I assume you<br />
are all adults and I do not have to chase you down for your work.
Material a b P T<br />
H2 0.246 0.02662 150 200<br />
CO2 3.604 0.04278 75 350<br />
H2O 5.460 0.03046 45 65<br />
Graded on:<br />
● Good programming<br />
● Neat & readable code<br />
● Comments<br />
● Use of selection<br />
● Use of repetition<br />
● Logic<br />
●<br />
Recommended Timeline:<br />
Converting the formula to C++ code Calculations<br />
Meaningful variables<br />
Be sure to echo your input values
Output <strong>–</strong> both results & format Input <strong>–</strong> prompting & use<br />
Sept 23 Sept 26 Sept 27 Oct 7<br />
Walked through the program and solved it by hand Pseudocode written<br />
Starting writing the program<br />
Program completed and running tests