Академический Документы
Профессиональный Документы
Культура Документы
ANALYSIS LABORATORY
JADAVPUR UNIVERSITY
DEPARTMENT OF CHEMICAL
ENGINEERING
CLASS: UG-II
SECTION: A-1
GROUP NUMBER: 4
GROUP MEMBERS:
DEBASMITA KUMAR
(ROLL:001310301014)
ANJIK
CHOWDHURY(ROLL:001310301015)
ASHWIN
AGARWAL(ROLL:001310301016)
BIPRATEEP
BANERJEE(ROLL:001310301017)
DATE OF SUBMISSION: - 24/03/2015
DAY 8
PROBLEM STATEMENT:
A batch experiment in liquid-liquid extraction is being
carried out in a laboratory by dispersing one phase into
the other. Obtain the concentration profiles evolving in
the drops assuming that the concentration in the
continuous phase is constant. The concentration
profiles in the drops is described by:
c D 2 c
=
r
t r2 r
r
) ( cr )
r=0
=0;
(c )r=R =c 0 ;
Debasmita Kumar
MATHEMATICAL
BACKGROUND
To solve this partial differential equation we shall use finite difference
method followed by Heuns Predictor Corrector Method. The Finite Difference
method converts the PDE to a set of simultaneous ODE-IVP which are then
solved using Heuns method.
According to finite difference method:
d 2 y y i+12 y i + y i1
=
2
2
dx
h
dy y i +1 y i1
=
dx
2h
Here we shall divide the line from r=0 to r=R(here R=1) in 4 equal parts
(h=0.25) such that at
=1, r=0
=2, r=0.25
=3, r=0.5
=4, r=0.75
=5, r=1
( cr )
r=0
=0;
(c )r=R =c 0 ;
32 32
0
0
0 32 32
0
0
8 32 243 +
32
0
0
32
3
[]
[]
0
0
0
128
3
d c1
dt
d c2
c1
dt = c 2 X
d c3
c3
dt
c4
d c4
dt
[]
ALGORITHM
Step 1: Start
Step 2: Declaring variables n, i, j, steps, iter of type int and r, R,
cin>>steps;
cout<<"\nEnter number of points for Finite Difference method"<<endl;
cin>>n;
size= (R-0)/n;
//Matrix-B is the coefficient matrix
B[0][0]=-32;
B[0][1]=32;
B[0][2]=0;
B[0][3]=0;
B[1][0]=0;
B[1][1]=-32;
B[1][2]=32;
B[1][3]=0;
B[2][0]=0;
B[2][1]=8;
B[2][2]=-32;
B[2][3]=24;
B[3][0]=0;
B[3][1]=0;
B[3][2]=(32/3);
B[3][3]=-32;
//Matrix-D is the constant matrix
D[0]=0;
D[1]=0;
D[2]=0;
D[3]=(128/3);
cout<<"\nThe matrix B is"<<endl;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
cout<<B[i][j]<<"\t";
}
cout<<"\n";
}
cout<<"\nThe matrix D is"<<endl;
for(i=0;i<4;i++)
cout<<D[i]<<endl;
cout<<"\nEnter initial guess for c at t=0"<<endl;
for(i=0;i<n;i++)
cin>>c_old[i];
for(iter=0;iter<steps;iter++)
{
//Predictor: Explicit Euler Method
for(i=0;i<n;i++)
{
c_new1[i]=c_old[i];
prod[i]=0;
for(j=0;j<n;j++)
{
prod[i]= prod[i]+ (B[i][j]*c_old[j]);
}
prod[i]= h*(prod[i]+D[i]);
c_new1[i]=c_new1[i]+ prod[i];
}
//Corrector: Crank-Nicholson Method
for(j=0;j<n;j++)
{
sum[j]=c_old[j]+c_new1[j];
}
for(i=0;i<n;i++)
{
c_new2[i]=c_old[i];
c_new2[i]=c_new2[i]+ (h*D[i]);
prod[i]=0;
for(j=0;j<n;j++)
{
prod[i]=prod[i]+ (B[i][j]*sum[j]);
}
prod[i]=(prod[i]*(h/2));
c_new2[i]=c_new2[i]+ prod[i];
}
time=time+h;
cout<<"\nFor step size="<<size<<endl;
cout<<"\nAt t="<<time<<" the values of c are"<<endl;
for(i=0;i<n;i++)
{
cout<<"c["<<i<<"]="<<c_new2[i]<<endl;
c_old[i]=c_new2[i];
}
}
return 0;
}//main function ends
SAMPLE OUTPUT
This program solves a partial differential equation by Finite
Difference method
followed by Heun's Predictor-Corrector Method.
First we convert the PDE to a set of simultaneous ODEs by Finite
Difference Meth
od
Enter the value of R
1
Enter the value of c0
1
Enter the value of D
1
32
-32
32
-32
24
10
-32
The matrix D is
0
0
0
42
Enter initial guess for c at t=0
0
0
0
0
For step size=0.25
c[3]=-2.51538e+009
-------------------------------Process exited after 10.8 seconds with return value 0
Press any key to continue . . .
PLOT
Value of c vs t
1.50E+10
1.00E+10
5.00E+09
0.00E+00
-5.00E+09
-1.00E+10
10
12
COMMENTS
A few points should be noted about the program.
The coefficient matrix and constant matrix have been
calculated from before and the values obtained have
been used in the program. The reason for doing this is
that it would be virtually impossible to perform
symbolic differentiation in a simplistic code without the
use of additional classes and header files. All the
values of the matrix elements are provided in the
program. All the necessary derivations and calculations
have been shown in the mathematical background
section. Also, all errors encountered in the Finite
Difference have been neglected.
The simultaneous system of ordinary differential
equation obtained are solved using Heuns PredictorCorrector method. The initial value of the unknown
matrix at t=0 has to be input by the user then for all
other time steps the value of c is calculated
accordingly.