0% found this document useful (0 votes)
59 views

Digital Assignment - I Computational Fluid Dynamics: Course Code-Mee4006

1. The document discusses solving the 2D steady state heat equation on a rectangular plate using analytical, finite difference method (FDM), and ANSYS Fluent solutions. 2. Results are presented for coarse, medium, and fine grids showing the temperature values match closely between exact, FDM, and Fluent solutions. 3. It is inferred that the governing equation is accurately captured even on coarse grids, and that FDM and Fluent solutions converge to the exact solution as grid size decreases.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views

Digital Assignment - I Computational Fluid Dynamics: Course Code-Mee4006

1. The document discusses solving the 2D steady state heat equation on a rectangular plate using analytical, finite difference method (FDM), and ANSYS Fluent solutions. 2. Results are presented for coarse, medium, and fine grids showing the temperature values match closely between exact, FDM, and Fluent solutions. 3. It is inferred that the governing equation is accurately captured even on coarse grids, and that FDM and Fluent solutions converge to the exact solution as grid size decreases.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

DIGITAL ASSIGNMENT – I

Computational Fluid Dynamics


COURSE CODE- MEE4006
SLOT- A1+TA1

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

with the following boundary conditions

𝑇 𝑥, 0 = 273 𝑓𝑜𝑟 0≤𝑥≤1

𝑇 0, 𝑦 = 𝑇 1, 𝑦 = 273 𝑓𝑜𝑟 0≤𝑦≤2

𝑇 𝑥, 2 = 273 + 100 1 − 𝑥 sin(𝑥) 𝑓𝑜𝑟 0≤𝑥≤1


Problem Statement:-
The problem given here is a 2 D steady state Heat Conduction Equation that
we are going to solve on a flat plate of dimensions 1 m x 2 m. The boundary
conditions which are given for the problem represents ‘Drichlet’ boundary
conditions and the two dimensional steady state heat conduction equation is an
‘Elliptic Equation’ so boundary conditions at each boundary are going to influence
the solution.

Analytical Solution Algorithm


The exact solution for the same is an infinite series representation which is
given in general form and we just need to calculate the solution at each of the
nodes to get the temperature contour on the flat plate.

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

Representation in Schematic form


Method-1
Analytical Solution (Using MATLAB)
clc;
clearvars;
x=input('Enter the number of divisions in x direction:');
y=input('Enter the number of divisions in y direction:');
symsTnijf
T=zeros(y,x);
for i=1:x
T(y,i)=273;
T(1,i)=273+100*(1-(i/x))*sin((i/x));
end
for j=1:y
T(j,1)=273;
T(j,x)=273;
end
for i=2:x-1
for j=2:y-1
sum=0;
for n=1:100
f=(400*n*pi*(1-((-1)^n)*cos(1))*sin(n*pi*(i/x))*sinh(n*pi*(2-
(j/y))))/(sinh(2*pi*n)*(1-(n*pi)^2)^2);
sum=sum+f;
end
T(j,i)=273+sum;
end
end
T
w=linspace(0,1,x);
z=linspace(0,2,y);
contourf(T)
a=T(1:y,x/2)
plot(z,a)
Alternative Code (Using C++)
#include<stdio.h>
#include<math.h>
int main()
{
double T=273;
double pi=3.14;
for (int i = 0; i<=1; i++)
{
for (int j=0; j<=2; j++)
{
for (int n=1; n<=1000; n++)
{
T = T + (400/sinh(2*n*pi)*(n*pi*(1-pow(-1,n)*cos(1)))/pow((1-
n*n*pi*pi),2)*sin(n*pi*i)*sinh(n*pi*j)
}}
printf(T)
}
}

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.

FDM Code:( Using MATLAB)

m=input('Enter the number of divisions in x direction:')


n=input('Enter the number of divisions in y direction:')
l=1.0;
w=2.0;
x=linspace(0,l,m);
y=linspace(0,w,n);
T=zeros(n,m);

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:

Method 3: (Ansys Fluent)

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.

Grid Generation( Images )


20 X 40 grid:

Contour:
Plot:

40 X 80 grid:

Contour
Plot

80 X 160 grid:
Contour

Plot
Final Plot

x=0.5 midaxis comparison:


Midaxis comparison for analytic, FDM and Ansys Fluent solution.

Inference:

1. The order of accuracy of the solution depends upon the schemes


followed like ‘second order upwind’ schemes while working in Ansys
Fluent.
2. The solution depends upon the grid generation based on its coarseness
or fineness and it also depends on how far the grid is of the same size.
3. The physics of two dimensional heat equation being an elliptic
equation will be always influenced by all its boundaries and we
validated this statement by the simulations.
4. Moving on to the finite difference method, the JACOBI method
numerical scheme had given almost exact results as compared to ‘second
order upwind scheme’ and the solution of both fluent and FDM are so
close that even high precision plotting of the graph cannot differentiate
between these two plots.
5. The grid independency is obtained in the coarse mesh(20*40) itself
because the governing equation is a 2 D steady state heat conduction
equation derived by Fourier also called ‘Fourier heat conduction
equation’ which is a simple second order differential equation and even
a coarse grid was sufficient enough to catch the diffusion physics.

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:

The table showing the results properly is as follows:

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---------

You might also like