Академический Документы
Профессиональный Документы
Культура Документы
To take account of deviations from ideal behaviour by real gases a modified van der Waals
Equation of State can be employed, given as:
8𝑇𝑅 27
𝑃𝑅 = − Equation 1
8𝜙−1 64𝜙2
Where 𝑃𝑅 is the reduced gas pressure, 𝑇𝑅 is the reduced absolute temperature and 𝜙 is a
corrected molar volume.
Tasks
1. Write Equation 1 as a Matlab function FOR reduced temperatures of 0.85, 0.9, 0.95
and 1, calculate the reduced pressure for molar volumes in the range of 0.15 to 1.75
with an interval of 0.02. Plot the four pressure isotherms (pressure on the y-axis,
molar volume on the x-axis) on a logarithmic y-scale using different scatter
symbols for each profile. Show a fifth dashed line profile at a constant reduced
pressure of 0.6 and label each of the 5 profiles in a legend.
2. Consider the isotherm at a reduced temperature of 0.9. As can be seen from your plot,
three different values of ϕ correspond to the same reduced pressure of 0.6. It is
possible to use Newton’s Method, described in the lecture slides, to find the three
values of 𝜙 for which the reduced pressure is 0.6. First, write a rearranged
expression for the van der Waals equation of state in the form 𝒇(𝝓) = 𝟎. Second,
𝒅𝑷
write an expression for the first derivative of pressure, 𝒅𝝓 = 𝒇(𝝓), and create a
new Matlab function to calculate the derivative of pressure for a given molar volume
and temperature.
3. For a function 𝑓(𝑥), Newton’s method uses the function and its derivative to solve for
the roots of the function, i.e. the values of 𝜙 such that 𝑓(𝜙) = 0 in this instance. Draw
a block diagram to demonstrate the processing steps required to iterate to within
a defined tolerance of an exact root using Newton’s method (see Figure 1 for
reference). Write a Matlab function which uses your Newton’s method algorithm to
iterate towards each of the three roots from initial estimates based on observations
from your graph in part 1. Your function should contain a ‘loop’ which updates the
estimated root until the function falls below a given tolerance (tol), 𝑓(𝜙) < 𝑡𝑜𝑙. How
many iterations of the loop are required to converge to within your chosen tolerance?
Comment on the physical significance (property of a gas) of each of these three
roots you have found.
4. Append some additional lines of code to the bottom of the function in part 3 to calculate
(1) the area between the first and second root and (2) the area between the second
and third root. In each case define a linearly spaced vector 50 values in length between
the lower and upper root to form a discretised dataset and approximate the areas
between the roots using the trapezium rule. Matlab has an in-built function to
numerically solve integrals with the trapezium rule called ‘trapz’, use the ‘help’ function
in Matlab to understand the syntax of this function.
5. For a given pressure isotherm, a characteristic reduced pressure will exist whereby
the area between the first and second root will be the same in magnitude as that
between the second and third root. The ‘block diagram’ in Figure 1 describes a basic
‘goal seek’ algorithm to iterate towards this solution and stop when the sum of the two
areas falls below a defined tolerance. Write a Matlab script based on this diagram to
solve for the characteristic reduced pressure for a reduced temperature of 0.9. How
many iterations of the goal seek loop are required to converge within tolerances
of 10-3 and 10-5? Create a plot (on linear axes) of the pressure isotherm between
the smallest and largest root along with a linear profile at the characteristic
reduced pressure, label the two profiles accordingly in a clear legend.
Submission
Overleaf, you should include four (clearly commented) Matlab codes in appendices as follows:
Appendix A – the function to calculate pressure using the modified van der Waals equation
Appendix B – the function to calculate the derivative of pressure with respect to molar volume
Appendix C – the function using the Newton-Raphson method to identify three roots and the
areas between each pair of roots using the trapezium rule
Appendix D – a Matlab script which includes the loop to ‘goal seek’ the characteristic pressure
and create the two figures included in your submission.
Calculate isotherm roots
Accept 𝑷𝑹 as the
characteristic pressure
No
Yes No
Figure 1: Block diagram of a goal seek algorithm to find the characteristic pressure of a pressure
isotherm whereby the areas between two pairs of its roots are equal in magnitude