{VERSION 2 3 "DEC ALPHA UNIX" "2.3" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 }{PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }} {SECT 0 {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 19 "F ilename: TCE2.mws" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 184 "Description: Solve the TCE problem with a discontinuous source term. The TCE in-flow will be shut off whenever the concentra tion in the lace exceeds 5 whatevers per cubic whatervers." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "resta rt;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "with(DEtools):" }}} {PARA 0 "" 0 "" {TEXT -1 134 "Define an ODE for the concentration of T CE in the lake. Look first at the case where the rate of in-flow is c onstant (and positive). " }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 37 " inflow1 := proc(r,Pin,V) r*Pin/V end;" }}}{PARA 0 "" 0 "" {TEXT -1 0 " " }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 58 "ode1 := diff(x(t),t) = i nflow1(13,10,1000) - 13*x(t)/1000;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 40 "sol1 := rhs(dsolve(\{ode1,x(0)=0\},x(t)));" }}}{PARA 0 "" 0 "" {TEXT -1 103 "As expected, the concentration in the lake app roaches the concentration in the in-flow as t increases. " }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 65 "plot(sol1,t=0..600,x=0..15,thicknes s=3,title=`Constant In-Flow`);" }}}{PARA 0 "" 0 "" {TEXT -1 222 "Now c hange it so that the in-flow turns on only when the concentration in t he lake is less than a prescribed level. In the example below, the ma ximum allowed concentration in the late is 5 (whatevers per cubic what evers)." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 64 "inflow2 := proc(x ,xmax,r,Pin,V) Heaviside(xmax - x)*r*Pin/V end;" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 50 "plot(inflow2(x,5,13,10,1000),x=0..15,thickness =3);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 65 "ode2 := diff(x(t),t ) = inflow2(x(t),5,13,10,1000) - 13*x(t)/1000;" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 27 "dsolve(\{ode2,x(0)=0\},x(t));" }}}{PARA 0 "" 0 "" {TEXT -1 242 "Note that dsolve is stuck. It simply cannot give y ou a formula for the solution. This does not mean that there is no so lution, just that you cannot give a simple formula for the solution. \+ You can still plot the solution curve using DEplot." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 122 "DEplot(\{ode2\},\{x(t)\},t=0..200,x=0..10, [[x(0)=0]],\nscene=[t,x(t)],method=classical[foreuler],arrows=thin,\nl inecolor=blue);\n" }}}{PARA 0 "" 0 "" {TEXT -1 449 "You got some prett y strange behavior, but is it real or is it Maple? This solution meth od is using the forward Euler method, which builds the solution by fol lowing the tangent line to the solution. You see \"chattering\" near \+ the maximum concentration because the numerical solution keeps jumping back and forth across the threshold level. Take a look at what happe ns when you force Maple to use a very small stepsize in its numerical \+ calculations:" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 132 "DEplot(\{o de2\},\{x(t)\},t=0..200,x=0..8,[[x(0)=0]],\nstepsize=1, scene=[t,x(t)] ,method=classical[foreuler],arrows=thin,\nlinecolor=blue);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{MARK "23 0" 0 }{VIEWOPTS 1 1 0 1 1 1803 }