0% found this document useful (0 votes)
414 views

Solution of A Concentration Problem Using Numerical Methods

In this project the dimensionless concentration profile of benzene in the reaction of benzene dehydrogenation into cyclohexane in absence of inter- and intra-phase gradients is calculated numerically using the first order explicit Euler method, the second order modified midpoint and modified Euler methods, the Fourth-order Runge-Kutta method and the fourth-order Adams-Bashforth-Moulton method, both by hand and using MATLAB. Finally all numerical results were compared to analytical results graphically and by hand calculations and errors were found. The stability criterion for each method was discussed in the conclusion.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
414 views

Solution of A Concentration Problem Using Numerical Methods

In this project the dimensionless concentration profile of benzene in the reaction of benzene dehydrogenation into cyclohexane in absence of inter- and intra-phase gradients is calculated numerically using the first order explicit Euler method, the second order modified midpoint and modified Euler methods, the Fourth-order Runge-Kutta method and the fourth-order Adams-Bashforth-Moulton method, both by hand and using MATLAB. Finally all numerical results were compared to analytical results graphically and by hand calculations and errors were found. The stability criterion for each method was discussed in the conclusion.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 59

American University of Sharjah

Faculty of Engineering
Department of Chemical Engineering

Advance Numerical Methods (NGN-509)

Solution of a concentration problem using


Numerical Methods

Submitted by:
Salma Elgaili Abdel-Karim Ahmed
@g00050051

January - 2013

Solution of a concentration problem using Numerical Methods

NGN 509

Abstract
In this project the dimensionless concentration profile of benzene in the reaction of benzene
dehydrogenation into cyclohexane in absence of inter- and intra-phase gradients is calculated
numerically using the first order explicit Euler method, the second order modified midpoint and
modified Euler methods, the Fourth-order Runge-Kutta method and the fourth-order AdamsBashforth-Moulton method, both by hand and using MATLAB.
Finally all numerical results were compared to analytical results graphically and by hand
calculations and errors were found.
The stability criterion for each method was discussed in the conclusion.

Solution of a concentration problem using Numerical Methods

NGN 509

Table of contents
Abstract...................2
Table of contents.........3
List of tables........4

Section1 General Background and Problem Modeling


Introduction.....6
Problem Modeling ..7

Section2 Numerical Solution


Solving using Euler method......12
Solving using the modified midpoint method.......15
Solving using the modified Euler method.........22
Solving using the fourth-order Runge-Kutta method method.......28
Solving using the fourth-order Adams-Bashforth-Moulton method.........35

Section3 MATLAB Results


Solving using MATLAB.......44

Section4 Discussion.......48
Section5 Conclusion.......49
References........51
Appendix A........52

Solution of a concentration problem using Numerical Methods

NGN 509

List of Tables
Table 1.1: Analytical results of the problem using explicit Euler method ........8
Table 2.1: Numerical results of the problem using explicit Euler method ......12
Table 2.2: Numerical results of the problem using the modified midpoint method .......16
Table 2.3: Numerical results of the problem using the modified Euler method ............22
Table 2.4: Numerical results of the problem using the fourth-order Runge-Kutta method........29
Table 2.5: Numerical results of the problem using the fourth-order Adams-Bashforth-Moulton
method...36

Solution of a concentration problem using Numerical Methods

NGN 509

Solution of a concentration problem using Numerical Methods

NGN 509

1.1.Introduction
The Hydrogenation process of benzene to give cyclohexane is an important case in industry and
considered as a large-scale process that represents the first stage of a caprolactam1 production
process according to the polish technology named CYCLOPOL.
The reaction is governed by equation
C6H6 + 3H2 C6H6;

H298 = -206.2 [kJ/mol]

(1.1)

And the complete process happens as shown in figure (1.1)


The Hydrogenation reaction is a well-known reaction that has been appreciably examined in the
laboratory as a model reaction for catalysis studies. The catalyst itself is based on most Group
VIII metals, mainly nickel, palladium or platinum.
Extensive care has been given to the kinetics of the benzene hydrogenation on nickel catalysts,
given that, in industry, standard nickel catalysts are used for the gas-phase hydrogenation and
Raney-nickel for the liquid phase hydrogenation.
One of the most important efforts was by Kehoe and Butt [1] who had studied the reaction on a
supported Ni/kieselguhr catalyst.

Figure 1.1 Hydrogenation of benzene


1

a nylon precursor

NGN 509

Solution of a concentration problem using Numerical Methods

They have found that in the presence of a large excess of Hydrogen, the reaction is pseudo-firstorder at temperatures below 200C with the rate given by:
[

mole/(g of catalyst.s)

(1.2)

Where
Rg= gas constant, 1.987cal/(mole0K)
-Q Ea= 2700cal/mole
PH2 = hydrogen partial pressure(torr)
k0= 4.22 mole/(gcatstorr)
K0 = 2.63 x10-6 cm3/(mole0K)
T = absolute temperature (K)
CB = concentration of benzene (mole/cm3)
Price and Butt [2] studied this reaction in an isothermal tubular, plug flow reactor where a typical
run, in which (PH2 = 685 torr, H = density of the reactor bed = 1,2 gcat/ cm3, = constant time =
0.266 s, T = 1500C), is used.

1.2.Problem modeling
Let
CB = feed concentration of benzene (mole/cm3)
z = axial reactor coordinate (cm)
L = reactor length
y = dimensionless concentration of benzene (CB/ CB0)
x = dimensionless axial coordinate (z/L).
The one-dimensional steady-state material balance for the reactor that expresses the fact that the
change in the axial convection of benzene is equal to the amount converted by reaction is
(

(1.3)

With CB = CB0 at x = 0
Since is constant,
[

NGN 509

Solution of a concentration problem using Numerical Methods

Gathering the constants and defining

as
[

Using the data provided, its found

= 21.6. Substituting back in (1.4)


(1.5)

With (y = 1 at x = 0), and the analytical solution


y = exp (-21.6 x)

(1.6)

The analytical results were as follows


Table0.1 Analytical results of the problem

x
0.00
0.01
0.02
0.03
0.04
0.05
0.06
0.07
0.08
0.09
0.10
0.11
0.12
0.13
0.14
0.15
0.16
0.17
0.18
0.19
0.20
0.21
0.22
0.23
0.24
0.25
0.26

Analytical results
(yn)
1.00000E+00
8.05735E-01
6.49209E-01
5.23091E-01
4.21473E-01
3.39596E-01
2.73624E-01
2.20469E-01
1.77639E-01
1.43130E-01
1.15325E-01
9.29215E-02
7.48701E-02
6.03255E-02
4.86064E-02
3.91639E-02
3.15557E-02
2.54256E-02
2.04863E-02
1.65065E-02
1.32999E-02
1.07162E-02
8.63441E-03
6.95705E-03
5.60554E-03
4.51658E-03
3.63917E-03

fn
-2.16000E+01
-1.74039E+01
-1.40229E+01
-1.12988E+01
-9.10381E+00
-7.33526E+00
-5.91028E+00
-4.76212E+00
-3.83701E+00
-3.09161E+00
-2.49102E+00
-2.00710E+00
-1.61720E+00
-1.30303E+00
-1.04990E+00
-8.45940E-01
-6.81604E-01
-5.49192E-01
-4.42504E-01
-3.56541E-01
-2.87277E-01
-2.31470E-01
-1.86503E-01
-1.50272E-01
-1.21080E-01
-9.75581E-02
-7.86060E-02
8

NGN 509

Solution of a concentration problem using Numerical Methods

x
0.27
0.28
0.29
0.30
0.31
0.32
0.33
0.34
0.35
0.36
0.37
0.38
0.39
0.40
0.41
0.42
0.43
0.44
0.45
0.46
0.47
0.48
0.49
0.50
0.51
0.52
0.53
0.54
0.55
0.56
0.57
0.58
0.59
0.60
0.61
0.62
0.63
0.64
0.65
0.66
0.67

Analytical results
(yn)
2.93221E-03
2.36258E-03
1.90362E-03
1.53381E-03
1.23585E-03
9.95764E-04
8.02322E-04
6.46460E-04
5.20875E-04
4.19688E-04
3.38157E-04
2.72465E-04
2.19535E-04
1.76887E-04
1.42524E-04
1.14837E-04
9.25279E-05
7.45530E-05
6.00700E-05
4.84005E-05
3.89980E-05
3.14221E-05
2.53179E-05
2.03995E-05
1.64366E-05
1.32435E-05
1.06708E-05
8.59784E-06
6.92758E-06
5.58180E-06
4.49745E-06
3.62375E-06
2.91979E-06
2.35258E-06
1.89555E-06
1.52731E-06
1.23061E-06
9.91546E-07
7.98924E-07
6.43721E-07
5.18669E-07

fn
-6.33357E-02
-5.10318E-02
-4.11181E-02
-3.31303E-02
-2.66943E-02
-2.15085E-02
-1.73302E-02
-1.39635E-02
-1.12509E-02
-9.06525E-03
-7.30419E-03
-5.88525E-03
-4.74195E-03
-3.82076E-03
-3.07852E-03
-2.48047E-03
-1.99860E-03
-1.61035E-03
-1.29751E-03
-1.04545E-03
-8.42357E-04
-6.78717E-04
-5.46866E-04
-4.40629E-04
-3.55031E-04
-2.86061E-04
-2.30489E-04
-1.85713E-04
-1.49636E-04
-1.20567E-04
-9.71449E-05
-7.82731E-05
-6.30674E-05
-5.08156E-05
-4.09439E-05
-3.29900E-05
-2.65812E-05
-2.14174E-05
-1.72568E-05
-1.39044E-05
-1.12032E-05
9

NGN 509

Solution of a concentration problem using Numerical Methods

x
0.68
0.69
0.70
0.71
0.72
0.73
0.74
0.75
0.76
0.77
0.78
0.79
0.80
0.81
0.82
0.83
0.84
0.85
0.86
0.87
0.88
0.89
0.90
0.91
0.92
0.93
0.94
0.95
0.96
0.97
0.98
0.99
1.00

Analytical results
(yn)
4.17910E-07
3.36725E-07
2.71311E-07
2.18605E-07
1.76138E-07
1.41920E-07
1.14350E-07
9.21360E-08
7.42372E-08
5.98156E-08
4.81955E-08
3.88328E-08
3.12890E-08
2.52106E-08
2.03131E-08
1.63670E-08
1.31875E-08
1.06256E-08
8.56142E-09
6.89824E-09
5.55815E-09
4.47840E-09
3.60840E-09
2.90742E-09
2.34261E-09
1.88752E-09
1.52084E-09
1.22540E-09
9.87347E-10
7.95540E-10
6.40995E-10
5.16472E-10
4.16140E-10

fn
-9.02685E-06
-7.27325E-06
-5.86032E-06
-4.72187E-06
-3.80457E-06
-3.06548E-06
-2.46996E-06
-1.99014E-06
-1.60352E-06
-1.29202E-06
-1.04102E-06
-8.38789E-07
-6.75842E-07
-5.44550E-07
-4.38763E-07
-3.53527E-07
-2.84849E-07
-2.29513E-07
-1.84927E-07
-1.49002E-07
-1.20056E-07
-9.67334E-08
-7.79415E-08
-6.28003E-08
-5.06004E-08
-4.07705E-08
-3.28502E-08
-2.64686E-08
-2.13267E-08
-1.71837E-08
-1.38455E-08
-1.11558E-08
-8.98862E-09

10

Solution of a concentration problem using Numerical Methods

NGN 509

11

NGN 509

Solution of a concentration problem using Numerical Methods

2.1.Solving using Euler method


The explicit Euler finite difference equation (FDE) is given by
yi+1 = yi + h fn,

i= 0, 1, 2, N-1

(2.1)

where (h) is the step used, (fn) is the derivative function and (N= 1/h).
Thus, and from (1.5), the desired equation forming the solution is
yi+1 = yi 21.6 h yi

(2.2)

Let h = 0.01 (N=100), for the first step,


y1 = 1 - 21.6 * 0.01 * 1 = 0.784
These results and the results of subsequent steps are summarized in Table 2.1.
Table2.1 Numerical results of the problem using explicit Euler method

x
0
0.01
0.02
0.03
0.04
0.05
0.06
0.07
0.08
0.09
0.1
0.11
0.12
0.13
0.14
0.15
0.16
0.17
0.18
0.19
0.2
0.21

Numerical results
(yn)
7.84000E-01
6.14656E-01
4.81890E-01
3.77802E-01
2.96197E-01
2.32218E-01
1.82059E-01
1.42734E-01
1.11904E-01
8.77325E-02
6.87823E-02
5.39253E-02
4.22775E-02
3.31455E-02
2.59861E-02
2.03731E-02
1.59725E-02
1.25224E-02
9.81760E-03
7.69700E-03
6.03444E-03
4.73100E-03

Error
-2.16000E-01
-1.91079E-01
-1.67319E-01
-1.45289E-01
-1.25276E-01
-1.07377E-01
-9.15650E-02
-7.77342E-02
-6.57356E-02
-5.53978E-02
-4.65428E-02
-3.89962E-02
-3.25927E-02
-2.71800E-02
-2.26203E-02
-1.87908E-02
-1.55832E-02
-1.29031E-02
-1.06687E-02
-8.80952E-03
-7.26544E-03
-5.98518E-03
12

NGN 509

Solution of a concentration problem using Numerical Methods

x
0.22
0.23
0.24
0.25
0.26
0.27
0.28
0.29
0.3
0.31
0.32
0.33
0.34
0.35
0.36
0.37
0.38
0.39
0.4
0.41
0.42
0.43
0.44
0.45
0.46
0.47
0.48
0.49
0.5
0.51
0.52
0.53
0.54
0.55
0.56

Numerical results
(yn)
3.70911E-03
2.90794E-03
2.27983E-03
1.78738E-03
1.40131E-03
1.09863E-03
8.61323E-04
6.75277E-04
5.29417E-04
4.15063E-04
3.25409E-04
2.55121E-04
2.00015E-04
1.56812E-04
1.22940E-04
9.63852E-05
7.55660E-05
5.92437E-05
4.64471E-05
3.64145E-05
2.85490E-05
2.23824E-05
1.75478E-05
1.37575E-05
1.07859E-05
8.45612E-06
6.62960E-06
5.19760E-06
4.07492E-06
3.19474E-06
2.50467E-06
1.96366E-06
1.53951E-06
1.20698E-06
9.46271E-07

Error
-4.92530E-03
-4.04911E-03
-3.32571E-03
-2.72920E-03
-2.23786E-03
-1.83358E-03
-1.50126E-03
-1.22834E-03
-1.00439E-03
-8.20782E-04
-6.70355E-04
-5.47201E-04
-4.46445E-04
-3.64064E-04
-2.96747E-04
-2.41772E-04
-1.96899E-04
-1.60291E-04
-1.30440E-04
-1.06109E-04
-8.62876E-05
-7.01455E-05
-5.70052E-05
-4.63125E-05
-3.76147E-05
-3.05419E-05
-2.47925E-05
-2.01203E-05
-1.63246E-05
-1.32419E-05
-1.07389E-05
-8.70713E-06
-7.05832E-06
-5.72060E-06
-4.63552E-06
13

NGN 509

Solution of a concentration problem using Numerical Methods

x
0.57
0.58
0.59
0.6
0.61
0.62
0.63
0.64
0.65
0.66
0.67
0.68
0.69
0.7
0.71
0.72
0.73
0.74
0.75
0.76
0.77
0.78
0.79
0.8
0.81
0.82
0.83
0.84
0.85
0.86
0.87
0.88
0.89
0.9
0.91

Numerical results
(yn)
7.41877E-07
5.81631E-07
4.55999E-07
3.57503E-07
2.80282E-07
2.19741E-07
1.72277E-07
1.35065E-07
1.05891E-07
8.30188E-08
6.50867E-08
5.10280E-08
4.00059E-08
3.13647E-08
2.45899E-08
1.92785E-08
1.51143E-08
1.18496E-08
9.29011E-09
7.28344E-09
5.71022E-09
4.47681E-09
3.50982E-09
2.75170E-09
2.15733E-09
1.69135E-09
1.32602E-09
1.03960E-09
8.15045E-10
6.38995E-10
5.00972E-10
3.92762E-10
3.07925E-10
2.41414E-10
1.89268E-10

Error
-3.75557E-06
-3.04212E-06
-2.46379E-06
-1.99507E-06
-1.61527E-06
-1.30757E-06
-1.05833E-06
-8.56481E-07
-6.93033E-07
-5.60703E-07
-4.53582E-07
-3.66882E-07
-2.96719E-07
-2.39946E-07
-1.94015E-07
-1.56859E-07
-1.26806E-07
-1.02501E-07
-8.28459E-08
-6.69538E-08
-5.41053E-08
-4.37187E-08
-3.53230E-08
-2.85373E-08
-2.30533E-08
-1.86217E-08
-1.50410E-08
-1.21479E-08
-9.81055E-09
-7.92242E-09
-6.39726E-09
-5.16539E-09
-4.17047E-09
-3.36699E-09
-2.71815E-09
14

NGN 509

Solution of a concentration problem using Numerical Methods

x
0.92
0.93
0.94
0.95
0.96
0.97
0.98
0.99
1

Numerical results
(yn)
1.48386E-10
1.16335E-10
9.12065E-11
7.15059E-11
5.60606E-11
4.39515E-11
3.44580E-11
2.70151E-11
2.11798E-11

Error
-2.19422E-09
-1.77119E-09
-1.42964E-09
-1.15389E-09
-9.31286E-10
-7.51588E-10
-6.06537E-10
-4.89457E-10
-3.94960E-10

2.2.Solving using the modified midpoint method


The modified midpoint method is given by
(2.3)

where the superscript P denotes that


evaluated using

and

are predictor values where

, and the superscript C denotes that

is

is the corrected second-order

result.
Thus, the desired equations forming the solution s are obtained as

Let h = 0.01 (N=100), for the first step,

These results and the results of subsequent steps are summarized in Table 2.2.

15

NGN 509

Solution of a concentration problem using Numerical Methods


Table2.2 Numerical results of the problem using modified midpoint method

xn

yn

yn+1/2
xn+1
yn+1
1.00000E+00
0
8.92000E-01
0.01 8.07328E-01
7.20137E-01
0.02
0.03
0.04
0.05
0.06
0.07
0.08
0.09
0.1
0.11
0.12
0.13
0.14
0.15

fn
fn+1/2

Error

-2.16000E+01 0.00000E+00
-1.92672E+01
-1.74383E+01 1.59270E-03
-1.55550E+01

6.51778E-01

-1.40784E+01

5.81386E-01

-1.25579E+01

5.26199E-01

-1.13659E+01

4.69370E-01

-1.01384E+01

4.24815E-01

-9.17601E+00

3.78935E-01
3.42965E-01
3.05925E-01
2.76885E-01
2.46982E-01
2.23537E-01
1.99395E-01
1.80468E-01
1.60977E-01
1.45697E-01
1.29962E-01
1.17625E-01
1.04922E-01
9.49621E-02
8.47062E-02
7.66655E-02
6.83857E-02
6.18942E-02
5.52097E-02
4.99689E-02
4.45723E-02
4.03413E-02
3.59845E-02

-8.18500E+00
-7.40805E+00
-6.60798E+00
-5.98073E+00
-5.33481E+00
-4.82841E+00
-4.30694E+00
-3.89811E+00
-3.47711E+00
-3.14705E+00
-2.80717E+00
-2.54070E+00
-2.26631E+00
-2.05118E+00
-1.82965E+00
-1.65598E+00
-1.47713E+00
-1.33692E+00
-1.19253E+00
-1.07933E+00
-9.62762E-01
-8.71373E-01
-7.77264E-01

2.56912E-03
3.10812E-03
3.34240E-03
3.36969E-03
3.26132E-03
3.06875E-03
2.82863E-03
2.56656E-03
2.30002E-03
2.04055E-03
1.79539E-03
1.56871E-03
1.36255E-03
1.17744E-03

16

NGN 509

Solution of a concentration problem using Numerical Methods

xn
xn+1
0.16
0.17
0.18
0.19
0.2
0.21
0.22
0.23
0.24
0.25
0.26
0.27
0.28
0.29
0.3
0.31
0.32
0.33

yn

fn

yn+1/2
yn+1
3.25687E-02
2.90513E-02
2.62936E-02
2.34539E-02
2.12276E-02
1.89350E-02
1.71376E-02
1.52867E-02
1.38357E-02
1.23414E-02
1.11699E-02
9.96357E-03
9.01779E-03
8.04387E-03
7.28032E-03
6.49404E-03
5.87760E-03
5.24282E-03
4.74515E-03
4.23268E-03
3.83090E-03
3.41716E-03
3.09279E-03
2.75877E-03
2.49690E-03
2.22723E-03
2.01581E-03
1.79811E-03
1.62742E-03
1.45166E-03
1.31386E-03
1.17197E-03
1.06072E-03
9.46162E-04
8.56348E-04

fn+1/2

Error

-7.03484E-01
-6.27507E-01
-5.67942E-01
-5.06604E-01
-4.58516E-01
-4.08996E-01
-3.70172E-01
-3.30194E-01
-2.98851E-01
-2.66575E-01
-2.41270E-01
-2.15213E-01
-1.94784E-01
-1.73748E-01
-1.57255E-01
-1.40271E-01
-1.26956E-01
-1.13245E-01
-1.02495E-01
-9.14258E-02
-8.27474E-02
-7.38106E-02
-6.68043E-02
-5.95894E-02
-5.39329E-02
-4.81082E-02
-4.35416E-02
-3.88391E-02
-3.51523E-02
-3.13559E-02
-2.83795E-02
-2.53145E-02
-2.29115E-02
-2.04371E-02
-1.84971E-02

1.01295E-03
8.68044E-04
7.41292E-04
6.31094E-04
5.35790E-04
4.53741E-04
3.83385E-04
3.23270E-04
2.72065E-04
2.28574E-04
1.91728E-04
1.60583E-04
1.34313E-04
1.12198E-04
9.36123E-05
7.80188E-05
6.49551E-05
5.40260E-05
17

NGN 509

Solution of a concentration problem using Numerical Methods

xn
xn+1
0.34
0.35
0.36
0.37
0.38
0.39
0.4
0.41
0.42
0.43
0.44
0.45
0.46
0.47
0.48
0.49
0.5

yn

fn

yn+1/2
yn+1
7.63863E-04
6.91354E-04
6.16688E-04
5.58149E-04
4.97869E-04
4.50610E-04
4.01944E-04
3.63790E-04
3.24501E-04
2.93698E-04
2.61978E-04
2.37110E-04
2.11502E-04
1.91426E-04
1.70752E-04
1.54543E-04
1.37853E-04
1.24767E-04
1.11292E-04
1.00728E-04
8.98495E-05
8.13206E-05
7.25380E-05
6.56524E-05
5.85620E-05
5.30030E-05
4.72787E-05
4.27908E-05
3.81694E-05
3.45462E-05
3.08152E-05
2.78901E-05
2.48780E-05
2.25165E-05
2.00847E-05

fn+1/2
-1.64994E-02
-1.49332E-02
-1.33205E-02
-1.20560E-02
-1.07540E-02
-9.73317E-03
-8.68199E-03
-7.85786E-03
-7.00921E-03
-6.34387E-03
-5.65873E-03
-5.12158E-03
-4.56845E-03
-4.13480E-03
-3.68824E-03
-3.33814E-03
-2.97762E-03
-2.69497E-03
-2.40392E-03
-2.17573E-03
-1.94075E-03
-1.75653E-03
-1.56682E-03
-1.41809E-03
-1.26494E-03
-1.14487E-03
-1.02122E-03
-9.24282E-04
-8.24459E-04
-7.46199E-04
-6.65609E-04
-6.02427E-04
-5.37365E-04
-4.86356E-04
-4.33830E-04

Error

4.48945E-05
3.72742E-05
3.09221E-05
2.56327E-05
2.12326E-05
1.75756E-05
1.45390E-05
1.20194E-05
9.93062E-06
8.20017E-06
6.76760E-06
5.58241E-06
4.60251E-06
3.79282E-06
3.12416E-06
2.57227E-06
2.11699E-06
18

NGN 509

Solution of a concentration problem using Numerical Methods

xn
xn+1
0.51
0.52
0.53
0.54
0.55
0.56
0.57
0.58
0.59
0.6
0.61
0.62
0.63
0.64
0.65
0.66
0.67
0.68

yn

fn

yn+1/2
yn+1
1.81782E-05
1.62150E-05
1.46758E-05
1.30908E-05
1.18482E-05
1.05686E-05
9.56535E-06
8.53229E-06
7.72237E-06
6.88836E-06
6.23449E-06
5.56116E-06
5.03328E-06
4.48968E-06
4.06351E-06
3.62465E-06
3.28058E-06
2.92628E-06
2.64851E-06
2.36247E-06
2.13821E-06
1.90729E-06
1.72624E-06
1.53981E-06
1.39364E-06
1.24313E-06
1.12513E-06
1.00361E-06
9.08345E-07
8.10244E-07
7.33333E-07
6.54133E-07
5.92040E-07
5.28100E-07
4.77970E-07

fn+1/2

Error

-3.92649E-04
-3.50243E-04
-3.16997E-04
-2.82761E-04
-2.55920E-04
-2.28281E-04
-2.06612E-04
-1.84297E-04
-1.66803E-04
-1.48789E-04
-1.34665E-04
-1.20121E-04
-1.08719E-04
-9.69772E-05
-8.77717E-05
-7.82924E-05
-7.08606E-05
-6.32076E-05
-5.72077E-05
-5.10293E-05
-4.61854E-05
-4.11974E-05
-3.72868E-05
-3.32598E-05
-3.01026E-05
-2.68516E-05
-2.43027E-05
-2.16780E-05
-1.96203E-05
-1.75013E-05
-1.58400E-05
-1.41293E-05
-1.27881E-05
-1.14070E-05
-1.03242E-05

1.74160E-06
1.43222E-06
1.17736E-06
9.67513E-07
7.94794E-07
6.52693E-07
5.35827E-07
4.39752E-07
3.60795E-07
2.95930E-07
2.42660E-07
1.98925E-07
1.63030E-07
1.33579E-07
1.09421E-07
8.96113E-08
7.33710E-08
6.00605E-08
19

NGN 509

Solution of a concentration problem using Numerical Methods

xn
xn+1
0.69
0.7
0.71
0.72
0.73
0.74
0.75
0.76
0.77
0.78
0.79
0.8
0.81
0.82
0.83
0.84
0.85

yn

fn

yn+1/2
yn+1
4.26350E-07
3.85879E-07
3.44204E-07
3.11531E-07
2.77886E-07
2.51508E-07
2.24345E-07
2.03049E-07
1.81120E-07
1.63927E-07
1.46223E-07
1.32343E-07
1.18050E-07
1.06844E-07
9.53051E-08
8.62583E-08
7.69424E-08
6.96388E-08
6.21178E-08
5.62213E-08
5.01494E-08
4.53891E-08
4.04870E-08
3.66439E-08
3.26863E-08
2.95836E-08
2.63886E-08
2.38837E-08
2.13042E-08
1.92820E-08
1.71995E-08
1.55669E-08
1.38856E-08
1.25676E-08
1.12103E-08

fn+1/2
-9.20915E-06
-8.33498E-06
-7.43481E-06
-6.72907E-06
-6.00233E-06
-5.43256E-06
-4.84585E-06
-4.38586E-06
-3.91219E-06
-3.54083E-06
-3.15842E-06
-2.85861E-06
-2.54988E-06
-2.30784E-06
-2.05859E-06
-1.86318E-06
-1.66196E-06
-1.50420E-06
-1.34174E-06
-1.21438E-06
-1.08323E-06
-9.80404E-07
-8.74520E-07
-7.91507E-07
-7.06025E-07
-6.39006E-07
-5.69993E-07
-5.15887E-07
-4.60172E-07
-4.16490E-07
-3.71509E-07
-3.36244E-07
-2.99930E-07
-2.71459E-07
-2.42142E-07

Error

4.91542E-08
4.02198E-08
3.29027E-08
2.69114E-08
2.20069E-08
1.79928E-08
1.47082E-08
1.20211E-08
9.82322E-09
8.02583E-09
6.55624E-09
5.35488E-09
4.37298E-09
3.57058E-09
2.91498E-09
2.37942E-09
1.94197E-09
20

NGN 509

Solution of a concentration problem using Numerical Methods

xn
xn+1
0.86
0.87
0.88
0.89
0.9
0.91
0.92
0.93
0.94
0.95
0.96
0.97
0.98
0.99
1

yn

fn

yn+1/2
yn+1
1.01462E-08
9.05037E-09
8.19127E-09
7.30661E-09
6.61304E-09
5.89883E-09
5.33889E-09
4.76229E-09
4.31024E-09
3.84473E-09
3.47978E-09
3.10396E-09
2.80932E-09
2.50591E-09
2.26804E-09
2.02309E-09
1.83106E-09
1.63330E-09
1.47826E-09
1.31861E-09
1.19344E-09
1.06455E-09
9.63499E-10
8.59441E-10
7.77860E-10
6.93851E-10
6.27988E-10
5.60165E-10
5.06992E-10

fn+1/2

Error

-2.19157E-07
-1.95488E-07
-1.76931E-07
-1.57823E-07
-1.42842E-07
-1.27415E-07
-1.15320E-07
-1.02866E-07
-9.31012E-08
-8.30462E-08
-7.51632E-08
-6.70456E-08
-6.06813E-08
-5.41278E-08
-4.89897E-08
-4.36988E-08
-3.95508E-08
-3.52793E-08
-3.19305E-08
-2.84820E-08
-2.57784E-08
-2.29943E-08
-2.08116E-08
-1.85639E-08
-1.68018E-08
-1.49872E-08
-1.35645E-08
-1.20996E-08
-1.09510E-08

1.58473E-09
1.29303E-09
1.05489E-09
8.60495E-10
7.01834E-10
5.72357E-10
4.66711E-10
3.80520E-10
3.10211E-10
2.52864E-10
2.06096E-10
1.67959E-10
1.36865E-10
1.11516E-10
9.08527E-11

21

NGN 509

Solution of a concentration problem using Numerical Methods

2.3.Solving using the modified Euler method


The modified Euler method is given by
(2.4)

where the superscript P denotes that


evaluated using

and

are predictor values where

, and the superscript C denotes that

is

is the corrected second-order

result.
Thus, the desired equations forming the solution s are obtained as

Let h = 0.01 (N=100), for the first step,

These results and the results of subsequent steps are summarized in Table 2.3.
Table2.3 Numerical results of the problem using modified Euler method

xn

yn

fn
P

xn+1
0
0.01
0.02

0.03

0.04

yn+1
yn+1C
1.00000E+00
7.84000E-01
8.07328E-01
6.32945E-01

fn+1

Error

-2.16000E+01 0.00000E+00
-1.69344E+01
-1.74383E+01 1.59270E-03
-1.36716E+01

6.51778E-01

-1.40784E+01

5.10994E-01

-1.10375E+01

5.26199E-01

-1.13659E+01

4.12540E-01

-8.91086E+00

4.24815E-01

-9.17601E+00

3.33055E-01

-7.19399E+00

2.56912E-03

3.10812E-03

3.34240E-03

22

NGN 509

Solution of a concentration problem using Numerical Methods

xn

yn

fn
P

xn+1
0.05
0.06
0.07
0.08
0.09
0.1
0.11
0.12
0.13
0.14
0.15
0.16
0.17
0.18
0.19
0.2
0.21

yn+1
yn+1C
3.42965E-01
2.68885E-01
2.76885E-01
2.17078E-01
2.23537E-01
1.75253E-01
1.80468E-01
1.41487E-01
1.45697E-01
1.14226E-01
1.17625E-01
9.22181E-02
9.49621E-02
7.44503E-02
7.66655E-02
6.01058E-02
6.18942E-02
4.85251E-02
4.99689E-02
3.91757E-02
4.03413E-02
3.16276E-02
3.25687E-02
2.55339E-02
2.62936E-02
2.06142E-02
2.12276E-02
1.66424E-02
1.71376E-02
1.34359E-02
1.38357E-02
1.08472E-02
1.11699E-02

fn+1

Error

-7.40805E+00
-5.80791E+00
-5.98073E+00
-4.68889E+00
-4.82841E+00
-3.78547E+00
-3.89811E+00
-3.05612E+00
-3.14705E+00
-2.46729E+00
-2.54070E+00
-1.99191E+00
-2.05118E+00
-1.60813E+00
-1.65598E+00
-1.29828E+00
-1.33692E+00
-1.04814E+00
-1.07933E+00
-8.46194E-01
-8.71373E-01
-6.83156E-01
-7.03484E-01
-5.51531E-01
-5.67942E-01
-4.45267E-01
-4.58516E-01
-3.59476E-01
-3.70172E-01
-2.90215E-01
-2.98851E-01
-2.34299E-01
-2.41270E-01

3.36969E-03
3.26132E-03
3.06875E-03
2.82863E-03
2.56656E-03
2.30002E-03
2.04055E-03
1.79539E-03
1.56871E-03
1.36255E-03
1.17744E-03
1.01295E-03
8.68044E-04
7.41292E-04
6.31094E-04
5.35790E-04
4.53741E-04
23

NGN 509

Solution of a concentration problem using Numerical Methods

xn

yn

fn
P

xn+1
0.22
0.23
0.24
0.25
0.26
0.27
0.28
0.29
0.3
0.31
0.32
0.33
0.34
0.35
0.36
0.37

yn+1
yn+1C
8.75722E-03
9.01779E-03
7.06995E-03
7.28032E-03
5.70777E-03
5.87760E-03
4.60804E-03
4.74515E-03
3.72020E-03
3.83090E-03
3.00342E-03
3.09279E-03
2.42475E-03
2.49690E-03
1.95757E-03
2.01581E-03
1.58040E-03
1.62742E-03
1.27590E-03
1.31386E-03
1.03007E-03
1.06072E-03
8.31604E-04
8.56348E-04
6.71377E-04
6.91354E-04
5.42022E-04
5.58149E-04
4.37589E-04
4.50610E-04
3.53278E-04
3.63790E-04
2.85211E-04

fn+1
-1.89156E-01
-1.94784E-01
-1.52711E-01
-1.57255E-01
-1.23288E-01
-1.26956E-01
-9.95337E-02
-1.02495E-01
-8.03563E-02
-8.27474E-02
-6.48739E-02
-6.68043E-02
-5.23745E-02
-5.39329E-02
-4.22834E-02
-4.35416E-02
-3.41366E-02
-3.51523E-02
-2.75594E-02
-2.83795E-02
-2.22495E-02
-2.29115E-02
-1.79626E-02
-1.84971E-02
-1.45017E-02
-1.49332E-02
-1.17077E-02
-1.20560E-02
-9.45193E-03
-9.73317E-03
-7.63081E-03
-7.85786E-03
-6.16056E-03

Error

3.83385E-04
3.23270E-04
2.72065E-04
2.28574E-04
1.91728E-04
1.60583E-04
1.34313E-04
1.12198E-04
9.36123E-05
7.80188E-05
6.49551E-05
5.40260E-05
4.48945E-05
3.72742E-05
3.09221E-05
2.56327E-05

24

NGN 509

Solution of a concentration problem using Numerical Methods

xn

yn

fn
P

xn+1
0.38
0.39
0.4
0.41
0.42
0.43
0.44
0.45
0.46
0.47
0.48
0.49
0.5
0.51
0.52
0.53
0.54

yn+1
yn+1C
2.93698E-04
2.30259E-04
2.37110E-04
1.85895E-04
1.91426E-04
1.50078E-04
1.54543E-04
1.21162E-04
1.24767E-04
9.78175E-05
1.00728E-04
7.89708E-05
8.13206E-05
6.37554E-05
6.56524E-05
5.14715E-05
5.30030E-05
4.15544E-05
4.27908E-05
3.35480E-05
3.45462E-05
2.70842E-05
2.78901E-05
2.18659E-05
2.25165E-05
1.76529E-05
1.81782E-05
1.42517E-05
1.46758E-05
1.15058E-05
1.18482E-05
9.28896E-06
9.56535E-06

fn+1

Error

-6.34387E-03
-4.97359E-03
-5.12158E-03
-4.01532E-03
-4.13480E-03
-3.24168E-03
-3.33814E-03
-2.61710E-03
-2.69497E-03
-2.11286E-03
-2.17573E-03
-1.70577E-03
-1.75653E-03
-1.37712E-03
-1.41809E-03
-1.11178E-03
-1.14487E-03
-8.97575E-04
-9.24282E-04
-7.24637E-04
-7.46199E-04
-5.85020E-04
-6.02427E-04
-4.72303E-04
-4.86356E-04
-3.81303E-04
-3.92649E-04
-3.07837E-04
-3.16997E-04
-2.48525E-04
-2.55920E-04
-2.00641E-04
-2.06612E-04

2.12326E-05
1.75756E-05
1.45390E-05
1.20194E-05
9.93062E-06
8.20017E-06
6.76760E-06
5.58241E-06
4.60251E-06
3.79282E-06
3.12416E-06
2.57227E-06
2.11699E-06
1.74160E-06
1.43222E-06
1.17736E-06
9.67513E-07
25

NGN 509

Solution of a concentration problem using Numerical Methods

xn

yn

fn
P

xn+1
0.55
0.56
0.57
0.58
0.59
0.6
0.61
0.62
0.63
0.64
0.65
0.66
0.67
0.68
0.69
0.7

yn+1
yn+1C
7.49923E-06
7.72237E-06
6.05434E-06
6.23449E-06
4.88784E-06
5.03328E-06
3.94609E-06
4.06351E-06
3.18579E-06
3.28058E-06
2.57198E-06
2.64851E-06
2.07643E-06
2.13821E-06
1.67636E-06
1.72624E-06
1.35337E-06
1.39364E-06
1.09261E-06
1.12513E-06
8.82098E-07
9.08345E-07
7.12143E-07
7.33333E-07
5.74933E-07
5.92040E-07
4.64159E-07
4.77970E-07
3.74729E-07
3.85879E-07
3.02529E-07
3.11531E-07
2.44240E-07

fn+1
-1.61983E-04
-1.66803E-04
-1.30774E-04
-1.34665E-04
-1.05577E-04
-1.08719E-04
-8.52355E-05
-8.77717E-05
-6.88130E-05
-7.08606E-05
-5.55547E-05
-5.72077E-05
-4.48509E-05
-4.61854E-05
-3.62094E-05
-3.72868E-05
-2.92328E-05
-3.01026E-05
-2.36005E-05
-2.43027E-05
-1.90533E-05
-1.96203E-05
-1.53823E-05
-1.58400E-05
-1.24185E-05
-1.27881E-05
-1.00258E-05
-1.03242E-05
-8.09414E-06
-8.33498E-06
-6.53463E-06
-6.72907E-06
-5.27559E-06

Error

7.94794E-07
6.52693E-07
5.35827E-07
4.39752E-07
3.60795E-07
2.95930E-07
2.42660E-07
1.98925E-07
1.63030E-07
1.33579E-07
1.09421E-07
8.96113E-08
7.33710E-08
6.00605E-08
4.91542E-08
4.02198E-08

26

NGN 509

Solution of a concentration problem using Numerical Methods

xn

yn

fn
P

xn+1
0.71
0.72
0.73
0.74
0.75
0.76
0.77
0.78
0.79
0.8
0.81
0.82
0.83
0.84
0.85
0.86
0.87

yn+1
yn+1C
2.51508E-07
1.97182E-07
2.03049E-07
1.59191E-07
1.63927E-07
1.28519E-07
1.32343E-07
1.03757E-07
1.06844E-07
8.37659E-08
8.62583E-08
6.76265E-08
6.96388E-08
5.45968E-08
5.62213E-08
4.40775E-08
4.53891E-08
3.55850E-08
3.66439E-08
2.87288E-08
2.95836E-08
2.31936E-08
2.38837E-08
1.87248E-08
1.92820E-08
1.51171E-08
1.55669E-08
1.22044E-08
1.25676E-08
9.85297E-09
1.01462E-08
7.95458E-09
8.19127E-09

fn+1

Error

-5.43256E-06
-4.25913E-06
-4.38586E-06
-3.43851E-06
-3.54083E-06
-2.77601E-06
-2.85861E-06
-2.24115E-06
-2.30784E-06
-1.80934E-06
-1.86318E-06
-1.46073E-06
-1.50420E-06
-1.17929E-06
-1.21438E-06
-9.52075E-07
-9.80404E-07
-7.68637E-07
-7.91507E-07
-6.20542E-07
-6.39006E-07
-5.00981E-07
-5.15887E-07
-4.04456E-07
-4.16490E-07
-3.26528E-07
-3.36244E-07
-2.63616E-07
-2.71459E-07
-2.12824E-07
-2.19157E-07
-1.71819E-07
-1.76931E-07

3.29027E-08
2.69114E-08
2.20069E-08
1.79928E-08
1.47082E-08
1.20211E-08
9.82322E-09
8.02583E-09
6.55624E-09
5.35488E-09
4.37298E-09
3.57058E-09
2.91498E-09
2.37942E-09
1.94197E-09
1.58473E-09
1.29303E-09
27

NGN 509

Solution of a concentration problem using Numerical Methods

xn

yn

fn
P

xn+1
0.88
0.89
0.9
0.91
0.92
0.93
0.94
0.95
0.96
0.97
0.98
0.99
1

yn+1
yn+1C
6.42196E-09
6.61304E-09
5.18463E-09
5.33889E-09
4.18569E-09
4.31024E-09
3.37923E-09
3.47978E-09
2.72814E-09
2.80932E-09
2.20251E-09
2.26804E-09
1.77815E-09
1.83106E-09
1.43555E-09
1.47826E-09
1.15896E-09
1.19344E-09
9.35659E-10
9.63499E-10
7.55384E-10
7.77860E-10
6.09842E-10
6.27988E-10
4.92343E-10
5.06992E-10
3.97482E-10

fn+1
-1.38714E-07
-1.42842E-07
-1.11988E-07
-1.15320E-07
-9.04110E-08
-9.31012E-08
-7.29913E-08
-7.51632E-08
-5.89279E-08
-6.06813E-08
-4.75742E-08
-4.89897E-08
-3.84080E-08
-3.95508E-08
-3.10078E-08
-3.19305E-08
-2.50335E-08
-2.57784E-08
-2.02102E-08
-2.08116E-08
-1.63163E-08
-1.68018E-08
-1.31726E-08
-1.35645E-08
-1.06346E-08
-1.09510E-08
-8.58561E-09

Error

1.05489E-09
8.60495E-10
7.01834E-10
5.72357E-10
4.66711E-10
3.80520E-10
3.10211E-10
2.52864E-10
2.06096E-10
1.67959E-10
1.36865E-10
1.11516E-10
9.08527E-11

2.4.Solving using the fourth-order Runge-Kutta method


The fourth-order Runge-Kutta method is given by
yn+1 = yn + (1/6) (y1 + 2 y2 + 2 y3 + y4)
y1 = h f(xn, yn)

(2.5)

y2 = h f(xn+ h/2, yn+y1/2 )


28

NGN 509

Solution of a concentration problem using Numerical Methods

y3 = h f(xn+ h/2, yn+y2/2 )

y4 = h f(xn+ h, yn+y3 )

Let h = 0.01 (N=100), for the first step,


y1 = 0.01*(-21.6*1) = -0.21600
y2 = 0.01* [-21.6*(1-0.21600/2)] = -0.192672
y3 = 0.01* [-21.6*(1-0.87856/2)] = -0.19519
y4 = 0.01* [-21.6*(1-0.19082)] = -0.17384
y1 = 1 + (1/6) (-0.216 + 2*-0.192672+ 2*-0.19519-0.17384) = 0.805739
These results and the results of subsequent steps are summarized in Table 2.4.
Table2.4 Numerical results of the problem using the fourth-order Runge-Kutta method

xn

yn

y1
y3

xn+1
yn+1
0
1.00000E+00 -2.16000E-01
-1.95191E-01
0.01 8.05739E-01 -1.74040E-01
-1.57273E-01
0.02

6.49215E-01

y2
y4

Error

-1.92672E-01
0
-1.73839E-01
-1.55243E-01 3.78139E-06
-1.40069E-01

-1.40231E-01 -1.25086E-01 6.09361E-06


-1.26721E-01 -1.12859E-01

0.03

5.23098E-01

-1.12989E-01 -1.00786E-01 7.36478E-06


-1.02104E-01 -9.09347E-02

0.04

4.21481E-01

0.05

3.39603E-01

0.06

2.73632E-01

0.07

2.20476E-01

0.08

1.77646E-01

0.09

1.43136E-01

0.1

1.15331E-01

-9.10398E-02 -8.12075E-02
-8.22694E-02
-7.33544E-02
-6.62877E-02
-5.91045E-02
-5.34106E-02
-4.76228E-02
-4.30350E-02
-3.83715E-02
-3.46750E-02
-3.09174E-02
-2.79390E-02
-2.49114E-02

-7.32696E-02
-6.54321E-02
-5.90362E-02
-5.27212E-02
-4.75678E-02
-4.24795E-02
-3.83272E-02
-3.42274E-02
-3.08817E-02
-2.75784E-02
-2.48826E-02
-2.22210E-02

7.9121E-06
7.96884E-06
7.70495E-06
7.24286E-06
6.66953E-06
6.04563E-06
5.41243E-06
29

NGN 509

Solution of a concentration problem using Numerical Methods

xn

yn

xn+1

yn+1

0.11

9.29263E-02

0.12

7.48744E-02

0.13

6.03292E-02

0.14

4.86096E-02

0.15

3.91667E-02

0.16

3.15581E-02

0.17

2.54276E-02

0.18

2.04880E-02

0.19

1.65080E-02

0.2

1.33011E-02

0.21

1.07172E-02

0.22

8.63530E-03

0.23

6.95780E-03

0.24

5.60617E-03

0.25

4.51711E-03

0.26

3.63961E-03

y1
y3

y2
y4

-2.25115E-02
-2.00721E-02
-1.81384E-02
-1.61729E-02
-1.46148E-02
-1.30311E-02
-1.17757E-02
-1.04997E-02
-9.48818E-03
-8.46000E-03
-7.64499E-03
-6.81655E-03
-6.15987E-03
-5.49236E-03
-4.96325E-03
-4.42541E-03
-3.99908E-03
-3.56573E-03
-3.22222E-03
-2.87304E-03
-2.59627E-03
-2.31492E-03
-2.09191E-03
-1.86522E-03
-1.68554E-03
-1.50288E-03
-1.35810E-03
-1.21093E-03
-1.09428E-03
-9.75696E-04
-8.81701E-04
-7.86156E-04
-7.10421E-04

-2.00489E-02
-1.79043E-02
-1.61542E-02
-1.44262E-02
-1.30161E-02
-1.16237E-02
-1.04875E-02
-9.36571E-03
-8.45023E-03
-7.54632E-03
-6.80868E-03
-6.08036E-03
-5.48602E-03
-4.89919E-03
-4.42030E-03
-3.94747E-03
-3.56161E-03
-3.18063E-03
-2.86973E-03
-2.56276E-03
-2.31225E-03
-2.06491E-03
-1.86307E-03
-1.66378E-03
-1.50115E-03
-1.34057E-03
-1.20953E-03
-1.08015E-03
-9.74569E-04
-8.70321E-04
-7.85248E-04
-7.01251E-04
-6.32705E-04

Error

4.7971E-06
4.21658E-06
3.68058E-06
3.1937E-06
2.75709E-06
2.36959E-06
2.02859E-06
1.73066E-06
1.47193E-06
1.24841E-06
1.05618E-06
8.9153E-07
7.5099E-07
6.3141E-07
5.29948E-07
4.44079E-07

30

NGN 509

Solution of a concentration problem using Numerical Methods

xn

yn

xn+1
0.27

yn+1
2.93258E-03

0.28

2.36289E-03

0.29

1.90388E-03

0.3

1.53403E-03

0.31

1.23603E-03

0.32

9.95914E-04

0.33

8.02447E-04

0.34

6.46563E-04

0.35

5.20961E-04

0.36

4.19758E-04

0.37

3.38216E-04

0.38

2.72514E-04

0.39

2.19575E-04

0.4

1.76920E-04

0.41

1.42551E-04

0.42

1.14859E-04

0.43

9.25466E-05

y1
y3

y2
y4

Error

-6.33437E-04
-5.72414E-04
-5.10385E-04
-4.61216E-04
-4.11237E-04
-3.71620E-04
-3.31350E-04
-2.99429E-04
-2.66981E-04
-2.41262E-04
-2.15117E-04
-1.94394E-04
-1.73328E-04
-1.56631E-04
-1.39658E-04
-1.26203E-04
-1.12528E-04
-1.01687E-04
-9.06678E-05
-8.19333E-05
-7.30546E-05
-6.60168E-05
-5.88630E-05
-5.31923E-05
-4.74282E-05
-4.28591E-05
-3.82147E-05
-3.45333E-05
-3.07911E-05
-2.78248E-05
-2.48096E-05
-2.24195E-05
-1.99901E-05

-5.65026E-04
-5.09795E-04
-4.55263E-04
-4.10762E-04
-3.66823E-04
-3.30967E-04
-2.95564E-04
-2.66673E-04
-2.38147E-04
-2.14869E-04
-1.91885E-04
-1.73128E-04
-1.54609E-04
-1.39496E-04
-1.24575E-04
-1.12398E-04
-1.00375E-04
-9.05631E-05
-8.08757E-05
-7.29702E-05
-6.51647E-05
-5.87950E-05
-5.25058E-05
-4.73734E-05
-4.23059E-05
-3.81706E-05
-3.40876E-05
-3.07556E-05
-2.74657E-05
-2.47810E-05
-2.21302E-05
-1.99670E-05
-1.78311E-05

3.71573E-07
3.10479E-07
2.59099E-07
2.15964E-07
1.79811E-07
1.49554E-07
1.24267E-07
1.0316E-07
8.55649E-08
7.09126E-08
5.87241E-08
4.8595E-08
4.01852E-08
3.32089E-08
2.74266E-08
2.26376E-08
1.86743E-08
31

NGN 509

Solution of a concentration problem using Numerical Methods

xn

yn

xn+1

yn+1

0.44

7.45684E-05

0.45

6.00827E-05

0.46

4.84110E-05

0.47

3.90066E-05

0.48

3.14292E-05

0.49

2.53237E-05

0.5

2.04043E-05

0.51

1.64405E-05

0.52

1.32468E-05

0.53

1.06734E-05

0.54

8.60002E-06

0.55

6.92937E-06

0.56

5.58326E-06

0.57

4.49865E-06

0.58

3.62474E-06

0.59

2.92060E-06

y1
y3

y2
y4

-1.80643E-05
-1.61068E-05
-1.45551E-05
-1.29779E-05
-1.17276E-05
-1.04568E-05
-9.44941E-06
-8.42543E-06
-7.61376E-06
-6.78870E-06
-6.13470E-06
-5.46992E-06
-4.94297E-06
-4.40733E-06
-3.98274E-06
-3.55116E-06
-3.20905E-06
-2.86130E-06
-2.58566E-06
-2.30547E-06
-2.08337E-06
-1.85760E-06
-1.67865E-06
-1.49674E-06
-1.35255E-06
-1.20598E-06
-1.08981E-06
-9.71709E-07
-8.78099E-07
-7.82944E-07
-7.07518E-07
-6.30849E-07
-5.70075E-07

-1.60882E-05
-1.43672E-05
-1.29629E-05
-1.15763E-05
-1.04447E-05
-9.32744E-06
-8.41570E-06
-7.51548E-06
-6.78086E-06
-6.05552E-06
-5.46360E-06
-4.87917E-06
-4.40224E-06
-3.93134E-06
-3.54705E-06
-3.16763E-06
-2.85800E-06
-2.55228E-06
-2.30280E-06
-2.05647E-06
-1.85546E-06
-1.65698E-06
-1.49502E-06
-1.33510E-06
-1.20459E-06
-1.07574E-06
-9.70587E-07
-8.66765E-07
-7.82040E-07
-6.98386E-07
-6.30120E-07
-5.62717E-07
-5.07712E-07

Error

1.53965E-08
1.26874E-08
1.04499E-08
8.60293E-09
7.07918E-09
5.82279E-09
4.78739E-09
3.93452E-09
3.23235E-09
2.65451E-09
2.17919E-09
1.78837E-09
1.46716E-09
1.20325E-09
9.86516E-10
8.08577E-10

32

NGN 509

Solution of a concentration problem using Numerical Methods

xn

yn

xn+1
0.6

yn+1
2.35324E-06

0.61

1.89610E-06

0.62

1.52776E-06

0.63

1.23097E-06

0.64

9.91844E-07

0.65

7.99168E-07

0.66

6.43921E-07

0.67

5.18832E-07

0.68

4.18043E-07

0.69

3.36834E-07

0.7

2.71400E-07

0.71

2.18678E-07

0.72

1.76197E-07

0.73

1.41969E-07

0.74

1.14390E-07

0.75

9.21684E-08

0.76

7.42637E-08

y1
y3

y2
y4

Error

-5.08299E-07
-4.59332E-07
-4.09557E-07
-3.70102E-07
-3.29996E-07
-2.98205E-07
-2.65891E-07
-2.40276E-07
-2.14238E-07
-1.93600E-07
-1.72620E-07
-1.55991E-07
-1.39087E-07
-1.25688E-07
-1.12068E-07
-1.01272E-07
-9.02973E-08
-8.15985E-08
-7.27561E-08
-6.57471E-08
-5.86224E-08
-5.29750E-08
-4.72344E-08
-4.26840E-08
-3.80586E-08
-3.43922E-08
-3.06653E-08
-2.77111E-08
-2.47082E-08
-2.23279E-08
-1.99084E-08
-1.79905E-08
-1.60410E-08

-4.53403E-07
-4.09084E-07
-3.65325E-07
-3.29615E-07
-2.94356E-07
-2.65583E-07
-2.37174E-07
-2.13991E-07
-1.91101E-07
-1.72421E-07
-1.53977E-07
-1.38926E-07
-1.24065E-07
-1.11938E-07
-9.99644E-08
-9.01931E-08
-8.05452E-08
-7.26721E-08
-6.48984E-08
-5.85547E-08
-5.22912E-08
-4.71798E-08
-4.21331E-08
-3.80146E-08
-3.39483E-08
-3.06299E-08
-2.73534E-08
-2.46797E-08
-2.20397E-08
-1.98854E-08
-1.77583E-08
-1.60224E-08
-1.43085E-08

6.62543E-10
5.42733E-10
4.44469E-10
3.63901E-10
2.97863E-10
2.43749E-10
1.99419E-10
1.63114E-10
1.33389E-10
1.09057E-10
8.91446E-11
7.28532E-11
5.95273E-11
4.86295E-11
3.97194E-11
3.24358E-11
2.64832E-11
33

NGN 509

Solution of a concentration problem using Numerical Methods

xn

yn

xn+1

yn+1

0.77

5.98372E-08

0.78

4.82132E-08

0.79

3.88472E-08

0.8

3.13007E-08

0.81

2.52202E-08

0.82

2.03209E-08

0.83

1.63734E-08

0.84

1.31927E-08

0.85

1.06298E-08

0.86

8.56487E-09

0.87

6.90105E-09

0.88

5.56045E-09

0.89

4.48027E-09

0.9

3.60993E-09

0.91

2.90866E-09

0.92

2.34362E-09

y1
y3

y2
y4

-1.44956E-08
-1.29248E-08
-1.16797E-08
-1.04140E-08
-9.41079E-09
-8.39100E-09
-7.58264E-09
-6.76096E-09
-6.10963E-09
-5.44757E-09
-4.92277E-09
-4.38932E-09
-3.96647E-09
-3.53664E-09
-3.19594E-09
-2.84961E-09
-2.57509E-09
-2.29604E-09
-2.07485E-09
-1.85001E-09
-1.67179E-09
-1.49063E-09
-1.34703E-09
-1.20106E-09
-1.08535E-09
-9.67739E-10
-8.74510E-10
-7.79745E-10
-7.04627E-10
-6.28271E-10
-5.67746E-10
-5.06222E-10
-4.57455E-10

-1.29099E-08
-1.15289E-08
-1.04020E-08
-9.28932E-09
-8.38131E-09
-7.48477E-09
-6.75315E-09
-6.03077E-09
-5.44128E-09
-4.85923E-09
-4.38425E-09
-3.91527E-09
-3.53256E-09
-3.15469E-09
-2.84632E-09
-2.54185E-09
-2.29339E-09
-2.04807E-09
-1.84788E-09
-1.65021E-09
-1.48891E-09
-1.32964E-09
-1.19967E-09
-1.07134E-09
-9.66621E-10
-8.63223E-10
-7.78844E-10
-6.95532E-10
-6.27545E-10
-5.60418E-10
-5.05638E-10
-4.51550E-10
-4.07412E-10

Error

2.16193E-11
1.76457E-11
1.44001E-11
1.17495E-11
9.58538E-12
7.81865E-12
6.3766E-12
5.19977E-12
4.23952E-12
3.45613E-12
2.81711E-12
2.29594E-12
1.87095E-12
1.52443E-12
1.24194E-12
1.01167E-12

34

NGN 509

Solution of a concentration problem using Numerical Methods

xn

yn

xn+1
0.93

yn+1
1.88835E-09

0.94

1.52152E-09

0.95

1.22594E-09

0.96

9.87792E-10

0.97

7.95902E-10

0.98

6.41290E-10

0.99

5.16712E-10

4.16335E-10

y1
y3

y2
y4

Error

-4.07883E-10
-3.68589E-10
-3.28647E-10
-2.96987E-10
-2.64804E-10
-2.39294E-10
-2.13363E-10
-1.92808E-10
-1.71915E-10
-1.55353E-10
-1.38519E-10
-1.25174E-10
-1.11610E-10
-1.00858E-10
-8.99284E-11
-8.12650E-11

-3.63832E-10
-3.28268E-10
-2.93153E-10
-2.64498E-10
-2.36205E-10
-2.13117E-10
-1.90320E-10
-1.71716E-10
-1.53348E-10
-1.38359E-10
-1.23559E-10
-1.11481E-10
-9.95559E-11
-8.98245E-11
-8.02161E-11
-7.23751E-11

8.24002E-13
6.71068E-13
5.46457E-13
4.44935E-13
3.62235E-13
2.94875E-13
2.40016E-13
1.95344E-13

2.5.Solving using the fourth-order Adams-Bashforth-Moulton method


The fourth-order Adams-Bashforth-Moulton method is given by
yPn+1 = yn + (h/24) (55 fn 59 fn-1 +37 fn-2 9 fn-3)
C

n+1

= yn + (h/24) (9

fPn+1

(2.6)

+19 fn -5 fn-1 + fn-2)

Rather than using starting values obtained by the fourth-order Runge-Kutta as done in the
general case, the first three exact values at x= 0.01, 0.02, 0.03 are used with their corresponding
(fn). These values are shown in Table 2.5.
For x4= 0.04:
yP4= 5.23091E-01 + (0.01/24) (55*-1.12988E-01 59*-1.40229E-01 +37* -1.74039E-01
-9*-2.16000E-01) = 5.22076E-1
fP4= -21.6* 5.22076E-1= -1.12768E-1
yC4= 5.23091E-01 + (0.01/24) (9*-1.12768E-1+19*-1.12988E-01 -5*-1.40229E-01 +
-1.74039E-01) = 5.21993E-01
35

NGN 509

Solution of a concentration problem using Numerical Methods

These results and the results of subsequent steps are summarized in Table 2.5.
Table2.5 Numerical results of the problem using the fourth-order Adams-Bashforth-Moulton method

xn
xn+1
0
0.01
0.02
0.03

0.04

0.05

0.06

0.07

0.08

0.09

0.1

0.11

yn

Error

fn

yPn+1
fPn+1
yCn+1
1.00000E+00 -2.16000E+01

yn+1

8.05735E-01
6.49209E-01
5.23091E-01

-1.74039E+01 Exact Solution


-1.40229E+01
-1.12988E+01

4.21581E-01

-9.10615E+00

4.21457E-01

-9.10347E+00

3.39675E-01

-7.33698E+00

3.39570E-01

-7.33472E+00

2.73673E-01

-5.91135E+00

2.73594E-01

-5.90963E+00

2.20502E-01

-4.76285E+00

2.20436E-01

-4.76143E+00

1.77660E-01

-3.83745E+00

1.77607E-01

-3.83631E+00

1.43142E-01

-3.09186E+00

1.43099E-01

-3.09094E+00

1.15330E-01

-2.49113E+00

1.15296E-01

-2.49039E+00

9.29221E-02

-2.00712E+00

9.28944E-02

-2.00652E+00

4.21473E-01

-1.57236E-05

3.39596E-01

-2.50607E-05

2.73624E-01

-2.99894E-05

2.20469E-01

-3.21918E-05

1.77639E-01

-3.24042E-05

1.43130E-01

-3.13158E-05

1.15325E-01

-2.94285E-05

9.29215E-02

-2.70925E-05
36

NGN 509

Solution of a concentration problem using Numerical Methods

xn

yn
P

xn+1

0.12

0.13

0.14

0.15

0.16

0.17

0.18

0.19

0.2

0.21

0.22

Error

fn
f

y n+1
yCn+1
7.48679E-02

-1.61715E+00

7.48456E-02

-1.61666E+00

6.03215E-02

-1.30294E+00

6.03035E-02

-1.30256E+00

4.86014E-02

-1.04979E+00

4.85869E-02

-1.04948E+00

3.91584E-02

-8.45822E-01

3.91468E-02

-8.45570E-01

3.15502E-02

-6.81484E-01

3.15408E-02

-6.81281E-01

2.54202E-02

-5.49076E-01

2.54126E-02

-5.48912E-01

2.04812E-02

-4.42394E-01

2.04751E-02

-4.42262E-01

1.65018E-02

-3.56439E-01

1.64969E-02

-3.56333E-01

1.32956E-02

-2.87185E-01

1.32917E-02

-2.87100E-01

1.07124E-02

-2.31387E-01

1.07092E-02

-2.31318E-01

8.63101E-03

-1.86430E-01

8.62844E-03

-1.86374E-01

n+1

yn+1

7.48701E-02

-2.45533E-05

6.03255E-02

-2.19782E-05

4.86064E-02

-1.94769E-05

3.91639E-02

-1.71180E-05

3.15557E-02

-1.49405E-05

2.54256E-02

-1.29630E-05

2.04863E-02

-1.11899E-05

1.65065E-02

-9.61651E-06

1.32999E-02

-8.23210E-06

1.07162E-02

-7.02266E-06

8.63441E-03

-5.97243E-06
37

NGN 509

Solution of a concentration problem using Numerical Methods

xn

yn
P

xn+1

0.23

0.24

0.25

0.26

0.27

0.28

0.29

0.3

0.31

0.32

0.33

Error

fn
f

y n+1
yCn+1
6.95406E-03

-1.50208E-01

6.95198E-03

-1.50163E-01

5.60292E-03

-1.21023E-01

5.60125E-03

-1.20987E-01

4.51431E-03

-9.75091E-02

4.51296E-03

-9.74800E-02

3.63721E-03

-7.85636E-02

3.63612E-03

-7.85402E-02

2.93052E-03

-6.32992E-02

2.92965E-03

-6.32803E-02

2.36114E-03

-5.10005E-02

2.36043E-03

-5.09853E-02

1.90238E-03

-4.10914E-02

1.90181E-03

-4.10792E-02

1.53276E-03

-3.31076E-02

1.53230E-03

-3.30978E-02

1.23495E-03

-2.66750E-02

1.23459E-03

-2.66671E-02

9.95010E-04

-2.14922E-02

9.94713E-04

-2.14858E-02

8.01685E-04

-1.73164E-02

8.01447E-04

-1.73112E-02

n+1

yn+1

6.95705E-03

-5.06521E-06

5.60554E-03

-4.28508E-06

4.51658E-03

-3.61689E-06

3.63917E-03

-3.04659E-06

2.93221E-03

-2.56137E-06

2.36258E-03

-2.14969E-06

1.90362E-03

-1.80130E-06

1.53381E-03

-1.50714E-06

1.23585E-03

-1.25929E-06

9.95764E-04

-1.05085E-06

8.02322E-04

-8.75879E-07
38

NGN 509

Solution of a concentration problem using Numerical Methods

xn

yn
P

xn+1

0.34

0.35

0.36

0.37

0.38

0.39

0.4

0.41

0.42

0.43

0.44

Error

fn
f

y n+1
yCn+1
6.45923E-04

-1.39519E-02

6.45730E-04

-1.39478E-02

5.20424E-04

-1.12412E-02

5.20269E-04

-1.12378E-02

4.19309E-04

-9.05707E-03

4.19184E-04

-9.05437E-03

3.37839E-04

-7.29733E-03

3.37739E-04

-7.29516E-03

2.72199E-04

-5.87950E-03

2.72118E-04

-5.87775E-03

2.19313E-04

-4.73715E-03

2.19247E-04

-4.73574E-03

1.76701E-04

-3.81675E-03

1.76649E-04

-3.81561E-03

1.42369E-04

-3.07518E-03

1.42327E-04

-3.07426E-03

1.14708E-04

-2.47769E-03

1.14674E-04

-2.47695E-03

9.24208E-05

-1.99629E-03

9.23933E-05

-1.99570E-03

7.44640E-05

-1.60842E-03

7.44418E-05

-1.60794E-03

n+1

yn+1

6.46460E-04

-7.29228E-07

5.20875E-04

-6.06500E-07

4.19688E-04

-5.03934E-07

3.38157E-04

-4.18330E-07

2.72465E-04

-3.46967E-07

2.19535E-04

-2.87543E-07

1.76887E-04

-2.38112E-07

1.42524E-04

-1.97036E-07

1.14837E-04

-1.62932E-07

9.25279E-05

-1.34643E-07

7.45530E-05

-1.11196E-07
39

NGN 509

Solution of a concentration problem using Numerical Methods

xn

yn
P

xn+1

0.45

0.46

0.47

0.48

0.49

0.5

0.51

0.52

0.53

0.54

0.55

Error

fn
f

y n+1
yCn+1
5.99961E-05

-1.29592E-03

5.99782E-05

-1.29553E-03

4.83392E-05

-1.04413E-03

4.83248E-05

-1.04382E-03

3.89472E-05

-8.41259E-04

3.89356E-05

-8.41009E-04

3.13800E-05

-6.77808E-04

3.13706E-05

-6.77606E-04

2.52830E-05

-5.46114E-04

2.52755E-05

-5.45951E-04

2.03707E-05

-4.40007E-04

2.03646E-05

-4.39876E-04

1.64128E-05

-3.54516E-04

1.64079E-05

-3.54411E-04

1.32239E-05

-2.85636E-04

1.32199E-05

-2.85551E-04

1.06546E-05

-2.30139E-04

1.06514E-05

-2.30070E-04

8.58445E-06

-1.85424E-04

8.58189E-06

-1.85369E-04

6.91654E-06

-1.49397E-04

6.91448E-06

-1.49353E-04

n+1

yn+1

6.00700E-05

-9.17772E-08

4.84005E-05

-7.57069E-08

3.89980E-05

-6.24168E-08

3.14221E-05

-5.14331E-08

2.53179E-05

-4.23614E-08

2.03995E-05

-3.48732E-08

1.64366E-05

-2.86957E-08

1.32435E-05

-2.36023E-08

1.06708E-05

-1.94049E-08

8.59784E-06

-1.59475E-08

6.92758E-06

-1.31011E-08
40

NGN 509

Solution of a concentration problem using Numerical Methods

xn

yn
P

xn+1

0.56

0.57

0.58

0.59

0.6

0.61

0.62

0.63

0.64

0.65

0.66

Error

fn
f

y n+1
yCn+1
5.57270E-06

-1.20370E-04

5.57104E-06

-1.20334E-04

4.48996E-06

-9.69830E-05

4.48862E-06

-9.69541E-05

3.61758E-06

-7.81398E-05

3.61651E-06

-7.81165E-05

2.91471E-06

-6.29577E-05

2.91384E-06

-6.29390E-05

2.34840E-06

-5.07254E-05

2.34770E-06

-5.07103E-05

1.89212E-06

-4.08698E-05

1.89156E-06

-4.08576E-05

1.52449E-06

-3.29290E-05

1.52404E-06

-3.29192E-05

1.22829E-06

-2.65311E-05

1.22793E-06

-2.65232E-05

9.89642E-07

-2.13763E-05

9.89347E-07

-2.13699E-05

7.97361E-07

-1.72230E-05

7.97123E-07

-1.72179E-05

6.42438E-07

-1.38767E-05

6.42247E-07

-1.38725E-05

n+1

yn+1

5.58180E-06

-1.07588E-08

4.49745E-06

-8.83211E-09

3.62375E-06

-7.24796E-09

2.91979E-06

-5.94599E-09

2.35258E-06

-4.87634E-09

1.89555E-06

-3.99788E-09

1.52731E-06

-3.27670E-09

1.23061E-06

-2.68484E-09

9.91546E-07

-2.19928E-09

7.98924E-07

-1.80105E-09

6.43721E-07

-1.47454E-09
41

NGN 509

Solution of a concentration problem using Numerical Methods

xn

yn
P

xn+1

0.67

0.68

0.69

0.7

0.71

0.72

0.73

0.74

0.75

0.76

0.77

Error

fn
f

y n+1
yCn+1
5.17616E-07

-1.11805E-05

5.17462E-07

-1.11772E-05

4.17047E-07

-9.00820E-06

4.16922E-07

-9.00552E-06

3.36017E-07

-7.25796E-06

3.35917E-07

-7.25580E-06

2.70731E-07

-5.84779E-06

2.70650E-07

-5.84604E-06

2.18129E-07

-4.71160E-06

2.18064E-07

-4.71019E-06

1.75748E-07

-3.79616E-06

1.75696E-07

-3.79503E-06

1.41601E-07

-3.05859E-06

1.41559E-07

-3.05768E-06

1.14089E-07

-2.46432E-06

1.14055E-07

-2.46359E-06

9.19222E-08

-1.98552E-06

9.18949E-08

-1.98493E-06

7.40623E-08

-1.59975E-06

7.40402E-08

-1.59927E-06

5.96724E-08

-1.28892E-06

5.96547E-08

-1.28854E-06

n+1

yn+1

5.18669E-07

-1.20692E-09

4.17910E-07

-9.87635E-10

3.36725E-07

-8.07998E-10

2.71311E-07

-6.60883E-10

2.18605E-07

-5.40433E-10

1.76138E-07

-4.41840E-10

1.41920E-07

-3.61158E-10

1.14350E-07

-2.95149E-10

9.21360E-08

-2.41157E-10

7.42372E-08

-1.97003E-10

5.98156E-08

-1.60903E-10
42

NGN 509

Solution of a concentration problem using Numerical Methods

xn

yn
P

xn+1

0.78

0.79

0.8

0.81

0.82

0.83

0.84

0.85

0.86

0.87

0.88

Error

fn
f

y n+1
yCn+1
4.80784E-08

-1.03849E-06

4.80641E-08

-1.03818E-06

3.87371E-08

-8.36721E-07

3.87255E-08

-8.36472E-07

3.12107E-08

-6.74151E-07

3.12014E-08

-6.73950E-07

2.51466E-08

-5.43168E-07

2.51392E-08

-5.43006E-07

2.02608E-08

-4.37633E-07

2.02548E-08

-4.37503E-07

1.63243E-08

-3.52604E-07

1.63194E-08

-3.52499E-07

1.31525E-08

-2.84095E-07

1.31486E-08

-2.84010E-07

1.05971E-08

-2.28897E-07

1.05939E-08

-2.28829E-07

8.53814E-09

-1.84424E-07

8.53559E-09

-1.84369E-07

6.87923E-09

-1.48591E-07

6.87718E-09

-1.48547E-07

5.54263E-09

-1.19721E-07

5.54098E-09

-1.19685E-07

n+1

yn+1

4.81955E-08

-1.31395E-10

3.88328E-08

-1.07279E-10

3.12890E-08

-8.75739E-11

2.52106E-08

-7.14764E-11

2.03131E-08

-5.83282E-11

1.63670E-08

-4.75910E-11

1.31875E-08

-3.88243E-11

1.06256E-08

-3.16677E-11

8.56142E-09

-2.58264E-11

6.89824E-09

-2.10595E-11

5.55815E-09

-1.71701E-11
43

NGN 509

Solution of a concentration problem using Numerical Methods

xn

yn
P

xn+1

0.89

0.9

0.91

0.92

0.93

0.94

0.95

0.96

0.97

0.98

0.99

Error

fn
f

y n+1
yCn+1
4.46573E-09

-9.64598E-08

4.46440E-09

-9.64311E-08

3.59807E-09

-7.77183E-08

3.59700E-09

-7.76951E-08

2.89899E-09

-6.26181E-08

2.89812E-09

-6.25994E-08

2.33573E-09

-5.04518E-08

2.33503E-09

-5.04367E-08

1.88191E-09

-4.06493E-08

1.88135E-09

-4.06372E-08

1.51627E-09

-3.27514E-08

1.51582E-09

-3.27416E-08

1.22167E-09

-2.63880E-08

1.22130E-09

-2.63801E-08

9.84303E-10

-2.12610E-08

9.84010E-10

-2.12546E-08

7.93059E-10

-1.71301E-08

7.92823E-10

-1.71250E-08

6.38972E-10

-1.38018E-08

6.38782E-10

-1.37977E-08

5.14824E-10

-1.11202E-08

5.14670E-10

-1.11169E-08

n+1

yn+1

4.47840E-09

-1.39970E-11

3.60840E-09

-1.14088E-11

2.90742E-09

-9.29796E-12

2.34261E-09

-7.57667E-12

1.88752E-09

-6.17327E-12

1.52084E-09

-5.02919E-12

1.22540E-09

-4.09664E-12

9.87347E-10

-3.33662E-12

7.95540E-10

-2.71729E-12

6.40995E-10

-2.21266E-12

5.16472E-10

-1.80155E-12
44

NGN 509

Solution of a concentration problem using Numerical Methods

xn

yn
P

xn+1

Error

fn
f

y n+1
yCn+1
4.14797E-10

-8.95961E-09

4.14673E-10

-8.95694E-09

n+1

yn+1

4.16140E-10

-1.4667E-12

45

Solution of a concentration problem using Numerical Methods

NGN 509

46

Solution of a concentration problem using Numerical Methods

NGN 509

3.1.Solving using MATLAB


In this section, graphs comparing the MATLAB results obtained using previous numerical
methods and the analytical solution are made. The MATLAB codes used to obtain the solution of
the ODE are shown in Appendix A.

Figure 3.1 Solution using Euler approximation

47

Solution of a concentration problem using Numerical Methods

NGN 509

Figure 3.2 Solution using Modified midpoint and Euler approximation

Figure 3.3 Solution using fourth-order Runge-Kutta approximation

48

Solution of a concentration problem using Numerical Methods

NGN 509

Figure 3.4 Solution using fourth-order Adams-Bashforth-Moulton approximation

49

Solution of a concentration problem using Numerical Methods

NGN 509

50

Solution of a concentration problem using Numerical Methods

NGN 509

4.1.Discussion
The problem was defined and modeled in the first section and an analytical solution was
presented.
The numerical solution of the problem was in Section 2, in which five approximation methods
were used and the results were compared to the exact solution by obtaining the error in each step.
Section 3 shows the figures compares the numerical solution to the analytical one graphically
using MATLAB, were the MATLAB codes were shown in Appendix A.
Approximating with Euler method gave the results in Table 2.1, while Figure 3.1 graphs the
solution.
The modified midpoint was applied introducing the predictor and corrected values and the results
were in Table 2.2 and Figure 3.2, successively.
The modified Euler was also applied using the predictor and corrected values as well and it gave
the results in Table 2.3 and Figure 3.2.
The forth-order Runge-Kutta method which evaluates y =(yn+1 -yn) as the weighted sum of
several yi was used and the procedure and the results were summarized in Table 2.4 and Figure
3.3.
The last method was the fourth-order Adams-Bashforth-Moulton which is concidered as a multipoints method that use starting value from either the fourth-order Runge-Kutta or the analytical
values.
The results were presented in Table 2.5 and Figure 3.4.

51

NGN 509

Solution of a concentration problem using Numerical Methods

5.1.Conclusion
Most of the problems in the engineering field can be explained in a way that gives an analytical
solution, but most of the times its complicated and might take long time to solve.
Numerical methods are used as fast ways that offer approximate solutions which are simple to
obtain and have accuracy that is good enough and close to the exact solution.
For the aim of this project, four single-point methods and one multi-points method were used.
The first, the fastest and the simplest was the 1st order Explicit Euler Method.
This method relatively has low accuracy but this was modified using a small step size. The
importance of small step size is extreme in this method as the solution might diverge if the step
was large as the method is conditionally stable.
The limit of stability for this method is [-1
always satisfied for (21h

]. The right-hand inequality is

1), while the left-hand side is satisfied only if h

0.095 (or 21h 2).

The second numerical method used was the modified midpoint method which is considered as a
second order single-point method.
The errors presented in Table 2.2 for the second-order modified midpoint method are
approximately1 5 times smaller than the errors presented in Table 2.1 for the first-order explicit
Euler method. This illustrates the advantage of the second-order method.
The third method used was the modified Euler method which is considered as an alternate
approach for solving the implicit midpoint FDE.
Both, the modified midpoint and the modified Euler methods have a limit of stability of (21h 2)
or (h

0.095) which is the same as the first-order Euler method.

The fourth-order Runge-Kutta method is one ne of the most popular method of the Runge-Kutta
family. It gave the most accurate results with extremely small error as described in Table 2.4 and
Figure 3.3.
The stability condition for this method is
G = 1 + 21 h + 0.5 ( -21 h)2 (1/6)*(-21h)3 + (1/24) (-21h)4
This implies that |G| 1 if (21h

(5.1)

2.785), where G = yn+1/yn.

Last method applied was the fourth-order Adams-Bashforth-Moulton method as an example of


the multi-points methods.
Comparing the results in Table 2.5 obtained using this method to the results in Table 2.4
obtained using the fourth-order Runge-Kutta method shows how different they are regarding the
52

NGN 509

Solution of a concentration problem using Numerical Methods

errors. For example, at x=1, Table 2.4 gives an error of 1.95344E-13 which is approximately 8
times smaller than the corresponding error in Table 2.5. However, the Runge-Kutta method
requires four derivative function evaluations per step compared to two for the Adams-BashforthMoulton method.
The stability condition for this method is
(

(5.2)

For stability, the whole for roots of G should be

1. Solving this equation gives the results

shown in Figure 5.1 [7]


In this project, the method is stable as (21h= 0.21) gives G

1.

Figure 5.1 Solution of equation (5.2)

53

Solution of a concentration problem using Numerical Methods

NGN 509

54

Solution of a concentration problem using Numerical Methods

NGN 509

References
[1] Kehoe, J. P. G. and J. B. Butt,(1972), "Interactions of Inter- and. Intraphase. Gradients in a
Diffusion Limited Catalytic Reaction," A.I.Ch.E. J., 18, 347
[2] Price. T. H, Gradients in a Diffusion Liniiteci Catalytic Reaction, A.I.Ch.E. J., 18, 347, and
J. B. Butt, Catalyst Poisoning and Fixed Bed Reactor Dynamics-TI. Chern. Eng, Sci., 32, 393,
(1977).

[3] http://chemelab.ucsd.edu/CAPE/tutorial/aspentutorial01.pdf, cited on January 2013


[4] S.B. Halligudi*, H.C. Bajaj, K.N. Bhatt and M. Krishnaratnam, Hydrogenation of Benzene to
Cyclohexane Catalyzed by Rhodium(I) Complex Supported on Montmorillonite Clay, Central
Salt and Marine Chemicals Research Institute, Bhavnagar 364 002, India, September 1992

[5] John K. Marangozis , Basil G. Mantzouranls , Anastasios N. Sophos, Intrinsic Kinetics of


Hydrogenation of Benzene on Nickel Catalysts Supported on Kieselguhr, March 1979

[6] K. M. M. Al-Abrahemee, Solution of Some Application of System of Ordinary Initial Value


Problems Using Osculatory Interpolation Technique, Department of Mathematics, College of
Education ,University of Al- Qadysea, December 2011

[7] Joe D. Hoffman, Numerical Methods for Engineers and Scientists, Second Edition, 2001

55

Solution of a concentration problem using Numerical Methods

NGN 509

APPENDIX A
A.1. Euler Approximation code
% The problem to be solved is:
%y'(x)=-21.6*y
%Note: this problem has a known exact solution
% y(x)=exp(-21.6*x)
h=0.01;
x=0:h:1;

%h is the time step.


%initialize time variable.

clear ystar;

%wipe out old variable.

ystar(1)=1.0;

%initial condition (same for approximation).

for i=1:length(x)-1,
%Set up "for" loop.
k1=-21.6*ystar(i);
%Calculate derivative;
ystar(i+1)=ystar(i)+h*k1;
%Estimate new value of y;
end
%exact solution
y=exp(-21.6*x);
%Plot numerical and exact solution.
plot(x,ystar,'b--',x,y,'r-');
legend('Numerical','Exact');
title('Euler Approximation, h=0.01');
xlabel('x');
ylabel('y*(x), y(x)');
%Print results
for i=1:length(x)
disp(sprintf('x=%5.3f,
end

y(x)=%6.4f,

y*(x)=%6.4f',x(i),y(i),ystar(i)));

A.2. Modified Euler Approximation code


% The problem to be solved is:
%y'(x)=-21.6*y
%Note: this problem has a known exact solution
% y(x)=exp(-21.6*x)
h=0.01;
x=0:h:1;

%h is the time step.


%initialize time variable.

56

Solution of a concentration problem using Numerical Methods


clear ystar;

%wipe out old variable.

ystar(1)=1.0;

%initial condition (same for approximation).

NGN 509

for i=1:length(x)-1,
%Set up "for" loop.
k1=-21.6*ystar(i);
%Calculate derivative;
ystar(i+1)=ystar(i)+ h *
subs(k1,{x(i),ystar},{(x(i)+1/2*h),(ystar(i)+1/2*h*subs(k1,{x,y},{x(i),ystar(
i)}))});
%Estimate new value of y;
end
%exact solution
y=exp(-21.6*x);
%Plot numerical and exact solution.
plot(x,ystar,'b--',x,y,'r-');
legend('Numerical','Exact');
title('Modified Euler Approximation, h=0.01');
xlabel('x');
ylabel('y*(x), y(x)');
%Print results
for i=1:length(x)
disp(sprintf('x=%5.3f,
end

y(x)=%6.4f,

y*(x)=%6.4f',x(i),y(i),ystar(i)));

A.3. Fourth-order Runge-Kutta Approximation code


% The problem to be solved is:
%y'(x)=-21.6*y
%Note: this problem has a known exact solution
% y(x)=exp(-21.6*x)
h=0.01;
x=0:h:1;

%h is the time step.


%initialize time variable.

clear ystar;
%wipe out old variable.
ystar = zeros(1,length(x));
ystar(1)=1.0;
%initial condition (same for approximation).
for i=1:length(x)-1,
%Set up "for" loop.
F_xy = @(t,r) -21.6*r;
%Calculate derivative;
k_1
k_2
k_3
k_4

=
=
=
=

F_xy(x(i),ystar(i));
F_xy(x(i)+0.5*h,ystar(i)+0.5*h*k_1);
F_xy((x(i)+0.5*h),(ystar(i)+0.5*h*k_2));
F_xy((x(i)+h),(ystar(i)+k_3*h));

ystar(i+1) = ystar(i) + (1/6)*(k_1+2*k_2+2*k_3+k_4)*h;


value of y;

%Estimate new

57

NGN 509

Solution of a concentration problem using Numerical Methods


end
%exact solution
y=exp(-21.6*x);
%Plot numerical and exact solution.
plot(x,ystar,'s',x,y,'r-');
legend('Numerical','Exact');
title('Forth-Order Runge-Kutta Approximation, h=0.01');
xlabel('x');
ylabel('y*(x), y(x)');
%Print results
for i=1:length(x)
disp(sprintf('x=%5.3f,
end

y(x)=%6.4f,

y*(x)=%6.4f',x(i),y(i),ystar(i)));

A.4. Fourth-order Adams-Bashforth-Moulton Approximation code


% The problem to be solved is:
%y'(x)=-21.6*y
%Note: this problem has a known exact solution
% y(x)=exp(-21.6*x)
h=0.01;
x=0:h:1;

%h is the time step.


%initialize time variable.

clear ystar;
%wipe out old variable.
ystar = zeros(1,length(x));
ystar(1)=1.0;
%initial condition (same for approximation).
for i=1:3,
% generate starting estimates using Runge-Kutta
F_xy = @(t,r) -21.6*r;
%Calculate derivative;
k_1
k_2
k_3
k_4

=
=
=
=

F_xy(x(i),ystar(i));
F_xy(x(i)+0.5*h,ystar(i)+0.5*h*k_1);
F_xy((x(i)+0.5*h),(ystar(i)+0.5*h*k_2));
F_xy((x(i)+h),(ystar(i)+k_3*h));

ystar(i+1) = ystar(i) + (1/6)*(k_1+2*k_2+2*k_3+k_4)*h;


value of y;

%Estimate new

end
% iterate
for i = 4:length(x)-1
% Adams-Bashforth -- *predict*
ystar(i+1) = ystar(i) + h/24*(55*F_xy(x(i), ystar(i)) - 59*F_xy(x(i1),ystar(i-1))+ 37*F_xy(x(i-2),ystar(i-2)) - 9*F_xy(x(i-3),ystar(i-3)));

58

Solution of a concentration problem using Numerical Methods

NGN 509

% Adams-Moulton -- *correct*
ystar(i+1) = ystar(i) + h/24*(9*F_xy(x(i+1),ystar(i+1)) +
19*F_xy(x(i),ystar(i))- 5*F_xy(x(i-1),ystar(i-1)) + F_xy(x(i-2),ystar(i-2)));
end

%exact solution
y=exp(-21.6*x);
%Plot numerical and exact solution.
plot(x,ystar,'s',x,y,'r-');
legend('Numerical','Exact');
title('Forth-Order Adams-Bashforth-Moulton Approximation, h=0.01');
xlabel('x');
ylabel('y*(x), y(x)');
%Print results
for i=1:length(x)
disp(sprintf('x=%5.3f,
end

y(x)=%6.4f,

y*(x)=%6.4f',x(i),y(i),ystar(i)));

59

You might also like