Concentration profile for a tubular reactor with axial dispersion​
​Authors: Housam BINOUS and Ahmed Bellagi

A first order chemical reaction is taking place in a tubular chemical reactor : A → B
​
We assume that the flow is turbulent and that some axial dispersion is occurring .
​
The determination of the concentration profile in the reactor turns out to be a split boundary condition problem that is solved in the present notebook using four different approaches . The governing equations are given below (reproduced from textbook by Fred Ramirez (Computational Methods for Process Simulation, Second Edition, 1997, Butterworth-Heinemann, Oxford).
​

In what follows, we will assume that Pe=100 and R=200 where Pe is the Peclet and R a dimensionless reaction rate group.
​
1- The first approach is given by Professor Ramirez.
​
2- The second method is based on the shooting method developed by Professor Brian Higgins (Chemical Engineering Department, University of California, Davis).
​
3- The third method is a direct computation of the concentration profile using NDSolve.
​
4- The fourth method is based on shifted-Legendre orthogonal collocation.
​
We will see that all four methods give the same results .

Acknowledgement :​
​​
​This problem was presented by W. F. Ramirez in Computational Methods for Process Simulation, 2ed Ed., 1997, Butterworth-Heinemann, Oxford.
​
In[]:=
Off[General::"spell1"]
Guessing the value of CA[y=0] by two methods
First Method inspired by Professor Fred Ramirez
In[]:=
CA0=0.5;
In[]:=
delta=10;
In[]:=
i=1;
In[]:=
While[delta>0.0001,{sol=NDSolve[{D[CA[y],{y,1}]-x1[y],D[x1[y],{y,1}]-100x1[y]-200CA[y],x1[0]0,CA[0]CA0,D[f1[y],{y,1}]-f2[y],D[f2[y],{y,1}]-200f1[y]-100f2[y],f1[0]==1,f2[0]==0},{CA[y],x1[y],f1[y],f2[y]},{y,0,1}],​​delta=((1-CA[y]+0.01x1[y])/(-f1[y]+0.01f2[y])/.sol/.y1)[[1]],CA0+=-delta,i=i+1,Print[i," ",delta]}]
2 0.359408
3 -1.72529×
-9
10
In[]:=
CA0
Out[]=
0.140592
Second Method inspired by Professor Brian Higgins (U C Davis)
In[]:=
CA0=.
In[]:=
SOLD[CA0_]:=NDSolve[{D[CA[y],{y,1}]-x1[y],D[x1[y],{y,1}]-100x1[y]-200CA[y],x1[0]0,CA[0]CA0},{CA[y],x1[y]},{y,0,1}]
In[]:=
yend[CA0_?NumericQ]:=1-(CA[y]/.SOLD[CA0]/.y1)+(0.01x1[y]/.SOLD[CA0]/.y1)
In[]:=
FindRoot[yend[CA0]0,{CA0,0.5},MaxIterations1000]
Out[]=
{CA00.140592}
Plotting the concentration profile
In[]:=
First[CA[y]/.SOLD[0.140592]/.y0]
Out[]=
0.140592
In[]:=
f=CA[y]/.SOLD[0.140592]
Out[]=
InterpolatingFunction
Domain: {{0.,1.}}
Output: scalar
[y]
In[]:=
plt1=Plot[(f/.y1-x),{x,0,1},PlotStyle{Thick,Darker@Red},AspectRatio->1,GridLines->Automatic,Frame->True]
Out[]=
Third Method using NDSolve
​
​Indeed, NDSolve can often solve boundary value problems
In[]:=
solbvp=NDSolve[{D[CA[x],{x,2}]-100D[CA[x],{x,1}]-200CA[x]0,​​CA'[1]0,1CA[0]-0.01CA'[0]},{CA[x]},{x,0,1}]
Out[]=
CA[x]InterpolatingFunction
Domain: {{0.,1.}}
Output: scalar
[x]
Plotting the concentration profile
In[]:=
plt2=Plot[Evaluate[CA[x]/.solbvp],{x,0,1},PlotStyle{Thick,Dashed,Darker@Blue},AspectRatio->1,GridLines->Automatic,Frame->True]
Out[]=
In[]:=
CA[x]/.solbvp/.x1
Out[]=
{0.140592}
Fourth Method using orthogonal collocation using shifted-Legendre polynomials
In[]:=
Np=15;
In[]:=
sol=Solve[JacobiP[Np-2,0,0,2x-1.]0,x]
Out[]=
{{x0.00790847},{x0.0412008},{x0.099211},{x0.178825},{x0.275754},{x0.384771},{x0.5},{x0.615229},{x0.724247},{x0.821174},{x0.90079},{x0.958799},{x0.992092}}
In[]:=
tbl=Select[Table[x/.sol[[i]],{i,1,Length[sol]}],#>0&];​​x[Np]=1.0;x[1]=10^-20;For[i=2,i<Np,{x[i]=tbl[[i-1]],i++}];
In[]:=
Q=Chop[Table[Table[x[j]^(i-1),{i,1,Np}],{j,1,Np}]];​​IQ=Inverse[Q]//Quiet;​​Ci=Chop[Table[Table[(i-1)x[j]^(i-2),{i,1,Np}],{j,1,Np}]];​​A=Ci.IQ;
In[]:=
A//MatrixForm
Out[]//MatrixForm=
-182.656
202.547
-25.8347
8.58099
-4.09272
2.38234
-1.58497
1.16771
-0.937069
0.812568
-0.760547
0.774683
-0.883883
1.26465
-0.780268
-79.0225
63.1965
19.8815
-5.7683
2.6356
-1.50268
0.98733
-0.721199
0.575127
-0.496372
0.462967
-0.470385
0.535796
-0.765918
0.472461
23.3577
-46.0837
12.5302
13.3608
-4.65294
2.34394
-1.41871
0.972717
-0.736895
0.610049
-0.550575
0.545744
-0.611237
0.865682
-0.532845
-11.2487
19.6596
-20.9192
4.32671
11.2326
-4.7538
2.85383
-2.02983
1.61458
-1.40241
1.31951
-1.35156
1.54895
-2.22205
1.37184
6.41783
-10.8492
9.27563
-13.5909
1.66595
10.0055
-4.7106
3.09204
-2.37818
2.03372
-1.89899
1.93773
-2.21656
3.17714
-1.96115
-4.6651
7.7349
-6.00251
6.6246
-10.8914
0.908285
8.9824
-4.39029
2.98702
-2.38925
2.14219
-2.13082
2.39996
-3.41277
2.1028
3.52647
-5.79308
4.30197
-4.27369
5.31045
-9.43236
0.363971
8.67309
-4.44474
3.17636
-2.68634
2.58427
-2.85546
4.022
-2.47291
-2.76494
4.51829
-3.27517
3.08708
-3.44061
4.61691
-8.70882
-0.0809496
8.87357
-4.7908
3.63141
-3.30675
3.54814
-4.92793
3.02056
2.22287
-3.62072
2.58644
-2.36544
2.49337
-2.9972
4.27139
-8.49902
-0.544995
9.62736
-5.5281
4.52764
-4.62049
6.27358
-3.82668
-1.81288
2.94672
-2.08536
1.87181
-1.91003
2.16943
-2.76972
4.16728
-8.74556
-1.16802
11.1855
-6.9716
6.44125
-8.3997
5.08088
1.48239
-2.40618
1.69238
-1.50087
1.501
-1.64975
1.99109
-2.68717
4.27325
-9.51906
-2.22354
14.2554
-10.1214
12.1353
-7.22289
-1.19486
1.93769
-1.35738
1.19444
-1.17946
1.27081
-1.48575
1.89921
-2.71715
4.6065
-11.0686
-4.51696
21.1552
-20.0129
11.4692
0.916712
-1.48578
1.03821
-0.909214
0.890935
-0.948709
1.08932
-1.3528
1.8411
-2.82611
5.21849
-14.0481
-11.6416
44.7209
-22.5033
-0.595773
0.965317
-0.673652
0.588487
-0.574381
0.607998
-0.691895
0.847461
-1.12763
1.6625
-2.82254
5.99507
-20.1741
-62.7494
78.7425
0.949326
-1.53808
1.07304
-0.936864
0.913601
-0.965784
1.09687
-1.33944
1.77365
-2.59323
4.33219
-8.85986
26.1784
-203.06
182.976

Hence, we get a value in close agreement with the results found above (i.e., CA(@ y=0) = 0.140611)

Comparing concentration profiles obtained using the various methods presented above.
A visual check confirms that all methods agree closely.