Download as xls, pdf, or txt
Download as xls, pdf, or txt
You are on page 1of 22

[1]

(from Jeff Munic)

A brine solution containing 0.2 lb of salt/gallon of water is added at a rate of 5 gallons per minute to
a tank with 1000 gallons of pure water. The volume in the tank is maintained at a constant volume
of 1000 gallons with an overflow drain. Find the concentration change with time.

The solution is intended to be fairly general for this type problem.

Outline
5 gpm
5 gpm
0.2 lb/gal V=1000 gal

Ms(t)

Material Balance Notation

Change in Salt [lb/min] = Salt in - Salt Out C -Salt concentration [lb/lb]


r - density [lb/gal]
dM s t - time [min]
=Q i ρi C i +Q o ρo C o
dt V - Volume [gallons]
Q - Flow [gal/min]
M - Mass [lbs]
Given
subscripts
i - in
0.2 lb salt/gal [lb salt/gal] o - out
Ms / V = Ms/1000 [lb salt/gal] w - water

s - salt
Data Material balance

gallons per minute to Ms : Mass of salt in the tank Mass of sal entering
t a constant volume C : Salt concentration Msi =
Ci : Salt concentration in the inlet flow
Ci = 0.2 lb/gal Msi =
Co : Salt concentration in the outlet flow,
also, the salt concentration in the tank Mass of salt leaving
Mso =
V : tank volume
5 gpm V= 1000 gal Salt mass content change
Q : Flow rate in the tank
Q= 5 gal/min dMs =
dMs =
Ms(t=0) = 0 lb dMs =

Salt mass flow rate change


dMs/dt =
Ratio Q/V
oncentration [lb/lb] Q= 5 gal/min Salt mass content in tank
V= 1000 gal Ms =
Q/V= 0.005 1/min
Salt concentration in tank
Maas flow rate of salt entering C=
Msi = Q*Ci
Q= 5 gal/min dMs/dt =
Ci = 0.2 lb/gal dMs/dt =
Q*Ci = 1 lb/min dMs/dt =
with
Q * Ci =
Q/V =

dMs/dt =
rev. cjc. 03.04.2018

Material balance The differential equation

Mass of sal entering dMs/dt = -0.005 * Ms +1


Q * Ci * dt
gal/s * lb/gal * s is solved with the Runge-Kutta method
Q * Ci * dt lb in sheet solution

Mass of salt leaving


Q * C * dt lb

Salt mass content change

Msi - Mso
Q * Ci * dt - Q * C * dt
Q * (Ci - Q ) * dt

Salt mass flow rate change


Q * (Ci - C)

Salt mass content in tank


V*C

Salt concentration in tank


Ms / V

Q * (Ci - Ms/V)
Q * Ci - Q * Ms/V
Q * Ci - Q/V * Ms

1.0 lb/min
0.005 * Ms

-0.005 * Ms +1
rev. cjc. 03.04.2018
page 1 of 1
Differential equation

dMs/dt = -0.005 * Ms +1

Salt content at the time


t= 1200 s

Ms = (1/0.005) * (1 - exp( -0.005*t ) )


Ms = 199.50 lb
dM s
= -0. 005⋅M s +1
dt
dM s =( -0 . 005⋅M s +1 ) dt
dM s
= dt
( -0. 005⋅M s +1 )
Ms t
dM s
∫ = ∫ dt
Ms=0 ( -0. 005⋅M s +1 ) t=0

Ln ( -0 . 005⋅M s +1 ) Ms
|=t
−0 . 005 0
Ln ( -0 . 005⋅M s +1 )|0Ms=t⋅(−0. 005 )
Ln ( -0 . 005⋅M s +1 )−Ln ( -0. 005⋅0 +1 )=t⋅(−0 . 005 )
Ln ( -0 . 005⋅M s +1 )=t⋅(−0 . 005 )
-0 . 005⋅M s +1=exp(-0. 005⋅t )
-0 . 005⋅M s =exp(-0 . 005⋅t )-1
0 . 005⋅M s =1−exp(-0 .005⋅t )
1−exp(-0. 005⋅t )
M s=
0 . 005
Microsoft Equation
3.0
rosoft Equation
3.0
Runge Kutta Method

In this application
dMs/dt = -0.005 * Ms +1
Change Function click here to insert a different function

Activate Function
Activates the change by using the function once

Initial Condition (equivalent to select cell F17 and press Enter)


at t = 0 Ms = 0.00
h= 60 increment t by this time
Find Ms-value at t = 1200

n t Ms dMs/dt k1 k2 k3 k4

0 0 0.0 #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!


1 60 #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!
2 120 #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!
3 180 #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!
4 240 #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!
5 300 #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!
6 360 #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!
7 420 #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!
8 480 #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!
9 540 #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!
10 600 #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!
11 660 #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!
12 720 #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!
13 780 #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!
14 840 #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!
15 900 #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!
16 960 #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!
17 1020 #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!
18 1080 #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!
19 1140 #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!
20 1200 #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!

Ci : Salt concentration of the inlet flow


Ci = 0.2 lb/gal Since the solution look like
an exponential case of the
Co : Salt concentration in the outlet flow, type
also, the salt concentration in the tank yo = A * ( 1-exp(-b*t))
the following solution can be
V : tank volume examined
V= 1000 gal A= 200.0
Q : Flow rate b= 0.005
Q= 5 gal/min yo = A * ( 1-exp(-b*t))

Initial salt content in the tank t y yo


Ms(t=0) = 0 lb 0 0.0 0.0
60 51.8 51.8
Final sal content in tank 120 90.2 90.2
A= Ci * V 180 118.7 118.7
Ci = 0.2 lb/gal 240 139.8 139.8
V= 1000 gal 300 155.4 155.4
A= 200 lb 360 166.9 166.9
420 175.5 175.5
Ratio Q/V 480 181.9 181.9
b= Q/V 540 186.6 186.6
Q= 5 gal/min 600 190.0 190.0
V= 1000 gal 660 192.6 192.6
b= 0.005 1/min 720 194.5 194.5
780 196.0 196.0
840 197.0 197.0
900 197.8 197.8
960 198.4 198.4
1020 198.8 198.8
1080 199.1 199.1
1140 199.3 199.3
1200 199.5 199.5

The result shows that the assumed


exponential curve fits quite good the data
Sub RK()
'Excel issue: The function needed to go along with a subroutine
e function once 'to appear in the code module and macros dialog box

Cells(17, 6).Formula = "=RuKu(D17,E17)" 'uses the function once to activate in Excel


"=RuKu( x , y)"
End Sub

Function RuKu(x, y)
'*****************************************************************
'CHANGE THE RIGHT SIDE OF THE FUNCTION BELOW TO ADD YOUR FUNCTION:

RuKu = *0.005 * Ms + 1 (Replace RHS of equation with the new function)

'*****************************************************************

End Function

Runge Kutta Results

1.0
0.8
Y

0.6
0.4
0.2
0.0
0 200 400 600 800 1000 1200 1400
X
f(x) = NaN ln(x) NaN
R² = NaN
Chart Title
1.0

0.9

0.8

0.7

0.6

0.5

0.4

0.3

0.2

0.1

0.0
0 200 400 600 8

See also
Math. Least squares method. Regressions linear, second to sixth grades parabolas and expone
7. Best fit for an exponential curve by the least squares method
Exponential curve through the N pairs of points (xn, yn)
the assumed
quite good the data
page 1 of 2

Runge Kutta

yn+1 = yn + (1/6)(k1 + 2k2 + 2k3 +k4)

k1 = h.f(xn ,yn)
k2 = h.f(xn+h/2, yn+k1/2)
k3 = h.f(xn+h/2, yn+k2/2)
k4 = h.f(xn+h, yn+k3)

Results for different increment values h


Comparison with the exact value
y(3) = 2.763

Calculation error
|et| = Abs( (yexact - ycalc) / yexact ) * 100

h= 1.5 h= 0.5

y(3)calc = 2.759 y(3)calc = 2.763


exact value exact value
y(3) = 2.763 y(3) = 2.763

|et| = 0.14477 % |et| = 0.000 %

0 1400

page 2 of 2
Chart Title

400 600 800 1000 1200 1400

grades parabolas and exponential curve.xls


http://www.chemecalcs.com/rk.php

R-K

http://www.chemecalcs.com/about-the-author.php

Fourth-Order Runge-Kutta Method


develops the solution to the ODE by proceeding stepwise in small increments. The method lends
itself to spreadsheet calculations. This spreadsheet uses Excel's ability to generate user-defined
Formulas Notation

The method solves an ordinary differential equation of the form: x - independent variable
y- dependent variable
dy/dx = f(x,y) h - increment amount
parameters
with initial condition: n - subscript for each step

y(x0) = y0

Fourth Order Runge-Kutta Formulas

yn+1 = yn + (1/6)(k1 + 2k2 + 2k3 +k4)

k1 = h.f(xn ,yn)

k2 = h.f(xn+h/2, yn+k1/2)

k3 = h.f(xn+h/2, yn+k2/2)

k4 = h.f(xn+h, yn+k3)

This spreadsheet defines an inline Excel function RK1(x,y) where:

RK1(x,y) = F(x,y)
To solve a 1st-order ODE problem, just change the function, input the initial conditions and
increment amount. The table can be easily expanded by copying the bottom row and pasting into
rows below.
The Runge-Kutta Runge-Kutta
Fourth-Order Method
Method is a commonly used numerical method for s
differential equations (ODEs) with a known initial condition. The metho
develops the solution to the ODE by proceeding stepwise in small incr
itself to spreadsheet calculations. This spreadsheet uses Excel's abili
functions to provide a general purpose algorithm. The user only needs
Formulas
location rather than altering formulas in an entire table.

The method solves an ordinary differential equation of the form:

dy/dx = f(x,y)

with initial condition:

y(x0) = y0

Fourth Order Runge-Kutta Formulas

yn+1 = yn + (1/6)(k1 + 2k2 + 2k3 +k4)

k1 = h.f(xn ,yn)

k2 = h.f(xn+h/2, yn+k1/2)

k3 = h.f(xn+h/2, yn+k2/2)

k4 = h.f(xn+h, yn+k3)

This spreadsheet defines an inline Excel function RK1(x,y) where:

RK1(x,y) = F(x,y)
To solve a 1st-order ODE problem, just change the function, input the
increment amount. The table can be easily expanded by copying the
rows below.
d numerical method for solving 1st-order ordinary
nitial condition. The method starts at a known point and
ding stepwise in small increments. The method lends
adsheet uses Excel's ability to generate user-defined
thm. The user only needs to change the function in one
ntire table. Notation

quation of the form: x - independent variable


y- dependent variable
h - increment
k1,k amount
2,k4,k4 - Runge-Kutta
parameters
n - subscript for each step

ction RK1(x,y) where:

ge the function, input the initial conditions and


expanded by copying the bottom row and pasting into
[1] http://www.chemecalcs.com/rk.php

You might also like