{VERSION 2 3 "IBM INTEL NT" "2.3" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Helvetica" 1 9 255 0 0 1 0 1 0 0 1 0 0 0 0 }{CSTYLE "2D Math" -1 2 "Times" 1 10 0 0 0 0 0 0 2 0 0 0 0 0 0 }{CSTYLE "2D Comment" 2 18 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 } {CSTYLE "2D Output" 2 20 "" 0 1 0 0 255 1 0 0 0 0 0 0 0 0 0 }{PSTYLE " Normal" -1 0 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 0 2 2 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Maple Output" 0 11 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 3 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 11 12 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }1 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Title" 0 18 1 {CSTYLE "" -1 -1 "" 1 18 0 0 0 0 0 1 1 0 0 0 0 0 0 }3 0 0 -1 12 12 0 0 0 0 0 0 19 0 }{PSTYLE "R3 Font 0" -1 256 1 {CSTYLE "" -1 -1 "Helve tica" 0 12 0 0 0 0 2 1 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 2" -1 257 1 {CSTYLE "" -1 -1 "Courier" 0 10 0 0 0 0 2 2 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 3 " -1 258 1 {CSTYLE "" -1 -1 "Courier" 0 14 0 0 0 0 2 2 2 0 0 0 0 0 0 } 0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 4" -1 259 1 {CSTYLE "" -1 -1 "Courier" 0 14 0 0 0 0 2 2 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 5" -1 260 1 {CSTYLE "" -1 -1 "Courier" 0 14 0 0 0 0 2 2 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 } {PSTYLE "R3 Font 6" -1 261 1 {CSTYLE "" -1 -1 "Courier" 0 14 0 0 0 0 2 2 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 7 " -1 262 1 {CSTYLE "" -1 -1 "Courier" 0 14 0 0 0 0 2 2 2 0 0 0 0 0 0 } 0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 8" -1 263 1 {CSTYLE "" -1 -1 "Courier" 0 14 0 0 0 0 2 2 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }} {SECT 0 {EXCHG {PARA 18 "" 0 "" {TEXT -1 48 "Diffusion and Reaction in a One Dimensional Slab" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 104 "This example involves the concent ration in plug flow reactor with axial dispersion. The governing ODE i s" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 47 "ODE := diff(C[A](z),z, z)=k/D[A,B]*C[A](z): ODE;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#/-%%diffG 6$-F%6$-&%\"CG6#%\"AG6#%\"zGF/F/*(%\"kG\"\"\"&%\"DG6$F-%\"BG!\"\"F)F2 " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 6 "where " }{XPPEDIT 18 0 "D[A,B] " "&%\"DG6$%\"AG%\"BG" }{TEXT -1 34 " is the diffusion coefficient and " }{XPPEDIT 18 0 "C[A]" "&%\"CG6#%\"AG" }{TEXT -1 98 " is the concent ration. The boundary conditions for this example are written in the fo llowing form." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "BC0 := C[A ](0)=C[A,0]: BC0;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#/-&%\"CG6#%\"AG6# \"\"!&F&6$F(F*" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 24 "BC1:= D(C [A])(L)=0: BC1;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#/--%\"DG6#&%\"CG6#% \"AG6#%\"LG\"\"!" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 75 "This problem \+ has an analytical solution that is easily obtained with Maple." }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 31 "dsolve(\{ODE, BC0,BC1\},C[A] (z));" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#/-&%\"CG6#%\"AG6#%\"zG,&*(&F& 6$F(\"\"!\"\"\",&-%$expG6#,$*(%\"LGF0&%\"DG6$F(%\"BG!\"\"*&F8F0%\"kGF0 #F0\"\"#F@F0F0F0F<-F36#*(F8F " 0 "" {MPLTEXT 1 0 16 "convert(\",trig);" }}{PARA 12 "" 1 "" {XPPMATH 20 "6#/-&%\"CG6#%\"AG6#%\"zG,&*(&F&6$F(\"\"!\"\"\",(-%%cos hG6#,$*(%\"LGF0&%\"DG6$F(%\"BG!\"\"*&F8F0%\"kGF0#F0\"\"#F@F0-%%sinhGF4 F0F0F0F<,&-F36#*(F8F " 0 "" {MPLTEXT 1 0 33 "ODE3:=diff(C[A](z),z)=y(z): ODE3;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#/-%%diffG6$-&%\"CG6#%\"AG6#%\"zGF--%\"yGF," }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 53 "The second derivative is obtained \+ on differentiation." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "diff (ODE3,z);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#/-%%diffG6$-F%6$-&%\"CG6# %\"AG6#%\"zGF/F/-F%6$-%\"yGF.F/" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 75 "Substitution of the original ODE gives the following expression fo r the ODE" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 24 "ODE4:=subs(ODE ,\"): ODE4;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#/*(%\"kG\"\"\"&%\"DG6$% \"AG%\"BG!\"\"-&%\"CG6#F*6#%\"zGF&-%%diffG6$-%\"yGF1F2" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 34 "The parameter values are specified" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 32 "Params :=\{D[A,B]=1.2e-9,k=1 e-3\};" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%'ParamsG<$/%\"kG$\"\"\"!\" $/&%\"DG6$%\"AG%\"BG$\"#7!#5" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 55 "a nd substituted into the set of differential equations." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 34 "Deqns := subs(Params,\{ODE3,ODE4\}) ;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%&DeqnsG<$/-%%diffG6$-&%\"CG6#% \"AG6#%\"zGF0-%\"yGF//,$F*$\"+LLLL$)!\"%-F(6$F1F0" }}}{EXCHG {PARA 0 " " 0 "" {TEXT -1 109 "The initial conditions are the known initial conc entration and a guess for the unknown first derivative term." }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 30 "IC := \{C[A](0)=0.2,y(0)=-13 0\};" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%#ICG<$/-%\"yG6#\"\"!!$I\"/-& %\"CG6#%\"AGF)$\"\"#!\"\"" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 51 "We c ombine the sets of ODEs and initial conditions." }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 26 "Alleqns := Deqns union IC;" }}{PARA 11 "" 1 " " {XPPMATH 20 "6#>%(AlleqnsG<&/-%%diffG6$-&%\"CG6#%\"AG6#%\"zGF0-%\"yG F//-F26#\"\"!!$I\"/-F+F5$\"\"#!\"\"/,$F*$\"+LLLL$)!\"%-F(6$F1F0" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 78 "dsolve is invoked to make a proced ure for numerical computation of the result." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 84 "g:=dsolve(Alleqns,\{C[A](z),y(z)\}, type=numeric , method=rkf45, output=procedurelist);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"gG:6#%(rkf45_xG6'%\"iG%(rkf45_sG%)outpointG%#r1G%#r2G6#%aoCo pyright~(c)~1993~by~the~University~of~Waterloo.~All~rights~reserved.G6 \"C&>8&-%&evalfG6#9$@$52-%$absG6#,$F3!\"\"-F<6#,&&%,loc_controlG6#\"\" #\"\"\"F3F?4-%'memberG6$&FD6#\"\"'<*$!\"#\"\"!$F?FR$FFFR$FGFRF?FGFQFFC %>FD-%%copyG6#=F06#;FG\"#LE\\[lB\"#A\"\"!\"\"($\"\"\"!\"*\"#BF[o\"\") \"&++$\"#CF[o\"\"*\"%+5\"#DF[o\"#5F[o\"#EF[o\"#6F[o\"#FF[o\"#7F[o\"#GF [o\"#8F[o\"#HF[o\"#9F[o\"#IF[o\"#:F[o\"#JF[o\"#;F[oF^o\"\"#\"#KF[o\"#< F[oFdpF[o\"#LF[o\"#=F[o\"\"$F[o\"#>F[o\"\"%$F^o!\")\"#?$Fdp!\"\"\"\"&F \\q\"#@$!$I\"F[o\"\"'F^o>%'loc_y0G-FY6#=F06#;FGFFE\\[l#F^oF_qFdpFcq>%' loc_y1G-FY6#=F0F[rE\\[l!@$0F;FRC$>&FD6#\"\"$F3@%1%'DigitsG-%'evalhfG6# F]sC$>8%-%*traperrorG6#-F_s6#-%=dsolve/numeric_solnall_rkf45G6,%&loc_F G-%$varG6#FD-F^t6#Fgq-F^t6#F_r-F^t6#%'loc_F1G-F^t6#%'loc_F2G-F^t6#%'lo c_F3G-F^t6#%'loc_F4G-F^t6#%'loc_F5G-F^t6#%)loc_workG@$/Fcs%*lasterrorG C%>8'-%+searchtextG6$.F_s-%(convertG6$-%#opG6$FG7#Fcs%%nameG>8(-F]v6$. %)hardwareGF`v@%50F[vFR0FivFR-Fjs6,F\\tFDFgqF_rFftFitF\\uF_uFbuFeu-%&E RRORG6#FcsFbw7$/%\"zGF7-%$seqG6$/&%$ordG6#,&8$FGFGFG&Fgq6#Fbx/FbxF\\rF 06%FDFgqF_r" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 80 "We compute the \"s olution\" (subject to the guessed initial value of y) as follows" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "g(1e-3);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#7%/%\"zG$\"\"\"!\"$/-&%\"CG6#%\"AG6#F%$\"1CTcUcg/9!#;/- %\"yGF/$\"1RSL:HQkF!#:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 64 "where t he value of 0.001 in the call to g is the final value of " }{XPPEDIT 18 0 "z" "I\"zG6\"" }{TEXT -1 1 "." }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 52 "We need to find an init ial value of y that leads to " }{XPPEDIT 18 0 "y(0.001)=0" "/-%\"yG6#$ \"\"\"!\"$\"\"!" }{TEXT -1 76 " (more or less). We make a procedure to automate the preceding computations:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 378 "f := proc(y0)\nlocal IC, Deqns, Params, Alleqns,g, e rr;\n Params :=\{D[A,B]=1.2e-9,k=1e-3, y[f,0]=0\};\n Deqns := \{83 3333.3333*C[A](z) = diff(y(z),z), diff(C[A](z),z) = y(z)\};\n IC := \+ \{C[A](0)=0.2,y(0)=y0\};\n Alleqns := Deqns union IC;\n g:=dsolve( Alleqns,\{C[A](z),y(z)\}, type=numeric, method=rkf45, output=procedure list);\n err := subs(Params,rhs(g(1e-3)[2]) - y[f,0]);\nend:" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 45 "and test it for some differing ini tial values" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "f(-130);" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#$\"+Vcg/9!#5" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "f(-140);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"+M k7!H\"!#5" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 216 "We can ask fsolve t o compute a numerical solution to this equation as shown below. Note t hat we must place '' marks around the name of the function to force it s re-evaluation each time the function must be computed. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "result:=fsolve('f'(y0),y0=-140..-13 0);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%'resultG$!+F>6>8!\"(" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 269 "The value obtained above is the \+ \"correct\" value of the first derivative at the origin. We need to co mpute all the other variables at the end using this value for the firs t derivative. To this end we repeat our initial computations, first re making the initial condition." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 32 "IC := \{C[A](0)=0.2,y(0)=result\};" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%#ICG<$/-%\"yG6#\"\"!%'resultG/-&%\"CG6#%\"AGF)$\"\"#!\"\"" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 77 "then reforming the full set of dif ferential equations and initial conditions," }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "Alleqns := Deqns union IC;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%(AlleqnsG<&/-%\"yG6#\"\"!$!+F>6>8!\"(/,$-&%\"CG6#%\"A G6#%\"zG$\"+LLLL$)!\"%-%%diffG6$-F(F5F6/-F1F)$\"\"#!\"\"/-F;6$F0F6F=" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 88 "and asking dsolve to generate a procedure from which we may compute a numerical solution" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 84 "g:=dsolve(Alleqns,\{C[A](z),y(z)\}, type=numeric, method=rkf45, output=procedurelist);" }}{PARA 11 "" 1 " " {XPPMATH 20 "6#>%\"gG:6#%(rkf45_xG6'%\"iG%(rkf45_sG%)outpointG%#r1G% #r2G6#%aoCopyright~(c)~1993~by~the~University~of~Waterloo.~All~rights~ reserved.G6\"C&>8&-%&evalfG6#9$@$52-%$absG6#,$F3!\"\"-F<6#,&&%,loc_con trolG6#\"\"#\"\"\"F3F?4-%'memberG6$&FD6#\"\"'<*$FG\"\"!F?FG!\"#FF$FFFQ $F?FQ$FRFQC%>FD-%%copyG6#=F06#;FG\"#LE\\[lB\"#A\"\"!\"\"($\"\"\"!\"*\" #BF[o\"\")\"&++$\"#CF[o\"\"*\"%+5\"#DF[o\"#5F[o\"#EF[o\"#6F[o\"#FF[o\" #7F[o\"#GF[o\"#8F[o\"#HF[o\"#9F[o\"#IF[o\"#:F[o\"#JF[o\"#;F[oF^o\"\"# \"#KF[o\"#F[o\"\"%$F^o!\")\"#?$!+F >6>8!\"(\"\"&F\\q\"#@$Fdp!\"\"\"\"'F^o>%'loc_y0G-FY6#=F06#;FGFFE\\[l#F ^oF_qFdpFdq>%'loc_y1G-FY6#=F0F\\rE\\[l!@$0F;FQC$>&FD6#\"\"$F3@%1%'Digi tsG-%'evalhfG6#F^sC$>8%-%*traperrorG6#-F`s6#-%=dsolve/numeric_solnall_ rkf45G6,%&loc_FG-%$varG6#FD-F_t6#Fhq-F_t6#F`r-F_t6#%'loc_F1G-F_t6#%'lo c_F2G-F_t6#%'loc_F3G-F_t6#%'loc_F4G-F_t6#%'loc_F5G-F_t6#%)loc_workG@$/ Fds%*lasterrorGC%>8'-%+searchtextG6$.F`s-%(convertG6$-%#opG6$FG7#Fds%% nameG>8(-F^v6$.%)hardwareGFav@%50F\\vFQ0FjvFQ-F[t6,F]tFDFhqF`rFgtFjtF] uF`uFcuFfu-%&ERRORG6#FdsFcw7$/%\"zGF7-%$seqG6$/&%$ordG6#,&8$FGFGFG&Fhq 6#Fcx/FcxF]rF06%FDFhqF`r" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 67 "Final ly, we invoke the procedure to find the desired concentration." }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "g(1e-3);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#7%/%\"zG$\"\"\"!\"$/-%\"yG6#F%$\"1u)G)[.tq5!#B/-&%\"CG6 #%\"AGF,$\"1T8rfks#Q\"!#;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{MARK "0 0 0" 0 }{VIEWOPTS 1 1 0 1 1 1803 }