Hands-on tutorials - Wolf Dynamics - Customer-driven flow ... · Hands-on tutorials 2 • In this...

14
Hands-on tutorials 1 Syphon effect (Flushing a tank) VOF In this 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. What will happen in this case? And what will happen in this case?

Transcript of Hands-on tutorials - Wolf Dynamics - Customer-driven flow ... · Hands-on tutorials 2 • In this...

Page 1: Hands-on tutorials - Wolf Dynamics - Customer-driven flow ... · Hands-on tutorials 2 • In this tutorial we ... • As we are solving the incompressible laminar Navier-Stokes equations

Hands-on tutorials

1

Syphon effect (Flushing a tank) – VOF

• In this 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.

What will happen

in this case?

And what will happen

in this case?

Page 2: Hands-on tutorials - Wolf Dynamics - Customer-driven flow ... · Hands-on tutorials 2 • In this tutorial we ... • As we are solving the incompressible laminar Navier-Stokes equations

Hands-on tutorials

2

• In this 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.

Syphon effect (Flushing a tank) – VOF

www.wolfdynamics.com/wiki/flushtank/ani1.gif

Page 3: Hands-on tutorials - Wolf Dynamics - Customer-driven flow ... · Hands-on tutorials 2 • In this tutorial we ... • As we are solving the incompressible laminar Navier-Stokes equations

Hands-on tutorials

3

Syphon effect (Flushing a tank) – VOF

• And in case you were wondering this, we can easily add a time dependent inlet mass flow.

• Also, pay attention to the bubbles created in the water. If you look closely, there are small

bubbles that are not resolved by the mesh and this adds some diffusion to the solution.

• To overcome this problem, we can use a finer mesh or a dispersed solution approach.

www.wolfdynamics.com/wiki/flushtank/ani2.gif

Page 4: Hands-on tutorials - Wolf Dynamics - Customer-driven flow ... · Hands-on tutorials 2 • In this tutorial we ... • As we are solving the incompressible laminar Navier-Stokes equations

Hands-on tutorials

4

Syphon effect (Flushing a tank) – VOF

• We will use this case to introduce the multiphase solver interFoam.

• To setup a multiphase case, we need to define the physical properties of the

phases (in this case we are using two phases). This is done in the transportProperties dictionary file.

• If it is required, we need to initialize the location of the phases.

• We will define the gravity vector in the dictionary g.

• After finding the solution, we will visualize the results. This is an unsteady

case so now we are going to see things moving.

• At the end, we will do some plotting and post-processing using gnuplot and

Python.

• We are going to briefly address how to post-process multiphase flows.

Page 5: Hands-on tutorials - Wolf Dynamics - Customer-driven flow ... · Hands-on tutorials 2 • In this tutorial we ... • As we are solving the incompressible laminar Navier-Stokes equations

Hands-on tutorials

5

Syphon effect (Flushing a tank) – VOF

• In the constant directory, we will find the following compulsory dictionary

files:

• g

• transportProperties

• turbulenceProperties

• g contains the definition of the gravity vector.

• transportProperties contains the definition of the physical properties of

each phase.

• turbulenceProperties contains the definition of the turbulence model to

use.

• In this case we are not using turbulence model (laminar).

Page 6: Hands-on tutorials - Wolf Dynamics - Customer-driven flow ... · Hands-on tutorials 2 • In this tutorial we ... • As we are solving the incompressible laminar Navier-Stokes equations

• The transportProperties dictionary file

contains the definition of the physical properties of

each phase.

• This dictionary file is located in the directory constant.

• We first define the name of the phases (line 18).

In this case we are defining the names water and

air. The first entry in this list is the primary phase

(water). And as our primary phase is water, we will need to create the file 0/alpha.water

(volume fraction of water phase).

• After defining the names of the phases, we define

the physical properties.

• In this case we set the kinematic viscosity (nu),

density (rho) and transport model

(transportModel) of the phases.

• We also define the surface tension (sigma).

18 phases (water air);

19

20 water

21 {

22 transportModel Newtonian;

23 nu [0 2 -1 0 0 0 0] 1e-06;

24 rho [1 -3 0 0 0 0 0] 1000;

25 }

26

27 air

28 {

29 transportModel Newtonian;

30 nu [0 2 -1 0 0 0 0] 1.48e-05;

31 rho [1 -3 0 0 0 0 0] 1.225;

32 }

33

34 sigma [1 0 -2 0 0 0 0] 0.072;

6

Primary phase

Hands-on tutorials

Syphon effect (Flushing a tank) – VOF

Page 7: Hands-on tutorials - Wolf Dynamics - Customer-driven flow ... · Hands-on tutorials 2 • In this tutorial we ... • As we are solving the incompressible laminar Navier-Stokes equations

Hands-on tutorials

7

Syphon effect (Flushing a tank) – VOF

• In the 0 directory, we will find the dictionary files that contain the boundary

and initial conditions for all the primitive variables.

• As we are solving the incompressible laminar Navier-Stokes equations using

the VOF method, we will find the following field files:

• alpha.water (volume fraction of water phase)

• p_rgh (pressure field minus hydrostatic component)

• U (velocity field)

• These files contain the boundary and initial conditions for the non-

dimensional scalar field alpha.water

• This file is named alpha.water, because the primary phase is water (we

defined the primary phase on the transportProperties dictionary).

Page 8: Hands-on tutorials - Wolf Dynamics - Customer-driven flow ... · Hands-on tutorials 2 • In this tutorial we ... • As we are solving the incompressible laminar Navier-Stokes equations

Hands-on tutorials

8

Syphon effect (Flushing a tank) – VOF

• In the system directory, we will find the following compulsory dictionary files:

• controlDict

• fvSchemes

• fvSolution

• In the system directory you will find the following optional dictionary files:

• setFieldsDict

• The dictionary setFieldsDict is read by the utility setFields. This utility

set values on selected cells/faces. This is the utility that we will use to

initialize the flow.

Page 9: Hands-on tutorials - Wolf Dynamics - Customer-driven flow ... · Hands-on tutorials 2 • In this tutorial we ... • As we are solving the incompressible laminar Navier-Stokes equations

• The controlDict file contains general instructions on how to run the case.

• In this case, the solver interFoam supports adjustable time-step.

• In line 55 we turn on the option adjustTimeStep.

• This option will automatically adjust the time step to achieve the maximum desired courant number for the

momentum equation (maxCo) and the volume fraction equation (maxAlphaCo).

• Usually, maxAlphaCo is most restrictive than maxCo. To avoid smearing the free surface, it is a good idea to

keep the value of maxAlphaCo less than 1.

• In line 59, we also set the maximum time step (maxDeltaT).

• Remember, the first time step of the simulation is done using the value set in line 35 (deltaT) and then it is

automatically scaled to achieve the desired maximum values (lines 50-51).

9

Hands-on tutorials

Syphon effect (Flushing a tank) – VOF

35 deltaT 0.001;

36

55 adjustTimeStep yes;

56

57 maxCo 1;

58 maxAlphaCo 1;

59 maxDeltaT 1;

Page 10: Hands-on tutorials - Wolf Dynamics - Customer-driven flow ... · Hands-on tutorials 2 • In this tutorial we ... • As we are solving the incompressible laminar Navier-Stokes equations

18 ddtSchemes

19 {

20 default Euler;

21 }

22

23 gradSchemes

24 {

25 default Gauss linear;

26 }

27

28 divSchemes

29 {

30 div(rhoPhi,U) Gauss linearUpwind grad(U);

31 div(phi,alpha) Gauss vanLeer;

32 div(phirb,alpha) Gauss linear;

33 div(((rho*nuEff)*dev2(T(grad(U))))) Gauss linear;

34 }

35

36 laplacianSchemes

37 {

38 default Gauss linear corrected;

39 }

40

41 interpolationSchemes

42 {

43 default linear;

44 }

45

46 snGradSchemes

47 {

48 default corrected;

49 }

• The fvSchemes dictionary contains instructions for the

discretization schemes that will be used for the different

terms in the equations.

• The terms div(phi,alpha) and div(phirb,alpha) are the ones

related to the volume fraction equation.

• The volume fraction equation solves the interface between

the two phases.

• We need to use high order TVD schemes when solving the

interface.

• For the term div(phi,alpha) we are using vanLeer

interpolation. For the term div(phirb,alpha) we are using

linear interpolation.

• Remember, at the end of the day we want a solution that is

second order accurate.

10

Hands-on tutorials

Syphon effect (Flushing a tank) – VOF

Page 11: Hands-on tutorials - Wolf Dynamics - Customer-driven flow ... · Hands-on tutorials 2 • In this tutorial we ... • As we are solving the incompressible laminar Navier-Stokes equations

19

20 "alpha.water.*"

21 {

22 nAlphaCorr 2;

23 nAlphaSubCycles 1;

24

25 cAlpha 1;

26

27 MULESCorr yes;

28 nLimiterIter 3;

29

30 solver smoothSolver;

31 smoother symGaussSeidel;

32 tolerance 1e-8;

33 relTol 0;

34 }

35

• The fvSolution dictionary contains instructions on how to

solve each discretized linear equation system.

• As we are solving for the alpha.water equation we need to

define the linear solvers.

• To solve the volume fraction or alpha.water (lines 20-34) we

are using the smoothSolver method.

• In line 27 we turn on the semi-implicit method MULES. The

keyword nLimiterIter controls the number of MULES iterations

over the limiter.

• To have more stability, it is possible to increase the number of

loops and corrections used to solve alpha.water (lines 22-23).

• The keyword cAlpha (line 25) controls the sharpness of the

interface (1 is usually fine for most cases).

11

Hands-on tutorials

Syphon effect (Flushing a tank) – VOF

Page 12: Hands-on tutorials - Wolf Dynamics - Customer-driven flow ... · Hands-on tutorials 2 • In this tutorial we ... • As we are solving the incompressible laminar Navier-Stokes equations

Hands-on tutorials

12

Syphon effect (Flushing a tank) – VOF

• Before proceeding to the simulation stage, we need to do a custom initialization of the fields using the utility setFields.

• In lines 17-20 we set the default value to be 0 in the whole

domain (no water).

• In lines 22-53, we initialize two rectangular regions (box)

containing water (alpha.water 1).

• In this case, setFields will look for the dictionary file

0/alpha.water and it will overwrite the original values

according to the regions defined in setFieldsDict.

17 defaultFieldValues

18 (

19 volScalarFieldValue alpha.water 0

20 );

21

22 regions

23 (

35 boxToCell

36 {

37 box (-0.01 0.01 -10) (1 0.04 10);

38 fieldValues

39 (

40 volScalarFieldValue alpha.water 1

41 );

42 }

43

44 boxToCell

45 {

46 box (-0.5 0.01 -10) (0.015 1 10);

47 fieldValues

48 (

49 volScalarFieldValue alpha.water 1

50 );

51 }

52

53 );

boxToCell region

Airalpha.water = 0

Wateralpha.water = 1

Page 13: Hands-on tutorials - Wolf Dynamics - Customer-driven flow ... · Hands-on tutorials 2 • In this tutorial we ... • As we are solving the incompressible laminar Navier-Stokes equations

Hands-on tutorials

13

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. $> foamCleanPolyMesh

3. $> rm –rf 0 > /dev/null 2>&1

4. $> cp –r 0_org 0

5. $> fluentMeshToFoam ../../../meshes_and_geometries/fluent_flushTank/ascii.msh

6. $> cp system/boundary_org constant/polyMesh/boundary

7. $> checkMesh

8. $> cp 0/alpha.water.org 0/alpha.org

9. $> setFields

10. $> interFoam > log | tail -f log

11. $> paraFoam

Page 14: Hands-on tutorials - Wolf Dynamics - Customer-driven flow ... · Hands-on tutorials 2 • In this tutorial we ... • As we are solving the incompressible laminar Navier-Stokes equations

Hands-on tutorials

14

Syphon effect (Flushing a tank) – VOF

• In steps 1-3, we clean the case directory. This is not compulsory, but it is highly

advisable.

• In step 4, we transfer the backup or original files to the directory 0. It is highly

advisable to always keep backup files.

• In step 5, we convert the mesh from fluent format to OpenFOAM® format.

• In step 6, we copy the already modified dictionary system/boundary_org to

constant/polyMesh/boundary (if you want you can modify the original

boundary file yourself).

• In step 7, we check the mesh quality.

• In step 8, we copy the backup file 0/alpha.water.org to 0/alpha.water, we do

this because in the next step we are going to use the utility setFields, and this

utility will overwrite the file 0/alpha.water, so it is a good idea to always keep a

backup file.

• In step 9, we do custom field initialization.

• In step 10, we run the solver and save the standard output in the file log.

• In step 11, we visualize the solution using paraFoam.