Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

ME 5107: Numerical methods in Thermal Engineering Jul–Nov 2022

Assignment 6
Solution due by 14th October 2022 (in class).

Hand calculations
1. (20 points) The following scheme has been proposed for solving y ′ = f (y):

yi+1 = yi + ω1 k1 + ω2 k2 ,

where

k1 = h f (yi )
k0 = h f (yi + β0 k1 )
k2 = h f (yi + β1 k0 )

with h being the step size.


(a) Determine the coefficients ω1 , ω2 , β0 and β1 that would maximize the order of accuracy of the method.
(b) Applying this method to y ′ = αy, what is the maximum step size h for α pure imaginary?
(c) Applying this method to y ′ = αy, what is the maximum step size h for α real negative?

2. (20 points) Consider solving the following first-order initial value problem:

dy
y ′ (x) = = f (x, y) = x + y, y(0) = 1, 0 ≤ x ≤ 1,
dx
using a fourth-order accurate Taylor-series method given as follows:

y(xi + h) = y(xi ) + h T4 (xi , yi , h)

where
h h2 h3
T4 (xi , yi , h) = y ′ (xi ) + y ′′ (xi )
+ y ′′′ (xi ) + y iv (xi ) .
2! 3! 4!
Starting with x = 0 using a step size of h = 0.1, calculate the solution at x = 1. Tabulate your results
showing the computed solution, exact solution and error at each step. The exact analytical solution is
given by y(x) = 2ex − x − 1.
3. (10 points) Verify that the modified wavenumber for the fourth-order Pade’ scheme for the first derivative
is
3 sin(kh)
k′ =
h(2 + cos(kh))
.
ME 5107: Numerical methods in Thermal Engineering Jul–Nov 2022

Programming
1. (60 points) Consider the following initial value problem

dy
= −λ (y − e−t ) − e−t , λ>0
dt
with the intial condition y(t = 0) = y0 . Solve this initial value problem for λ = 10 and y0 = 10
using explicit Euler, implicit Euler, trapezoidal, second-order Runge-Kutta, fourth-order Runge-Kutta
and Runge-Kutta-Fehlberg method. Use time step sizes h = 0.1, 0.05, 0.025, 0.0125, 0.00625 and integrate
from t = 0 to 0.8. The exact analytical solution to this equation is

y = e−t + (y0 − 1)e−λt .

(a) For each method, plot the solutions obtained along with the exact solution from t = 0 to t = 0.8.
(b) Evaluate the error between the numerical and the exact solution at t = 0.8 as follows. If the order
of the method is p, then the ratio of the error corresponding to a step size of h and h/2 should be 2p .
Tabulate this ratio for successive pairs of h and deduce the asymptotic value of p for each method. Use
double precision arithmetic throghout. The formulation of the methods is given as follows,

• Explicit Euler Method


yi+1 = yi + hf (xi , yi )

• Implicit Euler Method


yi+1 = yi + hf (xi+1 , yi+1 )

• Trapezoidal Method
h
yi+1 = yi + [f (xi , yi ) + f (xi+1 , yi+1 )]
2
• Second-Order Runge-Kutta Method
yi+1 = yi + hk2
where

k1 = f (xi , yi )
 
h h
k2 = f xi + , yi + k1
2 2

• Fourth-Order Runge-Kutta Method


h
yi+1 = yi + (k1 + 2k2 + 2k3 + k4 )
6
where

k1 = f (xi , yi )
 
h h
k2 = f xi + , yi + k1
2 2
 
h h
k3 = f xi + , yi + k2
2 2
k4 = f (xi + h, yi + hk3 )

• Runge-Kutta-Fehlberg Method
 
16 6656 28561 9 2
yi+1 = yi + k1 + k3 + k4 − k5 + k6
135 12825 56430 50 55
ME 5107: Numerical methods in Thermal Engineering Jul–Nov 2022

where

k1 = hf (xi , yi )
 
h k1
k2 = hf xi + , yi +
4 4
 
3h 3k1 9k2
k3 = hf xi + , yi + +
8 32 32
 
12h 1932k1 7200k2 7296k3
k4 = hf xi + , yi + − +
13 2197 2197 2197
 
439k1 3680k3 845k4
k5 = hf xi + h, yi + − 8k2 + −
216 513 4104
 
h 8k1 3544k3 1859k4 11k5
k6 = hf xi + , yi − + 2k2 − + − .
2 27 2565 4104 40

You might also like