1 / 28

Finding roots of equations using the Newton-Raphson method

Finding roots of equations using the Newton-Raphson method. Home. HOME. Introduction. Petroleum Exercise. Petroleum Exercise: Preliminaries. Useful Info. Resources. Quiz. Learning Objectives. Learning objectives in this module

Download Presentation

Finding roots of equations using the Newton-Raphson method

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Finding roots of equations using the Newton-Raphson method

  2. Home HOME Introduction Petroleum Exercise Petroleum Exercise: Preliminaries Useful Info Resources Quiz

  3. Learning Objectives • Learning objectives in this module • Develop problem solution skills using computers and numerical methods • Review of the Newton-Raphson method • Develop programming skills using FORTRAN • FORTRAN elements in this module • input/output • loops • format

  4. Introduction • Finding roots of equations is one of the oldest applications of mathematics, and is required for a large variety of applications, also in the petroleum area. A familiar equation is the simple quadratic equation (1) where the roots of the equation are given by  (2) • These two roots to the quadratic equation are simply the values of x for which the equation is satisfied, i.e. the left side of eq. (1) is zero. • How would you do this in Fortran? Think it through and see this of how it could be done Example More

  5. Introduction • In a more general form, we are given a function of x, F(x), and we wish to find a value for x for which: • The function F(x) may be algebraic or transcendental, and we generally assume that it may be differentiated. • In practice, the functions we deal with in petroleum applications have no simple closed formula for their roots, as the quadratic equation above has. Instead, we turn to methods for approximation of the roots, and two steps are involved: 1 Finding an approximate root • Refining the approximation to wanted accuracy • The first step will normally be a qualified guess based on the physics of the system. For the second step, a variety of methods exists. Please see the textbook for a discussion of various methods. More

  6. Introduction • Here, we will concern ourselves with the Newton-Raphson method. For the derivation of the formula used for solving a one-dimensional problem, we simply make a first-order Taylor series expansion of the function F(x) (4) Let us use the following notation for the x-values: (5) Then, eq. (4) may be rewritten as (6) More

  7. Introduction • Setting Eq. (6) to zero and solving for xk+1 yields the following expression (7) • This is the one-dimensional Newton-Raphson iterative equation, where represents the refined approximation at iteration level k+1, and is the approximation at the previous iteration level (k). View Graphic Illustration

  8. Graphic Illustration F(x) x • Graphically, the method is illustrated in the figure below. The first approximation (qualified guess) of the solution (x1) is around 1,6. The tangent to the function at that x-value intersects the x-axis at around 3,3 (x2). The tangent at that point intersects at around 2,4 (x3), and the fourth value (x4) is getting very close to the solution at around x=2,7 See the Newton-Raphson method - animated HERE

  9. Petroleum Exercise:Preliminaries Equations of State (EOS) are used for description of PVT-behavior (Pressure-Volume-Temperature) of hydrocarbon gases. One such equation is the Beattie-Bridgeman equation: (8) P is pressure in atmospheres (atm) V is molar volume (liter/g mole) T is temperature (oK) R is the universal gas constant (0,08205 liter-atm / oK-g mole) Next

  10. Beta Equations of State (EOS) are used for description of PVT-behavior (Pressure-Volume-Temperature) of hydrocarbon gases. One such equation is the Beattie-Bridgeman equation: (8) P is pressure in atmospheres (atm) V is molar volume (l/g mole) T is temperature (oK) R is the universal gas constant (0,08205 liter-atm / oK-g mole) A0, B0, a, b, c are gas specific constants Next

  11. Gamma Equations of State (EOS) are used for description of PVT-behavior (Pressure-Volume-Temperature) of hydrocarbon gases. One such equation is the Beattie-Bridgeman equation: (8) P is pressure in atmospheres (atm) V is molar volume (l/g mole) T is temperature (oK) R is the universal gas constant (0,08205 liter-atm / oK-g mole) A0, B0, a, b, c are gas specific constants Next

  12. Delta Equations of State (EOS) are used for description of PVT-behavior (Pressure-Volume-Temperature) of hydrocarbon gases. One such equation is the Beattie-Bridgeman equation: (8) P is pressure in atmospheres (atm) V is molar volume (l/g mole) T is temperature (oK) R is the universal gas constant (0,08205 liter-atm / oK-g mole) A0, B0, a, b, c are gas specific constants Next

  13. Petroleum Exercise:Preliminaries PV Z = RT After solving for the root of the eq. (8), ie. for the value for V that satisfies the equation for one particular set of pressure and temperature, we may find the corresponding compressibility factor (Z-factor) for the gas using the formula (the gas law for a real gas): (12) PV = ZRT Which can be rearranged to ... (obviously) Next

  14. Petroleum Exercise:Preliminaries The procedure for the exercise is described in the following. First, we rewrite the Beattie-Bridgeman equation as: (13) Then, we take the derivative of the function F(V) at constant Pand T Try yourself! What is the derivative of F (V)? Answer (click) then check the

  15. Quiz Did you really try?? Click the correct solution and see if you still know your maths A) B)

  16. Right Answer Right Answer!! BACK

  17. Wrong Answer Sorry, Wrong Answer!! BACK

  18. Petroleum Exercise:Preliminaries Now, the derivate of the function F(V) at constant P & T being (14) using the Newton-Raphson formula of eq. (7), we may find the root of Eq. (13) iteratively and after reducing the fraction, we get where k is the iteration counter More

  19. Petroleum Exercise:Preliminaries For the first iteration (k=1) we need a start value V1. Here, we estimate a value using the ideal gas law (assuming Z=1): or PV=RT V1=RT / P The iterative procedure is terminated when the relative change in V is less than a prescribed convergence criterion, e, i.e.

  20. Petroleum Exercise Tasks to be completed Make a FORTRAN program that uses the Newton-Raphson method to solve the Beattie-Bridgeman equation for molar volume (V) for any gas (i.e.. for any set of the parameters A0, B0, a, b, c) at a given pressure (P) and a given temperature (T). After finding the volume (V), the compressibility factor (Z) should be computed. The computer program will read all parameters, and pressure and temperature, from the input file, and should write the computed parameters, pressure and temperature, and computed compressibility factor, for each set of pressure and temperature to the output file. Run the computer program for This data set Make a plot of compressibility factor vs. pressure for the two different temperatures (on the same figure). 1 2 3

  21. Petroleum Exercise (continued) Parameter P (atm) Value T (C) Ao 1 2,2789 0 Bo 2 0,05587 0 a 5 0,01855 0 10 b -0,01587 0 c 20 128000 0 40 0 60 0 80 0 100 0 120 0 140 0 160 0 180 0 200 0 1 200 2 200 5 200 10 200 20 200 40 200 60 200 80 200 100 200 120 200 140 200 160 200 180 200 200 200 Use the following set of data for the gas (methane) Make computations for the following pressures and temperatures. (Remember that K=273,15+0C) Use a convergence criterion of 0.000001, and set max allowed number of iterations to 20 Useful info and tip on the Fortran Program HERE

  22. Useful Info For the Newton-Raphson program • Include an input and an output file. • For the iterative operation, the DO loop is recommended. • The convergence criterion should be tested with the IF statement • Find a reasonable format in which to present your calculations All clear? Go to Work!! Resources

  23. Resources Introduction to Fortran Fortran Template here The whole exercise in a printable format here Web sites • Numerical Recipes • Fortran Tutorial • Professional Programmer's Guide to Fortran77 • Programming in Fortran77

  24. Quiz • This section includes a quiz on the topics covered by this module. • The quiz is meant as a control to see if you have learned some of the most important features • Hit object to start quiz

  25. General information About the author

  26. FAQ • No questions have been posted yet. However, when questions are asked they will be posted here. • Remember, if something is unclear to you, it is a good chance that there are more people that have the same question For more general questions and definitions try these Dataleksikon Webopedia Schlumberger Oilfield Glossary

  27. References W. H. Preuss, et al., “Numerical Recipes in Fortran”, 2nd edition Cambridge University Press, 1992 • References to the textbook : Newton-Raphson Method Using Derivative: page 355 • The Textbook can also be accessed online: Numerical Recipes in Fortran

  28. Summary Subsequent to this module you should... • be able to translate a problem to Fortran code • write and handle DO loops • have a feel for the output format • know the conditional statements and use the IF structure

More Related