Numerical Methods for Engineers
Numerical Methods for Engineers
7th Edition
ISBN: 9780073397924
Author: Steven C. Chapra Dr., Raymond P. Canale
Publisher: McGraw-Hill Education
bartleby

Videos

Textbook Question
Book Icon
Chapter 28, Problem 1P

Perform the first computation in Sec. 28.1, but for the casewhere h = 10 . Use the Heun (without iteration) and the fourth-orderRK method to obtain solutions.

Expert Solution & Answer
Check Mark
To determine

To calculate: The solution for c if thedifferential equation for mass balance of single reactor is Vdcdt=QcinQc by the Heun method and fourth-order RK method where h=10.

Answer to Problem 1P

Solution:

The solution for c by the Heun method where h=10 is,

Heun withoutiteration
t c
0 10
10 25
20 34.375
30 40.23438
40 43.89648
50 46.1853

The solution for c by fourth-order RK method where h=10 is,

4th order RK
t c
0 10
10 25.72917
20 35.27317
30 41.06419
40 44.57801
50 46.71009

Explanation of Solution

Given Information:

The differential equation for mass balance of single reactor is, Vdcdt=QcinQc.

The values,

V=100m3Q=5m3/mincin=50mg/m3c0=10mg/m3

The analytical equation for mass balance of single reactor is,

c=cin(1e(Q/V)t)+c0e(Q/V)t

Formula used:

The iteration formula for Heun’s method is,

yi+1=yi+h2(f(xi,yi)+f(xi+h,yi+hf(xi,yi)))

The fourth-order RK method for dydt=f(t,y) is,

yn+1=yn+16(k1+2k2+2k3+k4)tn+1=tn+h

Where,

k1=hf(tn,yn)k2=hf(tn+h2,yn+k12)k3=hf(tn+h2,yn+k22)k4=hf(tn+h,yn+k3)

Calculation:

Consider the analytical equation for mass balance of single reactor is,

c=cin(1e(Q/V)t)+c0e(Q/V)t

Substitute the values V=100 m3Q=5 m3/min,cin=50mg/m3 and c0=10mg/m3 in the above equation,

c=cin(1e(5/100)t)+c0e(5/100)t=50(1e0.05t)+10e0.05t

Now, use VB code to determine c at different value of t using Heun’s method and RK4 method as below,

OptionExplicit

Subfind()

Dim t AsDouble, c AsDouble, h AsDouble,hhAsDouble

'Set the variables

t =0

c =10

h =10

'move to the cell b3

Range("b3").Select

ActiveCell. Value="Heun without iteration"

'Assign name to each columns

ActiveCell. Offset(1,0).Select

ActiveCell. Value="t"

ActiveCell. Offset(0,1).Select

ActiveCell. Value="c"

ActiveCell. Offset(0,1).Select

ActiveCell. Value="k_1"

ActiveCell. Offset(0,1).Select

ActiveCell. Value="c"

ActiveCell. Offset(0,1).Select

ActiveCell. Value="k_2"

ActiveCell. Offset(0,1).Select

ActiveCell. Value="fi"

'call Heun function to determine c at different values of t`

hh=Heun(t, c, h)

'Reset the values

t =0

c =10

h =10

'move to the cell b15

Range("b15").Select

'Assign name to each columns

ActiveCell. Value="4th order RK"

ActiveCell. Offset(1,0).Select

ActiveCell. Value="t"

ActiveCell. Offset(0,1).Select

ActiveCell. Value="c"

ActiveCell. Offset(0,1).Select

ActiveCell. Value="k_1"

ActiveCell. Offset(0,1).Select

ActiveCell. Value="cmid"

ActiveCell. Offset(0,1).Select

ActiveCell. Value="k_2"

ActiveCell. Offset(0,1).Select

ActiveCell. Value="cmid"

ActiveCell. Offset(0,1).Select

ActiveCell. Value="k_3"

ActiveCell. Offset(0,1).Select

ActiveCell. Value="cend"

ActiveCell. Offset(0,1).Select

ActiveCell. Value="k_4"

ActiveCell. Offset(0,1).Select

ActiveCell. Value="fi"

'call RK4 function to determine c at different values of t

hh= RK4(t, c, h)

EndSub

'Define the Heun function

FunctionHeun(t, c, h)

'Declare the variables

Dim dc1dt AsDouble,slpAsDouble, dc2dt AsDouble,ceAsDouble,cnewAsDouble

Dim j AsInteger

'Use loop to determine c at different value of t

For j =1To6

'move to cell b4

Range("b4").Select

'Display the value of t

ActiveCell. Offset(j,0).Select

ActiveCell. Value= t

'Display the value of c

ActiveCell. Offset(0,1).Select

ActiveCell. Value= c

'call drive function to determine derivative

dc1dt =drive(t, c)

ce= c +(dc1dt * h)

dc2dt =drive(t + h,ce)

slp=(dc1dt + dc2dt)/2

cnew= c +slp* h

t = t + h

'display the values in cell

ActiveCell. Offset(0,1).Select

ActiveCell. Value= dc1dt

ActiveCell. Offset(0,1).Select

ActiveCell. Value=ce

ActiveCell. Offset(0,1).Select

ActiveCell. Value= dc2dt

ActiveCell. Offset(0,1).Select

ActiveCell. Value=slp

c =cnew

Next

EndFunction

'define the drive functionto find the derivative

Functiondrive(t, c)

Dim Q AsDouble,cinAsDouble, v AsDouble, temp AsDouble

'set the variables

Q =5

cin=50

v =100

'use formula to find the derivative

temp =(Q *(cin- c))/ v

drive = temp

EndFunction

'define the RK4 function to find c

Function RK4(t, c, h)

Dim k_1 AsDouble, k_2 AsDouble, k_3 AsDouble, k_4 AsDouble

Dim cm AsDouble, cm1 AsDouble,ceAsDouble,slpAsDouble,cnewAsDouble

Dim j AsInteger

'determines k_1, k_2, k_3 and k_4 in Runge kutta to determine c

For j =1To6

'Move to cell b16

Range("b16").Select

ActiveCell. Offset(j,0).Select

ActiveCell. Value= t

ActiveCell. Offset(0,1).Select

ActiveCell. Value= c

'Call drive function to determine k_1

k_1 =drive(t, c)

cm = c +(k_1 *(h /2))

'Call drive function to determine k_2

k_2 =drive(t +(h /2), cm)

cm1 = c +(k_2 *(h /2))

'Call drive function to determine k_3

k_3 =drive(t +(h /2), cm1)

ce= c + k_3 * h

'Call drive function to determine k_4

k_4 =drive(t + h,ce)

slp=(k_1 +2*(k_2 + k_3)+ k_4)/6

cnew= c +(slp* h)

t = t + h

'Display values in cell

ActiveCell. Offset(0,1).Select

ActiveCell. Value= k_1

ActiveCell. Offset(0,1).Select

ActiveCell. Value= cm

ActiveCell. Offset(0,1).Select

ActiveCell. Value= k_2

ActiveCell. Offset(0,1).Select

ActiveCell. Value= cm1

ActiveCell. Offset(0,1).Select

ActiveCell. Value= k_3

ActiveCell. Offset(0,1).Select

ActiveCell. Value=ce

ActiveCell. Offset(0,1).Select

ActiveCell. Value= k_4

ActiveCell. Offset(0,1).Select

ActiveCell. Value=slp

c =cnew

Next

EndFunction

The following output gets displayed in the excel after the execution of the above code:

Numerical Methods for Engineers, Chapter 28, Problem 1P , additional homework tip  1

To draw the graph, use excel as below,

Step 1: Select cells from B5 to B10 and C5 to C10, then go to Insert tab and select the Line option from Charts subgroup.

Step 2: Select cells from B17 to B22 and C17 to C22, then go to Insert tab and select the Line option from Charts subgroup

Step 3: Merge the graphs.

The graph obtained is,

Numerical Methods for Engineers, Chapter 28, Problem 1P , additional homework tip  2

Hence, both the method gives the same results.

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!

Chapter 28 Solutions

Numerical Methods for Engineers

Ch. 28 - An on is other malbatchre actor can be described...Ch. 28 - The following system is a classic example of stiff...Ch. 28 - 28.13 A biofilm with a thickness grows on the...Ch. 28 - 28.14 The following differential equation...Ch. 28 - Prob. 15PCh. 28 - 28.16 Bacteria growing in a batch reactor utilize...Ch. 28 - 28.17 Perform the same computation for the...Ch. 28 - Perform the same computation for the Lorenz...Ch. 28 - The following equation can be used to model the...Ch. 28 - Perform the same computation as in Prob. 28.19,...Ch. 28 - 28.21 An environmental engineer is interested in...Ch. 28 - 28.22 Population-growth dynamics are important in...Ch. 28 - 28.23 Although the model in Prob. 28.22 works...Ch. 28 - 28.25 A cable is hanging from two supports at A...Ch. 28 - 28.26 The basic differential equation of the...Ch. 28 - 28.27 The basic differential equation of the...Ch. 28 - A pond drains through a pipe, as shown in Fig....Ch. 28 - 28.29 Engineers and scientists use mass-spring...Ch. 28 - Under a number of simplifying assumptions, the...Ch. 28 - 28.31 In Prob. 28.30, a linearized groundwater...Ch. 28 - The Lotka-Volterra equations described in Sec....Ch. 28 - The growth of floating, unicellular algae below a...Ch. 28 - 28.34 The following ODEs have been proposed as a...Ch. 28 - 28.35 Perform the same computation as in the first...Ch. 28 - Solve the ODE in the first part of Sec. 8.3 from...Ch. 28 - 28.37 For a simple RL circuit, Kirchhoff’s voltage...Ch. 28 - In contrast to Prob. 28.37, real resistors may not...Ch. 28 - 28.39 Develop an eigenvalue problem for an LC...Ch. 28 - 28.40 Just as Fourier’s law and the heat balance...Ch. 28 - 28.41 Perform the same computation as in Sec....Ch. 28 - 28.42 The rate of cooling of a body can be...Ch. 28 - The rate of heat flow (conduction) between two...Ch. 28 - Repeat the falling parachutist problem (Example...Ch. 28 - 28.45 Suppose that, after falling for 13 s, the...Ch. 28 - 28.46 The following ordinary differential equation...Ch. 28 - 28.47 A forced damped spring-mass system (Fig....Ch. 28 - 28.48 The temperature distribution in a tapered...Ch. 28 - 28.49 The dynamics of a forced spring-mass-damper...Ch. 28 - The differential equation for the velocity of a...Ch. 28 - 28.51 Two masses are attached to a wall by linear...
Knowledge Booster
Background pattern image
Advanced Math
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, advanced-math and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Text book image
Algebra & Trigonometry with Analytic Geometry
Algebra
ISBN:9781133382119
Author:Swokowski
Publisher:Cengage
Text book image
Elements Of Modern Algebra
Algebra
ISBN:9781285463230
Author:Gilbert, Linda, Jimmie
Publisher:Cengage Learning,
Solve ANY Optimization Problem in 5 Steps w/ Examples. What are they and How do you solve them?; Author: Ace Tutors;https://www.youtube.com/watch?v=BfOSKc_sncg;License: Standard YouTube License, CC-BY
Types of solution in LPP|Basic|Multiple solution|Unbounded|Infeasible|GTU|Special case of LP problem; Author: Mechanical Engineering Management;https://www.youtube.com/watch?v=F-D2WICq8Sk;License: Standard YouTube License, CC-BY
Optimization Problems in Calculus; Author: Professor Dave Explains;https://www.youtube.com/watch?v=q1U6AmIa_uQ;License: Standard YouTube License, CC-BY
Introduction to Optimization; Author: Math with Dr. Claire;https://www.youtube.com/watch?v=YLzgYm2tN8E;License: Standard YouTube License, CC-BY