Complex Physics Modelling with OpenFOAM · 2018-10-02 · Complex Physics Modelling with OpenFOAM...
Transcript of Complex Physics Modelling with OpenFOAM · 2018-10-02 · Complex Physics Modelling with OpenFOAM...
Complex Physics Modelling withOpenFOAM
Open Source CFD in Industry and Academia
Prof. Hrvoje Jasak
Wikki Ltd. United Kingdom
University of Zagreb, Croatia
Tsinghua University, Beijing, 17 September 2018
Complex Physics Modelling with OpenFOAM – p. 1
Outline
Objective
• Review the design modern numerical simulation / CFD software development and
capabilities
• Highlight applications of OpenFOAM in the automotive industry
• Review examples of electrochemistry simulations: PEM/SOFC fuel cells
Topics
1. Design and limitations of contemporary CFD software
2. Model representation through equation mimicking
3. Object orientation, generic programming and library design
4. Some practical applications: Automotive CFD
5. Modelling complex physics with OpenFOAM: detailed modelling of flow, heat
transfer and electrochemistry in fuel cells
6. Why consider OpenFOAM
7. Summary
Complex Physics Modelling with OpenFOAM – p. 2
Background
State of the Art in CFD Software Use
• Numerical modelling is a part of product design
◦ Improvements in computer performance: CPU speed and memory
◦ Improved physical modelling and numerics, covering more physics
◦ Sufficient validation and experience with modelling capabilities
• Two-fold requirements in CFD development
◦ Integration into the CAD-based design process
◦ Quick and reliable implementation of new and complex physical models
• Complex geometry support, high-performance computing, automatic meshing,
dynamic mesh capabilities etc. needed across the spectrum
• Opening new areas of CFD simulation
◦ Non-traditional physics: complex heat and mass transfer models,
electromagnetics, fluid-structure interaction, electrochemistry
◦ New solution techniques, eg. flow and shape optimisation; robust design,
uncertainty propagation, adjoint sensitivity, optimisation under uncertainty
Complex Physics Modelling with OpenFOAM – p. 3
Design of Modern Solvers
Physics and Numerics
• A single discretisation method (FVM, FEM), parallelism and vectorisation
• User-defined modifications inefficient and limiting: proprietary software
• Model-to-model interaction matrix is becoming increasingly complex
Software Organisation
• Functional approach: centralised data and multiple functions operating on it
• Monolithic implementation and integrated software: single executable for all cases
• A CFD software is a large project: order of 1-2 million lines of source code
• Complex solver-to-solver interaction or embedding virtually impossible: two
solvers, solver and mesh generator, embedding in a CAD environment
Consequences
• Difficulties in development, maintenance and support
• Some new simulation techniques cannot be accommodated at all: sensitivity
• In spite of the fact the all components are present, it is extremely difficult to
implement “non-traditional” models
Change of paradigm has started from approx. 2010
Complex Physics Modelling with OpenFOAM – p. 4
Object Orientation
Object-Oriented Software: Create a Language Suitable for the Problem
• Analysis of numerical simulation software through object orientation:
“Recognise main objects from the numerical modelling viewpoint”
• Objects consist of data they encapsulate and functions which operate on the data
Example: Sparse Matrix Class
• Data members: protected and managed
◦ Sparse addressing pattern (CR format, arrow format)
◦ Diagonal coefficients, off-diagonal coefficients
• Operations on matrices or data members: Public interface
◦ Matrix algebra operations: +,−, ∗, /,
◦ Matrix-vector product, transpose, triple product, under-relaxation
• Actual data layout and functionality is important only internally: efficiency
Example: Linear Equation Solver
• Operate on a system of linear equations [A][x] = [b] to obtain [x]
• It is irrelevant how the matrix was assembled or what shall be done with solution
• Ultimately, even the solver algorithm is not of interest: all we want is new x!
• Gauss-Seidel, AMG, direct solver: all answer to the same interface
Complex Physics Modelling with OpenFOAM – p. 5
Object Orientation
Implementation of Complex Physics Models
• Flexible handling of arbitrary equations sets is needed
• Natural language of continuum mechanics: partial differential equations
• Example: turbulence kinetic energy equation
∂k
∂t+∇•(uk)−∇•[(ν + νt)∇k] = νt
[
1
2(∇u+∇uT )
]2
−ǫo
kok
• Objective: Represent differential equations in their natural language
solve
(
fvm::ddt(k)
+ fvm::div(phi, k)
- fvm::laplacian(nu() + nut, k)
== nut*magSqr(symm(fvc::grad(U)))
- fvm::Sp(epsilon/k, k)
);
• Correspondence between the implementation and the original equation is clear
Complex Physics Modelling with OpenFOAM – p. 6
Object Orientation
Object Oriented Analysis
• Main object = operator, eg. time derivative, convection, diffusion, gradient
• How do we represent an operator in CFD?
◦ A field: explicit evaluation
◦ A matrix: implicit algorithm
• . . . but we need many other components to assemble the equation
◦ Representation of space and time: computational domain
◦ Scalars, vectors and tensors
◦ Field representation and field algebra
◦ Initial and boundary condition
◦ Systems of linear equations and solvers
◦ Discretisation methods
• The above does not complete the system
◦ Physical models, (eg. turbulence) and model-to-model interaction
◦ Pre- and post-processing and related utilities
◦ Top-level solvers
Complex Physics Modelling with OpenFOAM – p. 7
Object Orientation
Application Development in OpenFOAM
• Custom-written top-level solvers are written for each class of physics
• Solvers are optimised for efficiency and storage, re-using basic components
• Writing top-level code is very similar to manipulating the equations
• Ultimate user-coding capabilities: components can be re-used to handle most
problems in computational continuum mechanics
Layered Development
• Design encourages code re-use: developing shared tools
• Classes and functional components developed and tested in isolation
◦ Vectors, tensors and field algebra
◦ Mesh handling, refinement, mesh motion, topological changes
◦ Discretisation, boundary conditions
◦ Matrices and linear solver technology
◦ Physics by segment in library form
• Library level mesh, pre-, post- and data handling utilities
• Model-to-model interaction handled through common interfaces
• New components do not disturb existing code: fewer bugs
Complex Physics Modelling with OpenFOAM – p. 8
Object Orientation and User
How Does Object Orientation Impact the CFD Software User?
• The view above is relevant for software developer and model implementation
• . . . but user requirements are different
◦ Existing applications across CFD modelling areas
◦ Solver customisation and extension: “User Coding”
◦ Vertically integrated custom solver design: naval hydrodynamics,
turbomachinery, external aerodynamics, fuel cell design etc
◦ Automated execution, hiding of solver parameters
◦ Validation and verification
User-Specific CFD Solution Framework
1. Deploy ready-to-use OpenFOAM solvers to conventional applications:
aerodynamics, HVAC, marine hydrodynamics, turbomachinery, combustion
2. Based on existing components and building blocks to create a custom CFD solver
and work-flow: mesh generation, post processing and data analysis
3. For new complex physics CFD: develop and simulate new models:
eg. plasma physics in welding applications, catalytic chemistry, fluid-solid
interaction etc.
Complex Physics Modelling with OpenFOAM – p. 9
External Aerodynamics Simulations
DrivAer Geometry: External Aerodynamics, Coupled Solver, 13.2M Cells
Complex Physics Modelling with OpenFOAM – p. 11
Automotive Applications
Modelling Diesel Particular Filters
• Steady-state compressible flow through thin porous layers
• Detailed 3-D meshing of channels expensive: mesh resolution requirements
• . . . but due to flow non-uniformity, channel-scale simulations cannot provide the
answer: not all channels are equally loaded and energy equation is solved globally
• Solution: multi-scale filter model
◦ Each channel is one cell thick: (1-D) simulation
◦ Porosity is a face property; flow friction is a volumetric sink
◦ Porous faces are assigned time-dependent filtration efficiency due to soot
deposition, affecting the flow and species distribution
• Automatic meshing tool for the monolith, unstructured mesh for inlet and outlet
Complex Physics Modelling with OpenFOAM – p. 12
Automotive Applications
Spray, Wall Film and Combustion Simulations in Internal Combustion Engines
• Complete simulation of spray injection, evaporation, wall film and combustion in a
GDI engine. Mesh motion and topological changes as shown before
• Basic flow solver with automatic mesh motion and topological changes
• Full suite of Diesel spray modelling using Lagrangian modelling framework
• Spray-wall interaction; liquid film modelling
• Simulation of pollutants: NOx, unburnt hydrocarbons
• Mesh sensitivity of spray penetration: solved with adaptive refinement
Complex Physics Modelling with OpenFOAM – p. 13
Internal Combustion Engine
Internal Combustion Engine Simulations
• Diesel combustion, 1/8 cylinder sector
• RANS, k − ǫ turbulence model, simplified
5-species chemistry and 1 reaction,
Chalmers PaSR combustion model
• Temperature on the cutting plane, spray
droplets coloured with temperature
Cold Flow with Valves
• Parallel valves
• Exhaust and intakestroke
Two-Stroke Engine
• Topological
changes: cell
layering and sliding
• Simulating exhaust
gas recirculation
Complex Physics Modelling with OpenFOAM – p. 14
Fuel Injection Flash Boiling
Flash-Boiling Flows
• The fundamental difference between flash boiling and cavitation is that the process
has a higher saturation pressure and temperature: higher density
• Enthalpy required for phase change is provided by inter−phase heat transfer
• Jakob number: ratio of sensible heat available to amount of energy required for
phase change
Ja =ρlcp∆T
ρvhfg
• Equilibrium models are successful for cavitation since Ja is large and timescale of
heat transfer is small. Flash boiling represents a finite rate heat transfer process:
Homogeneous Relaxation Model (HRM)
Dx
Dt=
x− x
Θ; Θ = Θ0ǫ
−0.54φ1.76
x is the quality (mass fraction), relaxing to the equilibrium x over a time scale Θ
• The timescale Θ is obtained from empirical relationship: Downar–Zapolski [1996].
ǫ is the void fraction and φ is the non−dimensional pressure.
Complex Physics Modelling with OpenFOAM – p. 15
Fuel Injection Flash Boiling
Flash-Boiling Flows: Numerical Method
• Conservation of Mass∂ρ
∂t+∇ · (φvρ) = 0
• Conservation of Momentum
(∂ρU0)
∂t+∇ ·
(
φU0)
= −∇pn +∇ ·(
µ∇U0)
• Pressure Equation
1
ρ
∂ρ
∂p
∣
∣
∣
x,h
(
∂(ρpk+1)
∂t+∇ · (ρUpk+1)
)
+ ρ∇ ·φ∗− ρ∇
1
ap∇pk+1
+M(
pk)
+∂M
∂p
(
pk+1− pk
)
= 0
The HRM model term is denoted as M(= DxDt
). The superscripts k and k + 1 are
the corrector steps for the pressure equation.
Complex Physics Modelling with OpenFOAM – p. 16
Fuel Injection Flash Boiling
Asymmetric Fuel Injector Nozzle-Design from Bosch GmbH.
Complex Physics Modelling with OpenFOAM – p. 17
Liquid Film Model
Finite Area Method: Simulating Surface Phenomena
• Finite Area Method: discretised equations on a curved surface in 3-D
• Surface is discretised using polygonal faces
• Discretisation takes into account surface curvature. A level of smoothness isassumed in calculation of curvature terms
Equation Set of a Thin Liquid Film Model
• Continuity equation
∫
Sw
∂h
∂tdS +
∮
∂Sw
m•v h dL =
∫
Sw
mS
ρLdS
n
m
m h
v
nmd,i
Sw
Complex Physics Modelling with OpenFOAM – p. 18
Liquid Film Model
Equation Set of a Thin Liquid Film Model
• Momentum equation
∫
Sw
∂hv
∂tdS +
∮
∂Sw
m•(hvv +C) dL
=1
ρL
∫
Sw
(τ fs − τw) dS +
∫
Sw
hgt dS −1
ρL
∫
Sw
h∇spL dS +1
ρL
∫
Sw
Sv dS
n
m
m
n
v
v
pL
gtgn
vd,i
md,i pL = pg + pd + pσ + ph
pd,i =ρ(vd,i)
2
n
2
pσ = −σ∇s •(∇sh)
ph = −ρLn•gh
Sv =∑
imd,i (vd,i)tdt dS
τfsh τw
Sw
Complex Physics Modelling with OpenFOAM – p. 19
Liquid Film Model
Model Validation: Flow Down an Inclined Plane with a Hump, Polygonal Mesh
0.005
0.01
0.015
0.02
0.025
0.03
-1 -0.5 0 0.5 1
Ave
rage
vel
octy
, m/s
z, m
Average velocity at outlet edge
Numerical solutionExact solution for plate
Complex Physics Modelling with OpenFOAM – p. 20
Liquid Film Model
Roof and Down-Pipe System Performance Analysis by Arup: London Aquatic Centre
Complex Physics Modelling with OpenFOAM – p. 21
Liquid Film Model
Roof and Down-Pipe System Performance Analysis by Arup: London Aquatic Centre
Complex Physics Modelling with OpenFOAM – p. 22
Liquid Film Model
Roof and Down-Pipe System Performance Analysis by Arup: London Aquatic Centre
Complex Physics Modelling with OpenFOAM – p. 23
Liquid Film Model
Liquid Film Simulations: Avalanche Modelling and Vehicle Soiling: Rauter, 2017
Complex Physics Modelling with OpenFOAM – p. 24
Liquid Film Model
Volume-Surface-Lagrangian Simulation
• Main coupling challenge is to implement
all components side-by-side and control
their interaction
• Lagrangian tracking uses an ODE solver:
block coupling at matrix level is not
needed or cannot be used as before
• Close coupling is achieved by sub-cycling
or iterations over the block system for
each time-step
• If the model-to-model coupling fails,
options on improving the stability are
considerably limited
• Engine wall film simulation: courtesy of Po-
litecnico di Milano
Complex Physics Modelling with OpenFOAM – p. 25
Non-Linear Solid Mechanics
Two Decades of Solid Mechanics Development Bear Fruit
• Extensive development of FVM solid mechanics: non-linear structural problems
• Geometric non-linearity: large deformation
• Material non-linearity: plastic hardening, visco-elasto-plasticity
• Modelling of contact (linear and non-linear) with complex friction models
• New generation of mixed mode lubricated contact modelling
Complex Physics Modelling with OpenFOAM – p. 26
Fuel Cell Modelling
The MUSIC Project: A Multi-Scale Integrated Fuel Cell Project
• Fuel cells: potential source clean energy solutions. To build economically viable
and reliable fuel cells: need good models
• Proprietary software impedes progress: open source solution and shared
knowledge on physics and modelling
• MUSIC: An international collaboration to develop a better design tool to build
better fuel cells. Share the implementation, and its development, but hide the
actual fuel cell design
• Partners/financial support:
◦ Natural Science and Engineering Research Council, Canada
◦ Forschungszentrum Jülich GmbH, Germany
◦ Lund University, Sweden
◦ . . . and looking for further partners!
• Both SOFC and PEM cells considered; possibly include battery modelling
• Multi-scale modelling of physical processes
◦ Large (50-cell) stacks: rate equations in place of diffusion terms
◦ Single cells and small stacks: detailed CFD simulation
◦ Micro-scale simulations for effective properties and cell-level parameters
Complex Physics Modelling with OpenFOAM – p. 27
Fuel Cell Modelling
The MUSIC Project: A Multi-Scale Integrated Fuel Cell Project
• Cell-level flow simulation: Júlich F-design SOFC Fuel cell
Complex Physics Modelling with OpenFOAM – p. 28
Fuel Cell Modelling
The MUSIC Project: A Multi-Scale Integrated Fuel Cell Project
• Cell-level electrochemistry simulation: Júlich F-design SOFC Fuel cell
Complex Physics Modelling with OpenFOAM – p. 29
Fuel Cell Modelling
The MUSIC Project: Micro-Scale Simulations
• First used to compute effective diffusion and thermal conductivities in porous
media; currently used to evaluate detailed kinetics on micro-scale
• Geometry constructed either by dropping spheres or by detailed tomography
reconstruction of real materials
• Energy production occurs at the linear junction of triple-phase boundaries
• Local species values determined and mapped to line junction
• Electrochemical equations solved to determine local current production
• Linear current mapped back to adjacent cell volumes as source/sink terms
Complex Physics Modelling with OpenFOAM – p. 30
Fuel Cell Modelling
The MUSIC Project: Micro-Scale Work
• Results: ionic potential, electron potential, concentration of O2
Complex Physics Modelling with OpenFOAM – p. 31
Why Consider OpenFOAM
Why Consider OpenFOAM
• Open architecture
◦ Access to complete source: no secret modelling tricks, no cutting corners
◦ Both community-based and professional support available
◦ Common platform for new R&D projects: shipping results of research into the
hands of a customer with no delay
• Low-cost CFD
◦ No license cost, portable to any computing platform (IBM Blue Gene)
◦ Efficient on massively parallel computers, portable to new comms protocols
• Problem-independent numerics and discretisation
◦ Tackle non-standard continuum mechanics problem: looking beyond the
capabilities of commercial CFD
• Efficient environment for complex physics problems
◦ Tackling difficult physics is made easier through equation mimicking
◦ Utility-level tools readily available: parallelism, moving mesh
◦ Track record in non-linear and strongly coupled problems
◦ Excellent piece of C++ and software engineering! Decent piece of CFD
Complex Physics Modelling with OpenFOAM – p. 32
Summary
Summary
• OpenFOAM is a free software, available to all at no charge: GNU Public License
• Object-oriented approach facilitates model implementation
• Equation mimicking opens new grounds in Computational Continuum Mechanics
• Extensive capabilities already implemented; open design for easy customisation
• Solvers are validated in detail and match the efficiency of commercial codes
OpenFOAM in Research
• Open Source tools are ideal for a research environment: industrial partner gains
access not only to physical model equations but also to a validated implementation
• Deployment of results of research is faster and more reliable
• Uni Zagreb is the right partner: combination of in-depth knowledge of numerical
simulation tools, physical modelling and CFD methods
OpenFOAM in a Commercial Environment
• Deployment of Open Source CFD tools requires close collaboration: validation,
support, custom simulations, process integration and tool development
• Costs are reduced and simulation capability is expanded
• Wikki provides in-depth knowledge of methodology and industrial experience
Complex Physics Modelling with OpenFOAM – p. 33
About Me
Hrvoje Jasak
• First degree: mechanical engineering, University of Zagreb, Croatia 1988-1992
• PhD, Imperial College London 1993-1996
• Senior development engineer, CD-adapco (Siemens), 1996-2000
• Technical director, Nabla Ltd. 2000-2004
• Consultant on CFD software, numerics and modelling, ANSYS Fluent 2000-2008
Current Work
• Director, Wikki Ltd: UK-based CFD company 2004-
• Professor, University of Zagreb, Croatia 2007-
• Mercator Fellow, TU Darmstadt, 2016-
• Various software development and commercial support projects based on
OpenFOAM with consultants and large industrial partners
• Coordinating open source OpenFOAM development to allow contributions from the
public domain developers
• OpenFOAM workshops, lectures and seminars, visiting professorships (TU Delft,
Chalmers University, Uni Zaragoza, USM Chile and others)
Complex Physics Modelling with OpenFOAM – p. 34