an OpenSource Computational Fluid Dynamics Toolbox

– an OpenSource Computational Fluid Dynamics Toolbox Outline of the presentation: General presentation of OpenFOAM (www.openfoam.org) Tensors, tensor ...
Author: Bruce Riley
11 downloads 1 Views 2MB Size
– 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 OpenFOAM 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 available at the OpenFOAM homepage: www.openfoam.org

˚ Hakan Nilsson, Chalmers / Applied Mechanics / Fluid Dynamics

Find it at: www.openfoam.org Links to: OpenCFD information Download Documentation Discussion group

˚ Hakan 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.

˚ Hakan Nilsson, Chalmers / Applied Mechanics / Fluid Dynamics

Solving PDEs with OpenFOAM The PDEs we wish to solve involve derivatives of tensor fields with respect to time and space The PDEs must be discretized in time and space before we solve them

We will start by having a look at algebra of tensors in OpenFOAM at a single point We will then have a look at how to generate tensor fields from tensors Finally we will see how to discretize PDEs and how to set boundary conditions using high-level coding in OpenFOAM Later, in the worked example, we will see how to do this using FoamX – the OpenFOAM GUI

˚ Hakan 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 function 0 Scalar scalar 1 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() Outputs to the screen: Txz = 13

endl;

˚ Hakan 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 description Addition a+b Outer product Rank a, b ab Inner product Rank a, b a b Cross product Rank a, b a b Operations exclusive to tensors of rank 2 Transpose Diagonal diagT Determinant detT Operations exclusive to scalars Positive (boolean) s 0 Hyperbolic arc sine asinh s 









Description in OpenFOAM a+b a*b a&b aˆb



T.T() diag(T) det(T) pos(s) asinh(s)

˚ Hakan Nilsson, Chalmers / Applied Mechanics / Fluid Dynamics

Dimensional units in OpenFOAM OpenFOAM checks the dimensional consistency Declaration 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 Symbol 1 Mass kilogram kg 2 Length metre m 3 Time second s 4 Temperature Kelvin K 5 Quantity moles mol 6 Current ampere A 7 Luminous intensity candela cd     



sigma then has the dimension



˚ Hakan 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;

˚ Hakan 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 polyhedral mesh using the minimum information required The fvMesh class extends the polyMesh class to include additional data needed for the FV discretization The geometricField class relates a tensor field to an fvMesh (can also be typedef volField, surfaceField, pointField) A geometricField inherits all the tensor algebra of its corresponding field, has dimension checking, and can be subjected to specific discretization procedures

˚ Hakan 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 and inherits the algebra of its corresponding field, and it supports many of the standard algebraic matrix operations The fvm (Finite Volume Method) and fvc (Finite Volume Calculus) classes contain static functions 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:: functions Laplacian 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 



 



















 



























˚ Hakan 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)

˚ Hakan Nilsson, Chalmers / Applied Mechanics / Fluid Dynamics

Example: laplacianFoam, the source code #include ”fvCFD.H” // Include the class definitions int 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



˚ Hakan Nilsson, Chalmers / Applied Mechanics / Fluid Dynamics

Example: laplacianFoam, discretization and boundary conditions Discretization: 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; 



˚ Hakan Nilsson, Chalmers / Applied Mechanics / Fluid Dynamics

Applications in OpenFOAM An application in OpenFOAM is a high-level code using the OpenFOAM 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 Description Solver potentialFoam Simple potential flow solver which can be used to generate starting fi Solver simpleFoam Steady-state solver for incompressible, turbulent flow of non-Newtoni Solver turbFoam Transient solver for incompressible turbulent flow Solver sonicTurbFoam Transient solver for trans-sonic/supersonic turbulent flow of a compre Solver lesInterFoam Solver for 2 incompressible fluids capturing the interface, using a run Solver dnsFoam Direct numerical simulation solver for boxes of isotropic turbulence Solver dieselEngineFoam Diesel engine spray and combustion code Solver buoyantFoam Transient solver for buoyant, turbulent flow of compressible fluids for Solver electroStatic Foam Solver for electrostatics Solver stressedFoam Transient/steady-state solver of linear-elastic small-strain deformatio Solver financialFoam Solves the Black-Scholes equation to price commodities

˚ Hakan Nilsson, Chalmers / Applied Mechanics / Fluid Dynamics

Applications in OpenFOAM (continued)



Examples of precompiled utilities: Category Application Description Utility mapFields Maps volume fields from one mesh to another, reading and interpolat Utility blockMesh Mesh generator Utility fluentMeshToFoam Converts a Fluent mesh to OpenFOAM format Utility checkMesh Checks validity of a mesh Utility renumberMesh Renumbers the cell list in order to reduce the bandwidth, reading an Utility foamToEnsight Translates OpenFOAM data to Ensight format Utility Lambda2 Calculates and writes the second largest eigenvalue of the sum of the Utility checkYPlus Calculates and reports for all wall patches, for each time in a data Utility decomposePar Automatically decompose a mesh and fields for a case for parallel exe Etc., etc. ...

˚ Hakan 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. 



























































:



:

˚ Hakan Nilsson, Chalmers / Applied Mechanics / Fluid Dynamics











:

,

OpenFOAM for water turbine applications, and a validation

Financed by SVC (www.svc.nu): ¨ a Swedish Energy Agency, ELFORSK, Svenska Kraftnat, Chalmers, LTU, KTH, UU a

¨ ¨ ˚ Companies involved: CarlBro, E.ON Vattenkraft Sverige, Fortum Generation, Jamtkraft, J¨onk¨oping Energi, Malarenergi, Skelleftea˚ Kraft, Sollefteaforsens, Statoil Lubricants, Sweco VBB, Sweco Energuide, SweMin, Tekniska Verken i Link o¨ ping, Vattenfall Research and Development, Vattenfall Vattenkraft, Waplans, ¨ VG Power and Oresundskraft

˚ Hakan Nilsson, Chalmers / Applied Mechanics / Fluid Dynamics

Validation of engineering quantities, results Quasi-steady draft tube computation OpenFOAM cfx-5

PSfrag replacements

 

   

PSfrag replacements

1.1 1 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0

cfx-5 Ib

II

III

IVa

0.2 0.18 0.16 0.14 0.12 0.1 0.08 0.06 0.04 0.02 0

OpenFOAM cfx-5

Ib

II

III

IVa

OpenFOAM results

1.20 1.00

PSfrag replacements

0.60

1.00 0.80

corner

0.60

0.40

cfx-5

0.20

0.40 0.20

0.00 -0.20

OpenFOAM results

PSfrag replacements



 cfx-5

0.80

1.20

elbow

OpenFOAM cfx-5 OpenFOAM results experiments

0 0.5 1 1.5 2 2.5 3 3.5 4 Distance [m]

0.00 -0.20

elbow

OpenFOAM cfx-5 experiments

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 Distance [m]

˚ Hakan Nilsson, Chalmers / Applied Mechanics / Fluid Dynamics

Validation of velocity profiles at section Ia 2 Z

Above the blade

1.5

R

Section Ia



1

Section Ib

PSfrag replacements

0.5

0 0

0.2

0.4

0.6

0.8

1

Hub (0) to shroud (1)

g replacements

2

PSfrag replacements

1.5

1.5

Hub (0) to shroud (1)

1

1





0.5

Hub (0) to shroud (1)

Hub (0) to shroud (1) 0.5

0 0

0

0.2

0.4

0.6

Hub (0) to shroud (1)

0.8

1

−0.5 0

0.2

0.4

0.6

0.8

1

Hub (0) to shroud (1)

Squares: measured axial velocity. Triangles: measured tangential velocity. In (a) the colors correspond 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.

˚ Hakan Nilsson, Chalmers / Applied Mechanics / Fluid Dynamics

Vortex rope of the unsteady draft tube computation 





Periodicity in time:

(same as CFX-5)

˚ Hakan Nilsson, Chalmers / Applied Mechanics / Fluid Dynamics

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

˚ Hakan Nilsson, Chalmers / Applied Mechanics / Fluid Dynamics

People and projects at Chalmers using OpenFOAM Tobias Persson, Shipping and Marine Technology, Chalmers ¨ Cavitation modelling and LES, cavInterFoam (developed by Niklas Wikstr om, FOI/Chalmers

˚ Hakan Nilsson, Chalmers / Applied Mechanics / Fluid Dynamics

People and projects at Chalmers using OpenFOAM ˚ Aurelia Cure (LTH, Co-supervised by Hakan Nilsson, Chalmers) Lagrangian particle tracking at the NACA0015 profile Rising bubbles using the VOF method Purpose: Cavitation in water turbines

˚ Hakan Nilsson, Chalmers / Applied Mechanics / Fluid Dynamics

People and projects at Chalmers using OpenFOAM Rasmus Hemph, Applied Mechanics, Fluid Dynamics, Chalmers Fluidized beds using Lagrangian Particle Tracking Column packing using Lagrangian Particle Tracking

˚ Hakan Nilsson, Chalmers / Applied Mechanics / Fluid Dynamics

People and projects at Chalmers using OpenFOAM ¨ Fabian Peng Karrholm, Applied Mechanics, Combustion, Chalmers Cavitation in diesel nozzles cavitatingFoam (Now available in OpenFOAM 1.4)

˚ Hakan 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

˚ Hakan Nilsson, Chalmers / Applied Mechanics / Fluid Dynamics

Thank you for your attention!

Acknowledgements The OpenFOAM developers (www.openfoam.org) Dr. Hrvoje Jasak, Wikki Ltd. ˚ Hakan Nilsson is partly financed by SVC (www.svc.nu): ¨ 1 Swedish Energy Agency, ELFORSK, Svenska Kraftnat, Chalmers, LTU, KTH, UU 1

¨ ¨ ˚ Companies involved: CarlBro, E.ON Vattenkraft Sverige, Fortum Generation, Jamtkraft, J¨onk¨oping Energi, Malarenergi, Skelleftea˚ Kraft, Sollefteaforsens, Statoil Lubricants, Sweco VBB, Sweco Energuide, SweMin, Tekniska Verken i Link o¨ ping, Vattenfall Research and Development, Vattenfall Vattenkraft, Waplans, ¨ VG Power and Oresundskraft

˚ Hakan Nilsson, Chalmers / Applied Mechanics / Fluid Dynamics

Suggest Documents