CFD Lab Manual
CFD Lab Manual
List of Experiments:
1)Numerical Solutions of Parabolic Equation
using FDM.
Consider a given point P in this plane. Since we are dealing with a parabolic equation, there is
only one characteristic direction through point P. Furthermore, in Fig. assume that initial
conditions are given along the line ac and that boundary conditions are known along curves ab
and cd. The characteristic direction is given by a vertical line through P. Then, information at P
influences the entire region on one side of the vertical characteristic and contained within the two
boundaries; i.e., if we jab P with a needle, the effect of this jab is felt throughout the shaded
region shown in Fig. Parabolic equations lend themselves to marching solutions. Starting with
the initial data line ac, the solution between the boundaries cd and ab is obtained by marching in
the general x direction.
The following types of flow-field models are governed by parabolic equations:
1) STEADY BOUNDARY-LAYER FLOWS
2) "PARABOLIZED" VISCOUS FLOWS
3) UNSTEADY THERMAL CONDUCTION.
Considered Parabolic Equation is 1D Unsteady Thermal Conduction, which can be written as,
Here we will also present some of the basic aspects of discretization, i.e., how to replace the
partial derivatives (or integrals) in the governing equations of motion with discrete numbers.
Purpose of Discretization:
Analytical solutions of partial differential equations involve closed-form expressions which give
the variation of the dependent variables continuously throughout the domain. In contrast,
numerical solutions can give answers at only discrete points in the domain, called grid points.
Most partial differential equations involve a number of partial derivative terms. When all the
partial derivatives in a given partial differential equation are replaced by finite-difference
quotients, the resulting algebraic equation is called a difference equation, which is an algebraic
representation of the partial differential equation. Let us discretize the time & x derivative in
above Eq. with a forward & central difference pattern,
The above difference equation has two independent variables, x and t. We consider the grid as
sketched below,
Here, ‘i’ is the running index in the ‘x’ direction and ‘n’ is the running index in the ‘t’ direction.
When one of the independent variables in a partial differential equation is a marching variable,
such as ‘t’, it is conventional in CFD to denote the running index for this marching variable by n
and to display this index as a superscript in the finite-difference quotient.
PROGRAM:
#include<stdio.h>
#include<conio.h>
#include<math.h>
float T[100][100],i,n;
int x,t;
void display()
{
printf("\t\tTemperature difference across the grid is:\n\n\4");
for(n=t-1;n>=0;n--)
{
for(i=0;i<=x-1;i++)
printf("%-8.2f",T[n][i]);
printf("\n\4");
}
}
void xit()
{
printf("\n\n\t\t\tENTERED \"WRONG DATA\",\n\t\t\tPROGRAM IS
TERMINATING.");
delay(2000);
exit();
}
void main()
{
static float r=0.3,rbt,lbt,temp;
clrscr();
printf("MAX x and t is 100.\n");
printf("MIN x is 3 and t is 2.\n");
printf("Enter values for,\n");
printf("x=");
scanf("%d",&x);
printf("t=");
scanf("%d",&t);
if(x<3 || t<2)
xit();
printf("TEMPERATURE along LEFT & RIGHT BOUNDARY:\n");
scanf("%f%f",&lbt,&rbt);
printf("TEMPERATURE at (n)th LEVEL i.e. at Intial Data Line:\n");
scanf("%f",&temp);
for(n=0,i=0;n<=t-1;n++)
T[n][i]=lbt;
for(n=0,i=x-1;n<=t-1;n++)
T[n][i]=rbt;
for(n=0,i=1;i<x-1;i++)
T[n][i]=temp;
for(n=1;n<=t-1;n++)
{
for(i=1;i<x-1;i++)
T[n][i]=T[n-1][i]+(r*(T[n-1][i-1]+T[n-1][i+1]-(2*T[n-1][i])));
}
display();
getch();
}
PROGRAM:
#include<stdio.h>
#include<conio.h>
#include<math.h>
#define pf printf
void main()
{
int r,i;
float x,y,t;
clrscr();
pf("MAX RADIUS=20\nMIN RADIUS=0\n");
for(r=0;r<=20;r++)
{
getch();
pf("RADIUS=%d\n",r);
for(i=1;i<=10;i++)
{
t=i*12;
x=r*cos(t);
y=r*sin(t);
pf("%4.3f\t%4.3f\n",x,y);
}
}
getch();
}