Escolar Documentos
Profissional Documentos
Cultura Documentos
« Simulation in porous media from pore to large scale »
Stanford
Contact: cyprien.soulaine@stanford.edu
October 27, 2014
http://web.stanford.edu/~csoulain/ Version 5.0
Objectives
cyprien.soulaine@stanford.edu 2
General introduction to the OpenFOAM® technology
#2 – Cavity
#3 – Poiseuille flow
#4 – Drainage experiment in a capillary tube
How to mesh complex geometries with OpenFOAM® ?
Nov 10
snappyHexMesh overview
#5 – Mesh a pore-space with snappyHexMesh
#6 – Scalar transport in porous media at the pore-scale
Programming equations with OpenFOAM®
General structure of an application
#2 – Cavity
#3 – Poiseuille flow
#4 – Drainage experiment in a capillary tube
How to mesh complex geometries with OpenFOAM® ?
snappyHexMesh overview
#5 – Mesh a pore-space with snappyHexMesh
#6 – Scalar transport in porous media at the pore-scale
Programming equations with OpenFOAM®
General structure of an application
Basics of OpenFOAM programming
Pre-processing:
-
OpenFOAM® initiation
Solvers:
- incompressible / compressible flow
- multiphase flow
- combustion, electro-magnetism, solid mechanics
- heat transfer
- several turbulence approach (DNS, RANS, LES)
- etc…
post-processing:
- Distributed with ParaView (and the famous paraFoam)
- Exportation toward other post-treatment softwares (Fluent, Fieldview, EnSight, Tecplot…)
- « sample » utility for 1D or 2D sampling (export to gnuplot, Grace/xmgr et jPlot)
cyprien.soulaine@stanford.edu 6
OpenFOAM® initiation
openfoam.com
cyprien.soulaine@stanford.edu
Romain Guibert, 2013
7
Porous media modeling with OpenFOAM
Multiphase flow simulation in porous media at Darcy-scale
P. Horgue, C. Soulaine, J. Franc, R. Guibert, G. Debenest, An open-source toolbox for multiphase flow in porous
media, Computer Physics Communications (2014) https://github.com/phorgue/porousMultiphaseFoam.git
C. Soulaine, P. Horgue, J. Franc, M. Quintard, Gas–Liquid Flow Modeling in Columns Equipped with Structured
Packing, AIChE Journal 60 (2014) 3665-3674
Shewani, A., Horgue, P., Pommier, S., Debenest, G., Lefebvre, X., Gandon, E., Paul, E., Assessment of percolation
through a solid leach bed in dry batch anaerobic digestion processes, Bioresource Technology (2014)
OpenFOAM® initiation
Direct access to source-code (however, there is very few comments in the code !!)
Paying for support from OpenCFD Ltd, Wikki Ltd,….
An active community !
- A discussion forum (www.cfd-online.com/Forums/openfoam/)
- A community-driven wiki (openfoamwiki.net)
- An annual Workshop (9th edition in 2014) (www.openfoamworkshop.org)
- Social network related to OpenFOAM (www.extend-project.de)
- www.cocoons-project.org : A peer-reviewed documentation project
- A lot of tutorials, reports, presentations made by the community (search on Google)
cyprien.soulaine@stanford.edu 10
Why should I use OpenFOAM ?
OpenFOAM® initiation
• Completely free (No limitations due to licenses), • Need some time to learn,
• Direct access to source code (not a black-box), • Lack of documentation..
• An additional tool for code-to-code benchmarks, • There is no official GUI,
• Regular updates, • Unix command lines and C++
programing,
• A lot of out-of-the-box solvers and their tutorials,
•…
• Ease to program partial differential equations,
• A reactive and important community (forum,
conference, summer schools…),
• …..
cyprien.soulaine@stanford.edu 11
Some Unix commands
Navigation
pwd Tells you the name of the working directory.
Visualization
cat Outputs the contents of a specific file.
Manipulation of files
cp To copy a file. Use the -r option to copy a directory.
I/O redirection
> To redirect the output of an executable toward a file.
grep A filter to output every line that contains a specified pattern of characters.
cyprien.soulaine@stanford.edu 12
How to use the terminal in Mitchell/A65
1 Turn on or reboot the computer and hold down the Option key until the dual-
boot appears on screen.
OpenFOAM® initiation
cyprien.soulaine@stanford.edu 13
How to use OpenFOAM at Stanford
OpenFOAM 2.2.2 is installed in Stanford CEES-RCF cluster
You can login to the cluster with your SUNetID
For this training, we will use the tool servers in graphic mode
OpenFOAM® initiation
$ ssh sunetid@cees-tool-3.stanford.edu -X
Or
$ ssh sunetid@cees-tool-4.stanford.edu -X
Once you are login, create your OpenFOAM home directory (this stage only needs to
be done once)
$ cd ~
$ mkdir -p $FOAM_RUN
cyprien.soulaine@stanford.edu 14
General structure of an OpenFOAM case
cyprien.soulaine@stanford.edu 15
#1 - Heat diffusion (1/4)
Solver : laplacianFoam
573K
cyprien.soulaine@stanford.edu 16
#1 - Heat diffusion (2/4)
$ run
$ cp –r $FOAM_TUTORIALS/basic/laplacianFoam/flange Exo1
$ cd Exo1
$ ls
$ gedit 0/T
OpenFOAM® initiation
cyprien.soulaine@stanford.edu 17
#1 - Heat diffusion (3a/4)
Definition of initial and boundary
conditions
Dimensions (units) of the field T
[kg m s K kgmol A cd]
OpenFOAM® initiation
Zero flux
cyprien.soulaine@stanford.edu 18
#1 - Heat diffusion (3b/4)
$ gedit constant/transportProperties
OpenFOAM® initiation
cyprien.soulaine@stanford.edu 19
#1 - Heat diffusion (3c/4)
$ gedit system/controlDict
OpenFOAM® initiation
cyprien.soulaine@stanford.edu 20
#1 – Heat diffusion (4/4)
Convert the mesh from Ansys to OpenFOAM
Creation of new files in the
$ ansysToFoam flange.ans -scale 0.001
directory constant/polyMesh
Visualize the mesh with ParaView
$ paraFoam
Start the simulation Creation of a new folder for each
time step
$ laplacianFoam
OpenFOAM® initiation
4 – Choose the
field to display (T) 5 – Press play to
read all the time
steps
3- Choose
« surface »
2 - « apply » Exo1bis :
DT = 1e-7 m²/s
Until steady-state
1 – Choose
the field you
want to load
for viewing
cyprien.soulaine@stanford.edu 21
#2 - Cavity (1/6)
Ux=1m/s Tutorial detailed in the official User Guide
movingWall
fixedWalls
OpenFOAM® initiation
y
fixedWalls
x
$ run
$ cp –r $FOAM_TUTORIALS/incompressible/icoFoam/cavity Exo2
$ cd Exo2
$ ls
cyprien.soulaine@stanford.edu 22
#2 - Cavity (2/6)
blockMesh = pre-processing tool to design and mesh simple geometries
Geometry and grid are defined in the file blockMeshDict
Vertices definition
$ gedit constant/polyMesh/blockMeshDict
7 6
4 - « Apply » 5 - « wireframe »
2 – To display
the patch
names on the
geometry
1 – Choose the
elements you want
to visualize
cyprien.soulaine@stanford.edu 24
#2 - Cavity (4a/6)
$ gedit constant/transportProperties
OpenFOAM® initiation
cyprien.soulaine@stanford.edu 25
#2 - Cavity (4b/6)
$ gedit 0/U
OpenFOAM® initiation
cyprien.soulaine@stanford.edu 26
#2 - Cavity (4c/6)
$ gedit 0/p
OpenFOAM® initiation
cyprien.soulaine@stanford.edu 27
#2 - Cavity (4d/6)
$ gedit system/controlDict
OpenFOAM® initiation
cyprien.soulaine@stanford.edu 28
#2 - Cavity (5/6)
Start the simulation :
$ icoFoam
OpenFOAM® initiation
cyprien.soulaine@stanford.edu 29
#2 - Cavity (6a/6)
To view the velocity vectors
cyprien.soulaine@stanford.edu 31
#3 - Poiseuille flow (1/4)
Objectives:
Simulate a Poiseuille flow through a 2D pipe with symmetry plane condition
Steady-state solution of laminar incompressible Navier-Stokes equations with the
simpleFoam solver
OpenFOAM® initiation
symmetryPlane
outlet
inlet
y bottomWall
x
$ run
$ cp –r $FOAM_TUTORIALS/incompressible/simpleFoam/pitzDaily Exo3
$ cd Exo3
$ cp ../Exo2/constant/polyMesh/blockMeshDict constant/polyMesh/.
cyprien.soulaine@stanford.edu 32
#3 - Poiseuille flow (2/4)
$ gedit constant/polyMesh/blockMeshDict
symmetryPlane
3 2
inlet 7 outlet
6
OpenFOAM® initiation
y 0
z x 1
4
bottomWall
1e-3;
$ blockMesh
cyprien.soulaine@stanford.edu 33
#3 - Poiseuille flow (3a/4)
$ gedit 0/p $ gedit 0/U
OpenFOAM® initiation
cyprien.soulaine@stanford.edu 34
#3 - Poiseuille flow (3b/4)
$ gedit constant/RASProperties $ gedit system/controlDict
OpenFOAM® initiation
cyprien.soulaine@stanford.edu 35
#3 - Poiseuille flow (4/4)
We use the same parameters as Exo 2
To start the simulation: $ simpleFoam
cyprien.soulaine@stanford.edu 36
#4 – Drainage in a capillary tube (1/5)
Objectives :
non-wetting wetting fluid Simulate a drainage (a non-wetting fluid pushing
fluid (α=0) (α=1) a wetting fluid) experiment in a simple 2D
capillary tube
Contact
angle θ
Example adapted fom the damBreak tutorial
detailed in the official user guide
OpenFOAM® initiation
$ run
$ cp –r $FOAM_TUTORIALS/multiphase/interFoam/laminar/damBreak Exo4
$ cd Exo4
$ cp ../Exo3/constant/polyMesh/blockMeshDict constant/polyMesh/.
cyprien.soulaine@stanford.edu 37
#4 - Drainage in a capillary tube (2/5)
$ gedit constant/polyMesh/blockMeshDict
top (wall)
right (inlet)
3 2
OpenFOAM® initiation
7 6
0
1
4 5
y left (outlet)
x bottom (wall)
z
$ blockMesh ¶
cyprien.soulaine@stanford.edu 38
#4 - Drainage in a capillary tube (3a/5)
$ gedit constant/transportProperties
Non-wetting phase
properties
Surface tension
cyprien.soulaine@stanford.edu 39
#4 - Drainage in a capillary tube (3b/5)
$ gedit 0/U $ gedit 0/p_rgh
We use a hydrostatic
pressure
OpenFOAM® initiation
cyprien.soulaine@stanford.edu 40
#4 - Drainage in a capillary tube (3c/5)
$ mv 0/alpha1.org 0/alphawater.org¶
$ gedit 0/alphawater.org¶
alphawater represents the wetting/non-
wetting phase distribution in the
computational domain. (alpha=0 for the
non-wetting, alpha=1 for the wetting)
OpenFOAM® initiation
cyprien.soulaine@stanford.edu 41
#4 - Drainage in a capillary tube (3d/5)
Specify that the simulation will be without gravity in a laminar flow regime
cyprien.soulaine@stanford.edu 42
#4 - Drainage in a capillary tube (3e/5)
$ gedit system/controlDict
cyprien.soulaine@stanford.edu 43
#4 - Drainage in a capillary tube (4/5)
Before we start the simulation, we are going to specify the initial phase distribution with setFields
$ cp 0/alphawater.org/ 0/alphawater
$ paraFoam
$ gedit system/setFieldsDict
$ setFields
$ paraFoam
OpenFOAM® initiation
BEFORE
AFTER
cyprien.soulaine@stanford.edu 44
#4 - Drainage in a capillary tube (5/5)
Start the immiscible two-phase flow simulation:
$ interFoam
t=0.05s
t=0.10s
t=0.15s
t=0.20s
cyprien.soulaine@stanford.edu 45
In the next parts...
Part III: First programs, development of a heat tranfer solver in porous media
http://web.stanford.edu/~csoulain/
cyprien.soulaine@stanford.edu 46