unit05.mws

ORDINARY DIFFERENTIAL EQUATIONS POWERTOOL

Unit 5 -- Application: Mixing Problems

Prof. Douglas B. Meade

Industrial Mathematics Institute

Department of Mathematics

University of South Carolina

Columbia, SC 29208

URL: http://www.math.sc.edu/~meade/

E-mail: meade@math.sc.edu

Copyright © 2001 by Douglas B. Meade

All rights reserved

-------------------------------------------------------------------

>

Outline of Unit 5

>

Initialization

> restart;

> with( DEtools ):

> with( plots ):

Warning, the name changecoords has been redefined

> with( linalg ):

> with( PDEtools ):

Warning, the name adjoint has been redefined

Warning, the protected names norm and trace have been redefined and unprotected

>

5.A One-Tank Mixing Problem

Problem Statement

A tank initially contains 40 gal of sugar water having a concentration of 3 lb of sugar for each gallon of water. At time zero, sugar water with a concentration of 4 lb of sugar per gal begins pouring into the tank at a rate of 2 gal per minute. Simultaneously, a drain is opened at the bottom of the tank so that the volume of the sugar-water solution in the tank remains constant.

>

Solution

The mathematical formulation of this problem must express the physical requirement that

Diff(`amount of sugar in tank`,t) = ( rate sugar is added to tank ) - ( rate sugar is removed from tank )

Let x(t) denote the amount of sugar (pounds) in the tank at time t (minutes). Then,

> rate_in := 4 * 2;

rate_in := 8

> rate_out := (x(t)/40) * 2;

rate_out := 1/20*x(t)

>

so that the governing ODE is

> ode := diff( x(t), t ) = rate_in - rate_out;

ode := diff(x(t),t) = 8-1/20*x(t)

>

The amount of sugar in the tank initially, t = 0 , is

> ic := x(0)=40 * 3;

ic := x(0) = 120

>

The ODE in this IVP is first-order and linear. The integrating factor is

> mu(t) = intfactor( ode );

mu(t) = exp(1/20*t)

>

The solution to the IVP is

> sol := dsolve( { ode, ic }, x(t), [linear] );

sol := x(t) = 160-40*exp(-1/20*t)

>

(a)

The amount of sugar (in pounds) in the tank after 15 minutes is

> eval( sol, t=15. );

x(15.) = 141.1053379

>

(b)

The tank will contain 150 pounds of sugar at a time t (in minutes) satisfying

> eq150 := eval( sol, x(t)=150 );

eq150 := 150 = 160-40*exp(-1/20*t)

>

Thus,

> t150 := solve( eq150, t ):

> t[`150 lbs`] = t150;

> `` = evalf(t150);

t[`150 lbs`] = 20*ln(4)

`` = 27.72588722

>

Repeating the same steps for the time when 170 pounds of sugar are in the tank leads to

> eq170 := eval( sol, x(t)=170 );

eq170 := 170 = 160-40*exp(-1/20*t)

> t170 := solve( eq170, t ):

> t[`170 lbs`] = t170;
`` = evalf(t170);

t[`170 lbs`] = 20*ln(4)-20*I*Pi

`` = 27.72588722-62.83185308*I

>

This complex-valued solution is clearly not physically realistic. A quick inspection of the solution,

> plot( rhs(sol), t=0..120 );

[Maple Plot]

>

shows that the amount of sugar in the tank reaches a steady-state limit that is well below 170 pounds. Therefore, at no time is there ever 170 pounds of sugar in the tank.

>

(c)

In (b) it was noted that the amount of sugar in the tank levels off below 170 pounds. The exact limit can be determined from the solution by looking at the limit as t -> infinity :

> steady_state := map( Limit, sol, t=infinity );

steady_state := Limit(x(t),t = infinity) = Limit(16...

> value( steady_state );

limit(x(t),t = infinity) = 160

>

Note that x = 160 is an equilibrium solution for this ODE. Be careful to avoid the common error of concluding that the limit is 160 pounds because x = 160 is an equilibrium solution. (Recall the logistic growth model, Unit 3, Section B, which has two equilibria.)

>

>

5.B Variable Volume Mixing Problem

Problem Statement

Consider the previous problem, except that the outflow from the tank is at a rate of 3 gallons per minute.

>

Solution

(a)

The volume starts at 40 gallons. Every minute 2 gallons of sugar water are added to the tank and 3 gallons are removed; the net change is a loss of 1 gallon per minute. This situation is simple enough that one can simply write the formula for the volume

> Vrate_in := 2;

> Vrate_out := 3;

Vrate_in := 2

Vrate_out := 3

> V := 40 + (Vrate_in-Vrate_out)*t;

V := 40-t

>

Note that this could result could have been obtained as the solution to the IVP

> odeV := diff( v(t), t ) = 2 - 3;

odeV := diff(v(t),t) = -1

> icV := v(0) = 40;

icV := v(0) = 40

> dsolve( { odeV, icV }, v(t), [separable] );

v(t) = 40-t

>

(b)

The IVP for the amount of sugar in the tank is similar to the one in the previous example. There is no difference in the rate at which sugar enters the tank. The concentration of sugar exiting the tank is x(t)/V and this is different because V = V(t) is no longer constant.

> Srate_in := rate_in;

Srate_in := 8

> Srate_out := (x(t)/V) * 3;

Srate_out := 3*x(t)/(40-t)

>

Thus, the governing ODE is

> ode2 := diff( x(t), t ) = Srate_in - Srate_out;

ode2 := diff(x(t),t) = 8-3*x(t)/(40-t)

>

The initial condition is unchanged:

> ic2 := ic;

ic2 := x(0) = 120

>

(c)

The IVP for the concentration of sugar in the tank is obtained from the ODE in (b) and the fact that the concentration, c(t), satisfies

> conc_eq := c(t) = x(t)/'V';

conc_eq := c(t) = x(t)/V

>

Instead of manually deriving the differential equation for c(t), the dchange command from the PDEtools package will be used to automate the process.

>

> with( PDEtools ):

> odeC := dchange( x(t) = c(t)*V, ode2, [c] );

odeC := diff(c(t),t)*(40-t)-c(t) = 8-3*c(t)

>

The initial condition for the concentration is

> icC := c(0) = 3;

icC := c(0) = 3

>

(d)

The tank is empty when the volume of sugar water is zero. This occurs after 40 minutes.

> t_empty := solve( V=0, {t} );

t_empty := {t = 40}

>

The concentration is found by solving the (linear) IVP found in (c):

> solC := dsolve( { odeC, icC }, c(t), [linear] );

solC := c(t) = -1/1600*(-40+t)^2+4

>

Thus, the concentration at the instant the tank empties is

> subs( t_empty, solC );

c(40) = 4

>

The amount of sugar in the tank as the tank empties is

> sol2 := dsolve( {ode2,ic2}, x(t), [linear] );

sol2 := x(t) = 1/1600*(-40+t)^3+160-4*t

> subs( t_empty, sol2 );

x(40) = 0

>

This is exactly what one would expect. (If not, think about it!)

>

(e)

The requested plots are

> plot( rhs(sol2), t=0..40, title=`Amount of sugar` );

[Maple Plot]

>

> plot( rhs(solC), t=0..40, title=`Concentration of sugar` );

[Maple Plot]

>

The concentration remains positive until t = 120 , but after t = 40 , the volume and amount of sugar become negative. Even though the IVPs have solutions for all time, for t > 40 these results are non-physical.

>

5.C Two-Tank Mixing Problem

Problem Statement

Two tanks, tank I and tank II, are filled with V gal of pure water. A solution containing a lb of salt per gallon is poured into tank I at a rate of b gal per minute. The solution leaves tank I at a rate of b gal/min and enters tank II at the same rate ( b gal/min). A drain is adjusted on tank II and solution leaves tank II at a rate of b gal/min. This keeps the volume of solution constant in both tanks ( V gal). Show that the amount of salt solution in tank II, as a function of time t, is given by

a*V-a*b*t*exp(-b/V*t)-a*V*exp(-b/V*t) .

NOTE: This is Exercise 14 (p. 73) from Differential Equations,

by Polking, Boggess, and Arnold (Prentice-Hall, 2001).

>

Solution

Let x(t) and y(t) denote the amount of salt, in pounds, in tanks I and II, respectively, at time t . The initial conditions for the two tanks are

> icI := x(0) = 0;

icI := x(0) = 0

> icII := y(0) = 0;

icII := y(0) = 0

>

The "rate in" for tank I is a lb/gal * b gal/min and the outflow is x(t)/V lb/gal at a rate of b gal/min. That is,

> unassign('V');

> odeI := diff( x(t), t ) = a*b - b*(x(t)/V);

odeI := diff(x(t),t) = a*b-b*x(t)/V

>

While, for tank II, the inflow is the same as the outflow from tank I and the outflow exactly matches the inflow. Thus,

> odeII := diff( y(t), t ) = b*(x(t)/V) - b*(y(t)/V);

odeII := diff(y(t),t) = b*x(t)/V-b*y(t)/V

>

The IVP for tank I involves a first-order linear ODE with integrating factor

> mu[1](t) = intfactor( odeI );

mu[1](t) = exp(b*t/V)

>

The solution to this IVP is

> solI := dsolve( {odeI,icI}, x(t), [linear] );

solI := x(t) = a*V-exp(-b*t/V)*a*V

>

To find the amount of salt in tank II, substitute the solution for tank I into the ODE for tank II:

> odeIIa := subs( solI, odeII );

odeIIa := diff(y(t),t) = b*(a*V-exp(-b*t/V)*a*V)/V-...

>

Despite the somewhat complicated appearance of this ODE, note that it is linear

> odeadvisor( odeIIa );

[[_linear, `class A`]]

>

with integrating factor

> mu[2](t) = intfactor( odeIIa );

mu[2](t) = exp(b*t/V)

>

The solution to the IVP for tank II is

> solII := dsolve( {odeIIa,icII}, y(t), [linear] );

solII := y(t) = (a*b*(V*exp(b*t/V)/b-t)-a*V)*exp(-b...

>

Thus, the amount of salt in tank II at any time t, is

> expand( solII );

y(t) = a*V-a*b*t/exp(b*t/V)-a*V/exp(b*t/V)

>

[Back to ODE Powertool Table of Contents]