Lecture2A ONCORE Course
Lecture2A ONCORE Course
OpenFOAM
30 Aug 2022 – 6 October 2022 (every Tuesday & Thursday)
Contact: [email protected]
Course Enrollment : Multi-physics modelling and simulation of nuclear reactors using OpenFOAM
ONCORE: Open-source Nuclear Codes for Reactor Analysis
Objective of the lecture
We will have a look on:
• “Multi-physics modelling and simulation”
• How to model a nuclear engineering problem: from the physical system to the
mathematical and numerical modeling to result analysis
• Overview on PDEs, Finite Volume discretization method and linear algebra solvers in the
view of OF use
• Solver and case folder structure (where to find equations, parameters, boundary
conditions, and initial conditions),
• First steps with OF: download, installation, learning tools
2
Modelling and Simulation
Nuclear systems are complex systems
Multicomponent
Multidisciplinary
Multiphysics
Multiscale
3
Modelling and Simulation
How to study nuclear reactor (or complex system)?
Modelling
System Model
Experiment Simulation
5
Modelling and Simulation
To design and analyze system (prediction of plant parameters)
• Increase understanding
• Optimization
• Control
• Safety
Advantages
• Experiment are expensive, dangerous and cannot be performed on system that cannot
exist
• Time scale
• Variables may be inacessible
• Easy manipulation
• No disturbancies
• Exploring different scenario
6
Modelling and Simulation
Critical issues
Physics Simulation
7
Multiphysics
“Multiphysics is a computational discipline which treats simulations that involve multiple
physical models or multiple simultaneous physical phenomena” (Wikipedia et al., 2017)
Physics Simulation
• Fluid dynamics
• Heat Transfer
• Neutronics
• Chemistry
• Mechanics
• BoP
8
Modelling of an engineering problem
9
Modelling of an engineering problem
10
Modelling of an engineering problem
From Lecture 1: An overview on the use of OpenFOAM as a multi physics library for nuclear reactor analysis 12
Modelling of an engineering problem
Physical and domain modelling
14
Modelling of an engineering problem
−∇ ∙ 𝑘∇𝑇 = 𝑞ሶ
Example taken from «F. Moukalled, L. Mangani, M. Darwish. The Finite Volume Method in Computational Fluid Dynamics. Springer, 2016» 15
Modelling of an engineering problem
Example taken from «F. Moukalled, L. Mangani, M. Darwish. The Finite Volume Method in Computational Fluid Dynamics. Springer, 2016» 16
Modelling of an engineering problem
Example taken from «F. Moukalled, L. Mangani, M. Darwish. The Finite Volume Method in Computational Fluid Dynamics. Springer, 2016» 17
Modelling of an engineering problem
Example taken from «F. Moukalled, L. Mangani, M. Darwish. The Finite Volume Method in Computational Fluid Dynamics. Springer, 2016» 18
Modelling of an engineering problem
Example taken from «F. Moukalled, L. Mangani, M. Darwish. The Finite Volume Method in Computational Fluid Dynamics. Springer, 2016» 19
Modelling of an engineering problem
Example taken from «F. Moukalled, L. Mangani, M. Darwish. The Finite Volume Method in Computational Fluid Dynamics. Springer, 2016» 20
Introduction on FV
The purpose of any discretisation practice is to transform one or more partial
differential equations into a corresponding system of algebraic equations.
Taken from Joel Guerrero, Finite Volume Method: A Crash introduction. https://wiki.openfoam.com/Theory_by_Joel_Guerrero
Published under: CC BY-SA license 21
Introduction on FV
Two ingredients: domain discretization and equation discretization
The domain is divided in control volumes Vp where the solution is calculated by integrating
the PDE over Vp.
Taken from Joel Guerrero, Finite Volume Method: A Crash introduction. https://wiki.openfoam.com/Theory_by_Joel_Guerrero
Published under: CC BY-SA license 22
Introduction on FV
. Two ingredients: domain discretization and equation discretization
Hp: linear
variation in
space and time
Taken from Joel Guerrero, Finite Volume Method: A Crash introduction. https://wiki.openfoam.com/Theory_by_Joel_Guerrero
Published under: CC BY-SA license 23
Introduction on FV
Taken from Joel Guerrero, Finite Volume Method: A Crash introduction. https://wiki.openfoam.com/Theory_by_Joel_Guerrero
Published under: CC BY-SA license 24
Introduction on FV
. In the convective and diffusive flux, the variable of interest is calculated at the
face flux but we want the value at the centroid P
. The face values appearing in the convective and diffusive fluxes have to be
computed by some form of interpolation from the centroid values of the control
volumes at both sides of face f.
Taken from Joel Guerrero, Finite Volume Method: A Crash introduction. https://wiki.openfoam.com/Theory_by_Joel_Guerrero
Published under: CC BY-SA license 25
Introduction on FV
Convective flux
Linear interpolation
(central differencing)
. II order accurate
. May create oscillatory solution
Upwind differencing
. I order accurate
. Bounded solution
. Diffusive
Taken from Joel Guerrero, Finite Volume Method: A Crash introduction. https://wiki.openfoam.com/Theory_by_Joel_Guerrero
Published under: CC BY-SA license 26
Introduction on FV
Diffusive flux
Linear interpolation
(central differencing)
. II order accurate
. Truncation error
introduced due to the
mesh non-orthogonality
Taken from Joel Guerrero, Finite Volume Method: A Crash introduction. https://wiki.openfoam.com/Theory_by_Joel_Guerrero
Published under: CC BY-SA license 27
Introduction on FV
. Last but not least.. Time discretization
Taken from Joel Guerrero, Finite Volume Method: A Crash introduction. https://wiki.openfoam.com/Theory_by_Joel_Guerrero
Published under: CC BY-SA license 29
Introduction on FV
. The time discretizations lead to a linear system to be solved
Taken from Joel Guerrero, Finite Volume Method: A Crash introduction. https://wiki.openfoam.com/Theory_by_Joel_Guerrero
Published under: CC BY-SA license 30
Modelling of an engineering problem in OF
31
OpenFOAM case
How to perform simulation with OpenFOAM:
1) Select the solver, i.e., the modelling
2) Case preparation
. Geometry and mesh
. Initial and boundary conditions
. Physical models/parameters
. Discretization
. Solver parameters
. Simulation parameters
3) Post-processing
. Visualization
. Data analysis
32
OpenFOAM case
2) Case preparation
. Geometry and Mesh
. Initial and boundary conditions
. Physical models/parameters
. Discretization
. Solver parameters
. Simulation parameters
33
OpenFOAM case
2) Case preparation
. Geometry and Mesh
. Initial and boundary conditions
. Physical models/parameters
. Discretization
. Solver parameters
. Simulation parameters
34
OpenFOAM case
36
OpenFOAM case
2) Case preparation
. Geometry and Mesh
. Initial and boundary conditions
. Physical models/parameters
. Discretization
. Solver parameters
. Simulation parameters
37
OpenFOAM case
Taken from Joel Guerrero, Finite Volume Method: A Crash introduction. https://wiki.openfoam.com/Theory_by_Joel_Guerrero
Published under: CC BY-SA license 38
OpenFOAM case
2) Case preparation
. Geometry and Mesh
. Initial and boundary conditions
. Physical models/parameters
. Discretization
. Solver parameters
. Simulation parameters
39
OpenFOAM case
. Info on the linear (iterative)
solver for each discretized matrix-
related quantity
Taken from Joel Guerrero, Finite Volume Method: A Crash introduction. https://wiki.openfoam.com/Theory_by_Joel_Guerrero
Published under: CC BY-SA license 40
OpenFOAM case
2) Case preparation
. Geometry and Mesh
. Initial and boundary conditions
. Physical models/parameters
. Discretization
. Solver parameters
. Simulation parameters
41
OpenFOAM case
Taken from Joel Guerrero, Finite Volume Method: A Crash introduction. https://wiki.openfoam.com/Theory_by_Joel_Guerrero
Published under: CC BY-SA license 42
Modelling of an engineering problem in OF
43
OpenFOAM solver
Let’s take a laminar fluid dynamics problem…
𝛻∙𝒖=0
ቐ𝜕𝒖
+ 𝒖 ∙ 𝛻 𝒖 = 𝜐𝛻 2 𝒖 − 𝛻𝑝Τ𝜌0 + 𝑭
𝜕𝑡
In OpenFOAM-XXX/applications/solvers/incompressible/solver4NSFoam
Make
solver4NSFoam.C Ueqn.H
createFields.H pEqn.H 44
OpenFOAM solver
solver4NSFoam.C //Main file of the solver
#include "fvCFD.H"
#include "singlePhaseTransportModel.H"
#include "turbulentTransportModel.H"
#include "radiationModel.H«
#include "fvOptions.H"
#include "pimpleControl.H«
#include "fixedFluxPressureFvPatchScalarField.H«
#include "IOmanip.H"
while (runTime.loop())
{
while (pimple.loop())
{
#include "UEqn.H"
while (pimple.correct())
{
#include "pEqn.H"
}
if (pimple.turbCorr()
{
laminarTransport.correct();
turbulence->correct();
}
}
runTime.write();
}
46
OpenFOAM solver
UEqn.H
𝒖𝑡 + 𝒖 ∙ ∇ 𝒖 − 𝜐∆𝒖 + 𝛁𝒑 = 0
fvVectorMatrix Ueqn
(
fvm::ddt(U) + fvm::div(phi, U)
+ MRF.DDt(U)
+ turbulence->divDevReff(U)
==
fvOptions(U)
);
UEqn.relax();
fvOptions.constrain(UEqn);
if (pimple.momentumPredictor())
{
solve
( From Lecture 1: An overview on the use of OpenFOAM as a multi physics
UEqn == -fvc::grad(p) library for nuclear reactor analysis
)
fvOptions.correct(U);
}
47
OpenFOAM solver
pEqn.H
U = HbyA - rAU*fvc::grad(p); 48
OpenFOAM solver
Any remarks on the solver structure?
49
OpenFOAM solver
Any remarks on the solver structure?
. Four iteration loop (time loop, “pimple” loop, “pressure correction” loop and
nonOrthogonal correction loop)
. No straightforward way for the velocity – pressure coupling
. Use of fvm:: vs fvc:: e.g. fvm::ddt(U), fvc::grad(p)
50
OpenFOAM solver
𝛻∙𝒖=0
ቐ𝜕𝒖
+ 𝒖 ∙ 𝛻 𝒖 = 𝜐𝛻 2 𝒖 − 𝛻𝑝Τ𝜌0 + 𝑭
𝜕𝑡
Navier – Stokes equations pose different numerical challenges:
. Non linearity of the convective term 𝒖 ∙ 𝛻 𝒖
. There is no “pressure” equation (actually the continuity equation imposes a constraint
on the momentum equation)
outerCorrectiors
Taken from Joel Guerrero, Finite Volume Method: A Crash introduction. https://wiki.openfoam.com/Theory_by_Joel_Guerrero
Published under: CC BY-SA license 52
OpenFOAM
In fvSolution, you can specify the options for
PIMPLE
. # of nonOrthogonalCorrection
(for mesh non-orthogonality)
. # of (pressure) nCorrectors
Usually 2 (the first pressure corrector will
create a conservative velocity field, . # nOuterCorrectors
while the second and following will establish Help the convergence of the
the pressure distribution) nonlinear terms especially
when using large time step
Taken from Joel Guerrero, Finite Volume Method: A Crash introduction. https://wiki.openfoam.com/Theory_by_Joel_Guerrero
Published under: CC BY-SA license 53
First steps with OF
I am curious about OpenFOAM … but which version?
openfoam.com openfoam.org
IMPORTANT!
If you want to use an available solver, or take features from available
solvers for your own solver, be very careful and select the right OF version!
54
First steps with OF
Can I use it on my computer?
55
First steps with OF
56 56
First steps with OF
What comes with OpenFOAM? Main OF library
Typical
location
Pre-packaged OF solvers
(e.g. icoFoam) and
utilities (e.g. blockMesh)
57
First steps with OF
58
First steps with OF
Learn OpenFOAM - Overview of Finite Volume Method
from H. Jasak
https://www.youtube.com/watch?v=a4B_oXR5Kzs&ab_channel=
KennethHoste
59
First steps with OF
Learn OpenFOAM – Presentations and tutorial from OF wiki
https://wiki.openfoam.com/index.php?title=%223_weeks%22_series
60
First steps with OF
Learn OpenFOAM - Presentations from Wolf Dynamics
61
First steps with OF
Learn OpenFOAM – Book «F. Moukalled, L. Mangani, M. Darwish. The
Finite Volume Method in Computational Fluid Dynamics. Springer, 2016»
62
First steps with OF
Learn OpenFOAM – Browse the C++ source guide official documentation
• https://www.openfoam.com/documentation/guides/v2112/doc/
• https://cpp.openfoam.org/v9/
63
First steps with OF
Learn OpenFOAM – Plenty of additional resources
And remember:
▪ Don’t get frustrated: there is always a way out with OpenFOAM and, most likely,
someone who had your same problem and will be happy to help
▪ Don’t get discouraged: the entry barrier may seem steep, but skills you’ll learn will
allow you to tackle any kind of problems
▪ If possible, do not do it alone!
64
Multi-physics modeling and simulation of nuclear reactors using
OpenFOAM
30 Aug 2022 – 6 October 2022 (every Tuesday & Thursday)
Contact: [email protected]
Thank you!
Contact: [email protected]
Course Enrollment : Multi-physics modelling and simulation of nuclear reactors using OpenFOAM
ONCORE: Open-source Nuclear Codes for Reactor Analysis