SolutionTut7 10
SolutionTut7 10
SolutionTut7 10
1. The velocity of an object, travelling along a straight line, was measured at various times as
follows:
Time 0 1 2 3 4 5 6 7 8 9 10 11 12
(min)
Velocity 0.0 0.6 1.7 3.4 6.3 11.18 19.09 32.12 53.60 89.02 147.41 243.69 402.43
(cm/min) 0 5 2 8 9
Estimate the distance travelled in 12 minutes using (i) Simpson’s 1/3 rule, (ii) Simpson’s 3/8 rule,
and (iii) Romberg integration, applied to Trapezoidal rule estimates with h=1, 2, and 4.
Solution:
t v Simp 1/3 Simp 3/8 Trap h=1 Trap h=2 Trap h=4
0 0 0.33 1.72 12.78
1 0.65 1.44 3.97 1.19
2 1.72 2.60 8.11
3 3.48 7.34 4.94
4 6.39 28.23 8.79 25.48 119.98
5 11.18 23.40 15.14
6 19.09 25.61 72.69
7 32.12 67.06 136.98 42.86
8 53.6 71.31 201.01 912.06
9 89.02 185.70 118.22
10 147.41 624.28 195.55 549.84
11 243.69 508.20 323.06
12 402.43
793.14 793.46 809.57 858.85 1044.82
The distance travelled in 12 minutes is: 793.14 cm using Simpson’s 1/3 rule, 793.46 cm using
3/8 rule, and 792.89 cm using Romberg integration with three trapezoidal estimates (809.57
using h=1, 858.85 using h=2, 1044.82 using h=4). Note that the Romberg, O(h4), with h=1 and
2, is same as Simpson’s 1/3. Also note that 1/3 rule is more accurate than 3/8 (assuming
Romberg to be the best estimate).
4
2. The flow rate through a circular pipe is given by . = /6 5 201 2 31, where v is the velocity at a
distance of r from the centre of pipe and r0 is the radius of the pipe. If the velocity is
4 :/;
approximated by 2 = 2 71 8 4 9 (in m/s), and the pipe radius is 12 cm, compute Q using
5
Gauss-Legendre quadrature with 2, 3, and 4 Gauss points. Perform an error analysis for the
results, using the true value of the flow rate as 0.07389025921170497 m3/s.
Solution:
4 :/;
The table below shows the computation of Iz and I: @ = 201 A 2 71 8 6.:B9
3-point z w r f w.f
-0.77460 0.555556 0.013524 0.167072 0.092818
0 0.888889 0.060000 0.682900 0.607022
0.77460 0.555556 0.106476 0.979540 0.544189 I Error (%)
Iz 1.244028 0.074642 -1.01697
4-point z w r f w.f
-0.86114 0.347855 0.008332 0.103630 0.036048
-0.33998 0.652145 0.039601 0.469970 0.306489
0.33998 0.652145 0.080399 0.862339 0.56237
0.86114 0.347855 0.111668 0.958623 0.333462 I Error (%)
Iz 1.238368 0.074302 -0.55737
Tutorial 8
1. Solve the differential equation dy/dt = −100 y + 99 e−t with the initial condition y(0)=2
using, (a) Euler’s forward (explicit) method, and (b) Euler backward (implicit)
method, to obtain the value of y at t=0.1. Use time steps of 0.01, 0.02 and 0.025. Find
the analytical solution and compare the errors for these time steps.
Solution:
Clearly, explicit method is unstable for step size of 0.025, and is oscillating in a finite
band for 0.02.
2. The amount of lowering of water level, s, in a well at a time t, due to pumping from
groundwater is governed by an equation of the form s=C W(u), where C is a constant
(proportional to the discharge), W is called the Well Function, and u is inversely
proportional to t. The well function is given by the equation dW(u)/du = −Exp(−u)/u.
If the value of W(1) is 0.21938393, find the value of W(0.5) using (a) Romberg
integration algorithm with accuracy O(h6) (b) Modified Euler with h= −0.5 (c) Heun’s
method with h= −0.25 and (d) Fourth-order Runge-Kutta method with h= −0.25.
Perform an error analysis using the true value of W(0.5) as 0.55977359.
Solution:
: C DE
Romberg: Use trapezoidal with h=0.125, 0.25, 0.5 to estimate /6.H 8 F
3G
h h
Modified Euler: y n +1 = y n + hf t n + , y n + f (t n , y n )
2 2
f (t n , yn ) + f (t n +1 , yn + hf (t n , yn ))
Heun’s method: yn +1 = y n + h
2
1 1
k1 = f (t n , yn ); k 2 = f t n + h, yn + hk1
2 2
4th order R-K method:
1 1
k3 = f t n + h, yn + hk 2 ; k 4 = f (t n + h, yn + hk3 )
2 2
h
yn +1 = y n + (k1 + 2k 2 + 2k3 + k 4 )
6
f(u)=dW/du=-Exp(-u)/u Romberg I=From 0.5 to 1 Modified Euler
k1 -0.36788 -0.62982
k2 -0.47641 -0.85642
k3 -0.47641 -0.85642
k4 -0.62982 -1.21306
Solution: f(x,y) = x2y − 2y. Exact solution is y=exp(x3/3-2x) and value at 0.5 is 0.383531573.
h= 0.125
xi yi f(xi,yi) y0 xi+1 f(xi+1,y0) yi+1
0 1 -2 0.75 0.125000 -1.488281 0.78198242
0.125000 0.7819824 -1.55175 0.58801 0.250000 -1.139277 0.61379344
0.250000 0.6137934 -1.18922 0.46514 0.375000 -0.864870 0.48541249
0.375000 0.4854125 -0.90256 0.37259 0.500000 -0.652036 0.388250 -0.004718
2. Solve the differential equation dy/dx = 10 sin(πx) with the initial condition y(0)=0 and step length
of 0.2 using (a) the 4th order R-K method, (b) the Milne’s method and (c) 4th order Adams method to
obtain the value of y at t=0.2, 0.4, 0.6, 0.8 and 1.0. (For the multi-step methods use the values
obtained from the R-K method for start-up)
Solution: f(x,y) = 10 sin(πx). Exact solution is (10-10 cos πx)/π and the values are:
Adams' h= 0.2
Find y(0.8), y(1)
Milne's h= 0.2 f(x,y)
Find y(0.8), y(1) y(0.8)^0 5.6623 5.8779
f(x,y) y(0.8)^1 5.7663 5.8779
y(0.8)^0 5.6710 5.8779 y(0.8)^2 5.7663 5.8779
y(0.8)^1 5.7616 5.8779
y(0.8)^2 5.7616 5.8779
Solution:
(a) Note that Ralston’s method has been used to solve the IVP
f1=dy1/dx=y2
f2=dy2/dx=3+2y1-2x+y2
h= 0.25
Assume y2(0)=0 Assume y2(0)=1
x y1 y2 f1 f2 x y1 y2 f1 f2
0 0 0 0 3 0 0 1 1 4
0.1875 0 0.5625 0.5625 3.1875 0.1875 0.1875 1.75 1.75 4.75
0.25 0.09375 0.78125 0.25 0.375 2.125
x y1 y2 f1 f2 x y1 y2 f1 f2
0.25 0.09375 0.78125 0.78125 3.46875 0.25 0.375 2.125 2.125 5.375
0.4375 0.24023 1.43164 1.43164 4.03711 0.4375 0.77344 3.13281 3.13281 6.80469
0.5 0.39746 1.74316 0.5 1.07422 3.70703
x y1 y2 f1 f2
0 0 0.44217 0.44217 3.44217
0.1875 0.08291 1.08757 1.08757 3.87838
0.25 0.21811 1.37541
x y1 y2 f1 f2
0.25 0.21811 1.37541 1.37541 4.31163
0.4375 0.476 2.18384 2.18384 5.26084
0.5 0.6967 2.61152
Note: 0.21811 may be directly obtained by linear interpolation between 0.09375 and 0.375
(b) There are three nodes: at 0, 0.25, and 0.5. Only one unknown, y(0.25).
IB 8 2I: J I6 IB 8 I6
8 8 2I: J 2 A K: = 3 => 18I6 8 34I: J 14IB = 3 8 2 A K:
0.25B 0.5
With the known values of x1=0.25, y0=0 and y2=0.6967, we get y1=0.21335 (compared to 0.21811)
Solution: T=0
j=4
j=3
∂T/∂x=0 T=100
j=2
j=1
j=0
i=0 i=1 i=2
T=0
The discretization is shown above. We need to find T1,2. (Six unknowns are T0,1, T0,2, T0,3, T1,1, T1,2, and
T1,3)
MN O MN O
J = 0. The nodal equation, using central difference
MP N MQ N
The governing equation is
ORST,U VBOR,U WORDT,U OR,USTVBOR,UWOR,UDT
J = 0. Since
∆P N ∆Q N
approximation for the second derivative is
Using ghost nodes (i=−1), YV:,[ = Y:,[ . The system of equation is:
4 − 2 −1 T0,1 0
− 1 4 0 −1 T 100
1,1
− 1 0 4 − 2 −1 T0, 2 0
=
−1 −1 4 0 − 1 T1, 2 100
−1 0 4 − 2 T0,3 0
− 1 − 1 4 T1,3 100
\] \] \ B] \]
J2 8 _ B J `] = 0; 0 b K b 1; ](0, ^) = ]6 ; c d = 0; ](K, 0) = K B f VP
\^ \K \K \K (:,e)
Set-up the matrix equations for the solution of the above equation in terms of Courant Number (or
CFL number) and Grid Peclet Number for general ∆x and ∆t :
2∆^
Courant or CFL No. i =
∆K
2∆K
Grid Peclet No. lC =
_
Solution:
Using forward difference for time derivative and central for the space (time is denoted by
superscript, n, and space by subscript, i), we get (for spatial variables, using a weight of μ for the
known time step, n, and a weight of 1−μ for the unknown time step, n+1)
i i i i i
s(1 8 o) t8 8 uv ]ZV:
mW:
J s1 J (1 8 o) t`∆^ J 2 uv ]ZmW: J s(1 8 o) t 8 uv ]ZW:
mW:
2 lC lC 2 lC
i i i i i
= so t J uv ]ZV:
m
J s1 8 o t`∆^ J 2 uv ]Zm J so t8 J uv ]ZW:
m
2 lC lC 2 lC
Or,
wZ,ZV: ]ZV:
mW:
J wZ,Z ]ZmW: J wZ,ZW:]ZW:
mW:
= xZ
The matrix form is (given c0=0 and derivative=zero at the nth node)
a1,1 a1, 2 c1n +1 b1
a a2, 2 a2 , 3 n +1
2,1 c2 b2
a3 , 2 a3 , 3 a3 , 4 c3n +1 b3
=
. . . . .
an −1,n − 2 an −1,n −1 an −1, n cnn−+11 bn −1
an, n −1 + an, n +1 an, n cnn +1 bn