• Tidak ada hasil yang ditemukan

New Curve Fitting Method for Petroleum Engineering Applications

N/A
N/A
Protected

Academic year: 2024

Membagikan "New Curve Fitting Method for Petroleum Engineering Applications"

Copied!
102
0
0

Teks penuh

(1)

i

New Curve Fitting Method for Petroleum Engineering Applications

By

Muhammad Aizuddin bin Mohd Rosli 13653

Dissertation submitted in partial fulfillment of the requirements for the

Bachelor of Engineering (Hons) (Petroleum)

SEPTEMBER 2014

Universiti Teknologi PETRONAS Bandar Seri Iskandar

31750 Tronoh Perak Darul Ridzuan

(2)

ii

CERTIFICATION OF ORIGINALITY

The author hereby declares that the contents of his submitted thesis are free from any material already published by another author nor does it contain statements lifted without due acknowledgement of the sources. He similarly attests that materials taken from other sources are properly quoted.

Thus, except those which have been duly acknowledged, recognized and quoted in the text, the content of this thesis has been authentically produced by the author himself though he may have received assistance from others on style, presentation and language expression.

(Muhammad Aizuddin bin Mohd Rosli)

(3)

iii

CERTIFICATION OF APPROVAL

New Curve Fitting Method for Petroleum Engineering Applications

By

Muhammad Aizuddin bin Mohd Rosli

A project dissertation submitted to the Petroleum Engineering Programme

Universiti Teknologi PETRONAS in partial fulfilment of the requirement for the

BACHELOR OF ENGINEERING (Hons) (PETROLEUM ENGINEERING)

Approved by,

(Samsul Ariffin bin Abdul Karim)

UNIVERSITI TEKNOLOGI PETRONAS TRONOH, PERAK

SEPTEMBER 2014

(4)

iv

ABSTRACT

Data collected in petroleum engineering industry may come in a non-distribution form. Usually the data is really important for the approximation and future prediction purposes. It may lead to the increasing of time and cost if wrong prediction happened.

So, to avoid the problems that may occurred, the best fit is needed to represent the data.

Curve fitting is the process of creating a curve or mathematical function that will produce the best fit to a series of data points. It usually uses to design and control the shape of complex curves and surfaces. There are several of methods of approximation has been introduced such are Polynomial, Gaussian, Sine, Fourier Series and Smoothing Spline but unfortunately not yet meet the high expectations. For example, Polynomial approach in the algorithm which contains strongly oscillating properties and huge number of arithmetical operations for computations. Unsuitable type of curve fitting may destroy the original feature of the data. This research is about the invention of new curve fitting method that combined two interpolation method which are Cubic Spline and Piecewise Cubic Hermite Interpolation Polynomial (PCHIP) with the reduction of data method. This research will show the comparison between the new curve fitting method and the existing method by applying it to several sets of petroleum engineering data.

(5)

v

ACKNOWLEDGMENT

First and foremost, all thanks and praise to Allah the almighty for the guidance and blessing for giving the strength to pursue the research for this final year project. In this opportunity, I would like to convey my deepest appreciation and gratitude to my supervisor, Mr Samsul Ariffin bin Abdul Karim for his guidance, advice and knowledge throughout the duration of the project. Without his support and encouragement, I could not harvest experiences and knowledge as much that I wanted.

Besides, the appreciation will not complete without thanking my co-supervisor, Izzatullah Muhammad from Emerson Process Management Kuala Lumpur for his assistance and advices. I also would like to thank the Petroleum Engineering Department of Universiti Teknologi Petronas, the lecturers and the coordinators of the final year project for their readiness in providing full support and co-operation during the project period

Last but not least I, I like to take this opportunity to express my appreciation to my family, especially to my parent for giving me full support to complete this industrial training. May ALLAH SWT bless them all and thank you so much for their support.

(6)

vi

TABLE OF CONTENTS

CERTIFICATION OF ORIGINALITY ... ii

ABSTRACT ... iv

ACKNOWLEDGMENT ... v

CHAPTER 1... 1

1.1 BACKGROUND ... 1

1.2 PROBLEM STATEMENT ... 1

1.3 OBJECTIVES... 2

1.4 SCOPE OF STUDY... 2

1.5 THE RELEVANCY OF THE PROJECT ... 3

1.6 FEASIBILITY OF THE PROJECT WITHIN THE SCOPE AND TIME FRAME ... 3

CHAPTER 2... 4

2.1 INTRODUCTION OF INTERPOLATION CURVE ... 4

2.2 OVERVIEW OF APPROXIMATION AND INTERPOLATION THEORY ... 5

2.3 Computing Cubic Spline Interpolation ...12

2.4 INTRODUCTION TO CURVE FITTING ...22

CHAPTER 3...28

3.1 PETROLEUM ENGINEERING: DATA COLLECTION ...28

3.2 Research Methodology ...29

3.2 Project Activities ...29

3.3 Gantt Chart ...30

CHAPTER 4...31

4.1 Algorithm ...31

4.2 Framework New Curve Fitting Method ...33

CHAPTER 5...34

5.1Data Interpolation ...34

5.2 Error Analysis ...40

5.3 Curve Fitting Analysis ...51

5.4 Data fitting by using new curve fitting method ...74

(7)

vii

CHAPTER 6...88

6.1 Conclusion ...88

6.2 Recommendation ...88

REFERENCES ...89

PUBLICATIONS ...91

(8)

viii LIST OF FIGURES

Figure 1: Interpolating and Approximation Curve ... 4

Figure 2: High Order Polynomial Interpolation ... 6

Figure 3: Cubic Spline Interpolation Car Accelerating ... 20

Figure 4: Linear Interpolation (Measured Depth vs Torque)... 34

Figure 5: Pchip Interpolation (Measured Depth vs Torque) ... 35

Figure 6: Cubic Spline Interpolation (Measured Depth vs Torque) ... 35

Figure 7: Combined Interpolation (Measured Depth vs Torque)... 36

Figure 8: Linear Interpolation (Measured Depth vs Fluid Flow) ... 37

Figure 9: Pchip Interpolation (Measured Depth vs Fluid Flow) ... 37

Figure 10: Cubic Spline Interpolation (Measured Depth vs Fluid Flow) ... 38

Figure 11: Combined Interpolation (Measured Depth vs Fluid Flow) ... 38

Figure 12 : Original function, ( f

 

x x2 8 ) in [0, 4]. ... 41

Figure 13: Pchip Interpolation, ( f

 

xx28) in [0,4]. ... 42

Figure 14: Spline Interpolation, ( f

 

xx28 ) in [0,4] ... 42

Figure 15: Combined Interpolation, ( f

 

xx28 ) in [0,4]. ... 43

Figure 16: Original Function, ( f x( )2exx2 ) in [0, 4]. ... 45

Figure 17: Pchip Interpolation, ( f x( )2exx2 ) in [0, 4]. ... 45

Figure 18: Spline Interpolation, ( f x( )2exx2 ) in [0, 4]. ... 46

Figure 19: Combined Interpolation ( f x( )2exx2 ) in [0, 4]... 46

Figure 20: Original Function, ( f x( )cos ( )10 x ) in [0,4]. ... 48

Figure 21: Pchip Interpolation ( f x( )cos ( )10 x ) in [0,4]. ... 48

Figure 22: Spline Interpolation ( f x( )cos ( )10 x ) in [0,4]. ... 49

Figure 23: Combined Interpolation ( f x( )cos ( )10 x ) in [0,4]. ... 49

Figure 24: Polynomial Curve Fitting Method, n=1 (measured depth vs torque) ... 54

Figure 25: Polynomial Curve Fitting Method, n=2 (measured depth vs torque) ... 55

(9)

ix

Figure 26: Polynomial Curve Fitting Method, n=3 (measured depth vs torque) ... 55

Figure 27: Polynomial Curve Fitting Method, n=6 (measured depth vs torque) ... 55

Figure 28: Polynomial Curve Fitting Method, n=7 (measured depth vs torque) ... 56

Figure 29: Polynomial Curve Fitting Method, n=8 (measured depth vs torque) ... 56

Figure 30: Polynomial Curve Fitting Method, n=9 (measured depth vs torque) ... 57

Figure 31: Gaussian Curve Fitting Method, n=1 (measured depth vs torque) ... 57

Figure 32: Gaussian Curve Fitting Method, n=2 (measured depth vs torque) ... 58

Figure 33: Fourier Curve Fitting Method, n=1 (measured depth vs torque) ... 58

Figure 34: Fourier Curve Fitting Method, n=2(measured depth vs torque) ... 59

Figure 35: Sine Curve Fitting Method, n=1 (measured depth vs torque) ... 59

Figure 36: Sine Curve Fitting Method, n=2 (measured depth vs torque) ... 60

Figure 37: Smoothing Spline Curve Fitting Method, p=0.7 (measured depth vs torque) ... 60

Figure 38: Smoothing Spline Curve Fitting Method, p=0.8 (measured depth vs torque) ... 61

Figure 39: Smoothing Spline Curve Fitting Method, p=0.9 (measured depth vs torque) ... 61

Figure 40: Smoothing Spline Curve Fitting Method, p=0.95(measured depth vs torque) ... 61

Figure 41: Smoothing Spline Curve Fitting Method, p=0.99 (measured depth vs torque) ... 62

Figure 43: Polynomial Curve Fitting Method, n=1 (measured depth vs fluid flow) ... 66

Figure 44: Polynomial Curve Fitting Method, n=2 (measured depth vs fluid flow) ... 66

Figure 45: Polynomial Curve Fitting Method, n=3 (measured depth vs fluid flow) ... 66

Figure 46: Polynomial Curve Fitting Method, n=4 (measured depth vs fluid flow) ... 67

Figure 47: Polynomial Curve Fitting Method, n=7 (measured depth vs fluid flow) ... 67

Figure 48: Polynomial Curve Fitting Method, n=8 (measured depth vs fluid flow) ... 68

Figure 49: Polynomial Curve Fitting Method, n=9 (measured depth vs fluid flow) ... 68

Figure 50: Gaussian Curve Fitting Method, n=1 (measured depth vs fluid flow) ... 69

Figure 51: Gaussian Curve Fitting Method, n=2 (measured depth vs fluid flow) ... 69

Figure 52: Fourier Curve Fitting Method, n=1 (measured depth vs fluid flow) ... 70

Figure 53: Fourier Curve Fitting Method, n=2 (measured depth vs fluid flow) ... 70

Figure 54: Sine Curve Fitting Method, n=1 (measured depth vs fluid flow) ... 71

Figure 55: Sine Curve Fitting Method, n=2 (measured depth vs fluid flow) ... 71

Figure 56: Smoothing Spline Curve Fitting Method, p=0.85 (measured depth vs fluid flow) .... 72

Figure 57: Smoothing Spline Curve Fitting Method, p=0.9 ... 72

Figure 58: Smoothing Spline Curve Fitting Method, p=0.95 (measured depth vs fluid flow) .... 73

(10)

x

Figure 59: Smoothing Spline Curve Fitting Method, p=0.99 (measured depth vs fluid flow) .... 73

Figure 61: Original PCHIP Interpolation ... 75

Figure 62: Original Cubic Spline Interpolation, Measured Depth vs Torque ... 75

Figure 63:PCHIP Interpolation (after divided into several segment and points removal), Measured Depth vs Torque... 76

Figure 64:Cubic Spline Interpolation (after divided into several segment and points removal), Measured Depth vs Torque... 76

Figure 65: New Curve Fitting Method, Measured Depth vs Torque ... 77

Figure 66: Original PCHIP Interpolation, Measured Depth vs Fluid Flow ... 79

Figure 67: Original Cubic Splines Interpolation, Measured Depth vs Fluid Flow ... 80

Figure 68:PCHIP Interpolation (after divided into several segment and points removal), Measured Depth vs Fluid Flow ... 80

Figure 69: Cubic Spline Interpolation (after divided into several segment and points removal), Measured Depth vs Fluid Flow ... 81

Figure 70: New Curve Fitting Method, Measured Depth vs Fluid Flow... 81

Figure 71: Original PCHIP Interpolation, Temperature Correction Factor ... 84

Figure 72:Original Cubic Spline interpolation, Temperature Correction Factor ... 84

Figure 73: PCHIP Interpolation (after divided into several segment and points removal), Temperature Correction Factor ... 85

Figure 74: Cubic Spline Interpolation (after divided into several segment and points removal), Temperature Correction Factor ... 85

Figure 75:New curve fitting method, Temperature Correction Factor ... 86

(11)

xi LIST OF TABLES

Table 1: Car Accelrating ... 17

Table 2: Comparison between PCHIP and Cubic Spline Interpolation ... 21

Table 3: Data Interpolation Analysis ... 39

Table 4: Function 1 ( f

 

xx2 8)... 40

Table 5: Function 2 ( f x( )2exx2) ... 44

Table 6: Function 3 ( f x( )cos ( )10 x ) ... 47

Table 7: Error analysis ... 50

Table 8: Measured Depth vs Torque (Curve Fitting) ... 51

Table 9:Measured Depth vs Fluid Flow (curve fitting) ... 63

Table 10:Measured Depth vs Torque (New Curve Fitting Method) ... 77

Table 11: Comparison of RMSE (measured depth vs torque) ... 79

Table 12: Measured Depth vs Fluid FLow (New Curve FItting Method) ... 82

Table 13 : Comparison of RMSE (measured depth vs fluid flow) ... 83

Table 14: Temperature Correction Factor (New Curve Fitting Method) ... 86

(12)

1

CHAPTER 1

INTRODUCTION

1.1 BACKGROUND

The project is related to the understanding and applications about the interpolation and curve fitting methods used as an approximation and optimization tools in petroleum engineering field. Splines are being use widely nowadays. The application of spline method could be observed in the most sophisticated petroleum engineering software nowadays such as Schlumberger Eclipse, CMG, Tempest, etc. Besides, spline is being applied widely especially in the well placement optimization and history matching alongside with other mathematical algorithms i.e. genetic algorithm and gradient based algorithm. This could be proven by Lee at el (1986) where they used splines for history matching purposes in single-phase two-dimensional reservoirs. The main objective of this work is to investigate the use of cubic spline and Piecewise Cubic Hermite Interpolating Polynomial (PCHIP) interpolation and curve fitting methods in petroleum engineering data by proposing a new curve fitting involving data reduction that outperform the existing method .To achieve this objective, this work will be conducted with assistance of mathematical simulation software, Matlab.

1.2 PROBLEM STATEMENT

Petroleum engineering data set is usually came in sparse distributed order which would be in non-uniform distributions and in order to obtain the best reservoir performance results, specific equations and algorithm are needed as a tool for the approximation technique (Mehdi, 2011). Various methods of approximation had been introduced to approach the best approximation in petroleum engineering performance but unfortunately not yet meet the high expectations. One of the weaknesses of those methods are they are using polynomials approach in the algorithm which contains strongly oscillating properties and huge number of arithmetical operations for computation. It may destroy the features of the original data (Karim, 2013). By choosing the unsuitable type of curve fitting will destroy the original feature of the data. So the

(13)

2

best curve fitting method needed in process to obtain the best fit that will represent the trend of data and for approximation purpose. Different types of interpolation and curve fitting methods will be approached in this project to overcome the weakness and as a part for constructing a new curve fitting method.

1.3 OBJECTIVES

1. To investigate the existing methods for data interpolation and data fitting such as Polynomial, Gaussian, Fourier, Sine and Spline Smoothing.

2. To propose a new curve fitting method to overcome the weakness of existing curve fitting methods. Our new curve fitting method are efficient and reliable with less error and data reduction.

3. To develop new algorithm based on new curve fitting method.

4. To compare the performance between new curve fitting method with the existing methods.

1.4 SCOPE OF STUDY

In this project, different types of interpolation and curve fitting method will be applied to the petroleum engineering data. All the data set will be analyzed by using all the different methods and the result will be compared to produce a smooth curve with piecewise polynomial attribute. Based on the best fit interpolation and curve fitting, the high integrity of well performance could be analyzed and the best results could be presented. A new data fitting method also will be applied in this project by proposing new algorithm involving data reduction

(14)

3 1.5 THE RELEVANCY OF THE PROJECT

This project is relevant to be conducted because data collected in petroleum engineering industry always come in non-uniform distribution and it is difficult to obtain the best fit to represent the data trend. Because of that matter, additional time and cost are needed to overcome the problems that may occur. Thus, it will lead to the loss in profit for the operator. In petroleum engineering whether in reservoir and drilling part, correct planning is needed to give the best performance result. So, the best estimation and approximation of the planning data are needed to avoid any problem occur during operation and give the best results.

1.6 FEASIBILITY OF THE PROJECT WITHIN THE SCOPE AND TIME FRAME

This project is feasible and can be finished within the time frame because it only needs several analyses from the real drilling report, internet articles and some opinion from the engineer in the petroleum engineering area. Most of this project contains are being conducted using the MATLAB software and it may takes about 2 to 3 months to be completed.

(15)

4

CHAPTER 2

LITERATURE REVIEW

In this section, three different parts of review will be made which are the interpolation, curve fitting and the new curve fitting method. All steps and equations will be explained in more detailed for every part.

2.1 INTRODUCTION OF INTERPOLATION CURVE

One of the mathematical representations that help user to design and control the shape of complex curves and surfaces is a spline curve. It can be divided into two different types of curves which are interpolating curve and approximation curve. Interpolating curve passes through each control point while approximation curve passes near to the control points but not necessarily through them

Figure 1: Interpolating and Approximation Curve

(16)

5

2.2 OVERVIEW OF APPROXIMATION AND INTERPOLATION THEORY Smooth and continuous curve to pass through or closer to a set of data points can be found by using the curve fitting method. Curve fitting method could indicate the best trend of data set (Won et al, 2005) without need to go through all the data points.

Two approaches can be done to fit the curve of a set of data points. The first one can be called as a Collocation, where every data point will be passed through by the curve. This can be used either when the data is accurate or the data are known to be generated by evaluating a complicated function at a discrete set of points (Singiresu, 2002).

There are three type of functions can be used to approximate a set of data points which are Polynomial, trigonometric or exponential. Piecewise curve fitting is used where a specified function is made through sub-groups of data points in some cases.

Another approach is where the curve is made to represent the behavior of the data.

According to Singiresu (2002), this approach is convenient to be used when the number of unknown coefficients is less than the data points or when the data may have being disturbed by some noise or contain some errors. Kruger (n.d.) stated that the value of a function between data points can be estimated by using interpolation method without knowing the actual function.

According to Henrici. (1982), as cited in Kruger (n.d.), there are two major categories for the interpolation methods. First is the global interpolation where single equation that fits all the data point needs to be constructed and the degree of the polynomial equation mostly high. Even though smooth curve will be the result from this interpolation, it may lead to severe oscillation and it is not suitable to be applied in engineering applications.

The other category is the piecewise interpolation. Low degree of polynomial function will be constructed in this method. First degree polynomial can be known as a linear interpolation. Second degree polynomial is called as quadratic and lastly, the third

(17)

6

degree polynomial is cubic spline. The curve will be smoother with the increasing of the degree of spline.

For a given set of 𝑁+1 data points (𝑥0, 𝑦0), (𝑥1, 𝑦1),…..(𝑥𝑛, 𝑦𝑛), the objective is to find the 𝑁th order polynomial function that can match them. But, the unknown coefficients and equations will be increasing as the number of the data points are increases.

According to Singiresu (2002), the polynomial will tend to increase acutely due to the errors as the order 𝑛 is increasing. Singiresu (2002) stated that the high degree of polynomial often lead to the unnecessary oscillations and wiggles. Thus, the polynomial interpolation will not give an accurate interpretation to the given data. Therefore spline interpolation is the most suitable to be use becauselarge data point can be used and the data behavior can be maintained. There are three common spline interpolations used which are linear, quadratic, and cubic splines. Cubic spline is the most recommended if want to obtain a smoother curve. Figure below show the example of high order polynomial interpolation that show the wildly oscillations.

Figure 2: High Order Polynomial Interpolation

(18)

7

Thus, we may conclude that interpolation of the data by using the higher degree of polynomial may be resulting the interpolation oscillates wildly. This behavior is unacceptable and cubic spline interpolation can be used to overcome this problem. This is because cubic splines may avoid the wild oscillation as well as the overshoot and the obtained interpolating curves are acceptable or desirable as desired by the user or respective designer (Kruger, n.d.).

2.2.1 Linear Interpolation

According to Singiresu (2002), linear spline represents a straight line between the data points (knots). Let n1 data points be available as[𝑥𝑖, 𝑓(𝑥)],

0,1,2,... .

i n Singiresu (2002) explained that between two data points next to each other which is [x f xi1, ( i1)]and [x f xi, ( )]i , the equation of the line that join the two points is defined in Equation (1) where the function f xi( ) represent a set of 𝑛 piecewise linear equation (splines) using the n1 data points and Equation (2) is the slope between xi1

and xi.

According to Addendum (n.d.), there is no different between linear spline interpolation and linear polynomial interpolation. The author stated that linear splines still using the data from the two consecutive data points. Also at the interior points of the data, the slope will changes abruptly which means that the first derivative is not continuous at these points.

1

1 1

1

( ) ( )

( ) i i ( )

i i i

i i

f x f x

f f x x x

x x

;i1, 2,... .n (1)

(19)

8

1 1

( )i ( i )

i i

f x f x x x

(2)

2.2.2 Quadratic Spline

A type of spline where the second order polynomial approximates the data between two consecutive data points or knots. According to Singiresu (2002), the quadratic spline that given x f xi, ( ),i i0,1, 2,....,n to denoten1data points, the equation of the quadratic spline between the data points xi1, (x )f i1 and x fi, (x )i can be expressed in Equation (2) where ,a bi iand ci are the unknown coefficients.

( ) 2; 1, 2,...,

i i i i

f x  a b x c x i  n (3)

3n coefficients need to be evaluated for the

n

intervals. To calculate the 3n unknowns, 3n equations need to be build and will be solved simultaneously. According to Singiresu (2002), these 3n equations can be found by the following conditions.

The function value at the interior knotxi must be equal to f

 

xi whether it is computed using f

 

xi or f

 

xi1 which is

( ) 2 ( ); 1, 2,... ,

i i i i i i i i

f x  a b xc xf x in

(4)

and

2

1( ) 1 1 1 ( ); 1, 2,... 1,

i i i i i i i i

f xab xc xf x in (5)

Equations (3) and (4) gives (2n2) conditions.

(20)

9

The end points

x

0and

x

n must be passed by first and last functions, f x1( )and f xn( ).

2

1( 0) 1 1 0 1 0 ( 0),

f x  a b xc xf x (6)

and

( ) 2 ( ).

n n n n n n n n

f xab xc xf x (7)

The slope of two quadratic spline or first derivative is continuous at the interior points.

For example, the derivative of Equation (5) gives the slope as

'( ) 2 ; 1, 2,....,

i i i i

f x  b x c in (8)

and hence, the continuity of slope leads to

' '

1 1

( ) ( ),

i i i i

f xf x (9)

that is

1 1

2 2 ; 1, 2,.... 1.

i i i i i i

bc xbc x in (10)

Equation above give (𝑛- 1) conditions.

Thus, the total number of equations is (3n - 1) equations. One more equation is needed to calculate all3nconstants. Several possible conditions can be used for the calculations.

For example, at final point (xn) the second derivative can be assumed to be zero.

"

( ) 2 0,

n n n

f xc  orcn 0. (11)

(21)

10 2.2.3 Cubic Spline

Won et al. (2005) stated in his thesis that the smoothness of the quadratic curve is not smooth enough since the second-order derivatives of quadratic polynomial for adjacent subintervals cannot be made to conform for each other. However, cubic splines have proven its goodness in term of complexity and accuracy. A cubic spline through a set of data points is a curve obtained by joining each point to the next with a cubic polynomial, where the important part is that the adjoining cubic spline must a have matching first and second derivative at their common point. The equation of the cubic spline in theith

interval[xi1, ]xi , is show in Equation (12).

2 3

( ) ; 1, 2,... ,

i i i i i

f x  a b x c x d x in (12)

whereai,bi,ci,and di is the 4n coefficients for i1, 2,... ,n

According to Hoffman (2001) these 4n coefficientsai,bi, ciand di can be evaluated by using the following condition:

1. The function values f xi( ) f i( 2,3... ),n must be the same in the two splines on either side of xi at all of the n-1 interior points. This constraint yields 2(n-1) conditions.

2. The slope of the first order derivative of the two splines on either side of point xi

must be equal at all of the n-1 interior points.

' '

( ) 1( )

i i i i

f xf x . (13)

This constraint yields (n-1) conditions.

(22)

11

3. The second derivative of the two splines on either side of point xi must be equal at all of the n1 interior points. This constraint yields (n-1) conditions.

4. The first and last spline must pass through the first and last points. This shown in Equation (14).

1( )1 1

f xf ,

1 1

( )

n n n

f xf . (14)

This yield two conditions.

5. To obtain unique polynomial, two more equations are needed. Several types of conditions can be used to obtain the two equations;

 For this project, only natural spline will be used in which set the two conditions as in Equation (15).

" "

( )0 0, ( n) 0

f xf x (15)

Thus, the curvature must be specified at the first (

x

1) and last (

x

n1)points as shown in Equation (16).

" "

1( )1 1

f xf and f"(xn1)fn"1. (16)

This constraint yields 2 conditions.

(23)

12 2.3 Computing Cubic Spline Interpolation

To fit a different interpolation coefficient, cubic spline interpolation to each successive pair of points, we will define a set of functionsS xi( ), on each interval [ ,x xi i1].To keep the solution smooth we would like the match the first and second derivatives, as well as the function itself, at each grid point. The conditions are

i( )i i

f xf (17)

1 1 1

( ) ( )

i i i i

f xf x (18)

' '

1 1 1

( ) ( )

i i i i

f xf x (19)

" "

1 1 1

( ) ( )

i i i i

f xf x (20)

Equation (17) until (20) gives a total of 4-2𝑛 conditions. As stated before, for cubic spline interpolation, we need 4n parameters to be determined. So, we lack of two more condition 4n-2 < 4n. We can uniquely determine a set of cubic spline by adding two additional conditions. There exists many type of additional condition somehow, but as stated before natural boundary conditions will be used.

" "

0( )0 n 1( n) 0

f xf x  (21)

General equation of cubic spline is given as follows:

(22)

Substituting Equation (17) into Equation (22), to find the value ai

2 3

( ) ( ) ( ) ( )

i i i i i i i

f x  a b xxc xxd xx

(24)

13

(23)

Next, from Equation (18), where hxi1xi

2 3

1

i i i i i i i i

ab hc hd ha (24)

Derive Equation (22) into 1st and 2nd order differentiation, will give the following:

' 2

( ) 2 ( ) 3 ( )

i i i i i i

f x  b c xxd xx (25)

"

( ) 2 6 ( )

i i i i

f xcd xx (26)

Then we substitute Equation (19) and (20) into Equation (25) and (26)

2

2 3 1

i i i i i i

bc hd hb (27)

2ci6d hi i 2ci1 (28) As stated before, we lack of two additional conditions, so first we define one additional number.

1 3 1 1

n n n n

ccd h (29)

To obtain the parameterdi, substitute Equation (21) into Equation (26).

0 0

c  and2cn 2ci16dn1hn10 (30)

i i

af

(25)

14

Rearranging the Equation (30), we get the equation fordi.

1

3

i i

i

i

c c

d h

 (31)

Thus we now have determined all of the aiand di are fully determined by theci.

Next, to get bi,substitute Equation (31) into Equation(24)

2 1 3

3 1

i i

i i i i i i i

i

c c

a b h c h h a

h

     (32)

Rearrange Equation (31), we obtained the following equation for 𝑏𝑖.

1

(2 1)

3

i i i

i i i

i

a a h

b c c

h

    (33)

Finally, to obtain the parameter ofci, first we reduce the index of Equation (17) by 1.

1 1

1 1

1

(2 )

3

i i i

i i i

i

a a h

b c c

h

    (34)

Then, substitute Equation (31) into Equation (27).

1 2 ( 1 )

i i i i i i i

b  b c hcc h  bi h ci( ici1) (35)

Again we reduce the index by 1

(26)

15

1 1( 1 )

i i i i i

bbh cc (36)

Substitute Equation (34) into the right hand side of Equation (36) and Equation (17) into the left hand side of Equation (20).

1 1 1

1 1 1 1

1

(2 ) (2 ) ( )

3 3

i i i i i i

i i i i i i i

i i

a a h a a h

c c c c h c c

h h

 

       (37)

Rearrange Equation (37)

1 1 1 1 1 1

1

3 i i 3 i i i i 2 (i i i ) i i

i i

a a a a

h c c h h c h

h h

 

     (38)

This equation is defined for i=0……,n-1. We can extend it to include an extra parameter anthat we actually not interested in, to give

0 1

0 0 1 1

2

1 1 2 2

2 1 2 1

2 1 1 0

1 0

1 1 2

1 2

)

)

)

3 3

( ) ( )

3 3

( ) ( )

1 0 0

2(

0 2(

0 0 2(

0 0 1

0

0

n n n n

n

n n n n

n n

h

h

h

a a a a

h h

a a a a

h h

c c

h h h

c

h h h

h h h

c

 

 

    

 

 

  

 

 

  

 

  

 

 

  

  

 

 

    

 

 

 

 

  

 

 

 

 

(39)

(27)

16

If the grid points are equally spaced with hih for some numberh, then

0

1 0 1 2

2

2 1

2 3

2

1 0 0 0

4 0

0 4 0

0 0 4

0 0 1 0

n n n

n

a a

h

a a

c c

h h h a

c

h h h

h h h a

c

    

 

      

   

 

   

 

   

    

      

    

    

    

(40)

The linear system of Equations in (39) and (40) are triadiagonal and positive definite.

Thus the solution will unique and 𝐿𝑈 decomposition, Thomas algorithm or Gauss Jordan can be used to solve the linear equation.

(28)

17

2.3.1 Computing Cubic Spline Interpolating Example

Given data below is a simple data of car velocity versus time when the car is accelerating.

Table 1: Car Accelrating

1. First we find aiby using Equation (23).

ao=25 , a1=36 , a2=52 , a3=59

2. Next by using Equation (40), we can find the parameter of c since the value of h is equally spaced (h1). The right hand side is equal to the linear system of equation (in matrix form)

So, it becomes,

0 1 2 3

1 0 0 0 0

1 4 1 0 15

0 1 4 1 27

0 0 0 1 0

c c c c

    

    

 

   

 

   

 

   

    

(41)

Multiplying the matrices on the left and setting like components equal give the equivalent system of equations,

Time,s Velocity, m.p.h.

2 25

3 36

4 52

5 59

(29)

18

By solving the system of linear, we obtain the value of c.

1 2 3

0, 5.8, 8.2, 0

cocc   c  (42)

3. To calculate the value of parameter b, we use Equation (33) with h=1

(36 35) 1

(2(0) 5.8)

1 3

9.07

bo  

1

(52 36) 1

(2(5.8) ( 8.2)

1 3

14.87

b   

2

(59 52) 1

(2( 8.2) 0)

1 3

12.47

b   

(43)

4. Next, for the value of parameter 𝑑, we use Equation (31).

0

5.8 0 3 1.93

d

1

( 8.2 5.8) 3 4.67 d

 

2

(0 ( 8.2) 3 2.73 d 

 (44)

(30)

19

5. Combine Equation (41), (42), (43) and (44) into general equation of cubic spline.

2 3

0 0 0 0 0 0 0 0

2 3

3 2

( ) ( ) ( ) ( )

25 9.07( 2) 0( 2) 1.93( 2) 1.93 11.58 32.23 8.58

f x a b x x c x x d x x

x x x

x x x

      

      

   

2 3

1 1 1 1 1 1 1 1

2 3

3 2

( ) ( ) ( ) ( )

36 14.87( 3) 5.8( 3) ( 4.67)( 3) 4.67 47.83 146.02 169.68

f x a b x x c x x d x x

x x x

x x x

      

       

   

2 3

2 2 2 2 2 2 2 2

2 3

3 2

( ) ( ) ( ) ( )

52 12.47( 4) ( 8.2)( 4) 2.73( 4) 2.73 40.96 209.11 303.80

f x a b x x c x x d x x

x x x

x x x

      

       

   

Thus,

 

 

 

3 2

3 2

3 2

1.93 11.58 32.23 8.58, 2,3 ( ) 4.67 47.83 146.02 169.68, 3, 4

2.73 40.96 209.11 303.80 4,5

x x x

f x x x x

x x x

 

 (45)

(31)

20 2.3.2 Matlab Implementation

The main objective of this section is to show the use of cubic spline interpolation by using matlab scheme. In Matlab, the cubic spline can be applied by using the command line: interp1 (x,y,’spline’)

2.3.2.1 Example

%Sample matlab coding for data interpolation by using cubic spline x=2:5;

y=[25 36 52 59];

x1=2:0.01:5;

y1=interp1(x,y,x1,'spline');

plot(x,y,'o',x1,y1,'-')

Figure 3: Cubic Spline Interpolation Car Accelerating

(32)

21

2.3.3 Comparison between Piecewise Cubic Hermite Interpolating Polynomial and Cubic Spline Interpolation

Table 2: Comparison between PCHIP and Cubic Spline Interpolation PCHIP Interpolation Cubic Spline Interpolation

 Can be used for monotonicity-, positivity- and convexity-preserving data interpolation

 Can be used to the existing method such as linear regression and non- linear regression

 𝐶1 continuity.  𝐶2 continuity

 Curves tend to overshoot  Smooth interpolating Curves

(33)

22 2.4 INTRODUCTION TO CURVE FITTING

Curve fitting is the process of creating a curve, or mathematical function, that produce the best fit to a series of data points and it will possibly subject to constraints.

Interpolation can also be involved in the curve fitting, where an exact fit to the data is needed, or smoothing, in which a "smooth" function is constructed for the approximation of data. Another topic that is related to curve fitting is regression analysis where it will focuses more on statistical interference. For example, a calculation of the value of uncertainty that present in a curve fitting with random error. The data fitting method is it can be used as an aid for data visualization, i.e. to create values of a function where no data provided and to sum up between two or more variables relationship. Several types of curve fitting that will be discussed in this project are as follows:

(1) Polynomial (2) Gaussian (3) Fourier series (4) Sine

(5)Spline Smoothing.

(34)

23 2.4.1 Linear Regression

This type of fitting method is known as the first degree of polynomial fitting. Below is the example on how this method is being applied.

Let a straight line y a bx (46)

Which is fitted to the data points (x1,y ), (1 x2,y ), (2 x3,y ),..., (3 xn,y ),n Let y1be the theoretical value for x1then the error,

1 y1 y1

e   Then,

e1y1 (a bx1)

2 2

1 (y1 1)

e   a bx (47)

Now we have the sum of square error, S

2 2 2 2

1 2 3 ... n Se   e ee

2 1 n

i i

S e

2 1

(y )

n

i i

i

S a bx

  (48)

By using the principal of least squares, the value of S is minimum, thus, S 0

a

(49)

and

S 0 b

(50)

Solve equations (48) and (49), and dropping the suffix, we obtain equation below yna bx

 

(51)

xya x bx2

  

(52)

The equation (50) and (51) are known as normal equations. By solving equations (50) and (51), we get the value of a and b. This value will be substitute into Equation (46) to

(35)

24

obtain the least square linear fitting to the given data sets. The final fitting line has minimum error

.

2.4.2 Non-Linear Regression

This method can be used when we required to fit the data that clearly not present the linear characteristic. Exponential model is one of the example of nonlinear regression.

Given (x1,y ), (1 x2,y ), (2 x3,y ),..., (3 xn,y ),n best fit yaebx to the data. The variables a andbare the constants of the experimental model. The residual at each data point xiis

y bxi

i i

E  ae (53)

The sum of the square of the residuals is

2 1 n

r i

i

S E

2

1

(y i)

n

bx i i

ae

(54)

To find the constants aandbof the exponential model, we minimize Srby differentiating with respect to aand b and equating the resulting equations to zero.

1

2(y i)( i) 0

n

bx bx

r

i i

S ae e

a

    

(55)

1

2(y i)( i) 0

n

bx bx

r

i i

i

S ae ax e

b

    

(56)

or

2

1 1

y i i 0

n n

bx bx

i

i i

e a e

 (57)

2

1 1

y i i 0

n n

bx bx

i i i

i i

x e a x e

 

 

(58)
(36)

25

Equations (57) and (58) are non-linear in aand band thus not in a closed form to be solved as was the case for linear regression. Generally, iterative methods such as Gauss- Newton iteration method, method of steepest descent, Marquardt’s method or direct can be used to find valuesaandb.

However, in this case, from Equation (57), a can be written explicitly in term of b as

1 2 1

y i

i

n bx i i

n bx i

e a

e

(59)

Substituting equation (59) in (58) gives

1 2

1 2 1

1

y

y 0

i

i i

i

n bx

n i n

bx i bx

i i n i

i bx i

i

e

x e x e

e

 

(60)

The equation is still a nonlinear equation in b and can be solved best by numerical methods such as the bisection method or the secant method.

2.4.3 Gaussian

The Gaussian fitting is defined as follows:

2

1

y

i i

x b

N c

i i

a e



(61)

Where 𝑁 is a number of terms used and

x

is an original data. The real coefficient a bi, i and ci need to be determined by using least square method.

For example if we used Gaussian fitting with one term and two terms, the Gaussian fitting equation is given by:

2 1 1

1

y1

x b

a e c



(62)

and

2 2

1 2

1 2

1 2

y1

x b x b

c c

a e a e

Gambar

Table 2: Comparison between PCHIP and Cubic Spline Interpolation  PCHIP Interpolation  Cubic Spline Interpolation
Figure 10: Cubic Spline Interpolation (Measured Depth vs Fluid Flow) 4.  Combination of Linear, PCHIP and Spline Interpolation
Figure 37: Smoothing Spline Curve Fitting Method, p=0.7 (measured depth vs torque)
Figure 38: Smoothing Spline Curve Fitting Method, p=0.8 (measured depth vs torque)
+7

Referensi

Dokumen terkait