Challenge

Week 12 - Validation studies of Symmetry BC vs Wedge BC in OpenFOAM vs Analytical H.P equation

Theory

In this Project we are ccomparing the velocity,pressure drop and shear stress for two different boundary condition types wedge and symmentry and also simulating them for different angles(`theta`). By this way we are finding how the results are affacted and compare the theoratical and simulation results and the percentage of error.

Assumptions:

  • Laminar Flow :

Laminar flow is a type of flow in which the fluid travells smoothly over each other. in this type of flow all fluid properties at any point remains constant. The fluid particles or layer that is in close contact with the solid surface follows no slip condition, that is the velocity of that particles will be zero. The flow of fluid is considered laminar when there is no opposing fluid which causes disturbance and produces turbulant flows. Laminar flows are commen when the flow happen in a small channel,low velocity, high viscous fluid. There will be almost no friction produced between the adjusent layers inside the fluid.

  • Reynolds Number :

The reynolds number is a non diementional number. it is the ratio of intertial forces to viscous forces within a fluid which is due to difference in velocity within the fluid. The reynolds number is an important designing tool as it predicts at what conditions does a flow over a body becomes turbulant.This number can be predicted for a live size model by using its proper scaling model.The properties of a fluid such as viscosity, velocity of the fluid flow,density and characteristic lendth.The turbulant flow is developed when two different fluid mixes and produces friction between the fluid layers and the viscous property of a fluid balances this effect. And the reynolds number quantifies this and predict if the flow is turbulant or laminar. If the number is greater than 2300 then the flow is said to be laminar, If the value is greater than 2900 then the fluid is said to be in turbulant flow and if the number is inbetween two then the flow is said to be transient flow.

`Re = (rho u L)/ mu`

u = flow speed

L = Characteristic Length

`mu =` Dynamic Viscosity

  • Hydrodynamic Entrance Length:

It is the distance a flow travells after entering the closed channel till the flow becomes a fully developed flow. The fully developed flow is a point along the axis of the channel beyond which the flow flows with maximum velocity. The area beyond the entrance length where the effects on flow characteristics is negligible. This formation of velocity profile is due to the viscous property of the fluid.

Procedure:

  • First we write the code in matlab to generate mesh file,where we define the constants and compute entrance length,and average velocity and pressure drop.
  • We totaly write two code one for symmetry and other for wedge boundary conditions.
  • We generate mesh for three values of `theta =` 10,25 and 45. For both bounddary conditions. Once done we have to input for the velocity and mention the total simulation time and time step 'dt'.
  • Onces successfully generating the mesh we have to plot the graph for velocity,pressure and shear stress using necessary tools such as plot over line command. The velocity plot is plotted at the entrance length and the pressure difference plot is plotted across the length of the pipe.
  • For shear stress plot we first have to calculate the magnutide of velocity and convert into gradiants and then multiply with the dynamic viscosity and obtain the shear stress plot using command avove at point beyond the entrance length.

Dynamic Viscosity (Water)= `0.00089 (Ns)/(m)^2`

Kinematic Viscosity = Dynamic Viscosity/Density

Entrance Length = `0.06*Re*D`

Avg.Velocity =`(Re *mu)/D`

Pressure Drop = (Max Pressure - Min Pressure) / Max pressure

clear all 
close all 
clc

Re = 2100;
p= 997;
m=0.00089;
D=0.02;
R=D/2;
L_e=(0.06*Re*D);
L= L_e+0.3;
n=m/p
v_avg=Re*(n/D);
vmax=2*v_avg;
theta=25;
Pdiff= (32*m*L*v_avg)/(D^2)


v0=[0 0 0];
v1=[0 R*cosd(theta/2) -R*sind(theta/2)];
v2=[0 R*cosd(theta/2) +R*sind(theta/2)];
v3=[L 0 0];
v4=[L R*cosd(theta/2) -R*sind(theta/2)];
v5=[L R*cosd(theta/2) +R*sind(theta/2)];


h1='/*--------------------------------*- C++ -*----------------------------------*\';
h2='| =========                 |                                                 |';
h3='| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |';
h4='|  \\    /   O peration     | Version:  2.2.1                                 |';
h5='|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |';
h6='|    \\/     M anipulation  |                                                 |';
h7='\*---------------------------------------------------------------------------*/';
h8='FoamFile ';
h9=' {';
h10='    version     2.0;';
h11='   format      ascii;';
h12='    class       dictionary;';
h13='    object      blockMeshDict;';
h14=' }';
h15=' // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //';
h16='convertToMeters 1;';
h17='mergePatchPairs'; 
h18='(';
h19=');';

h20='// ************************************************************************* //';

f1=fopen('blockmeshDict.txt','wt');

fprintf(f1,'%s \n',h1);
fprintf(f1,'%s \n',h2);
fprintf(f1,'%s \n',h3);
fprintf(f1,'%s \n',h4);
fprintf(f1,'%s \n',h5);
fprintf(f1,'%s \n',h6);
fprintf(f1,'%s \n',h7);
fprintf(f1,'%s \n',h8);
fprintf(f1,'%s \n',h9);
fprintf(f1,'%s \n',h10);
fprintf(f1,'%s \n',h11);
fprintf(f1,'%s \n',h12);
fprintf(f1,'%s \n',h13);
fprintf(f1,'%s \n',h14);
fprintf(f1,'%s \n',h15);
fprintf(f1,'%s \n',h16);

fprintf(f1,'vertices \n ( \n ');
fprintf(f1,'   (%d %d %d)\n ',v0);
fprintf(f1,'   (%d %d %d)\n ',v1);
fprintf(f1,'   (%d %d %d)\n ',v2);
fprintf(f1,'   (%d %d %d)\n ',v3);
fprintf(f1,'   (%d %d %d)\n ',v4);
fprintf(f1,'   (%d %d %d)\n ',v5);
fprintf(f1,'\n %2s\n',');');
fprintf(f1,'\n\n');
fprintf(f1,' blocks \n (  ');
fprintf(f1,'\n\t  %s (%d %d %d) %s (%d 1 1)','hex(0 1 2 0 3 4 5 3)',50,1,200,'Simplegrading',0.2);
fprintf(f1,'\n %2s  \n'   ,');');
fprintf(f1,'\n\n');
fprintf(f1,'edge \n ( \n ');
fprintf(f1,'\n   %3s (0 %d 0) \n','arc 1 2',R);
fprintf(f1,'\n   %3s (%d %d 0) \n','arc 4 5',L,R);
fprintf(f1,'\n %2s  \n'  ,');');

fprintf(f1,'\n\n');
fprintf(f1,'boundary \n ( \n ');
fprintf(f1,'  \n  %5s \n','axis');
fprintf(f1,' \n  %5s  \n','{' );
fprintf(f1,'\n\t      %5s  %5s  \n','type','empty;');
fprintf(f1,' \n   %18s \n','faces');
fprintf(f1,' \t  %14s','(');
fprintf(f1,'\n\t\t     %20s \n','(0 3 3 0)');
fprintf(f1,'\t   %14s  \n'  ,');');
fprintf(f1,' \n  %5s  \n','}' );

fprintf(f1,'  \n  %5s \n','Inlet');
fprintf(f1,' \n  %5s  \n','{' );
fprintf(f1,'\n\t      %5s  %5s  \n','type','patch;');
fprintf(f1,' \n   %18s \n','faces');
fprintf(f1,' \t  %14s'  ,'(');
fprintf(f1,'\n\t\t     %20s  \n','(0 1 2 0)');
fprintf(f1,'\t   %14s  \n'  ,');');
fprintf(f1,' \n  %5s  \n','}' );

fprintf(f1,'  \n  %5s \n','Wall');
fprintf(f1,' \n  %5s  \n','{' );
fprintf(f1,'\n\t      %5s  %5s  \n','type','wall;');
fprintf(f1,' \n   %18s \n','faces');
fprintf(f1,' \t  %14s'  ,'(');
fprintf(f1,'\n\t\t     %20s  \n','(2 1 4 5)');
fprintf(f1,'\t   %14s  \n'  ,');');
fprintf(f1,' \n  %5s  \n','}' );

fprintf(f1,'  \n  %5s \n','Back');
fprintf(f1,' \n  %5s  \n','{' );
fprintf(f1,'\n\t      %5s  %5s  \n','type','wedge;');
fprintf(f1,' \n   %18s \n','faces');
fprintf(f1,' \t  %14s'  ,'(');
fprintf(f1,'\n\t\t     %20s  \n','(0 2 5 3)');
fprintf(f1,'\t   %14s  \n'  ,');');
fprintf(f1,' \n  %5s  \n','}' );

fprintf(f1,'  \n  %5s \n','Front');
fprintf(f1,' \n  %5s  \n','{' );
fprintf(f1,'\n\t      %5s  %5s  \n','type','wedge;');
fprintf(f1,' \n   %18s \n','faces');
fprintf(f1,' \t  %14s'  ,'(');
fprintf(f1,'\n\t\t     %20s  \n','(0 3 4 1)');
fprintf(f1,'\t   %14s  \n'  ,');');
fprintf(f1,' \n  %5s  \n','}' );

fprintf(f1,'  \n  %5s \n','Outlet');
fprintf(f1,' \n  %5s  \n','{' );
fprintf(f1,'\n\t       %5s  %5s  \n','type','patch;');
fprintf(f1,' \n   %18s  \n','faces');
fprintf(f1,' \t  %14s'  ,'(');
fprintf(f1,'\n\t\t     %20s  \n','(3 5 4 3)');
fprintf(f1,'\t   %14s  \n'  ,');');
fprintf(f1,' \n  %5s  \n','}' );
fprintf(f1,'\n %2s  \n'  ,');');
fprintf(f1,'\n\n');

fprintf(f1,'%s \n',h17);
fprintf(f1,'%s \n',h18);
fprintf(f1,'%s \n',h19);

fprintf(f1,'%s \n',h20);

fclose(f1);

Code for generating with symmetry boundary conditions.

clear all 
close all 
clc

Re = 2100;
p= 997;
m=0.00089;
D=0.02;
R=D/2;
L_e=(0.06*Re*D);
L= L_e+0.3;
n=m/p
v_avg=Re*(n/D);
vmax=2*v_avg;
theta=25;
Pdiff= (32*m*L*v_avg)/(D^2)


v0=[0 0 0];
v1=[0 R*cosd(theta/2) -R*sind(theta/2)];
v2=[0 R*cosd(theta/2) +R*sind(theta/2)];
v3=[L 0 0];
v4=[L R*cosd(theta/2) -R*sind(theta/2)];
v5=[L R*cosd(theta/2) +R*sind(theta/2)];


h1='/*--------------------------------*- C++ -*----------------------------------*\';
h2='| =========                 |                                                 |';
h3='| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |';
h4='|  \\    /   O peration     | Version:  2.2.1                                 |';
h5='|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |';
h6='|    \\/     M anipulation  |                                                 |';
h7='\*---------------------------------------------------------------------------*/';
h8='FoamFile ';
h9=' {';
h10='    version     2.0;';
h11='   format      ascii;';
h12='    class       dictionary;';
h13='    object      blockMeshDict;';
h14=' }';
h15=' // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //';
h16='convertToMeters 1;';
h17='mergePatchPairs'; 
h18='(';
h19=');';

h20='// ************************************************************************* //';

f1=fopen('blockmeshDict.txt','wt');

fprintf(f1,'%s \n',h1);
fprintf(f1,'%s \n',h2);
fprintf(f1,'%s \n',h3);
fprintf(f1,'%s \n',h4);
fprintf(f1,'%s \n',h5);
fprintf(f1,'%s \n',h6);
fprintf(f1,'%s \n',h7);
fprintf(f1,'%s \n',h8);
fprintf(f1,'%s \n',h9);
fprintf(f1,'%s \n',h10);
fprintf(f1,'%s \n',h11);
fprintf(f1,'%s \n',h12);
fprintf(f1,'%s \n',h13);
fprintf(f1,'%s \n',h14);
fprintf(f1,'%s \n',h15);
fprintf(f1,'%s \n',h16);

fprintf(f1,'vertices \n ( \n ');
fprintf(f1,'   (%d %d %d)\n ',v0);
fprintf(f1,'   (%d %d %d)\n ',v1);
fprintf(f1,'   (%d %d %d)\n ',v2);
fprintf(f1,'   (%d %d %d)\n ',v3);
fprintf(f1,'   (%d %d %d)\n ',v4);
fprintf(f1,'   (%d %d %d)\n ',v5);
fprintf(f1,'\n %2s\n',');');
fprintf(f1,'\n\n');
fprintf(f1,' blocks \n (  ');
fprintf(f1,'\n\t  %s (%d %d %d) %s (%d 1 1)','hex(0 1 2 0 3 4 5 3)',50,1,200,'Simplegrading',0.2);
fprintf(f1,'\n %2s  \n'   ,');');
fprintf(f1,'\n\n');
fprintf(f1,'edge \n ( \n ');
fprintf(f1,'\n   %3s (0 %d 0) \n','arc 1 2',R);
fprintf(f1,'\n   %3s (%d %d 0) \n','arc 4 5',L,R);
fprintf(f1,'\n %2s  \n'  ,');');

fprintf(f1,'\n\n');
fprintf(f1,'boundary \n ( \n ');
fprintf(f1,'  \n  %5s \n','axis');
fprintf(f1,' \n  %5s  \n','{' );
fprintf(f1,'\n\t      %5s  %5s  \n','type','empty;');
fprintf(f1,' \n   %18s \n','faces');
fprintf(f1,' \t  %14s','(');
fprintf(f1,'\n\t\t     %20s \n','(0 3 3 0)');
fprintf(f1,'\t   %14s  \n'  ,');');
fprintf(f1,' \n  %5s  \n','}' );

fprintf(f1,'  \n  %5s \n','Inlet');
fprintf(f1,' \n  %5s  \n','{' );
fprintf(f1,'\n\t      %5s  %5s  \n','type','patch;');
fprintf(f1,' \n   %18s \n','faces');
fprintf(f1,' \t  %14s'  ,'(');
fprintf(f1,'\n\t\t     %20s  \n','(0 1 2 0)');
fprintf(f1,'\t   %14s  \n'  ,');');
fprintf(f1,' \n  %5s  \n','}' );

fprintf(f1,'  \n  %5s \n','Wall');
fprintf(f1,' \n  %5s  \n','{' );
fprintf(f1,'\n\t      %5s  %5s  \n','type','wall;');
fprintf(f1,' \n   %18s \n','faces');
fprintf(f1,' \t  %14s'  ,'(');
fprintf(f1,'\n\t\t     %20s  \n','(2 1 4 5)');
fprintf(f1,'\t   %14s  \n'  ,');');
fprintf(f1,' \n  %5s  \n','}' );

fprintf(f1,'  \n  %5s \n','Back');
fprintf(f1,' \n  %5s  \n','{' );
fprintf(f1,'\n\t      %5s  %5s  \n','type','symmetry;');
fprintf(f1,' \n   %18s \n','faces');
fprintf(f1,' \t  %14s'  ,'(');
fprintf(f1,'\n\t\t     %20s  \n','(0 2 5 3)');
fprintf(f1,'\t   %14s  \n'  ,');');
fprintf(f1,' \n  %5s  \n','}' );

fprintf(f1,'  \n  %5s \n','Front');
fprintf(f1,' \n  %5s  \n','{' );
fprintf(f1,'\n\t      %5s  %5s  \n','type','symmetry;');
fprintf(f1,' \n   %18s \n','faces');
fprintf(f1,' \t  %14s'  ,'(');
fprintf(f1,'\n\t\t     %20s  \n','(0 3 4 1)');
fprintf(f1,'\t   %14s  \n'  ,');');
fprintf(f1,' \n  %5s  \n','}' );

fprintf(f1,'  \n  %5s \n','Outlet');
fprintf(f1,' \n  %5s  \n','{' );
fprintf(f1,'\n\t       %5s  %5s  \n','type','patch;');
fprintf(f1,' \n   %18s  \n','faces');
fprintf(f1,' \t  %14s'  ,'(');
fprintf(f1,'\n\t\t     %20s  \n','(3 5 4 3)');
fprintf(f1,'\t   %14s  \n'  ,');');
fprintf(f1,' \n  %5s  \n','}' );
fprintf(f1,'\n %2s  \n'  ,');');
fprintf(f1,'\n\n');

fprintf(f1,'%s \n',h17);
fprintf(f1,'%s \n',h18);
fprintf(f1,'%s \n',h19);

fprintf(f1,'%s \n',h20);

fclose(f1);

BlockMesh Output for wedge Bc's at `theta =` 25:

/*--------------------------------*- C++ -*----------------------------------*\ 
| =========                 |                                                 | 
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           | 
|  \\    /   O peration     | Version:  2.2.1                                 | 
|   \\  /    A nd           | Web:      www.OpenFOAM.com                      | 
|    \\/     M anipulation  |                                                 | 
\*---------------------------------------------------------------------------*/ 
FoamFile  
 { 
    version     2.0; 
   format      ascii; 
    class       dictionary; 
    object      blockMeshDict; 
 } 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 
convertToMeters 1; 
vertices 
 ( 
    (0 0 0)
    (0 9.762960e-03 -2.164396e-03)
    (0 9.762960e-03 2.164396e-03)
    (2.820000e+00 0 0)
    (2.820000e+00 9.762960e-03 -2.164396e-03)
    (2.820000e+00 9.762960e-03 2.164396e-03)
 
 );


 blocks 
 (  
	  hex(0 1 2 0 3 4 5 3) (50 1 200) Simplegrading (2.000000e-01 1 1)
 );  


edge 
 ( 
 
   arc 1 2 (0 1.000000e-02 0) 

   arc 4 5 (2.820000e+00 1.000000e-02 0) 

 );  


boundary 
 ( 
   
   axis 
 
      {  

	       type  empty;  
 
                faces 
 	               (
		                (0 3 3 0) 
	               );  
 
      }  
  
  Inlet 
 
      {  

	       type  patch;  
 
                faces 
 	               (
		                (0 1 2 0)  
	               );  
 
      }  
  
   Wall 
 
      {  

	       type  wall;  
 
                faces 
 	               (
		                (2 1 4 5)  
	               );  
 
      }  
  
   Back 
 
      {  

	       type  wedge;  
 
                faces 
 	               (
		                (0 2 5 3)  
	               );  
 
      }  
  
  Front 
 
      {  

	       type  wedge;  
 
                faces 
 	               (
		                (0 3 4 1)  
	               );  
 
      }  
  
  Outlet 
 
      {  

	        type  patch;  
 
                faces  
 	               (
		                (3 5 4 3)  
	               );  
 
      }  

 );  


mergePatchPairs 
( 
); 
// ************************************************************************* // 

Results:

Mesh:

Mesh @ `theta =`10

Mesh @ `theta =`25

Mesh @ `theta =`45

Velocity:

As we can observe that as the angle increases the slope of the curve increases. and the Theoratical maximum velocity is obtained through matalb stands at 0.1875 and the analytical from the graph stands at 0.1625. The error is 0.133%.

Pressure:

As we can see the pressure drop for wedge and symmetry remains constat for a paticular angle. And it increases as we increase the angle theta. The therotical value is for pressure drop is 18.8197 and the maximum pressure drop computed from all the above graphs is 17.50 .Therefore the difference is 0.07%

Shear Stress:

From the above plots of shear stress when comparing the shear stress of wedge and symmetry for a paticular angle, we can see that the peak value of symetry is slighetly lesser than that of wedge. This is because the slope of symettry plot is higher than that of wedge. The therotical value stands at 0.0334 where as the analytical value stands at about 0.036 therefore the error is 0.003 for shear stress plots. The difference is 0.072%

The hydrodynamic length for every theta value remains constant at 2.52 m. The velocity plot ahead this point will not be a proper parabollic curve.

Conclusion:

The error increases with increase in theta. The total simulation time taken for computing with symmetry boundary condition will be higher than wedge condition. And for symmetry results are obtained for a 3-D body.so, we can use symmetry type boundary conditions for all complex and simple models whereas we can apply wedge boundary conditions only when the model is symmetry about the axis. The error for all the results when compared with theoratical values is less than 2% and therefore the simulations results are accecptable.

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.