OpenFOAM-version-7/C3/Simulating-Flow-using-Cyclic-Conditions/English

From Script | Spoken-Tutorial
Revision as of 15:42, 13 October 2023 by Omkar (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Title of the script: Simulating flow using cyclic conditions

Author: Divyesh Variya, Abhushan Regmi 

Keywords: OpenFOAM, Channel flow, Cyclic condition, Paraview, Video-Tutorial.

Visual Cue Narration
Slide: Opening Slide Welcome to this tutorial on Simulating flow using cyclic conditions.
Slide: Learning Objectives In this tutorial, we will learn to,
  • Setup mesh for a cyclic flow
  • Setup boundary conditions for a cyclic flow
  • Add momentum source
  • Simulate the case using pimpleFoam solver.
Slide

System Specifications

To record this tutorial, I am using,
  • Ubuntu Linux OS version 22.04
  • OpenFOAM version 9
  • ParaView version 5.6.0 and
  • gedit Text Editor

However, you may use any other text editor of your choice.

Slide

Prerequisites

To practise, this tutorial learner should have knowledge of,
  • Basic Linux commands, and
  • Basic knowledge of OpenFOAM software
  • If not, please go through the prerequisite OpenFOAM tutorials on this website.
Slide

Cyclic Conditions

Cyclic condition is a special periodic boundary condition.

It is often used in CFD when we have repetitive geometry for larger domains

Here we consider that both the ends of the geometry are connected.

Mainly two types of repetitive conditions can be seen.

  1. Rotational and
  2. Transitional
Slide

Cyclic Conditions

Rotational cyclic condition is helpful in turbomachinery applications.

Transitional cyclic conditions are helpful in simulating long pipes.

Cyclic conditions can help to save the computational time and resources.

Slide

Problem Statement

As you can see, we have a 2D channel geometry on the screen. 

Dimensions are 2 meters in height and 4 meters in length. 

Reynolds number will be 100, so the case will be laminar.

In this case we will simulate cyclic conditions.

And compare computational time with traditional inlet-outlet condition cases.

Slide

Analytical Solution

From the input data, we can analytically calculate:

Entrance length,

Maximum velocity , and

Pressure gradient.

Slide

Solver & Base Tutorial

We know that when we install OpenFOAM some benchmark cases come as tutorials

For a cyclic condition, we have channel395 case in pimpleFoam/LES location.

pimpleFoam solver is a Transient solver for:

  • Incompressible fluid
  • Turbulent flow on a moving mesh

But it can also be used for laminar flow with static mesh.

Slide

Source Term

When we use cyclic conditions, two ends of the geometry are  connected.

To keep the fluid flowing, adding a constant force in the domain is necessary. 

This force can be applied using source terms in OpenFOAM.

We can give the mean velocity source in the fvConstraints file.

Syntax of the code is given in the slide for reference.

We shall explain the code later.

Only Narration Let’s copy the base case from the pimpleFoam tutorial to our local directory FOAM_RUN.
CTRL + ALT + T Open the terminal by pressing Ctrl, Alt and T keys.
[Terminal] Type:

cd $FOAM_RUN

cp -r $FOAM_TUTORIALS/incompressible/pimpleFoam/LES/channel395 $FOAM_RUN

Type these commands to go to the run folder and then copy the base case.
[Terminal] Type:

cd channel395

Go to the channel395 directory.
[Terminal] Type:

rm -r 0 0.orig/k 0.orig/nu*

The tutorial case we used is made for LES simulations.

There are a few unnecessary files to simulate a laminar case.

Hence, type this command to delete those files.

Only Narration Let’s first look at the blockMeshDict file.

Then setup geometry and mesh for our problem statement.

[Terminal] Type:

gedit system/blockMeshDict

Type the following command to open the blockMeshDict file in the text editor.
[gedit] Change:

Here you need to mention from which number the changes have to be made.(0 0 2) => (0 0 0.2)

(4 0 2) => (4 0 0.2)

(0 1 2) => (0 1 0.2)

(4 1 2) => (4 1 0.2

(0 2 2) => (0 2 0.2

(4 2 2) => (4 2 0.2)

(40 25 30) => (40 25 1

(40 25 30) => (40 25 1

As we can see, the entire geometry is made of 2 blocks and it is 3D geometry.

To convert it into 2D, we can simply change z-coordinates with 0.2.

Also, don’t forget to make the number of cells in the z-direction = 1.

Point to the expansion ratio. By default, some expansion ratio is used to refine the mesh near the wall.

We will keep it as it is.

Point to the Top and Bottom walls part in the text editor. Here, our main focus is the boundary section.

As we can see, top and bottom walls were taken as wall types.

Point to the cyclic patches in the file. The cyclic patches can be defined as shown on the screen.

The type of the cyclic patch can be given as “cyclic.”

An additional entry needs to be added to define the neighbor patch.

Click on Save and Click on Close. Save the file and close it.
Only Narration To define boundary conditions, we can go to the 0.orig folder and modify the fields file.
[Terminal] Type:

gedit 0.orig/U

Let’s open the velocity file first.
[gedit] Change:

internalField uniform (0.1335 0 0); => internalField uniform (1 0 0); 

Click on Save and Click on Close.

Set up 1 m/s velocity in the internal field to initialize the simulation. 

The other boundary conditions will be cyclic

Save the file and close it.

[Terminal] Type:

gedit 0.orig/p

Click on Close

In the same way, we have initialized the field with 0 kinematic pressure in the p file.

The boundary conditions for other patches will be cyclic similar to that of U

Close the file.

[Terminal] Type:

cp -r 0.orig 0

Type the following command to make a clone of the 0.orig file with 0 name.
[Terminal] Type:

gedit constant/transportProperties

Now, we can set up kinematic viscosity in the transportProperties file from the constant folder.
[gedit] Change:

nu 2e-05 => 0.02

Ubar 0.1335 => 1

Click on Save and Click on Close

Also, set the Ubar value in the x-direction to 

1 m/s.

Save and close the file.

[Terminal] Type:

gedit constant/momentumTransport

simulationType LES; => simulationType laminar;

Click on Save and Click on Close.


In the momentumTransport file, we need to specify laminar type flow.

Save and close the file

[Terminal] Type:

gedit system/controlDict

endTime 1000 => 15

deltaT 0.2 => 0.1

writeInterval 200 => 10

Click on Save and Click on Close

In the controlDict file, let's set endTime equal to 15 seconds

Also, set deltaT equals 0.1 and writeInterval 10.

Save and close the file.

[Terminal]:

Only Narration

Our case setup is almost ready. 

But here, we haven't specified any force to drive fluid in our system.

It is necessary to provide an external force in our system to keep fluid flowing.

To add a specific type of external force, we can use the fvConstraints utility in OpenFOAM.

[Terminal] Type:

gedit system/fvConstraints

The fvConstraints file is located in a constant or system folder. 

Here, in this tutorial, it is located under the system folder. 

Open it in a text editor using the following command.

[gedit fvConstraints]:

Point to momentumForce

In this dictionary we are providing momentumSource as a Source
[gedit fvConstraints]:

Point to type

We are providing meanVelocityForce

This applies a force to maintain a user-specified volume-averaged mean velocity

[gedit fvConstraints]:

Point to SelectionMode

Here we are selecting all cells of the domain
[gedit fvConstraints]:

Point to fields and Ubar

We are providing this source term to the field velocity.

We will provide mean velocity of 1m/s in the x-direction.

Also, we will get a parabolic velocity profile in the domain.

[gedit] Change:

Ubar (0.1335 0 0); =>

Ubar (1 0 0); 

Click on Save and Click on Close.

Change Ubar value from 0.1335 to 1.

Save and close the file.

[Terminal] Type:

blockMesh

pimpleFoam

Let us run simulation commands.

First type blockMesh for meshing and then pimpleFoam to run the simulation.

[Terminal] Type:

paraFoam

In just a few seconds, the simulation is finished.

Let us open our case in ParaView using the paraFoam command.

[ParaView] Properties Tab

Click on Apply button

Click on the apply button and see the velocity field.
[ParaView] 

VCR Controls => Click on Last Frame


&&

Active Variable Controls => Click on vtkBlockColors ==> Click on a box icon


On the top of the screen, click on the last frame as shown.

Click on vtkBlockColors on the top-left and from the drop down menu select U with box icon

[ParaView]

Showing Velocity Contour

As you can see, we have the same profile or velocity distribution all over the domain.
[ParaView] 

Data Analysis => Click on plot over line filter


Now, let us check the velocity profile over radial distance.

Click on the plot over line icon located on top of the screen as shown.

[ParaView] 

Properties Tab => Click on y-axis

&&

Properties Tab => Click on Apply

Click on the y-axis and then click on the Apply button.

As we can see, it is parabolic.

The maximum velocity is 1.5 m/s.

where is the analytic solution? 

Point to it, instead writing only Narration.Only Narration

Now, let us compare our result with the analytical solution.
Slide: Result Comparison From the comparison we can find the following.

Cyclic condition results exactly match the analytical solution and full-length channel case.

The time consumed to simulate cyclic cases is less than the entire domain case.

Slide

Summary

In this tutorial, we have learned to,
  • Setup mesh for cyclic flow
  • Setup boundary conditions for cyclic flow
  • Add momentum source
  • Simulate the case using pimpleFoam solver.
Slide

Assignment

As an assignment:
  • Simulate two cases using the same geometry with velocity 0.002 m/s.
  • One with the cyclic condition and,
  • Second without cyclic condition
  • Compare both results with analytical solution
  • Note time difference to run both cases
Slide

About the Spoken Tutorial Project

The video at the following link summarizes the Spoken Tutorial project.

Please download and watch it.

Slide

Spoken Tutorial Workshops

We conduct workshops using Spoken Tutorials and give certificates.

Please contact us.

Slide: Spoken Tutorial Forum
  • Please post your timed queries on this website
Slide: FOSSEE Forum
  • Do you have any general/technical questions?
  • Please visit the forum given in this link.
Slide: FOSSEE Case Study Project
  • The FOSSEE team coordinates solving feasible CFD problems of reasonable complexity using OpenFOAM.
  • We give honorarium and certificates to those who do this.
  • For more details, please visit these sites.
Slide: Spoken Tutorial The Spoken Tutorial project is supported by the Ministry of Education, Govt. of India.

This tutorial is contributed by Divyesh Varya, Aabhushan Regmi and Payel Mukherjee from IIT Bombay. Thank you for joining.

Contributors and Content Editors

Omkar