Digital Assignment - I Computational Fluid Dynamics: Course Code-Mee4006
Digital Assignment - I Computational Fluid Dynamics: Course Code-Mee4006
PRESENTED BY
SIDDHANT KUMAR
REG NO - 17BEM0015
SUBMITTED TO - PROF. BIBIN JOHN
Solution of Laplace Equation
Methods:
1. Analytical
2. Using your own FDM-code
3. Using Ansys Fluent
Problem Statement: consider the temperature distribution in a
rectangular plate covering the region, 0 ≤ 𝑥 ≤ 1, 0 ≤ 𝑦 ≤ 2 in
the plane.
𝜕2 𝑇 𝜕2 𝑇
+ =0 𝑓𝑜𝑟 0 < 𝑥 < 1, 0 < 𝑦 < 2
𝜕𝑥 2 𝜕𝑦 2
This will be important while comparing the results because exact solution is
the real solution and does not contains any errors so the analytic solution will be
important in comparing our FDM as well as ‘ANSYS Fluent’ solution
Result
Case 1 : 20 x 40 grid
Case 2: 40 x 80 grid:
Case 3: 80 X 160 grid:
Method 2: (FDM)
Solution Description
In this section we are basically writing the finite difference code for solving the 2-
D steady state heat equation on a flat plate of 1m X 2m dimension. The algorithm
followed is that first of all we are initializing a matrix consisting of the required
nodes and then setting value at each node to be zero except at boundary nodes
because there we are giving the required boundary condition using ‘for loop’ in
matrix form. After this we are declaring the eps as 1e-06 and then we are running a
while loop till (error>eps) and then inside that we are using the ‘Jacobi Method’
for iterating the temperature values that is basically the average of the adjacent four
neighbouring nodes.
T(1,1:m)=273+100.*(1-x).*sin(x)
T(n,1:m)=273
T(1:n,1)=273
T(1:n,m)=273
eps=1e-6;
error=1;
k=0;
while error>eps
k=k+1
Told=T
for i=2:n-1;
for j=2:m-1;
T(i,j)=.25*(T(i+1,j)+T(i-1,j)+T(i,j-1)+T(i,j+1));
end
end
error=max(max(abs(Told-T)));
end
T
a=T(1:n,(m-1)/2+1)
[x,y]=meshgrid(0:l/(m-1):1,0:w/(n-1):2);
contour(x,y,T)
contourf(T)
plot(y,a)
Alternate Code: (Using C++)
#include <stdio.h>
int main()
{
int i,j,k,m,n,x,y;
float a[20][20],l,r,t,b;
FILE *fp;
fp=fopen("c:\\laplace.dat","w"); //output will be stored in this file
printf("\tEnter boundary conditions\n");
printf("\tValue on left side: ");
scanf("%f",&l);
printf("\tValue on right side: ");
scanf("%f",&r);
printf("\tValue on top side: ");
scanf("%f",&t);
printf("\tValue on bottom side: ");
scanf("%f",&b);
printf("\tEnter length in x direction: ");
scanf("%d",&x);
printf("\tEnter number of steps in x direction: ");
scanf("%d",&m);
printf("\tEnter length in y direction: ");
scanf("%d",&y);
printf("\tEnter number of steps in y direction: ");
scanf("%d",&n);
m++;
n++; //number of mesh points is one more than number of steps
for(i=1;i<=m;i++) //assigning boundary values begins
{
a[i][1]=b;
a[i][n]=t;
}
for(i=1;i<=n;i++)
{
a[1][i]=l;
a[m][i]=r;
} //assigning boundary values ends
for(i=2;i<m;i++)
for(j=2;j<n;j++)
a[i][j]=t; //initialization of interior grid points
for(k=0;k<100;k++)
{
for(i=2;i<m;i++)
{
for(j=2;j<n;j++)
{
a[i][j]=(a[i-1][j]+a[i+1][j]+a[i][j-1]+a[i][j+1])/4;
}
}
} //calculation by Gauss-Seidel Method
for(i=1;i<=m;i++)
{
for(j=1;j<=n;j++)
fprintf(fp,"%.2f\t",a[i][j]);
fprintf(fp,"\n");
}
fclose(fp);
printf("\nData stored\nPress any key to exit...");
getch();
}
Result
Case 1: 20 X 40 grid:
CASE 2:40x80 Grid
Case 3: 80 X 160 grid:
Solution Description
Fluent software contains the broad, physical modeling capabilities needed to model
flow, turbulence, heat transfer and reactions for industrial applications. These
range from air flow over an aircraft wing to combustion in a furnace, from bubble
columns to oil platforms, from blood flow to semiconductor manufacturing and
from clean room design to wastewater treatment plants. Fluent spans an expansive
range, including special models, with capabilities to model in-cylinder combustion,
aero-acoustics, turbomachinery and multiphase systems.
Contour:
Plot:
40 X 80 grid:
Contour
Plot
80 X 160 grid:
Contour
Plot
Final Plot
Inference:
Mesh Mesh 𝑇𝑒𝑥𝑎𝑐𝑡 (0.5, 1.5) 𝑇𝐹𝐷𝑀 (0.5, 1.5) 𝑇𝐹𝑙𝑢𝑒𝑛𝑡 (0.5, 1.5) 𝑇𝑒𝑥𝑎𝑐𝑡 𝑇𝑒𝑥𝑎𝑐𝑡 − 𝑇𝐹𝑙𝑢𝑒𝑛𝑡
Size − 𝑇𝐹𝐷𝑀
coarse 20×40 283.4845 278.1234 278.106 5.3611 5.3785
Medium 40×80 283.8145 278.1114 278.104 5.7031 5.7105
Fine 80×160 283.9815 278.1078 278.151 5.8737 5.8305
Result:
Mesh Mesh 𝑇𝑒𝑥𝑎𝑐𝑡 (0.5, 1.5) 𝑇𝐹𝐷𝑀 (0.5, 1.5) 𝑇𝐹𝑙𝑢𝑒𝑛𝑡 (0.5, 1.5) 𝑇𝑒𝑥𝑎𝑐𝑡 𝑇𝑒𝑥𝑎𝑐𝑡 − 𝑇𝐹𝑙𝑢𝑒𝑛𝑡
Size − 𝑇𝐹𝐷𝑀
coarse 20×40 283.4845 278.1234 278.106 5.3611 5.3785
Medium 40×80 283.8145 278.1114 278.104 5.7031 5.7105
Fine 80×160 283.9815 278.1078 278.151 5.8737 5.8305
---------XXXX---------