In: Computer Science
For any gas whose internal energy depends on temperature only,
the relation between pressure p, molar volume v, and absolute
temperature T can be approximated by using the Ideal Gas law: ??=??
where R is the universal gas constant. If p is measured in
atmospheres, v in liters/mole, and T in Kelvin, then R=0.08205
????? ?????? ?.
However, for certain physical conditions (notably high T and/or
high p), gases may behave in a nonideal way. A more general
description of their behavior is given by the following
higher-order approximation, known as the Beattie-Bridgeman
Equation: ?=???+??2+??3+??4,
where ?,?,and ? are temperature dependent quantities given as
follows: ?=?0??−?0−???2 ; ?=−?0???+?0?−?0???2 ; ?=?0????2.
Constants ?0,?0,?,?,and ? have been determined by fitting curves to
experimental data. For methane (CH4), the values of the constants
(in units consistent with the ones above) are: ?0=2.2769;
?0=0.05587; ?=0.01855; ?=−0.01857; and ?−12.81?4.
a. (24 points) Write a program that, when given T in kelvin and p
in atmospheres, uses Muller’s Method to solve the Beattie-Bridgeman
Equation for the molar volume of CH4. You are not required use
complex variables, but you should include a section in your program
that checks to see whether ??+1 is complex, and, if it is, stops
the method. Close initial guesses chosen in part b will allow you
to find the root without venturing into the complex plane. Try to
reduce the number of function evaluations.
Before the iteration begins, your program should print the starting
estimates ?−2,?−1,?0 and their corresponding ?(?) values. At each
iteration, your program should print out the iteration number
(?),??,?(??), and the quantity |??−??−1||??|. Implement a
convergence criterion of the form: |??−??−1||??|≤?,?ℎ???
?=10−5
When your program finishes running, it should either print out the
converged solution and the number of iterations required, or else
it should print out a statement that a solution could not be found
(perhaps because the method found a complex ??+1.
b. (8 points) Run your program for the following data (note that
there are 10 possible combinations): ?=500 and 1500 ?,with
?=1,5,10,50 and 100 atm. In each case, choose your own starting
points (perhaps using the Ideal EoS).