0% found this document useful (0 votes)
10 views65 pages

Lecture2A ONCORE Course

The document outlines a course on multi-physics modeling and simulation of nuclear reactors using OpenFOAM, focusing on practical applications and theoretical foundations. It details the steps required to model nuclear engineering problems, including physical and domain modeling, discretization, and solution of equations. Key topics include the use of partial differential equations, finite volume methods, and the importance of proper analysis and validation in complex systems.

Uploaded by

Pulches
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views65 pages

Lecture2A ONCORE Course

The document outlines a course on multi-physics modeling and simulation of nuclear reactors using OpenFOAM, focusing on practical applications and theoretical foundations. It details the steps required to model nuclear engineering problems, including physical and domain modeling, discretization, and solution of equations. Key topics include the use of partial differential equations, finite volume methods, and the importance of proper analysis and validation in complex systems.

Uploaded by

Pulches
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 65

Multi-physics modeling and simulation of nuclear reactors using

OpenFOAM
30 Aug 2022 – 6 October 2022 (every Tuesday & Thursday)
Contact: [email protected]

Multi-physics modelling and simulation of nuclear


reactors using OpenFOAM
Lecture 2A: A practical introduction to OpenFOAM -
Theory background and first steps
1st September 2022
Stefano Lorenzi ([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)?

“For every complex problem


there is an answer that is clear,
simple, and… wrong” (H. L.
Mencken)

“There are no simple answers to complex problems”


Proper analysis: The analysis performed for a system should not be more complex
than is necessary for a given purpose
. We should know which is our purpose (what we want to know about the problem)
. We should know which are the limits of our analysis approach (what we can
studied with this approach or not)
4
Modelling and Simulation

Modelling
System Model

Experiment Simulation

Experimental Validation Simulation


results results

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

• A model is not the real world – Pygamlion effect


• Forcing reality into the constraints of a model – Procrustes effect
• Forgetting the model’s level of accuracy
• Forgetting the purpose of the model – Proper modelling
• The computational resources are not unlimited

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

“Multiphysics is the study of the mutual interaction of different physical phenomena”

• Fluid dynamics
• Heat Transfer
• Neutronics
• Chemistry
• Mechanics
• BoP
8
Modelling of an engineering problem

“How do you model a nuclear engineering problem?”

“Which are the steps required to model a nuclear engineering problem?”

9
Modelling of an engineering problem

“Which are the step required to model a nuclear engineering problem?”

1. Physical modelling: choose the proper modelling approach (PDEs)


2. Domain modelling: establish the boundary of the system and create the geometry
(with possible assumptions)
3. Domain + equation discretization: selection of a discretization method (FV, FE, DG,…) +
mesh creation + equation discretization (including selection of boundary and initial
conditions)
4. Solution of (discretized) equations: selection of the method to solve the system of
linear algebraic equations
5. Post-processing: visualization of the results

10
Modelling of an engineering problem

“Which are the step required to model a nuclear engineering problem?”

1. Physical modelling: choose the proper modelling approach (PDEs)


2. Domain modelling: establish the boundary of the system and create the geometry
(with possible assumptions)
3. Domain + equation discretization: selection of a discretization method (FV, FE, DG,…) +
mesh creation + equation discretization (including selection of boundary and initial
conditions)
4. Solution of (discretized) equations: selection of the method to solve the system of
linear algebraic equations
5. Post-processing: visualization of the results

Solver vs Simulation case


11
Modelling of an engineering problem

“Which are the step required to model a nuclear engineering problem?”


1. Physical modelling
2. Domain modelling
3. Domain + equation discretization
4. Solution of (discretized) equations
5. Post-processing

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

Choose the proper modelling


Physical/Mathematical
Physical system approach (Solver) + create
modelling
the Geometry

From a continuous real problem


to a discretized numerical one:
Domain and
equation . Numerical method (FV)
discretization . Spatial discretization (Mesh)
. Initial and Boundary
Conditions
. Linear algebra solver

Results analysis Solve the case! Numerical modelling

Solution of (discretized) equations 13


Modelling of an engineering problem
Example taken from «F. Moukalled, L. Mangani, M. Darwish. The Finite Volume Method in
Computational Fluid Dynamics. Springer, 2016»
Problem: study the heat transfer in a
electronic device where a microprocessor
is connected to a heat sink

14
Modelling of an engineering problem

1. Physical modelling: how do we model


the heat transfer?

−∇ ∙ 𝑘∇𝑇 = 𝑞ሶ

In OF, the physical model is decided by the


solver you are using!

You can find the available solvers in


/OpenFOAM-XXX/applications/solvers/

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

2. Domain modelling: we need to


approximate the real geometry.

This is the first step of the simulation of a


case. To build the geometry, you can use
custom or external utilities/programmes.

A simulation in OF (case) follows a specific


file structure.

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

3. Domain discretization: It is required


since analytical solution of PDE is usually
difficult (impossible to achieve) → we
need an approximation

In OF, the discretization method is the


Finite Volume (FV) method.

Once created the geometry, we need a


mesh on which the PDE is solved.

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

3. Equation discretization: Thanks to the


FVM we transform the PDE in a discretized
form. We need to specify the boundary
conditions, initial conditions plus the
discretization options (aka discretization
schemes)

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

4. Solution of (discretized) equations: The


discretized form is nothing more than a
system of linear algebraic equations.

We need to specify how to solve this


linear system (iterative or direct solvers?)

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

This is an example involving one physics. In


case of a multiphysics system the
mathematical modelling and the numerical
consideration are usually interconnected.

In a multiphysics solver, we need to specify


how do we solve the multiphysics coupling.

In OF, this is usually done with operator-


splitting (one equation at time + fixed point
iteration)

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.

. P is the centroid of the corresponding CV


. N is the centroid of the neighbor CV
. d is the distance from P to N
. f is the control volume face
. Sf is the face area vector pointing outwards
from the control volume, normal to the face
with magnitude equal to the area of the face

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

Gauss (divergence) theorem to


convert the volume integrals into
surface integrals.

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

. ϕ0 is the value at the previous time step (known)


. ϕn is the value at the current time step (unknown)
Taken from Joel Guerrero, Finite Volume Method: A Crash introduction. https://wiki.openfoam.com/Theory_by_Joel_Guerrero
Published under: CC BY-SA license 28
Introduction on FV
Euler explicit (very bad)
. I order accurate
. Possibly unstable
Euler implicit
. I order accurate
. Stable
. Leads to a linear system
Crank Nicholson
. II order accurate
. Stable
. Leads to a linear system

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

“Which are the step required to model a nuclear engineering problem?”


1. Physical modelling → Solver
2. Domain modelling
3. Domain discretization Case
4. Solution of (discretized) equations
5. Post-processing

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

Taken from “Running my first OpenFOAM® case setup blindfold”. http://www.wolfdynamics.com/wiki/tut_cavity.pdf 35


OpenFOAM case
2) Case preparation
. Geometry and Mesh
. Initial and boundary conditions
. Physical models/parameters
. Discretization
. Solver parameters
. Simulation parameters

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

. Info related to the method for


Navier – Stokes equation

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

“Which are the step required to model a nuclear engineering problem?”


1. Physical modelling → Solver
2. Domain modelling
3. Domain discretization Case
4. Solution of (discretized) equations
5. Post-processing

43
OpenFOAM solver
Let’s take a laminar fluid dynamics problem…

Physical modelling = Incompressible Navier – Stokes equations

𝛻∙𝒖=0
ቐ𝜕𝒖
+ 𝒖 ∙ 𝛻 𝒖 = 𝜐𝛻 2 𝒖 − 𝛻𝑝Τ𝜌0 + 𝑭
𝜕𝑡

Which is the structure of an hypotetical OF solver for Incompressible NS?

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"

int main(int argc, char *argv[])


{
#include "setRootCase.H"
#include "createTime.H"
#include "createMesh.H "
pimpleControl pimple(mesh);
#include "createFvOptions.H"
#include "createFields.H "
#include "createMRF.H"
#include "initContinuityErrs.H"
#include "createTimeControls.H"
#include "CourantNo.H"
#include "setInitialDeltaT.H" 45
OpenFOAM solver
solver4NSFoam.C //Main file of the solver

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

volScalarField rAU("rAU", 1.0/UEqn.A());


volVectorField HbyA(constrainHbyA(rAU*UEqn.H(), U, p));
surfaceScalarField phiHbyA
(
"phiHbyA",
fvc::flux(HbyA)
+ fvc::interpolate(rAU)*fvc::ddtCorr(U, phi)
);
while (pimple.correctNonOrthogonal())
{
fvScalarMatrix pEqn
(
fvm::laplacian(rAU, p) == fvc::div(phiHbyA)
);
if (pimple.finalNonOrthogonalIter())
{
phi = phiHbyA - pEqn.flux();
}
}

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)

In OF, this is tackled with segregated pressure-based (predictor-corrector) methods as


SIMPLE, PISO, PIMPLE where:
. 𝒖 ∙ 𝛻 𝒖 ≈ 𝒖𝑖−1 ∙ 𝛻 𝒖𝑖 until convergence
. A derived “pressure” equation is solved, starting from the discretized momentum
equation and substituting it in the continuity equation – here one or more (pressure)
correction may be needed
51
OpenFOAM
PIMPLE is used for unsteady (transient) calculation for better accuracy
when nonlinearity of the convective term is strong

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?

OpenFOAM runs natively on Linux systems…

MAC, or the Linux subsystem for


Windows can be used, but not
recommended

55
First steps with OF

How to get OpenFOAM?

Follow the simple steps on the download


page

(example for OF-9 from the .org version)

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

Learn OpenFOAM - Official documentation


• https://cfd.direct/openfoam/user-guide/ It includes some post-
• https://www.openfoam.com/documentati processing examples
on/user-guide

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

• Tutorials/lectures (have a look on Google or YouTube)


• Master/PhD thesis etc.
• Forums
• (Often) direct communication with solver developers

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

You might also like