finding roots of equations using the newton-raphson method
DESCRIPTION
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 - PowerPoint PPT PresentationTRANSCRIPT
Finding roots of equations using the
Newton-Raphson method
FAQReferenc
esSummar
yInfo
Learning Objectives
Introduction
Petroleum Exercise:
Preliminaries
Petroleum Exercise
Useful info
Resources
Quiz
Home
HOME
Introduction
Petroleum Exercise:
Preliminaries
Petroleum Exercise
ResourcesUseful Info
Quiz
FAQReferenc
esSummar
yInfo
Learning Objectives
Introduction
Petroleum Exercise:
Preliminaries
Petroleum Exercise
Useful info
Resources
Quiz
Learning objectives in this module
1. Develop problem solution skills using computers and numerical methods
2. Review of the Newton-Raphson method3. Develop programming skills using FORTRAN
FORTRAN elements in this moduleinput/outputloopsformat
Learning Objectives
FAQReferenc
esSummar
yInfo
Learning Objectives
Introduction
Petroleum Exercise:
Preliminaries
Petroleum Exercise
Useful info
Resources
Quiz
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
ax2 bx c 0
x b b2 4ac
2a
Example
More
FAQReferenc
esSummar
yInfo
Learning Objectives
Introduction
Petroleum Exercise:
Preliminaries
Petroleum Exercise
Useful info
Resources
Quiz
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 root2 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.
F(x) 0
More
FAQReferenc
esSummar
yInfo
Learning Objectives
Introduction
Petroleum Exercise:
Preliminaries
Petroleum Exercise
Useful info
Resources
Quiz
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)
F(x h) F(x) h F (x)
xk x
xk1 x h
F(xk1) F(xk) xk1 xk F (xk)
More
FAQReferenc
esSummar
yInfo
Learning Objectives
Introduction
Petroleum Exercise:
Preliminaries
Petroleum Exercise
Useful info
Resources
Quiz
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).
xk1 xk F(xk )F (xk)
View Graphic Illustration
FAQReferenc
esSummar
yInfo
Learning Objectives
Introduction
Petroleum Exercise:
Preliminaries
Petroleum Exercise
Useful info
Resources
Quiz
Graphic Illustration
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,7F(x)
x
x1
x2
x3
x4
See the Newton-Raphson method - animated
HEREHERE
FAQReferenc
esSummar
yInfo
Learning Objectives
Introduction
Petroleum Exercise:
Preliminaries
Petroleum Exercise
Useful info
Resources
Quiz
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)
432 VVVV
RTP
Next
FAQReferenc
esSummar
yInfo
Learning Objectives
Introduction
Petroleum Exercise:
Preliminaries
Petroleum Exercise
Useful info
Resources
Quiz
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
432 VVVV
RTP
)9(200 T
RcARTB
Next
FAQReferenc
esSummar
yInfo
Learning Objectives
Introduction
Petroleum Exercise:
Preliminaries
Petroleum Exercise
Useful info
Resources
Quiz
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
432 VVVV
RTP
)10(2
000 T
RcBaAbRTB
Next
FAQReferenc
esSummar
yInfo
Learning Objectives
Introduction
Petroleum Exercise:
Preliminaries
Petroleum Exercise
Useful info
Resources
Quiz
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
432 VVVV
RTP
)11(2
0
T
bcRB
Next
FAQReferenc
esSummar
yInfo
Learning Objectives
Introduction
Petroleum Exercise:
Preliminaries
Petroleum Exercise
Useful info
Resources
Quiz
Petroleum Exercise:Preliminaries
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 = ZRTWhich can be rearranged to
...
(obviously)
Z =PV
RT
Next
FAQReferenc
esSummar
yInfo
Learning Objectives
Introduction
Petroleum Exercise:
Preliminaries
Petroleum Exercise
Useful info
Resources
Quiz
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 P and T
0)(432
PVVVV
RTVf
Try yourself! What is the
derivative of F (V)?
then check the
Answer (click)
FAQReferenc
esSummar
yInfo
Learning Objectives
Introduction
Petroleum Exercise:
Preliminaries
Petroleum Exercise
Useful info
Resources
Quiz
Quiz
Did you really try??
Click the correct solution and see if you still know your maths
A)A)
B)B)
5432' 432
)(VVVV
RTVf
32'
32)ln()(
VVVRTVVf
FAQReferenc
esSummar
yInfo
Learning Objectives
Introduction
Petroleum Exercise:
Preliminaries
Petroleum Exercise
Useful info
Resources
Quiz
Right Answer
Right Answer!!Right Answer!!
BACKBACK
FAQReferenc
esSummar
yInfo
Learning Objectives
Introduction
Petroleum Exercise:
Preliminaries
Petroleum Exercise
Useful info
Resources
Quiz
Wrong Answer
Sorry, Wrong Answer!!Sorry, Wrong Answer!!
BACKBACK
FAQReferenc
esSummar
yInfo
Learning Objectives
Introduction
Petroleum Exercise:
Preliminaries
Petroleum Exercise
Useful info
Resources
Quiz
Petroleum Exercise:Preliminaries
Now, the derivate of the function F(V) at constant P & T being
5432' 432
)(VVVV
RTVf
)(
)('1
k
kkk Vf
VfVV
432 23
5234
1
kkk
kkkkkkk VVRTV
PVVVVRTVVV
where k is the
iteration counter
using the Newton-Raphson formula of eq. (7), we may find the root of Eq. (13) iteratively
and after reducing the fraction, we get
(14)
More
FAQReferenc
esSummar
yInfo
Learning Objectives
Introduction
Petroleum Exercise:
Preliminaries
Petroleum Exercise
Useful info
Resources
Quiz
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):
1
1
k
kk
V
VV
The iterative procedure is terminated when the relative change in V is less than a prescribed convergence criterion, , i.e.
PV=RTPV=RT oror VV11=RT / P=RT / P
FAQReferenc
esSummar
yInfo
Learning Objectives
Introduction
Petroleum Exercise:
Preliminaries
Petroleum Exercise
Useful info
Resources
Quiz
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 differenttemperatures (on the same figure).
1
2
3
FAQReferenc
esSummar
yInfo
Learning Objectives
Introduction
Petroleum Exercise:
Preliminaries
Petroleum Exercise
Useful info
Resources
Quiz
Petroleum Exercise (continued)
Parameter Value
Ao 2,2789
Bo 0,05587
a 0,01855
b -0,01587
c 128000
P (atm) T (C)1 02 05 010 020 040 060 080 0100 0120 0140 0160 0180 0200 01 2002 2005 20010 20020 20040 20060 20080 200100 200120 200140 200160 200180 200200 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)
Useful info and tip on the Fortran
Program
HEREHERE
Use a convergence criterion of
0.000001, and set max allowed number of
iterations to 20
FAQReferenc
esSummar
yInfo
Learning Objectives
Introduction
Petroleum Exercise:
Preliminaries
Petroleum Exercise
Useful info
Resources
Quiz
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!!
Resource
s
FAQReferenc
esSummar
yInfo
Learning Objectives
Introduction
Petroleum Exercise:
Preliminaries
Petroleum Exercise
Useful info
Resources
Quiz
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
Fortran Template
Newton-Raphson
Method
FAQReferenc
esSummar
yInfo
Learning Objectives
Introduction
Petroleum Exercise:
Preliminaries
Petroleum Exercise
Useful info
Resources
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
Quiz
Shockwave Flash Object
FAQReferenc
esSummar
yInfo
Learning Objectives
Introduction
Petroleum Exercise:
Preliminaries
Petroleum Exercise
Useful info
Resources
Quiz
General information
Title: Finding roots of equations using the Newton-Raphson method
Teacher(s): Professor Jon Kleppe
Assistant(s): Per Jørgen Dahl Svendsen
Abstract: Provide a good background for solving problems within petroleum related topics using numerical methods
4 keywords: Newtons Method, Loops, Fortran, Input/Output
Topic discipline:
Level: 2
Prerequisites: None
Learning goals: Develop problem solution skills using computers and numerical methods
Size in megabytes: 0.7 MB
Software requirements: MS Power Point 2002 or later, Flash Player 6.0
Estimated time to complete:
Copyright information: The author has copyright to the module and use of the content must be in agreement with the responsible author or in agreement with http://www.learningjournals.net.
About the author
FAQReferenc
esSummar
yInfo
Learning Objectives
Introduction
Petroleum Exercise:
Preliminaries
Petroleum Exercise
Useful info
Resources
Quiz
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
FAQReferenc
esSummar
yInfo
Learning Objectives
Introduction
Petroleum Exercise:
Preliminaries
Petroleum Exercise
Useful info
Resources
Quiz
References
W. H. Preuss, et al., “Numerical Recipes in Fortran”, 2nd editionCambridge 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
FAQReferenc
esSummar
yInfo
Learning Objectives
Introduction
Petroleum Exercise:
Preliminaries
Petroleum Exercise
Useful info
Resources
Quiz
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