You are on page 1of 31

Advanced Training

February 18, 2020

Multiphase flows modeling in


OpenFOAM®:
Guided Tutorials

GT-1
Guided tutorials

Guided tutorial 1
Syphon effect (Flushing a tank)

GT-2
Guided tutorials

Guided tutorial 1
Syphon effect (Flushing a tank) – VOF

What will happen in this case?

• In this guided tutorial we model a tank emptying due to syphon effect.


• The problem is transient in nature.
• We will use the VOF approach to resolve the interface between the two phases.
GT-3
Guided tutorials

Guided tutorial 1
Syphon effect (Flushing a tank) – VOF

http://www.wolfdynamics.com/training/mphase/image34a.gif

• In reality nothing should happen.


• But as the mesh at the interface is not aligned with the free surface, we see some
spurious oscillation due to the mesh.

GT-4
Guided tutorials

Guided tutorial 1
Syphon effect (Flushing a tank) – VOF

What will happen in this case?

• In this guided tutorial we model a tank emptying due to syphon effect.


• The problem is transient in nature.
• We will use the VOF approach to resolve the interface between the two phases.
GT-5
Guided tutorials

Guided tutorial 1
Syphon effect (Flushing a tank) – VOF

http://www.wolfdynamics.com/training/mphase/image34.gif

• In this guided tutorial we model a tank emptying due to syphon effect.


• The problem is transient in nature.
• We will use the VOF approach to resolve the interface between the two phases. GT-6
Guided tutorials

Guided tutorial 1 – Syphon effect (Flushing a tank) – VOF

• This case is ready to run.


• The case is located in the directory:
$TM/multiphase/guided_tutorials/GT1/C2

• As this is an advanced course, we assume that you already know how to use
OpenFOAM®. Therefore, we are only going to explain advanced concepts.
• Remember, you will find the instructions of how to run this case in the file
README.FIRST located in the case directory.
• From this point on, please follow me. We are all going to work at the same pace.

GT-7
Guided tutorials

Guided tutorial 1
Syphon effect (Flushing a tank) – VOF
• We are going to use the following solver: interFoam
• Let us explore every dictionary in the case directory.
• The first step is to set the physical properties.
• Go to the directory constant and open the following dictionaries:
• g: in this dictionary we set the gravity.
• transportProperties: this dictionary contains the material properties for
each phase, separated into two blocks (one for water and the other for air).
• turbulenceProperties: in this dictionary we select the turbulence
model to use.
• In this case we are not using turbulence model (laminar).
• If you want you can use a turbulence model. Remember, you will need to set the
boundary conditions, initial conditions, discretization method and solution method for
the new turbulent variables.
GT-8
Guided tutorials

Guided tutorial 1
Syphon effect (Flushing a tank) – VOF
• The next step is to set the boundary and initial conditions.
• Go to the directory 0 (or 0_org) and open the following dictionaries:
• U: in this dictionary we set the boundary and initial conditions for the velocity
vector field.
• p_rgh: in this dictionary we set the boundary and initial conditions for the
pressure scalar field.
• alpha.water.org: in this dictionary we set the boundary and initial
conditions for the alpha scalar field (volume of fraction).

• In the dictionary constant/transportProperties we defined the phases water


and air, hence in the directory 0 we define the dictionary alpha.water.org that will take
the values of the phase water.
• The other phase will take the remaining values.

GT-9
Guided tutorials

Guided tutorial 1
Syphon effect (Flushing a tank) – VOF
• We set the boundary and initial conditions for the alpha scalar field (volume of
fraction) in the dictionary alpha.water.
• The dictionary alpha.water.org is a backup of the original dictionary as it will be
overwritten when we initialize the fields.
• Remember, the name of the base type boundary condition
(dictionary constant/polyMesh/boundary) and the name of the numerical type
boundary condition (dictionaries located in the directory 0) need to be the same, if
not, OpenFOAM® will complain.
• Also, the base type and numerical type boundary conditions need to be consistent.

GT-10
Guided tutorials

Guided tutorial 1
Syphon effect (Flushing a tank) – VOF
• Finally, we set the run-time parameter, numerical method and linear solvers.
• Go to the directory system and open the following dictionaries:
• controlDict: in this dictionary we set general run-time parameters and
function objects.
• fvSchemes: in this dictionary we set the discretization method.
• fvSolution: in this dictionary we set the linear solvers and parameters
specific of the pressure-velocity coupling method.

• Do not worry, later on we are going to study in more details the dictionaries
fvSchemes and fvSolution.

GT-11
Guided tutorials

Guided tutorial 1
Syphon effect (Flushing a tank) – VOF
• Before proceeding to the simulation stage, we need to do a custom initialization of the
fields.
• Go to the directory system and open the following dictionary:
• setFieldsDict: we use this dictionary for custom initialization of the fields

GT-12
Guided tutorials

Guided tutorial 1
Syphon effect (Flushing a tank) – VOF
• At this point, we are ready to run the simulation.
• To run the tutorial, type in the terminal:
1. $> foamCleanTutorials
2. $> rm –rf 0
3. $> cp –r 0_org 0
4. $> fluentMeshToFoam ../mesh/2dmesh.msh
5. $> createPatch –overwrite
6. $> changeDictionary
7. $> cp 0/alpha.water.org 0/alpha.org
8. $> setFields
9. $> interFoam | tee log

GT-13
Guided tutorials

Guided tutorial 1
Syphon effect (Flushing a tank) – VOF
• In steps 1 and 2, we clean the case directory. This is not compulsory, but it is highly
advisable.
• Be careful, the commands foamCleanTutorials as it will erase the mesh.
• If you want to erase the solution and keep the mesh, type in the terminal:
• $> foamListTimes -rm
• In step 3, we transfer the backup or original files to the directory 0. I highly
recommend you to always keep backup files. Also, name the directory as 0_org and
not 0.org, sooner or later you will see why.
• In step 4, we convert the mesh from fluent format to OpenFOAM® polymesh format.
When converting the mesh from another format, most of the times OpenFOAM® will
not recognize the base type boundary conditions, hence you will need to modify the
dictionary constant/polyMesh/boundary

GT-14
Guided tutorials

Guided tutorial 1
Syphon effect (Flushing a tank) – VOF
• In steps 5 and 6, we change the name and type of the patches.
• In step 7, we copy the backup file 0/alpha.water.org to 0/alpha.water, we do
this because later on we are going to use the utility setFields, this utility will overwrite
the file 0/alpha.water, so it is a good idea to always keep a backup file.
• In step 8, we do custom field initialization.
• In step 9, we run the solver and save the standard output in the file log.interFoam.

GT-15
Guided tutorials

Important note on the VOF method and


turbulent flows

• Dealing with turbulent flows using the VOF method is exactly the same as
dealing with turbulence in single phase flows.
• When setting boundary and initial conditions for turbulent flows using the
VOF method, it is recommended to use the primary phase properties to
compute the turbulent quantities.
• If you are simulating a quiescent process, set the turbulent quantities to zero.

GT-16
Guided tutorials

Guided tutorial 2
Surface tension driven flow or bubble in
zero gravity

GT-17
Guided tutorials

Guided tutorial 2
Surface tension driven flow or bubble in zero gravity – VOF

• According to you, what will happen to a perfect circular bubble, in perfect equilibrium,
in zero gravity, with no perturbations and with given surface tension?
GT-18
Guided tutorials

Guided tutorial 2
Surface tension driven flow or bubble in zero gravity – VOF

http://www.wolfdynamics.com/training/mphase/image36.gif

• In reality, nothing should happen but due to the mesh, numerical diffusion and
discretization errors the bubble wobbles a little bit.
GT-19
Guided tutorials

Guided tutorial 2
Surface tension driven flow or bubble in zero gravity – VOF

• According to you, what will happen to this elliptical bubble in zero gravity, with no
perturbations and no surface tension?
GT-20
Guided tutorials

Guided tutorial 2
Surface tension driven flow or bubble in zero gravity – VOF

• According to you, what will happen to this elliptical bubble in zero gravity, with no
perturbations and with given surface tension?
GT-21
Guided tutorials

Guided tutorial 2
Surface tension driven flow or bubble in zero gravity – VOF

http://www.wolfdynamics.com/training/mphase/image37.gif

• In this guided tutorial we model an elliptical bubble in a zero gravity field.


• The problem is transient in nature.
• The wobbling is due to surface tension.
• We will use the VOF approach to resolve the interface between the two phases.
• When dealing with surface tension driven flows, numerical accuracy is extremely important as the surface
tension forces depend on the curvature of the surface. GT-22
Guided tutorials

Guided tutorial 2 – Surface tension driven flow or bubble in


zero gravity – VOF
• This case is ready to run.
• The case is located in the directory:
$TM/multiphase/guided_tutorials/GT2/C1

• As this is an advanced course, we assume that you already know how to use
OpenFOAM®. Therefore, we are only going to explain advanced concepts.
• Remember, you will find the instructions of how to run this case in the file
README.FIRST located in the case directory.
• From this point on, please follow me. We are all going to work at the same pace.

GT-23
Guided tutorials

Guided tutorial 2
Surface tension driven flow or bubble in zero gravity – VOF
• We are going to use the following solver: interFoam
• Let us explore every dictionary in the case directory.
• The first step is to set the physical properties.
• Go to the directory constant and open the following dictionaries:
• g: in this dictionary we set the gravity.
• transportProperties: this dictionary contains the material properties for
each phase, separated into two blocks (one for water and the other for air).
• turbulenceProperties: in this dictionary we select the turbulence
model to use.
• In this case we are not using turbulence model (laminar).
• If you want you can use a turbulence model. Remember, you will need to set the
boundary conditions, initial conditions, discretization method and solution method for
the new turbulent variables.
GT-24
Guided tutorials

Guided tutorial 2
Surface tension driven flow or bubble in zero gravity – VOF
• The next step is to set the boundary and initial conditions.
• Go to the directory 0 (or 0_org) and open the following dictionaries:
• U: in this dictionary we set the boundary and initial conditions for the velocity
vector field.
• p_rgh: in this dictionary we set the boundary and initial conditions for the
pressure scalar field.
• alpha.phase1.org: in this dictionary we set the boundary and initial
conditions for the alpha scalar field (volume of fraction).

• In the dictionary constant/transportProperties we defined the phases


phase1 and phase2, hence in the directory 0 we define the dictionary
alpha.phase1.org that will take the values of the phase phase1.
• The other phase will take the remaining values.

GT-25
Guided tutorials

Guided tutorial 2
Surface tension driven flow or bubble in zero gravity – VOF
• We set the boundary and initial conditions for the alpha scalar field (volume of
fraction) in the dictionary alpha.water.
• The dictionary alpha.water.org is a backup of the original dictionary as it will be
overwritten when we initialize the fields.
• Remember, the name of the base type boundary condition
(dictionary constant/polyMesh/boundary) and the name of the numerical type
boundary condition (dictionaries located in the directory 0) need to be the same, if
not, OpenFOAM® will complain.
• Also, the base type and numerical type boundary conditions need to be consistent.

GT-26
Guided tutorials

Guided tutorial 2
Surface tension driven flow or bubble in zero gravity – VOF
• Finally, we set the run-time parameter, numerical method and linear solvers.
• Go to the directory system and open the following dictionaries:
• controlDict: in this dictionary we set general run-time parameters and
function objects.
• fvSchemes: in this dictionary we set the discretization method.
• fvSolution: in this dictionary we set the linear solvers and parameters
specific of the pressure-velocity coupling method.

• Do not worry, later on we are going to study in more details the dictionaries
fvSchemes and fvSolution.

GT-27
Guided tutorials

Guided tutorial 2
Surface tension driven flow or bubble in zero gravity – VOF
• Before proceeding to the simulation stage, we need to do a custom initialization of the
fields.
• Go to the directory system and open the following dictionary:
• setFieldsDict.ellipse we use this dictionary for custom initialization
of the fields using a STL file

GT-28
Guided tutorials

Guided tutorial 2
Surface tension driven flow or bubble in zero gravity – VOF
• At this point, we are ready to run the simulation.
• To run the tutorial, type in the terminal:
1. $> foamCleanTutorials
2. $> rm –rf 0
3. $> blockMesh
4. $> cp –r 0_org 0
5. $> cp 0/alpha.phase1.org 0/alpha.phase1
6. $> setFields –dict system/setFields.ellipse
7. $> interFoam | tee log

GT-29
Guided tutorials

Guided tutorial 2
Surface tension driven flow or bubble in zero gravity – VOF
• In steps 1 and 2 we clean the case directory. This is not compulsory, but it is highly
advisable.
• Be careful, the commands foamCleanTutorials as it will erase the mesh.
• If you want to erase the solution and keep the mesh, type in the terminal:
• $> foamListTimes –rm
• In steps 4 and 5, we copy the backup file 0/alpha.phase1.org to
0/alpha.phase1, we do this because later on we are going to use the utility
setFields, this utility will overwrite the file 0/alpha.water, so it is a good idea to
always keep a backup file.
• In steps 6 we do custom field initialization using the dictionary file
setFields.ellipse.
• In step 7, we run the solver and save the standard output in the file log.interFoam

GT-30
Guided tutorials

From this point on and unless it is strictly


necessary, or we introduce new features,
we will not explain every single step or
comment on the directories and files to be
used.

GT-31

You might also like