Œ an opensource computational fluid dynamics toolboxhani/pdf_files/of-seminar_070515.pdf · 2007....

27
H ˚ akan Nilsson, Chalmers / Applied Mechanics / Fluid Dynamics – an OpenSource Computational Fluid Dynamics Toolbox Outline of the presentation: General presentation of OpenFOAM (www.openfoam.org) Tensors, tensor fields and discretization of PDEs in OpenFOAM Applications in OpenFOAM OpenFOAM by an example (simpleFOAM, pitzDaily tutorial) Presentation of the use of OpenFOAM in the water turbine field, including validation against results from CFX-5 and measurements Presentation of other people and activities at Chalmers using Open- FOAM Interest for an OpenFOAM course in the fall of 2007? Some of the material in this presentation is based on the OpenFOAM manual, which is avail- able at the OpenFOAM homepage: www.openfoam.org

Upload: others

Post on 29-Jan-2021

9 views

Category:

Documents


0 download

TRANSCRIPT

  • Håkan Nilsson, Chalmers / Applied Mechanics / Fluid Dynamics

    – an OpenSource Computational Fluid Dynamics ToolboxOutline of the presentation:

    � General presentation of OpenFOAM (www.openfoam.org)

    � Tensors, tensor fields and discretization of PDEs in OpenFOAM

    � Applications in OpenFOAM

    � OpenFOAM by an example (simpleFOAM, pitzDaily tutorial)

    � Presentation of the use of OpenFOAM in the water turbine field,including validation against results from CFX-5 and measurements

    � Presentation of other people and activities at Chalmers using Open-FOAM

    � Interest for an OpenFOAM course in the fall of 2007?

    Some of the material in this presentation is based on the OpenFOAM manual, which is avail-able at the OpenFOAM homepage: www.openfoam.org

  • Håkan Nilsson, Chalmers / Applied Mechanics / Fluid Dynamics

    Find it at:www.openfoam.org

    Links to:OpenCFD informationDownloadDocumentationDiscussion group

  • Håkan Nilsson, Chalmers / Applied Mechanics / Fluid Dynamics

    The OpenSource OpenFOAM CFD solver - a quick overview� OpenFOAM = Open Field Operation and Manipulation, www.openfoam.org

    An OpenSource object oriented C++ tool for solving PDE’s

    � Preprocessing (grid generator, converters, manipulators, case setup)

    � Postprocessing (using OpenSource Paraview)

    � Many specialized CFD solvers implemented, e.g.. – simpleFoam: A finite volume steady-state solver for incompressible,. turbulent flow of non-Newtonian fluids, using the SIMPLE algorithm. – turbFoam: A finite volume solver for unsteady incompressible, turbulent. flow of non-Newtonian fluids, using the PISO algorithm. – icoDyMFoam: Sliding/moving grid

    � OpenSource = possibility to have insight into the code. * Makes development and tailor-made solvers possible. – simpleUnsteadyRotatingFoam: Unsteady SIMPLE solver. with Coriolis and centrifugal terms. – cavInterFoam: Cavitation using VOF and the Kunz’ cavitation model. * Makes research implementations available and results reproducable.

    � Access to an international community of OpenFOAM users

    � Runs in parallel using automatic/manual domain decomposition.

  • Håkan Nilsson, Chalmers / Applied Mechanics / Fluid Dynamics

    Solving PDEs with OpenFOAM

    � The PDEs we wish to solve involve derivatives of tensor fields withrespect to time and space

    � The PDEs must be discretized in time and space before we solvethem

    � We will start by having a look at algebra of tensors in OpenFOAMat a single point

    � We will then have a look at how to generate tensor fields fromtensors

    � Finally we will see how to discretize PDEs and how to set boundaryconditions using high-level coding in OpenFOAM

    � Later, in the worked example, we will see how to do this usingFoamX – the OpenFOAM GUI

  • Håkan Nilsson, Chalmers / Applied Mechanics / Fluid Dynamics

    Basic tensor classes in OpenFOAM� Pre-defined classes for tensors of rank 0-3, but may be extended indefinitely

    Rank Common name Basic name Access function0 Scalar scalar1 Vector vector x(), y(), z()2 Tensor tensor xx(), xy(), xz(), ...

    Example:

    A tensor is defined line-by-line:tensor T( 11, 12, 13, 21, 22, 23, 31, 32, 33);

    Info � � “Txz = “ � � T.xz() � � endl;Outputs to the screen:Txz = 13

  • Håkan Nilsson, Chalmers / Applied Mechanics / Fluid Dynamics

    Algebraic tensor operations in OpenFOAM� Tensor operations operate on the entire tensor entity instead of a

    series of operations on its components

    � The OpenFOAM syntax closely mimics the syntax used in written mathematics,using descriptive functions or symbolic operators

    Examples:

    Operation Comment Mathematical Descriptiondescription in OpenFOAM

    Addition a + b a + bOuter product Rank a, b � � ab a * bInner product Rank a, b � � a � b a & bCross product Rank a, b � � a � b a ˆ bOperations exclusive to tensors of rank 2Transpose ��� T.T()Diagonal diagT diag(T)Determinant detT det(T)Operations exclusive to scalarsPositive (boolean) s � 0 pos(s)Hyperbolic arc sine asinh s asinh(s)

  • Håkan Nilsson, Chalmers / Applied Mechanics / Fluid Dynamics

    Dimensional units in OpenFOAM

    � OpenFOAM checks the dimensional consistencyDeclaration of a tensor with dimensions:dimensionedTensor sigma. (. ”sigma”,. dimensionSet( 1, -1, -2, 0, 0, 0, 0),. tensor( 1e6, 0, 0, 0, 1e6, 0, 0, 0, 1e6). );

    The values of dimensionSet correspond to the powers of each SI unit:No. Property Unit Symbol1 Mass kilogram kg2 Length metre m3 Time second s4 Temperature Kelvin K5 Quantity moles mol6 Current ampere A7 Luminous intensity candela cd

    sigma then has the dimension � � � ��� ���

  • Håkan Nilsson, Chalmers / Applied Mechanics / Fluid Dynamics

    Construction of a tensor field in OpenFOAM

    � A tensor field is a list of tensors� The use of typedef in OpenFOAM yields readable type definitions:

    scalarField, vectorField, tensorField, symmTensorField, ...

    � Algebraic operations can be performed between different fields,and between a field and a single tensor, e.g. Field U, scalar 2.0:U = 2.0 * U;

  • Håkan Nilsson, Chalmers / Applied Mechanics / Fluid Dynamics

    Discretization of a tensor field in OpenFOAM

    � FVM (Finite Volume Method) or FEM (Finite Element Method)� No limitations on the number of faces bounding each cell

    � No restriction on the alignment of each face

    � The mesh class polyMesh can be used to construct a polyhedralmesh using the minimum information required

    � The fvMesh class extends the polyMesh class to include additionaldata needed for the FV discretization

    � The geometricField class relates a tensor field to an fvMesh (canalso be typedef volField, surfaceField, pointField)

    � A geometricField inherits all the tensor algebra of its correspond-ing field, has dimension checking, and can be subjected to specificdiscretization procedures

  • Håkan Nilsson, Chalmers / Applied Mechanics / Fluid Dynamics

    Equation discretization in OpenFOAM

    � Converts the PDEs into a set of linear algebraic equations, Ax=b, where x and b are volFields(geometricFields). A is an fvMatrix, which is created by a discretization of a geometricField andinherits the algebra of its corresponding field, and it supports many of the standard algebraicmatrix operations

    � The fvm (Finite Volume Method) and fvc (Finite Volume Calculus) classes contain static func-tions for the differential operators, and discretize any geometricField. fvm returns an fvMatrix,and fvc returns a geometricField.

    Examples:Term description Implicit/explicit Mathematical expression fvm::/fvc:: functionsLaplacian Implicit/Explicit � � � � � laplacian(Gamma,phi)Time derivative Implicit/Explicit � � � �� ddt(phi)

    � � � � � � ddt(rho, phi)Convection Implicit/Explicit � � �� � div(psi, scheme)

    � � � � � � div(psi, phi, word)div(psi, phi)

    Source Implicit � � Sp(rho, phi)Implicit/Explicit SuSp(rho, phi)

    � : vol � type Field, � : scalar, volScalarField, � : surfaceScalarField

  • Håkan Nilsson, Chalmers / Applied Mechanics / Fluid Dynamics

    Example

    The equation

    � ��

    ���

    � � � ��

    � � � � � ��

    � � � � �

    has the OpenFOAM representation

    solve(

    fvm::ddt(rho, U)+ fvm::div(phi, U)- fvm::laplacian(mu, U)

    ==- fvc::grad(p)

    )

  • Håkan Nilsson, Chalmers / Applied Mechanics / Fluid Dynamics

    Example: laplacianFoam, the source code#include ”fvCFD.H” // Include the class definitionsint main(int argc, char *argv[])

    # include ”setRootCase.H” // Set the correct path# include ”createTime.H” // Create the time# include ”createMesh.H” // Create the mesh# include ”createFields.H” // Create temperature field T and set thermal diffusivity DT

    . for (runTime++; !runTime.end(); runTime++) // Time loop

    . �

    # include ”readSIMPLEControls.H” // Solution controls ( ICCG, nNonOrthCorr = 4). for (int nonOrth=0; nonOrth � =nNonOrthCorr; nonOrth++). �

    . solve( fvm::ddt(T) - fvm::laplacian(DT, T) ); // Solve � � � �� � � � � � � � �

    . �

    # include ”write.H” // Write out results at specified time instances. �

    . return(0); // End with ’ok’ signal

  • Håkan Nilsson, Chalmers / Applied Mechanics / Fluid Dynamics

    Example: laplacianFoam, discretization and boundary conditionsDiscretization:dictionary fvSchemes, read from file:

    ddtSchemes

    . default Euler;

    laplacianSchemes

    . default none;

    . laplacian(DT,T) Gauss linear corrected;

    Boundary conditions:Part of class volScalarField object T, read from file:boundaryField �

    . patch1 � type zeroGradient; �

    . patch2 � type fixedValue; value uniform 273; � �

  • Håkan Nilsson, Chalmers / Applied Mechanics / Fluid Dynamics

    Applications in OpenFOAM

    � An application in OpenFOAM is a high-level code using theOpenFOAM libraries

    � Applications are categorized into Solvers and Utilities.Solvers solve specific problems in continuum mechanics,Utilities perform tasks involving data manipulation

    Examples of precompiled solvers:Category Application DescriptionSolver potentialFoam Simple potential flow solver which can be used to generate starting fields for full Navier Stokes codesSolver simpleFoam Steady-state solver for incompressible, turbulent flow of non-Newtonian fluidsSolver turbFoam Transient solver for incompressible turbulent flowSolver sonicTurbFoam Transient solver for trans-sonic/supersonic turbulent flow of a compressible gasSolver lesInterFoam Solver for 2 incompressible fluids capturing the interface, using a runtime-selectable incompressible LES modelSolver dnsFoam Direct numerical simulation solver for boxes of isotropic turbulenceSolver dieselEngineFoam Diesel engine spray and combustion codeSolver buoyantFoam Transient solver for buoyant, turbulent flow of compressible fluids for ventilation and heat transferSolver electroStatic Foam Solver for electrostaticsSolver stressedFoam Transient/steady-state solver of linear-elastic small-strain deformation of solid bodies in contactSolver financialFoam Solves the Black-Scholes equation to price commodities

  • Håkan Nilsson, Chalmers / Applied Mechanics / Fluid Dynamics

    Applications in OpenFOAM (continued)

    Examples of precompiled utilities:Category Application DescriptionUtility mapFields Maps volume fields from one mesh to another, reading and interpolating all fields present in the time directory of both cases. Parallel and non-parallel cases are handled without the need to reconstruct them firstUtility blockMesh Mesh generatorUtility fluentMeshToFoam Converts a Fluent mesh to OpenFOAM formatUtility checkMesh Checks validity of a meshUtility renumberMesh Renumbers the cell list in order to reduce the bandwidth, reading and renumbering all the fields from all the time directoriesUtility foamToEnsight Translates OpenFOAM data to Ensight formatUtility Lambda2 Calculates and writes the second largest eigenvalue of the sum of the square of the symmetrical and anti-symmetrical parts of the velocity gradient tensor, at each time in a databaseUtility checkYPlus Calculates and reports ��� for all wall patches, for each time in a databaseUtility decomposePar Automatically decompose a mesh and fields for a case for parallel execution of OpenFOAM

    Etc., etc. ...

  • Håkan Nilsson, Chalmers / Applied Mechanics / Fluid Dynamics

    OpenFOAM by an example (simpleFOAM, pitzDaily tutorial)Inlet: � � � � �� � � � � � � � � � �� � � � � of inlet height, Outlet: � � �� � ,

    Walls: Wall functions, Total height: � � � � , �� �� � � Hex cells.

    � :

    � :

    � :

  • Håkan Nilsson, Chalmers / Applied Mechanics / Fluid Dynamics

    OpenFOAM for water turbine applications, and a validation

    Financed by SVC (www.svc.nu):Swedish Energy Agency, ELFORSK, Svenska Kraftnät, a

    Chalmers, LTU, KTH, UUaCompanies involved: CarlBro, E.ON Vattenkraft Sverige, Fortum Generation, Jämtkraft, Jönköping Energi, Mälarenergi, Skellefteå Kraft, Sollefteåforsens,

    Statoil Lubricants, Sweco VBB, Sweco Energuide, SweMin, Tekniska Verken i Linköping, Vattenfall Research and Development, Vattenfall Vattenkraft, Waplans,VG Power and Öresundskraft

  • Håkan Nilsson, Chalmers / Applied Mechanics / Fluid Dynamics

    Validation of engineering quantities, results

    Quasi-steady draft tube computation

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9

    1 1.1

    Ib II III IVa

    OpenFOAM

    PSfrag replacements �������

    ���

    cfx-5

    0 0.02 0.04 0.06 0.08

    0.1 0.12 0.14 0.16 0.18

    0.2

    Ib II III IVa

    OpenFOAMcfx-5

    PSfrag replacements

    cfx-5

    ���

    OpenFOAM results

    -0.20

    0.00

    0.20

    0.40

    0.60

    0.80

    1.00

    1.20

    0 0.5 1 1.5 2 2.5 3 3.5 4

    Distance [m]

    elbowOpenFOAM

    cfx-5experiments

    PSfrag replacements

    cfx-5

    OpenFOAM results

    ��

    -0.20

    0.00

    0.20

    0.40

    0.60

    0.80

    1.00

    1.20

    0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

    Distance [m]

    elbow

    corner

    OpenFOAMcfx-5

    experiments

    PSfrag replacements

    cfx-5

    OpenFOAM results

    ��

  • Håkan Nilsson, Chalmers / Applied Mechanics / Fluid Dynamics

    Validation of velocity profiles at section Ia

    Z

    R

    Above the blade

    Section Ia

    Section Ib

    0 0.2 0.4 0.6 0.8 10

    0.5

    1

    1.5

    2

    PSfrag replacements

    Hub (0) to shroud (1)

    ���

    0 0.2 0.4 0.6 0.8 10

    0.5

    1

    1.5

    2

    PSfrag replacements

    Hub (0) to shroud (1)

    Hub (0) to shroud (1)

    � �

    0 0.2 0.4 0.6 0.8 1−0.5

    0

    0.5

    1

    1.5PSfrag replacements

    Hub (0) to shroud (1)

    Hub (0) to shroud (1)

    Hub (0) to shroud (1)

    ���

    Squares: measured axial velocity. Triangles: measured tangential velocity. In (a) the colorscorrespond to two different measurements. In (b) and (c): Blue curve: quasi-steady draft tube,Black curve: runner without hub clearance, Red curve: runner with hub clearance.

  • Håkan Nilsson, Chalmers / Applied Mechanics / Fluid Dynamics

    Vortex rope of the unsteady draft tube computation

    Periodicity in time: � �� � (same as CFX-5)

  • Håkan Nilsson, Chalmers / Applied Mechanics / Fluid Dynamics

    People and projects at Chalmers using OpenFOAMRickard Benzow, Shipping and Marine Technology, Chalmers)LES of a turning submarineLES of a propeller in a rotating mesh

  • Håkan Nilsson, Chalmers / Applied Mechanics / Fluid Dynamics

    People and projects at Chalmers using OpenFOAMTobias Persson, Shipping and Marine Technology, ChalmersCavitation modelling and LES, cavInterFoam (developed by Niklas Wikström, FOI/Chalmers

  • Håkan Nilsson, Chalmers / Applied Mechanics / Fluid Dynamics

    People and projects at Chalmers using OpenFOAMAurelia Cure (LTH, Co-supervised by Håkan Nilsson, Chalmers)Lagrangian particle tracking at the NACA0015 profileRising bubbles using the VOF methodPurpose: Cavitation in water turbines

  • Håkan Nilsson, Chalmers / Applied Mechanics / Fluid Dynamics

    People and projects at Chalmers using OpenFOAMRasmus Hemph, Applied Mechanics, Fluid Dynamics, ChalmersFluidized beds using Lagrangian Particle TrackingColumn packing using Lagrangian Particle Tracking

  • Håkan Nilsson, Chalmers / Applied Mechanics / Fluid Dynamics

    People and projects at Chalmers using OpenFOAMFabian Peng Kärrholm, Applied Mechanics, Combustion, ChalmersCavitation in diesel nozzlescavitatingFoam (Now available in OpenFOAM 1.4)

  • Håkan Nilsson, Chalmers / Applied Mechanics / Fluid Dynamics

    Interest for an OpenFOAM course in fall 2007?

    If you are interested in joining an OpenFOAM course this fall,please send an e-mail to: [email protected]

    You will learn the basics of OpenFOAM and apply it to your own problems

  • Håkan Nilsson, Chalmers / Applied Mechanics / Fluid Dynamics

    Thank you for your attention!

    AcknowledgementsThe OpenFOAM developers (www.openfoam.org)Dr. Hrvoje Jasak, Wikki Ltd.

    Håkan Nilsson is partly financed by SVC (www.svc.nu):Swedish Energy Agency, ELFORSK, Svenska Kraftnät, 1

    Chalmers, LTU, KTH, UU

    1Companies involved: CarlBro, E.ON Vattenkraft Sverige, Fortum Generation, Jämtkraft, Jönköping Energi, Mälarenergi, Skellefteå Kraft, Sollefteåforsens,Statoil Lubricants, Sweco VBB, Sweco Energuide, SweMin, Tekniska Verken i Linköping, Vattenfall Research and Development, Vattenfall Vattenkraft, Waplans,VG Power and Öresundskraft