Sie sind auf Seite 1von 162

MILONGA

version 0.1
1
a free nuclear reactor core analysis code
German Theler
TECNA S.A.
http://www.tecna.com
Instituto Balseiro
http://www.ib.edu.ar
1
This is a test release aimed at getting some feedback before a preliminary version 0.9, hoping to converge to a rst
serious release 1.0. Read the preface. Any kind of feedback about this version 0.1 will be highly appreciated.
MILONGA
a free nuclear reactor core analysis code
Abstract
Milonga is a free computer code that solves the steady-state multigroup neutron diusion equation
using either a nite-volumes or a nite-dierences scheme. Not only is it designed to cope with common
reactor geometries but also to parametrically study the eect of one or more parameters in order to
optimize some aspect of the reactor design. The code is especially designed emphasizing exibility
in the way the geometry and the cross-sections distributions are entered, including dependence on
arbitrary parameters such as temperatures, burn-up, poisons, etc. This information can be entered
as algebraic expressions, multidimensional interpolated tables or from data given by external codes
trough shared memory objects. Milonga can handle a wide variety of one, two and three-dimensional
cases, from simple idealized problems up to common reactor congurations, including xenon eects
and coupled calculations with thermal-hydraulics and control-logic codes. For example, milonga can
be used to solve a case with analytical solution using its built-in algebraic and dierential functions,
and then easily compare it to the discrete solution along with the corresponding CPU times as a
function of the number of spatial cells. The code output is completely dened by the user through
the input. The eigenvalue problem is solved by the SLEPc+PETSc libraries, so the computational
implementation can be scaled virtually up to the limit of current available hardware, and hopefully for
many years to come. Moreover, not only can milonga utilize user-provided ad-hoc numerical routines,
but it is also released under the GNU Public License so further scalability and improvements may be
introduced at will.
Preface to version 0.1
This document describes version 0.1 of the free nuclear reactor analysis code milonga that is part of
the developments made under my PhD thesis in Nuclear Engineering. In particular, this version of
the code and especially of this document the very rst not-so-public release and is aimed at getting
as much feedback as possible. The objective is to improve the code to get into a version 0.9 that
hopefully should converge into a fully-usable version 1.0 in a nearby future. By not-so-public I mean
that this document was distributed mainly between friends and colleagues. Thus, if you have received
this document directly from memeaning you are a friend of minethen I rmly ask you to say
something back. On the other hand, if you have got this document from other indirect source, you are
kindly encouraged to give your comments back. These may be a linear combination of suggestions,
corrections, bug reports and improvements, in increasing order of desirability.
This version of the code is not entirely complete in the sense that there are some kind of problems it
cannot solve in its present state. Particularly, it does not fully support three dimensional calculations,
mainly because of its lack of management of boundary conditions. Chapter 4 gives a wide variety of
examples that this version can solve. Completion of these capabilities is expected for the next version.
In the same sense, this version of the documentation is neither entirely complete. There are some
sections marked as to be done meaning the code is lacking that particular feature. There are also
some sections containing the text to be explained. In this case, the code is able to perform the task
but it is not documented. This is closely related to the fact that milonga is part of a set of codes that
share a common framework, conforming a suite of engineering codes called wasora that is also part of
my PhD thesis and of course are under development.
I would like to point out here in this preface that milonga is based on the PETSc library to handle
the matrices that are the base of the multigroup diusion problem formulation. This library provides
very ecient methods for creating, accessing and operating matrices. It is especially designed to
work in parallel using MPI. The current version 0.1 of milonga does not take any advantage of
the parallelization facilities provided by PETSc. In fact, this rst version is very computationally
demanding because eciency was not the main focus. Optimization is expected to drive my attention
as of version 1.0.
Finally, I want to say that milongaand indeed the whole wasora suitewas conceived as free
software from scratch. Not only are hacking and distribution under the terms of the GNU General
Public License allowed, but also encouraged. And of course, the kind gesture of giving feedback to
the original author will be highly appreciated.
Buenos Aires, July 2011
Contents
1 Introduction 1
1.1 The wasora suite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Milonga design basis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3 Software license . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2 The equations inside milonga 7
2.1 The neutron diusion equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.1.1 Multigroup formulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.1.2 Finite volumes spatial discretization . . . . . . . . . . . . . . . . . . . . . . . . 14
2.1.3 Finite dierences scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.2 Cell cross-section computation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.3 Boundary conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.3.1 External planar surfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
2.3.2 Cylindrical surfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
2.3.3 Spherical surfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
2.3.4 Mirror conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
2.3.5 Sharp edges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
2.4 The eigenvalue problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
2.4.1 Iterations tolerance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
2.4.2 Flux and power . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
2.5 Xenon poisoning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
3 Input preparation 40
3.1 Input les . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
3.2 Problem denition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
3.3 Zones . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
3.4 Boundary conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
3.5 Materials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
3.6 Collecting results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
3.7 Power and xenon distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
3.8 Numerical scheme settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
3.9 Parametric calculations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
3.10 Debugging and benchmarking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
3.11 Commandline arguments replacement . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
3.12 Advanced eigenvalue solver settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
3.13 External coupling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
3.14 User-dened eigenvalue solver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
3.15 If anything goes wrong . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
milonga v0.1
4 Examples 59
4.1 Cases with analytical solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
4.1.1 Homogeneous bare slab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
4.1.2 Homogenoeus bare square . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
4.1.3 Homogeneous bare circle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
4.1.4 Innite reactor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
4.1.5 Slab with continuously-changing properties . . . . . . . . . . . . . . . . . . . . 75
4.1.6 Two-zone slab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
4.2 General problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
4.2.1 Reected slab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
4.2.2 Reected circle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
4.2.3 IAEA 2D PWR Benchmark . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
4.2.4 Two-dimensional slice of a PHWR . . . . . . . . . . . . . . . . . . . . . . . . . 103
4.3 Parametric problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
4.3.1 Grid size eects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
4.3.2 Discrete boundary conditions eects . . . . . . . . . . . . . . . . . . . . . . . . 117
4.3.3 Circle quadrature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
4.3.4 Control rod cusp problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
4.4 Non-linear problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
4.4.1 Xenon eects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
4.4.2 Criticallity with a control rod . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
4.5 Coupled calculations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
4.5.1 1D core coupled with RELAP . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
5 Installation and execution 142
5.1 Very quick instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
5.2 Quick instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
5.2.1 With root access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
5.2.2 Without root access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
5.3 Detailed installation instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
5.3.1 Obtaining the package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
5.3.2 Required libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
5.3.3 Compiling milonga . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
5.4 Execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
5.5 Syntax highlight . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
Keywords, variables and functions index 155

Chapter I
Introduction
An engineer has to think without doing anything fty percent of the time,
and do without thinking the other fty percent of the time.
And a good engineer knows when to think without doing
and when to do without thinking.
Fabian. J. Bonetto, PhD in Nuclear Engineering
comment to the author during an engineering thesis advisory, 2007
The rst thing that should be said in relation to this code is that it is an academic project part of
a PhD thesis in Nuclear Engineering. This thesis is not about software development, but about its
usage as a design optimization tool. That is to say, milonga is not the goal but the mean. The second
statement is that as such, it is a personal research project written from scratch by someone who works
in the nuclear industry and is not fully dedicated to the academic environment.
Having said these two things, a corollary in the form of a warning is issued: you should not expect
a lot from milonga. In particular, it should not be compared to commercial reactor codes, nor directly
applied to real cases without a deep comprehension of both its design philosophy and the mathematics
behind it.
No propaganda about the convenience of using milonga instead of other codes will be given in this
document because of three reasons. Firstly, if this code does provide some interesting features that
maybe other program does not, its drawbacks far overcome the benets. Secondly, there is no need
to do marketing because there is no commercial interest behind milonga, as it is free software both in
the speech and in the beer senses. The implications are explained in sections 1.2 and 1.3. And last
but not least, there is a problem with the conjunction used in the rst sentence of this paragraph. As
in many other aspects, it is not milonga or other codes, but milonga and other codes.
1.1 The wasora suite
Milonga is part of wasora, which stands for Wanna-be Advanced Suite for Optimization and Reactor
Analysis, that in turn is part of a PhD thesis work. It consists of a general code framework that
provides routines and methods for engineering programs that share a common basis and may work
coupled. In particular it provides input-le keyword parsing routines and an ecient method for pars-
ing and evaluating algebraic expressions. It also includes routines for accessing standard mathematical
functions, interpolation, root nding, integration and dierentiation. Most of the mathematical meth-
ods provided by wasora are implemented by the free GSL library [1]. Access to shared memory objects
and semaphores for data exchange and coupling is also provided, along with text-based output through
les and error handling routines. From the users point of view, this just means that codes built on
top of wasora work in a similar wayfor example their inputs look all alikeand that they share
certain common functionality.
The whole suite is under development but, as the current version of milonga shows, the frame-
work is usable. As of July 2011, the engineering codes that are either under development or under
consideration are:
milonga v0.1
colach a control logic analysis code to quickly design, implement and test control algorithms in the
time domain. Besides regular linear control function such as lags and integrators, matrix-vector
operations, arbitrary transfer functions and fuzzy logic rules can be entered. A real-time version
capable to operate with data acquisition hardware using COMEDI is under consideration.
mochin a dynamical systems solver code to numerically integrate sets of dierential-algebraic initial-
value equations. It uses library IDA from the SUNDIALS suite as a back-end for time-advancing
the set DAEs and the wasora framework for parsing the equations and probably coupling the
code to other processes. Real-time simulation is also possible.
besssugo a graphical-interface code to generate graphical time-dependent representations of the re-
sults obtained with engineering codes, either part of the wasora suite or not. Output may be
real-time graphics in a screen or a series of frames to build a video afterward.
prime a non-linear numerical optimization code. Under consideration.
cingi a multi-point reactor kinetics model solver. Under consideration.
Further information and updates be obtained by accessing
http://ib.cnea.gov.ar/

thelerg/wasora
Of course, milongawhose description is this tiny documentis also part of the suite. A great
deal of milongas functionality directly depends on the routines and methods provided by wasora, so
its documentation should complement this description. Sadly, at the time of writing the present doc-
ument for the rst version of milonga, there is no consistent documentation for the wasora framework
available. Some explanation about the basic usagefrom the users point of viewis given in this
document, but probably there may be some gaps either in the information given here or when trying
to understand some particularities of the code. Hopefully, future releases will contain a complete set
of documentation covering every aspect of both wasora and milonga.
1.2 Milonga design basis
The quote of the beginning of this chapter was told privately to me by Dr. F. J. Bonetto while he
was my BE thesis advisor [2]. Later on, he advised my Masters thesis [3] and he is now
1
one of my
PhD thesis advisors. While years passed by, I have been able to understand the rationale behind
this statement. It is important to note that the implementation of this phrase actually gave rise to
remarkable results all in all. Indeed, the development of milonga is an actual consequence of this
advise. This project has a lot of time spent just in thinking rather than programming and, of course,
the other way round.
Many of milongas features were coded just after wondering what features I wanted commercial
programs to have and how I would have liked to work with canned codes available in the nuclear
industry. Indeed, one of the reasons of the high component of thinking without doing comes from
the fact that working all day long in the nuclear business takes away a lot of time that could be
used in the doing without thinking part. Thus, a clear denition of the design basisin the
algebraic sense of tiny vectors that span an arbitrary huge spacewas done at very early stages of the
development. Actually, milongas design basis that follows was presented at the 2010 Annual Meeting
of the Argentine Nuclear Technology Association [4].
There are four main subspaces in the design basis, each spanned by several vectors, as schematically
illustrated in gure 1.1. The rst subspace is about the kind of problems to solve, the second is about
what kind of features the code should have and should be able to handle, the third is about the expected
results and how to present them to the user and the fourth is about scalability. Event though they
are somehow related to each other, they are discussed separately in the next four paragraphs. The
construction should be able to is deliberately over-used.
1
As of 2011.
:
milonga v0.1
problems
features
results
scalability
Figure 1.1: Design basis vectors, spanning four subspaces
For the code to be of interest, it should be able to solve detailed models of both power and
research nuclear reactors. So this is one of the main vectors to keep in mind: the ability to cope with
mathematical descriptions of real cases, incorporating means to take into account the inuence of each
of the dierent parameters that dene the actual ux distribution that real reactors have. Nevertheless,
milonga is part of a design optimization suite and as such, most of the cases in practice will be
conceptual ideas or very crude simplications of the nal to-be-designed reactor. Thus, simplied
cases in one or two dimensions should also be handled. Besides, because of its academic nature, the
code should also be able to solve cases with analytical solutions to benchmark numerical schemes and
solutions methods. In addition, the parameters to be optimized usually change the set of macroscopic
cross sections in very diverse ways, so a very exible way of providing their dependence on a few to-
be-optimized parameters. The actual approach is discussed in the next subspace, but the important
thing to take into account in this one is that during the optimization, there may be intermediate steps
with parameters that might be inconsistent or either give rise to unphysical sets of cross sections.
Milonga should be able to cope with these situations without crashing catastrophically. And last but
not least, a great deal of the design optimization process is based on parametric studies, i.e. analyzing
how certain gures or functions change with a certain parameter while keeping constant the rest.
Solving this parametric kind of problems should be also a central part of the design basis vectors.
The second subspace spanned by the basis is about exibility. It is the main subject around mi-
longas design andat least in these rsts versionsexibility should have precedence over eciency.
One important part of this subspace is about the way input data is entered. A large amount of
engineering codes still rely on the card concept, that is anachronistic, obfuscated, makes no sense
nowadays and renders the preparation of the problem a complex and time-consuming task without
adding extra value. An input preparation concept based in a parser similar to how compilers translate
a human-readable source code into a binary machine-readable executable should be preferred. Milonga
should read one or more text les containing keywords and arguments that should be parsed and sub-
sequently converted into the proper coecients in the neutron diusion equation. Another aspect of
the exibility that is desired in modern engineering computer codes, and in the same direction as that
of the parametric vector, is that the reactor geometry and the parameters spatial distribution should
be dened independently from the particular spatial nodalization chosen to discretize the diusion
problem. The spatial distribution of cross sections that nally characterize the problem to be solved
should be viewed as continuous multidimensional functions with an arbitrary dependence on other
parameters, such as temperature or burn-up distributions that, in turn, are also viewed as continuous
spatial distributions. To handle varying parameters, milonga should be able to deal with auxiliary
variables, vectors and multidimensional functions, to operate by applying algebraic or dierential op-
erators to them, and to use these results to evaluate either the geometry denition or cross sections
distributions. The basic results computed by the code should also be prone to further mathematical
manipulation to show only what the user requests, trying to minimize or avoid the necessity of exter-
nal data processing. One big deal of the degree of exibility of this kind of computational code is the

milonga v0.1
set of possible sources for the information that fully dene the problem (i.e. geometry, including the
position of the control rods, temperatures, burn-up and poisons distributions). They might be given
as point-wise dened functions or as algebraic expressions. From step to step, either the independent
(the parameters themselves) or the dependent (their locations) values may change. And of course,
even both. They might be entered in the input, read from local or remote text les or exchanged with
other engineering codes using some ecient coupling mechanism.
Back when input data was entered by making holes in a card, T-Rexes ruled the continent and
calculation times were measured in weeks, computer simulation codes had to give as much output
as possible to reduce costs. In the engineering departments, it was preferred to have a large number
of sheets with a lot of tiny scientic-notation matrix-dot printed numbers stored in cabinets and
shelves for eventual consultation, than to have to re-run simulations each time a particular result
was needed. This is no longer true, especially for engineering design calculations. Nowadays, the
activity of browsing through old-fashioned huge text les looking for a needle or having to convert
and process numerical data to feed graphical plotters or post-processing tools is usually far more
time consuming that the execution of the actual simulations. Moreover, as computational capacity
has grown exponentially over the last yearsand of course it is expected to continue increasing
more and more detailed models are being utilized, and therefore more and more information can
be computed. If all the results are written to the outputconsider transient cases of several days
of operation for examplethe simulation turns into an inecient process in terms of data storage
and retrieval. Milonga should be as exible as possible in terms of what its output is. First, no
unwanted information should be obtained. Second, output post-processing and further treatment is
to be reduced or even avoided. And third, means to easily compare resultseither with the same
calculation method but with dierent parameters or with the same parameters but with dierent
methodsshould be taken into account in the design. Not only should the actual output routines
comply with the basis discussed in this paragraph, but also the whole code structure has to provide
the needed exibility to present to the user the proper output information.
Finally, a very important subset of the design basis is that of scalability. This concept basically
means that the code should be able to run eciently not only in what are considered current scientic
computing standard architectures, but also to be smoothly adaptable and take advantage of future im-
provements in hardware development without the necessity to be rewritten from scratch. In particular,
the eciency of an engineering code is directly related to the numerical methods routines. In milonga,
any relevant numerical calculation should be implemented by using existing software libraries as, for
sure, mathematicians and computer science professionals write better numerical methods routines
than I do. Moreover, relying on well-known state-of-the-art numerical libraries guarantees scalability,
at least up to the same level the library scales. Also, scalability is closed related to portability, as
this feature increases the chances that the code could be compiled in whatever architecture is going
to be considered standard for scientic computing in a reasonable software lifetime (a decade or so).
This can only be achieved on the one hand by sticking to reliable programming standards as much as
possible and, on the other hand, delegating non-specic tasks to available libraries that also incorpo-
rate portability and scalability in their design basis. In addition, being an academic project, it would
be desirable to have a platform where to test new numerical methods or to compare performances.
Therefore, a straightforward way of incorporating user-coded numerical methods should be provided.
Usually, engineering codes claim to be modular in nature, easily allowing the incorporation of new
features. But, more often than not, the truth is that they are not modular in the sense of dynamically-
loaded modules that extend the functionality of a certain computer programas for example Linux
kernel modules dobut the modularity comes from the use of so-called Fortran modules. This partic-
ularity does not provide the expected benets of a modular designas the Linux kernel doesand,
moreover, the overall coding scheme is prone to obfuscation. Also, the same functionality can be
implemented in a cleaner way using other data structures and languages like C instead of Fortran, so
modularity is not part of milongas design basis. To help milonga to survive to changes in computing
paradigms and to scale its power along future hardware availability, its source code should be freely
available for anyone to be able to modify it as desired, including changes due to exibility, eciency,
portability and scalability. Of course, being milonga free software, it can only depend on free libraries,
that may themselves be modied to enhance exibility, eciency, portability and scalability, closing
i
milonga v0.1
a positive feedback loop where everyone benets from the freedom that free software provides.
1.3 Software license
Living in a country that should be ashamedamongst other thingsabout its software piracy rate [5],
it seems appropriate at this point to clearly state the license under which the code is distributed. To
know what kind of rights you are entitled to is as important as to know how to use the software.
Milonga is free softwareboth as in free speech and as in free beer, although the rst meaning
is far more important than the second oneand is distributed under the terms of the GNU General
Public License version 3 [6]. In words of the Free Software Foundation,
Nobody should be restricted by the software they use. There are four freedoms that every
user should have:
1. the freedom to use the software for any purpose,
2. the freedom to change the software to suit your needs,
3. the freedom to share the software with your friends and neighbors, and
4. the freedom to share the changes you make.
When a program oers users all of these freedoms, we call it free software.
Developers who write software can release it under the terms of the GNU GPL. When they
do, it will be free software and stay free software, no matter who changes or distributes
the program. We call this copyleft: the software is copyrighted, but instead of using those
rights to restrict users like proprietary software does, we use them to ensure that every
user has freedom.
Not only does milonga provide all the four basic freedoms to the software user, but also encourages
her to study, understand, analyze and hack it. And of course, to share under the terms of the GNU
GPLespecially with milongas original authorher discoveries, suggestions, improvements and xed
bugs. To sum up:
Milonga is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Milonga is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with wasora. If not, see http://www.gnu.org/licenses/.
Milonga relies on a few libraries, all of them available also under dierent free licenses:
PETSc (http://www.mcs.anl.gov/petsc), released freely under the copyright of Univer-
sity of Chicago
SLEPc (http://www.grycap.upv.es/slepc), released freely under the GNU Lesser Gen-
eral Public License v3
GSL (http://www.gnu.org/software/gsl), released freely under the GNU General Pub-
lic License v3
j
milonga v0.1
Cubature (http://ab-initio.mit.edu/wiki/index.php/Cubature), released under
the GNU General Public License v2 or later
These libraries may depend on other free libraries themselves. Check the associated documentation
for more information.
Bibliography
[1] M. Galassi et. al. GNU Scientic Library Reference Manual. Third edition, 2009. ISBN 0954612078,
http://www.gnu.org/software/gsl.
[2] G. Theler. Controladores basados en logica difusa y loops de conveccion natural caoticos. Bachelors
thesis in Nuclear Engineering, Instituto Balseiro, Bariloche, Argentina, 2007.
[3] G. Theler. Analisis no lineal de inestabilidades en el problema acoplado termohidraulico-
neutr onico. Masterss thesis in Nuclear Engineering, Instituto Balseiro, Bariloche, Argentina,
2008.
[4] G. Theler, A. Clausse, and F. J. Bonetto. Optimizacion de parametros en reactores de potencia:
base de dise no del codigo neutronico milonga. In Actas de la XXXVII Reunion Anual de la
Asociacion Argentina de Tecnologa Nuclear, 2010.
[5] BSA, IDC, and Ipsos. Eight Annual BSA Global Software 2010 Piracy Study. Technical report,
Bussines Software Alliance, May 2011.
[6] GNU General Public License version 3. http://www.gnu.org/licenses.
6
Chapter II
The equations inside milonga
I am not scared by this complicated scattering
kernel integral, but by the tiny divergence term.
Javier Fernandez, PhD in Mathematics,
after his rst looking at the diusion equation, 2006
Milonga is a computer code that essentially solves a certain mathematical equation whose solution,
in some way, can be useful from an engineering point of view. Needless to say, the code is by no
means immune to the garbage in-garbage out concept. Therefore, for the results to be of real interest,
the user should be aware of the mathematics that milonga is based on, and ought not to execute
the code as a black box. Moreover, the input allows certain options that can be only understood by
knowing what equations milonga solves and what models and simplications are implied within them.
And last but not least, the uncertainties and errors introduced by the discretization of a continuous
equation into the nite number of unknowns depend on how the input continuous parameters are also
condensed into a nite set. All these features are thoroughly explained in this chapter and thus, it is
of central importance for the practical usage of the software.
Milonga is a neutron diusion code, i.e. it solves the steady-stateat least in this versionneutron
diusion equation. This means that its results cannot be more accurate than the diusion equation
itself, that is already an approximation to the neutron transport problemwhich might be thought
of as another simplication of the physical problem also. Indeed, gure 2.1 shows one of the many
conceptual paths that could be taken to go from the actual real situation to the results obtained by
using a digital computer to solve the problem. Each rectangle is a source of uncertainties that should
be taken into account, and whose magnitude the user ought to be able to quantify when executing
the last step shown in the diagram.
Whenever an approximation is introduced in the development, an exclamation mark as the one
shown in the left margin will appear.
This chapter focuses on the particular mathematical steps that milonga takes to go from the
continuous diusion equation up to the numerical solution of the eigenvalue problem, specically the
three rectangles shaded in gure 2.1. Naturally, corrections, suggestions and improvements are more
than welcome. Indeed, the usual $2.56 reward for each bug found [1] can also be discussed.
2.1 The neutron diusion equation
The derivation of the diusion equation from the neutron transport theory can be found in the
nuclear reactor theory literature. Classical books that treat the subject paying special attention to
mathematical steps include [2] and [3], while other are based on a physical background like [4] and [5].
A modern approach is given in [6]. Reference [7, section 5-3 page 129] gives explicitly the conditions
where the diusion approximation holds which, of course, should be met for milonga to be useful. It
milonga v0.1
plant physics reactor physics nuclear properties
neutron transport
theory
multigroup
formulation
spatial
discretization
numerical
solution
interpretation
of results
mathematical
models
experimental
microscopic XS
condensation &
homogeneization
diusion
theory
Figure 2.1: One of the many possible paths that connect the physical problem with the results obtained
in a computer. This chapter focuses just in the route that goes from the diusion equation up toand
includingits numerical solution.
is assumed that the user thoroughly understands the physics behind Ficks law and what the diusion
equation implies.
The main goal is to solve the associated critical reactor neutron diusion equation with ssion
sources, namely
0 = div

1(r. 1. {) grad

(r. 1)



t
(r. 1. {) (r. 1)
+

s
(r. 1

1. {) (r. 1

) d1

+ (1)

f
(r. 1

. {)
/
e
(r. 1

) d1

(2.1)
for the steady-state ux distribution (r. 1) and the eective multiplication factor /
e
over a : + 1-
dimensional phase space with spatial coordinates r R
m
and one energy component 1, as depicted
in gure 2.2. The divergence and gradient operators are applied only to the spatial coordinates,
and thus boundary conditionseither Dirichlet, Neumann or mixedare needed only in the spatial
domain boundary. 1(r. 1. {),
t
(r. 1. {) and
f
(r. 1. {) are the diusion coecient, total and
-ssion macroscopic cross sections at the spatial position r for neutrons of energy 1. They can
also depend on arbitrary parameters { that are further discussed below. The scattering kernel is
such that
s
(r. 1 1

) d1 d1

gives the macroscopic cross-section in r for a scattering collision of


a neutron that changes its energy from 1 + d1 to 1

+ d1

. Equation (2.1) assumes that there is


only one ssile isotopeor equivalently, that all the ssile isotopes produce ssion neutrons with the
same energy distribution, that is indeed the most common situation. The ssion spectrum gives the
probability (1) d1 for a ssion neutron to be born with an energy between 1 and 1 + d1. For
simplicity, this chapter assumes there is a single common ssion spectrum.
8
milonga v0.1
Figure 2.2: Four-dimensional phase space where the solution of the diusion equation is sought for. Three
coordinates correspond to a spatial domain and the other one corresponds to neutron energy.
The typical problem to be tackled by milonga is a three-dimensional reected nuclear reactor core,
including its reactivity control mechanisms and possibly taking into account the eects of temperature,
density and poison spatial distributions as depicted in gure 2.3. These distributions can be entered
by means of multidimensional tables, algebraic expressions or read from shared memory objects (i.e.
computed by other codes coupled to milonga). By using either interpolation or algebraic parsing tech-
niques, the parameters and thus the nuclear cross sections can be evaluatedand of course integrated
and dierentiatedat any point in space as desired.
If the macroscopic nuclear parameters 1,
t
,
s
and
f
are known functions of the space and
the energy only, then equation (2.1) is linear. However, in all practical cases the nuclear properties
of the materials depend on other arbitrary parameters { that may themselves depend either on the
actual ux at a particular point of the phase space such as fuel, coolant or moderator temperature,
neutronic poison concentration, etc. In this case, equation (2.1) is nonlinear.
Moreover, even though the dependence of the macroscopic cross sections on these parameters can
be known a priori, the calculation of the actual value of the parameters is out of milongas scope
and should be handled by thermal-hydraulic or control system engineering codes. Nevertheless, this
arbitrary dependence can implemented by means of successive coupled calculations until an certain
ux distribution

(r. 1) is obtained such that the corresponding parameters {

give rise to the same


ux

(r. 1) when inserted back into equation (2.1)

(r. 1) {

(r. 1) (2.2)
For example, consider the case of a reactor calculation involving the eects of xenon poisoning.
The vector of nuclear parameters N at position r depend on the
135
Xe concentration at r, that depends
on the local neutron ux at r that of course depends on the nuclear parameters at r. To solve this
nonlinear problem, rst guess an initial xenon concentration A
0
(r)which may be identically zero.
Now evaluate the nuclear parameters N(r. 1), obtain a ux distribution
1
(r. 1) and compute again
the associated equilibrium xenon concentration A
1
(r). Use this distribution to evaluate new nuclear
parameters, calculate the ux and so on.
In some way, a mapping is dened such that at step n + 1 one has

n+1
= F(
n
) (2.3)
and the actual solution to the non-linear problem is obtained whenever this mapping has an stable
xed point that attracts nearby phase-space solutions, as assumed in equation (2.2). The xed point
is obtained when

n+1
=
n
(2.4)
The fact that there exists a xed point and that it is stable depends on F(), whose behavior
is quite dicult to analyze. However, under normal circumstancesi.e. usual dependence of cross
sections with parametersthere is an stable xed point that is the actual solution to the non-linear
problem.
o
milonga v0.1
control rods
core
reector
Figure 2.3: Typical problem to be tackled with milonga. The core and reector may have dierent temper-
atures, void fractions, poisons, burn-up distribution, etc. These parameters can be computed by other codes
coupled to milonga or they can be given from the input as multidimensional tables, algebraic expressions or
a combination of all of them. As a result, all the parameters are continuous functions that can be evaluated
at any point in space.
In this example case, {

was related to the equilibrium xenon concentration, but the same idea
holds for other parameters such as temperature and density distributions, boron concentration, etc.
Note that these distributions are outside milongas scope so in order to take these eects into account
a coupled calculation between the reactor and other codes is needed.
For a denite step n of this iterative procedure with xed parameters, the explicit dependence on {
may be dropped and thought of as implicit in the dependence of the cross sections on the position r
and the diusion equation may be written as
0 = div

1(r. 1) grad

(r. 1)



t
(r. 1) (r. 1)
+

s
(r. 1

1) (r. 1

) d1

+ (1)

f
(r. 1

)
/
e
(r. 1

) d1

(2.5)
that is a linear and homogeneous integro-dierential equation.
2.1.1 Multigroup formulation
The diusion equation (2.1) spans several orders of magnitude in energytypically from 10
2
up to
10
6
eVwith the macroscopic cross sections varying greatly and abruptly also by dierent orders be-
cause of nuclear resonances. To handle this, milonga works with the common multi-group formulation
of the diusion problem [4] which is introduced in this section.
The continuous energy dependence of both the neutron ux and the nuclear parameters can be
transformed into a set of equations describing the average behavior of the neutrons inside nite
intervals of energy by using the following approach. The continuous energy domain is divided into G
groups with cut-o values 0 = 1
G
< 1
G1
< < 1
1
< 1
0
not necessarily equally-spaced, as
depicted in gure 2.4. Energy 1
0
should be greater than the energy of the fastest expected neutron.
Energy group o is dened as the interval [1
g
. 1
g1
].
The ux in group o N G is dened as
1o
milonga v0.1
Figure 2.4: Partition of the energy range 0 < E < E
0
into G discrete groups

g
(r) = (r. o) =

E
g1
E
g
(r. 1) d1 (2.6)
To avoid an excessive use of sub-indexes, the notation (r. o) will be preferred. In the analysis that
follows, functions of the integer index o are group values. Note that the ux in group o is an integrated
ux, while the continuous ux (r. 1) is a density in energy. The former has units of inverse squared
length and inverse time (commonly cm
2
s
1
) while the latter has units of inverse squared length,
inverse time and inverse energy (i.e. cm
2
s
1
eV
1
).
The multi-group formulation seeks to obtain G equations for the group uxes. Integrating equa-
tion (2.5) with respect to energy between 1
g
and 1
g1
it is
0 =

E
g1
E
g
div

1(r. 1) grad

(r. 1)


d1

E
g1
E
g

t
(r. 1) (r. 1) d1
+

E
g1
E
g

s
(r. 1

1) (r. 1

) d1

d1
+

E
g1
E
g
(1)

f
(r. 1

)
/
e
(r. 1

) d1

d1
Now, it is desired to express each term as a product of a group-mean parameter times a group
ux. Starting with the total removal termwhich is the easiest oneone would like to write

E
g1
E
g

t
(r. 1) (r. 1) d1 =
t
(r. o) (r. o)
so the mean total cross section in group o should be dened as

t
(r. o) =

E
g1
E
g

t
(r. 1) (r. 1) d1

E
g1
E
g
(r. 1) d1
(2.7)
Of course, if the mean group cross section depends on the ux itself, then the proposed integration
operation is of no help at all. However, lattice codes are able to obtain reasonable nuclear parameters
for the multi-group formulation by assuming certain energy distributions for the neutron ux. Indeed,
if the ux is assumed to be constant for the whole energy interval the total cross section is just the
traditional mean value

t
(r. o) =

E
g1
E
g

t
(r. 1) d1
1
g1
1
g
(2.8)
From milongas point of view, the value of the macroscopic absorption cross section is a known
function of the spatial coordinates and eventually of other parameters than can be evaluated before
solving the diusion equation, at least for each step of the non-linear iteration (2.3). Whether the
lattice code utilized to generate the macroscopic cross sections uses equation (2.7) with a certain
approximation for (r. 1), equation (2.8) or even another approach, does not depend on milonga.
The user should know that the code expects a total macroscopic cross section whose meaning should
be compatible with the denition given by equation (2.7).
11
milonga v0.1
The scattering term can be written as

E
g1
E
g

s
(r. 1

1) (r. 1

) d1

d1 =

E
g1
E
g
G

=1

E
g

1
E
g

s
(r. 1

1) (r. 1

) d1

d1 =
G

=1

E
g1
E
g

E
g

1
E
g

s
(r. 1

1) (r. 1

) d1

d1 =
G

=1

s
(r. o

o) (r. o)
As the energies 1
g
are arbitrary, for this equality to hold the individual terms should be equal.
Thus the scattering cross section from group o

to group o is

s
(r. o

o) =

E
g1
E
g

E
g

1
E
g

s
(r. 1

1) (r. 1

) d1

d1

E
g1
E
g
(r. 1) d1
(2.9)
Again, these G
2
parameters are treated as known values prior to the solution of the diusion
equation.
The ssion term can be written as

E
g1
E
g
(1)

f
(r. 1

)
/
e
(r. 1

) d1

d1 =

E
g1
E
g
(1)
G

=1

E
g

1
E
g

f
(r. 1

)
/
e
(r. 1

) d1

d1 =

E
g1
E
g
(1) d1
G

=1

E
g

1
E
g

f
(r. 1

)
/
e
(r. 1

) d1

= (o)
G

=1

f
(r. o

)
/
e
(r. o

)
where the ssion spectrum of group o is
(o) =

E
g1
E
g
(1) d1 (2.10)
and the mean -ssion cross section is

f
(r. o) =

E
g1
E
g

f
(r. 1) (r. 1

) d1

E
g1
E
g
(r. 1) d1
(2.11)
Note that the ssion spectrum has to be normalized such that


0
(1) d1 = 1
and thus
G

g=1
(o) = 1 (2.12)
1:
milonga v0.1
Finally, the leakage termwhich is the trickiesthas to be written as

E
g1
E
g
div

1(r. 1) grad

(r. 1)


d1 = div

1(r. o) grad

(r. o)


(2.13)
In general this equation does not have an exact solution for the multigroup diusion coecient.
However, one workaround is to assume that the ux can be separated into energy and position
(r. 1) = (r) (1)
so that

E
g1
E
g
div

1(r. 1) grad

(r)(1)


d1 = div

1(r. o) grad

(r. o)


div

E
g1
E
g
1(r. 1) (1) grad

(r)

d1

= div

1(r. o) grad

E
g1
E
g
(r)(1) d1

div

E
g1
E
g
1(r. 1) (1) d1 grad

(r)

= div

1(r. o) grad

(r)

E
g1
E
g
(1) d1

and thus the diusion coecient for the group o can be computed as
1(r. o) =

E
g1
E
g
1(r. 1) (1) d1

E
g1
E
g
(1) d1
Another approach may be to calculate the mean transport cross section for the group o with
the same weighting procedure used in the total cross section (equation (2.7)) and then compute the
diusion coecient from its denition
1(r. o) =
1
3
tr
(r. o)
=
1
3

E
g1
E
g
(r. 1) d1

E
g1
E
g

tr
(r. 1) (r. 1) d1
Once again, milonga expects the multigroup parameters as known distributions of space and even-
tually other parameters such as temperatures, densities, burn-up and/or poisons, which themselves
depend on the position. So the multigroup parameters, from milongas point of view, are essentially
known continuous functions of the position r. It is the users responsibility to generate them from a
lattice code or whatever other applicable source consistently with the expected usage shown in this
section.
Collecting these results, the continuous diusion equation (2.5) can be discretized in energy as G
coupled dierential equations in the spatial coordinates for the group neutron uxes (r. o)
0 = div

1(r. o) grad

(r. o)



t
(r. o) (r. o)
+
G

=1

s
(r. o

o) (r. o

) + (o)
G

=1

f
(r. o

)
/
e
(r. o

) (2.14)
1
milonga v0.1
Provided the nuclear parameters are computed from the denitions (2.7), (2.9), (2.10), (2.11)
and (2.13), equation (2.14) is exact and the only loss produced during the energy discretization process
is the detailed dependence of the ux on 1 inside each group. Any approximation done during the
generation of the multi-group macroscopic parameters will induce dierences between the continuous
linear energy diusion equation (2.5) and the energy-discretized equation (2.14).
2.1.2 Finite volumes spatial discretization
To solve a partial dierential equation in a digital computer, a certain discretization of the spatial
coordinates ought to be done. As one of milongas design goals is research and development, the code
has several dierent approaches to the subject, mainly for comparison and academic reasons. The code
is mainly based on a nite volumes scheme as these kind of methods are best suitable for conservation
problems than nite dierences or nite elements are. Nonetheless, some nite dierences schemes
recipes are also provided by milonga that are introduced in section 2.1.3.
The basis of the nite volumes spatial discretization is the division of the domain into adjacent
cells, as depicted in gure 2.5. In principle, cells can be arbitrary, but to x ideas rectangular and
uniform cells are going to be considered for the moment being, as shown in gure 2.6. The ux of the
group o N < G in cell i N < is dened as

i
g
= (i. o) =

V
i
(r. o) d
m
r

V
i
d
m
r
(2.15)
where

V
i
is to be understood as the integral over the volume of the i-th cell and d
m
r represents the
volume dierential of the spatial coordinates in R
m
. For : = 1. 2. 3 (gures 2.6a, 2.6b and 2.6c) the
uniform volume \
i
of the i-th cell is equal to r, rn and rn. respectively.
Figure 2.5: Discretization of a two-dimensional spatial domain into a nite number of cells.
Again, the notation (i. o) over
i
g
will be preferred to avoid the excessive use of sub-indexes. The
ux of group o in cell i is a scalar number, not a function. The set of the uxes (i. o) for i = 1. . . . .
and for o = 1. . . . . G is the numerical solution of the diusion problem sought for. Note that (i. o) is
the mean value of the continuous ux (r. o) over the i-th cell and thus (i. o) and (r. o) have the
same unitsas opposed to what happens between (r. 1) and (r. o) given by equation (2.6)namely,
inverse squared length and inverse time.
1i
milonga v0.1
(a) 1D (b) 2D (c) 3D
Figure 2.6: Discrete cells for one, two and three-dimensional spatial domains
It should be remarked again that the mean ux (i. o) that will be the solution to the problem is
the mean value of the continuous ux distribution over the cell, and not the value of the ux evaluated
at the cell center
(i. o) =

V
i
(r. o) d
m
r

V
i
d
m
r
= (r
i
. o)
although they are equal in the order of r
2
, so the following approximation may be taken
(i. o) (r
i
. o) (2.16)
throughout the mathematical development that follows.
The multigroup diusion equation (2.14) is now integrated throughout the volume of cell i
0 =

V
i
div

1(r. o) grad

(r. o)


d
m
r

V
i

t
(r. o) (r. o) d
m
r
+

V
i
G

=1

s
(r. o

o) (r. o

) d
m
r +

V
i
(o)
G

=1

f
(r. o

)
/
e
(r. o

) d
m
r
and each term is analyzed separately. First, the term of the total interactions should be equal to the
product of the mean total cross section, the mean ux and the cell volume

V
i

t
(r. o) (r. o) d
m
r =
t
(i. o) (i. o)

V
i
d
m
r
so the mean cross section associated to cell i for total neutron interaction is

t
(i. o) =

V
i

t
(r. o) (r. o) d
m
r

V
i
(r. o) d
m
r
(2.17)
Now, this parameter is not an input to milonga but should rather be computed from the continuous
total cross section for group o spatial dependance
s
(r. o), that is the actual input to the code. The
total cross section may depend on r because of materials interfaces and also because of potential
property changes such as temperatures throughout a single material. As the continuous ux (r. o)
is not known, some approximation ought to be done. Milonga provides a few dierent methods for
computing the integral in equation (2.17) avoiding direct references to the ux (r. o). These methods
1j
milonga v0.1
are discussed in section 2.2, and give rise to dierent expressions for the numerical mean cross sections
that should be taken into account when analyzing results. The rest of this section explicitly develops
the form of the discrete form of the diusion equation and gives the equations that should be satised
by the mean cell cross sections in order for the discretization to be a faithful representation of the
continuous equation.
The integrated scattering term is

V
i
G

=1

s
(r. o

o) (r. o

) d
m
r =
G

=1

V
i

s
(r. o

o) (r. o

) d
m
r =
G

=1

s
(i. o

o) (i. o

V
i
d
m
r
and the mean scattering cross section from group o

to group o for cell i is

s
(i. o

o) =

V
i

s
(r. o

o) (r. o

) d
m
r

V
i
(r. o

) d
m
r
(2.18)
Similarly, the ssion term should be

V
i
(o)
G

=1

f
(r. o

)
/
e
(r. o

) d
m
r =
(o)
/
e
G

=1

V
i

f
(r. o

) (r. o

) d
m
r =
(o)
/
e
G

=1

f
(i. o

) (i. o

V
i
d
m
r
Therefore

f
(i. o) =

V
i

f
(r. o) (r. o) d
m
r

V
i
(r. o) d
m
r
(2.19)
The only term remaining is the net leakage out of the cell. It is in the spatial discretization of this
term that the fun of the neutron diusion problem pops up, so it is analyzed thoroughly for one, two
and three dimensions. An alternative approach based on the nite dierences method is introduced
in section 2.1.3.
One dimension
Consider a one-dimensional problem consisting of a slab of length o spanning the interval [0. o] in
the r direction surrounded by vacuum. The interval is divided into cells of equal length, such
that the i-th cell spans the interval [r
i1
. r
i
], as depicted in gure 2.7. To simplify the notation,
the neutron ux will be referred to as (i) without any particular indication of the energy group.
The spatial discretization is the same for all the groups. Integer values of arguments indicate the
value of the mean ux in the cell (crosses) and half-integer arguments indicate uxes evaluated at cell
boundaries (squares). The rst are the values computed by milonga and the latter are estimated from
the former.
The integrated leakage term in one dimension is
16
milonga v0.1
Figure 2.7: Spatial discretization of a one-dimensional domain. The uxes with integer indexes (crosses)
are the solution sought for, while the uxes with half-integer arguments (squares) are estimations from the
integer-indexes uxes.
Figure 2.8: Estimation of the neutron ux (i +1/2) at the cell boundary (square) from the mean cell uxes
(i) and (i +1). (crosses). There may be a material discontinuity at the boundary x = x
i
, so (i +1/2) may
not be equal to the average of the cell uxes.

V
i
div

1(r) grad

(r)


dr =

x
i
x
i1

1(r)
(r)
r

dr
=

1(r)
(r)
r

x
i
x
i1
= 1(r
i
)

r

x=x
i
1(r
i1
)

r

x=x
i1
(2.20)
It may happen that neither 1(r) nor r are dened at the cell boundary if a material interface
exists at r = r
i
. However, the product 1(r) r is always well-dened, as it represents the net
neutron current at r. Moreover, the continuity of the current implies that
lim
0
+
1(r
i
c)

r

x
i

= lim
0
+
1(r
i
+ c)

r

x
i
+
(2.21)
The ux (i +12) at the boundary between cells i and i +1 is dened so that a discrete rst-order
version of equation (2.21) holds
1(r
i
c)
(i + 12) (i)
1
2
r
= 1(r
i
+ c)
(i + 1) (i + 12)
1
2
r
for some 0 < c <r. The ux (i + 12) as a function of the uxes in cells i and i + 1 is therefore
1
milonga v0.1
(i + 12) =
1(r
i
c) (i) + 1(r
i
+ c) (i + 1)
1(r
i
c) + 1(r
i
+ c)
(2.22)
Note that if 1(r) is continuous, the intermediate uxes in equation (2.22) are
(i + 12) =
1
2

(i) + (i + 1)

The current 1(r) r at r


i
can thus be approximated as
lim
0
+
1(r
i
c)
(r
i
c)
r

1(r
i
c)

(i + 12) (i)
1
2
r

=
1(r
i
c)
2
r

1(r
i
c)
1(r
i
c) + 1(r
i
+ c)
1

(i) +
1(r
i
+ c)
1(r
i
c) + 1(r
i
+ c)
(i + 1)

(2.23)
Conversely, the current at r
i
from the point of view of cell i + 1 can be written as
lim
0
+
1(r
i
+ c)

r

x
i
+

1(r
i
+ c)

(i + 1) (i + 12)
1
2
r

=
1(r
i
+ c)
2
r

1
1(r
i
+ c)
1(r
i
c) + 1(r
i
+ c)

(i + 1)
1(r
i
c)
1(r
i
c) + 1(r
i
+ c)
(i)

(2.24)
Note again that if 1(r) is continuous, the current at r
i
is
1(r
i
)
(i + 1) (i)
r
Equation (2.24) can be used to evaluate the current at i 12 from the point of view of cell i by
replacing i by i 1
lim
0
+
1(r
i1
+ c)

r

x
i1
+

1(r
i1
+ c)

(i) (i 12)
1
2
r

=
1(r
i1
+ c)
2
r

1
1(r
i1
+ c)
1(r
i1
c) + 1(r
i1
+ c)

(i)
1(r
i1
c)
1(r
i1
c) + 1(r
i1
+ c)
(i 1)

(2.25)
Taking into account equations (2.23) and (2.25), the integrated leakage term of equation (2.20)
can be approximated as
1(r
i
)

r

x=x
i
1(r
i1
)

r

x=x
i1

21(r
i
c)
r

1(r
i
c)
1(r
i
c) + 1(r
i
+ c)
1

(i) +
1(r
i
+ c)
1(r
i
c) + 1(r
i
+ c)
(i + 1)

21(r
i1
+ c)
r

1
1(r
i1
+ c)
1(r
i1
c) + 1(r
i1
+ c)

(i)
1(r
i1
c)
1(r
i1
c) + 1(r
i1
+ c)
(i 1)

18
milonga v0.1
which can be cleanly rewritten in terms of the cell uxes at i and its two rst neighbors

x
i
x
i1

1(r)
(r)
r

dr = C

i
(i 1) + C
i
(i) + C
+
i
(i + 1) (2.26)
with
C
i
=
2
r

1(r
i1
c) 1(r
i1
+ c)
1(r
i1
c) + 1(r
i1
+ c)
+
1(r
i
c) 1(r
i
+ c)
1(r
i
c) + 1(r
i
+ c)

i
=
2
r
1(r
i1
c) 1(r
i1
+ c)
1(r
i1
c) + 1(r
i1
+ c)
C
+
i
=
2
r
1(r
i
c) 1(r
i
+ c)
1(r
i
c) + 1(r
i
+ c)
(2.27)
This set of coecients gives good results either for cases with 1(r) varying smoothly with r or
for discontinuities located exactly at cell boundaries. When there are material interfaces that do not
coincide with the spatial discretization, equations (2.27) give rise to poor estimations. This is because
if 1(r) is continuous at r = r
i
, then the intermediate ux (i + 12) according to equation (2.22)
is always the average of (i) and (i + 1) and thus the current given by equation (2.23) does not
depend explicitly on the actual position of the interface, but indirectly via the way of computing the
cell-averaged macroscopic cross sections, which is physically incorrect or at least inaccurate.
One way of avoiding these unphysical results is to use average values over each half of the cells for
the diusion coecients
'1(r
i
c)` =

x
i
x
i

1
2
x
1(r) dr
1
2
r
'1(r
i
+ c)` =

x
i
+
1
2
x
x
i
1(r) dr
1
2
r
instead of the actual values 1(r
i
c) and 1(r
i
+ c), as illustrated in gures 2.9. This way, the
current depends continuously on the material interface position and the solutionsfor example the
multiplication factor /
e
also depend continuously on this position. Whether 1(r
i
c) or '1(r
i
c)`
should be used depends on the particular problem being solved.
Note nally that if the diusion coecient is homogeneous in the whole domain, i.e. 1(r) = 1,
the coecients C (either using 1 or '1`) are
C
i
=
21
r
C

i
=
1
r
C
+
i
=
1
r
and the integrated leakage term of equation (2.26) is reduced to
1o
milonga v0.1
(a) (b)
Figure 2.9: Dierence between the computation of D(x
i
) and

D(x
i
).
Figure 2.10: Two-dimensional spatial discretization. For each energy group, uxes are computed at two
integer indexes (crosses) and estimated when one index is half-integer (squares).

x
i
x
i1

1
(r)
r

dr
1
r

(i 1) 2 (i) + (i + 1)

which is the 3-point stencil for the 1 times the ux Laplacian multiplied by the cell volume r.
Two dimensions
Consider now a two-dimensional case, where the spatial domain is divided uniformly into rectangular
cells of length r and height n, as in gure 2.6b. Each cell can be uniquely dened by means of two
integer indexes i
x
and i
y
, such that the i-th cell (also referred to as the i
x
-i
y
cell) spans the geometric
place r
i
x
1
< r < r
i
x
and n
i
y
1
< n < n
i
y
(gure 2.10). The leakage term for this cell is

V
i
div

1(r. n) grad (r. n)

d
2
r
that can be rewritten using the divergence theorem as a surface integral

V
i

1(r. n) grad (r. n)

n(r. n) d (\
i
)
:o
milonga v0.1
where \
i
is the i-th cell boundary and n(r. n) is the unitary outward vector normal to the boundary
at r = (r. n) \
i
. For the cell in gure 2.10, it is

V
i

1(r) grad (r)

n(r) d (\
i
) = +

y
i
y
y
i
y
1
1(r
i
x
. n)

r
(r
i
x
. n) dn

y
i
y
y
i
y
1
1(r
i
x
1
. n)

r
(r
i
x
1
. n) dn
+

x
i
x
i
x
1
1(r. n
i
y
)

n
(r. n
i
y
) dr

x
i
x
i
x
1
1(r. n
i
y
1
)

n
(r. n
i
y
1
) dr (2.28)
Even though these four integrals ought to be solved individually, they all have the same structure
and can be reduced to results that somehow resemble the one-dimensional case. Take for example
the rst one. This integral represents the net leakage of neutrons passing outward (i.e. to the right)
through the right boundary of the cell. Because of neutron conservation, it should be equal to the net
incoming (i.e. also to the right) neutron current through the left boundary in cell (i
x
+ 1)-i
y
. And,
because there may be a material interface at the boundary, proceeding like in the previous section, it
should be

y
i
y
y
i
y
1
1(r
i
x
c. n)

r
(r
i
x
c. n) dn =

y
i
y
y
i
y
1
1(r
i
x
+ c. n)

r
(r
i
x
+ c. n) dn (2.29)
for some 0 < c <r.
To obtain a nite volumes scheme using only four neighbors, is must be assumed that the net
current can be written as

y
i
y
y
i
y
1
1(r
i
x
c. n)

r
(r
i
x
c. n) dn

r

r
i
x

r
2
c. n
i
y

y
i
y
y
i
y
1
1(r
i
x
c. n) dn (2.30)
This approximation is correct up to order n
2
. To simplify the notation in the development that
follows, use the nomenclature dened in gure 2.10
(i
x
. i
y
) =

r
i
x

r
2
. n
i
y

n
2

(i
x
12. i
y
) =

r
i
x
1
. n
i
y

n
2

(i
x
+ 12. i
y
) =

r
i
x
. n
i
y

n
2

(i
x
. i
y
12) =

r
i
x

r
2
. n
i
y
1

(i
x
. i
y
+ 12) =

r
i
x

r
2
. n
i
y
1

as the mean ux in the i


x
-i
y
cell and the mean uxes in each side of the rectangle, and let
:1
milonga v0.1

1(r. i
y
) =

y
i
y
y
i
y
1
1(r. n) dn

1(i
x
. n) =

x
i
x
x
i
x
1
1(r. n) dr
Note that r. n R and i
x
. i
y
N, so the rst expression is a function of r for a xed i
y
and the
second is a function of n for a xed i
x
.
By using the approximation (2.30) in equation (2.29) the current continuity implies the identity

1(r
i
x
c. i
y
)

n
(r
i
x
c. i
y
) =

1(r
i
x
+ c. i
y
)

n
(r
i
x
+ c. i
y
)
In the same spirit of equation (2.21), the derivatives are approximated by half increments such
that

1(r
i
x
c. i
y
)
(i
x
+ 12. i
y
) (i
x
. i
y
)
1
2
r
=

1(r
i
x
+ c. i
y
)
(i
x
+ 1. i
y
) (i
x
+ 12. i
y
)
1
2
r
The intermediate ux (i
x
+ 12. i
y
) as a function of the cell uxes is thus
(i
x
+ 12. i
y
) =

1(r
i
x
c. i
y
) (i
x
. i
y
) +

1(r
i
x
+ c. i
y
) (i
x
. i
y
+ 1)

1(r
i
x
c. i
y
) +

1(r
i
x
+ c. i
y
)
and the ux derivative at the boundary cell i
x
-i
y
is

r
(r
i
x
c. i
y
)
2
r


1(r
i
x
c. i
y
)

1(r
i
x
c. i
y
) +

1(r
i
x
+ c. i
y
)
1

(i
x
. i
y
)
+

1(r
i
x
1
+ c. i
y
)

1(r
i
x
c. i
y
) +

1(r
i
x
+ c. i
y
)
(i
x
+ 1. i
y
)

(2.31)
Equation (2.31) should be compared with equation (2.23). The form is actually the same, with
the two-dimensional version having expressions integrated in the n axis for the diusion coecients,
i.e. hats. The rst integral in the right term of equation (2.28) can then be written as

y
i
y
y
i
y
1
1(r
i
x
. n)

r
(r
i
x
. n) dn
2

1(r
i
x
c. i
y
)
r


1(r
i
x
c. i
y
)

1(r
i
x
c. i
y
) +

1(r
i
x
+ c. i
y
)
1

(i
x
. i
y
)
+

1(r
i
x
+ c. i
y
)

1(r
i
x
c. i
y
) +

1(r
i
x
+ c. i
y
)
(i
x
+ 1. i
x
)

An analog reasoning leads to expressions for the rest of the three integrals as

y
i
y
y
i
y
1
1(r
i
x
1
. n)

r
(r
i
x
1
. n) dn
2

1(r
i
x
1
+ c. i
y
)
r

1(r
i
x
1
+ c. i
y
)

1(r
i
x
1
c. i
y
) +

1(r
i
x
1
+ c. i
y
)

(i
x
. i
y
)

1(r
i
x
1
c. i
y
)

1(r
i
x
1
c. i
y
) +

1(r
i
x
1
+ c. i
y
)
(i
x
1. i
y
)

::
milonga v0.1

x
i
x
x
i
x
1
1(r. n
i
y
)

n
(r. n
i
y
) dr
2

1(i
x
. n
i
y
c)
n


1(i
x
. n
i
y
c)

1(i
x
. n
i
y
c) +

1(i
x
. n
i
y
+ c)
1

(i
x
. i
y
)
+

1(i
x
. n
i
y
+ c)

1(i
x
. n
i
y
c) +

1(i
x
. n
i
y
+ c)
(i
x
. i
y
+ 1)

x
i
x
x
i
x
1
1(r. n
i
y
1
)

n
(r. n
i
y
1
) dr
2

1(i
x
. n
i
y
1
+ c)
n

1(i
x
. n
i
y
1
+ c)

1(i
x
. n
i
y
1
c) +

1(i
x
. n
i
y
1
+ c)

(i
x
. i
y
)

1(i
x
. n
i
y
1
c)

1(i
x
. n
i
y
1
c) +

1(i
x
. n
i
y
1
+ c)
(i
x
. i
y
1)

Having derived these expressions, the two-dimensional leakage term in cell i


x
-i
y
can be written as
a linear combination of the cell uxes at i
x
-i
y
and its four rst neighbors

V
i
div

1(r. n) grad (r. n)

d
2
r =C
i
x
,i
y
(i
x
. i
y
) + C
x
i
x
,i
y
(i
x
1. i
y
) + C
x+
i
x
,i
y
(i
x
+ 1. i
y
)
+ C
y
i
x
,i
y
(i
x
. i
y
1) + C
y+
i
x
,i
y
(i
x
. i
y
+ 1)
with the coecients
C
i
x
,i
y
=
2
r


1(r
i
x
1
c. i
y
)

1(r
i
x
1
+ c. i
y
)

1(r
i
x
1
c. i
y
) +

1(r
i
x
1
+ c. i
y
)
+

1(r
i
x
c. i
y
)

1(r
i
x
+ c. i
y
)

1(r
i
x
c. i
y
) +

1(r
i
x
+ c. i
y
)

2
n


1(i
x
. n
i
y
1
+ c)

1(i
x
. n
i
y
1
+ c)

1(i
x
. n
i
y
1
c) +

1(i
x
. n
i
y
1
+ c)
+

1(i
x
. n
i
y
c)

1(i
x
. n
i
y
c. i
y
)

1(i
x
. n
i
y
c) +

1(i
x
. n
i
y
+ c)

C
x
i
x
,i
y
=
2
r

1(r
i
x
1
c. i
y
)

1(r
i
x
1
+ c. i
y
)

1(r
i
x
1
c. i
y
) +

1(r
i
x
1
+ c. i
y
)
C
y
i
x
,i
y
=
2
n

1(i
x
. n
i
y
1
c)

1(i
x
. n
i
y
1
+ c)

1(i
x
. n
i
y
1
c) +

1(i
x
. n
i
y
1
+ c)
C
x+
i
x
,i
y
=
2
r

1(r
i
x
c. i
y
)

1(r
i
x
+ c. i
y
)

1(r
i
x
c. i
y
) +

1(r
i
x
+ c. i
y
)
C
y+
i
x
,i
y
=
2
n

1(i
x
. n
i
y
c)

1(i
x
. n
i
y
+ c)

1(i
x
. n
i
y
c) +

1(i
x
. n
i
y
+ c)
(2.32)
As in the previous section, 1(r. n) may have a discontinuity that does not coincide with a cell
border, so instead of using the line integral along r
i
c to evaluate the net ux through the right,
an average value using the surface integral over the right half of the cell can be used. For example,

1(r
i
c. i
y
) may be replaced by

1(r
i
c)

x
i
y
x
i
x
1/2x

1(r. i
y
) dr
1
2
r
=

x
i
y
x
i
x
1/2x

y
i
y
y
i
y
1
1(r. n) dn dr
1
2
r
:
milonga v0.1
with similar expressions for the rest of the diusion coecients in equations (2.32).
If the diusion coecient is homogeneous over the whole spatial domain 1(r. n) = 1, then the
leakage term in two dimensions is

V
i
div

1(r. n) grad (r. n)

d
2
r 1

(i
x
1. i
y
) 2(i
x
. i
y
) + (i
x
+ 1. i
y
)
r

+r

(i
x
. i
y
1) 2(i
x
. i
y
) + (i
x
. i
y
+ 1)
n

that is the expression of 1


2
rn written with the usual 5-point stencil for the Laplacian.
Three dimensions
The one-dimensional case was used to introduce the basic idea of the scheme, while the two di-
mensions case was used to show the extension to multiple spatial dimensions. The equations for
three-dimensional problems are presented as a generalization of equations (2.32):

V
i
div

1(r. n. .) grad (r. n. .)

d
3
r =C
i
x
,i
y
,i
z
(i
x
. i
y
. i
z
)
+ C
x
i
x
,i
y
,i
z
(i
x
1. i
y
. i
z
) + C
x+
i
x
,i
y
,i
z
(i
x
+ 1. i
y
. i
z
)
+ C
y
i
x
,i
y
,i
z
(i
x
. i
y
1. i
z
) + C
y+
i
x
,i
y
,i
z
(i
x
. i
y
+ 1. i
z
)
+ C
z
i
x
,i
y
,i
z
(i
x
. i
y
. i
z
1) + C
z+
i
x
,i
y
,i
z
(i
x
. i
y
. i
z
+ 1)
C
i
x
,i
y
=
2
r


1(r
i
x
1
+ c. i
y
. i
z
)

1(r
i
x
1
c. i
y
. i
z
)

1(r
i
x
1
c. i
y
. i
z
) +

1(r
i
x
1
+ c. i
y
. i
z
)
+

1(r
i
x
c. i
y
. i
z
)

1(r
i
x
+ c. i
y
. i
z
)

1(r
i
x
c. i
y
. i
z
) +

1(r
i
x
+ c. i
y
. i
z
)

2
n


1(i
x
. n
i
y
1
c. i
z
)

1(i
x
. n
i
y
1
+ c. i
z
)

1(i
x
. n
i
y
1
c. i
z
) +

1(i
x
. n
i
y
1
+ c. i
z
)
+

1(i
x
. n
i
y
c. i
z
)

1(i
x
. n
i
y
c. i
z
)

1(i
x
. n
i
y
c. i
z
) +

1(i
x
. n
i
y
+ c. i
z
)

2
.


1(i
x
. i
y
. .
i
z
1
c)

1(i
x
. i
y
. .
i
z
1
+ c)

1(i
x
. i
y
. .
i
z1
c) +

1(i
x
. i
y
. .
i
z
1
+ c)
+

1(i
x
. i
y
. .
i
z
c)

1(i
x
. i
y
. .
i
z
+ c)

1(i
x
. i
y
. .
i
z
c) +

1(i
x
. i
y
. .
i
z
+ c)

C
x
i
x
,i
y
,i
z
=
2
r

1(r
i
x
1
c. i
y
. i
z
)

1(r
i
x
1
+ c. i
y
. i
z
)

1(r
i
x
1
c. i
y
. i
z
) +

1(r
i
x
1
+ c. i
y
. i
z
)
C
y
i
x
,i
y
,i
z
=
2
n

1(i
x
. n
i
y
1
c. i
z
)

1(i
x
. n
i
y
1
+ c. i
z
)

1(i
x
. n
i
y
1
c. i
z
) +

1(i
x
. n
i
y
1
+ c. i
z
)
C
z
i
x
,i
y
,i
z
=
2
n

1(i
x
. i
y
. .
i
z
1
c)

1(i
x
. i
y
. .
i
z
1
+ c)

1(i
x
. i
y
. .
i
z
1
c) +

1(i
x
. i
y
. .
i
z
1
+ c)
C
x+
i
x
,i
y
,i
z
=
2
r

1(r
i
x
c. i
y
. i
z
)

1(r
i
x
+ c. i
y
. i
z
)

1(r
i
x
c. i
y
. i
z
) +

1(r
i
x
+ c. i
y
. i
z
)
C
y+
i
x
,i
y
,i
z
=
2
n

1(i
x
. n
i
y
c. i
z
)

1(i
x
. n
i
y
+ c. i
z
)

1(i
x
. n
i
y
c. i
z
) +

1(i
x
. n
i
y
+ c. i
z
)
C
z+
i
x
,i
y
,i
z
=
2
n

1(i
x
. i
y
. .
i
z
c)

1(i
x
. i
y
. .
i
z
+ c)

1(i
x
. i
y
. .
i
z
c) +

1(i
x
. i
y
. .
i
z
+ c)
(2.33)
2.1.3 Finite dierences scheme
Instead of a nite volumes scheme, an approach based on the nite dierences method can be used
to discretize the neutron diusion equation. In this case, the spatial domain is also divided in a nite
:i
milonga v0.1
number of cells, but instead of working with cell-averaged values, the ux is computed at the cell
centers that are taken as the problem nodes as depicted in gure 2.11.
Figure 2.11: Finite-dierences approach to the discretization of the spatial domain introduced in gure 2.5.
The properties and the ux are evaluated at nodes (lled circles) instead of representing cell (squares) mean
values. For convenience, the nodes are taken as the nite-volumes cells centers.
The nite dierences scheme consists in replacing the G continuous multigroup diusion equa-
tions (2.14)
0 = div

1(r. o) grad

(r. o)



t
(r. o) (r. o)
+
G

=1

s
(r. o

o) (r. o

) + (o)
G

=1

f
(r. o

)
/
e
(r. o

)
by G equations with the cross sections evaluated in each cell and the divergence term replaced by
a dierences approximation. Denote by the integer argument i the properties evaluated at the center
of the i-th cell in an :-dimensional spatial domain. As equation (2.14) holds for every point in the
spatial domain, then in particular it must hold for the cell centers r
i
0 = div

1(i. o) grad

(i. o)



t
(i. o) (i. o)
+
G

=1

s
(i. o

o) (i. o

) + (o)
G

=1

f
(i. o

)
/
e
(i. o

)
The rst term can be expanded as
div

1(i. o) grad

(i. o)


= 1(i. o)
2
(i. o) + grad

1(i. o)

grad

(i. o)

(2.34)
The nite dierences scheme proposed consists of approximating both the ux Laplacian and
gradient by rst-neighbors dierences expressions. In one dimension, it is
:j
milonga v0.1
div

1(i. o) grad

(i. o)


1(i. o)
(i + 1. o) 2(i. o) + (i 1. o)
r
2
+
1(i. o)
r

(i + 1. o) (i 1. o)
2r
In two dimensions, using the i
x
-i
y
nomenclature introduced in section 2.1.2, the scheme is
div

1(i
x
. i
y
. o) grad

(i
x
. i
y
. o)


1(i
x
. i
y
. o)
(i
x
+ 1. i
y
. o) 2(i
x
. i
y
. o) + (i
x
1. i
y
. o)
r
2
+ 1(i
x
. i
y
. o)
(i
x
. i
y
+ 1. o) 2(i
x
. i
y
. o) + (i
x
. i
y
1. o)
n
2
+
1(i
x
. i
y
. o)
r

(i
x
+ 1. i
y
. o) (i
x
1. i
y
. o)
2r
+
1(i
x
. i
y
. o)
n

(i
x
. i
y
+ 1. o) (i
x
. i
y
1. o)
2n
and for three dimensions
div

1(i
x
. i
y
. i
z
. o) grad

(i
x
. i
y
. i
z
. o)



1(i
x
. i
y
. i
z
. o)
(i
x
+ 1. i
y
. i
z
. o) 2(i
x
. i
y
. i
z
. o) + (i
x
1. i
y
. i
z
. o)
r
2
+ 1(i
x
. i
y
. i
z
. o)
(i
x
. i
y
+ 1. i
z
. o) 2(i
x
. i
y
. i
z
. o) + (i
x
. i
y
1. i
z
. o)
n
2
+ 1(i
x
. i
y
. i
z
. o)
(i
x
. i
y
. i
z
+ 1. o) 2(i
x
. i
y
. i
z
. o) + (i
x
. i
y
. i
z
1. o)
.
2
+
1(i
x
. i
y
. i
z
. o)
r

(i
x
+ 1. i
y
. i
z
. o) (i
x
1. i
y
. i
z
. o)
2r
+
1(i
x
. i
y
. i
z
. o)
n

(i
x
. i
y
+ 1. i
z
. o) (i
x
. i
y
1. i
z
. o)
2n
+
1(i
x
. i
y
. i
z
. o)
n

(i
x
. i
y
. i
z
+ 1. o) (i
x
. i
y
. i
z
1. o)
2.
Because of the dierential nature of the method, only local eects are retained in this formulation
and variations of parameters within cells are usually damped an even neglected. To somehow take
into account these eects, two things can be done. The rst one is to use cell-averaged properties
instead of the values evaluated at the centers (see section 2.2), and the second one is to compute the
gradient of the diusion coecient also as a nite-dierence approximation instead of using the actual
derivative of the continuous property. All these four combinations can be handled by milonga.
Last but not least, there is one important thing to add. If the diusion coecient 1(r) is not
dierentiable at some point r
d
, then equation (2.14) does not hold at r
d
. If this point happens to
coincide with a cell center r
i
, the numerical method is not consistent. Moreover, even if r
d
does not
coincide with a cell center, the uxes in the neighboring cells will have unphysical results because the
original equation (2.14) is not valid. If one wants to nd the solution to the dierential equation all in
all, current continuity conditions have to be solved at r
d
instead of the diusion equation. The nite
volumes scheme proposed in section 2.1.2 includes both the diusion equation and current continuity
in its formulation, so it is expected to give better results than the nite dierences approximationat
least without using ad-hoc correction factors. For example, if there is a discontinuity in the distribution
of the diusion coecient then the evaluation of grad may depend on the size of the cells.Also note
that while the nite dierences scheme solves the dierential diusion equation, the nite volumes
scheme solves the diusion equation integrated over the cell volume.
:6
milonga v0.1
2.2 Cell cross-section computation
The discretized multigroup equations give a relationship between the expected neutron ux in each
cell for each energy group (the s) and some parameters that depend on the nuclear properties of the
materials present in the diusive media (the s). Strictly speaking, these macroscopic cross sections
depend on the local ux distribution as shown by the exact equation (2.17) derived for the total
macroscopic cross section:

t
(i. o) =

V
i

t
(r. o) (r. o) d
m
r

V
i
(r. o) d
m
r
(2.17)
However, it is clear that for the formulation to be useful, the coecients ought not to depend on
the ux itself.
Up to a rst order approximation, two approaches can be taken to take out the uxes of the
cross-section expression. The rst is to assume a at prole inside each cell. Call it (r. o) = for
r cell i. Then

t
(i. o) =

V
i

t
(r. o) d
m
r

V
i
d
m
r
=

V
i

t
(r. o) d
m
r

V
i
d
m
r
(2.35)
and the cell total macroscopic cross section is the mean value of the continuous macroscopic cross
section distribution inside the cell.
The secondand rather extremeapproach is to assume that somehow the ux is concentrated in
the center of the cell (r. o) = (r
i
) where r
i
is the location of the i-th cell center. Thus

t
(i. o) =

V
i

t
(r. o) (r
i
) d
m
r

V
i
(r
i
) d
m
r
=
t
(r
i
. o) (2.36)
and the cell cross section is the value taken by the distribution at the cell center.
Either of these schemes can be chosen to be used by milonga. They give similar results for cross
sections that depend weakly on r, so equation (2.36) should be preferred because it requires less
computational eort. However, for discontinuous propertiesespecially if they do not coincide with
cell bordersequation (2.35) should be used. If the cross section distribution is homogeneous inside
the cell, both formulations coincide.
2.3 Boundary conditions
To fully dene the diusion problem, boundary conditions on the spatial domain must be given. These
can be Dirichlet, Neumann or mixed, i.e. specify the ux, the derivative in the normal direction or a
linear combination of them at the domain boundary. In the discretized diusion problem, as illustrated
for a two-dimensional case in gure 2.12, in those cells that are completely contained in the domain
the diusion equation is solved. In those that are completely outside the domain, the ux is forced to
be null. And in those that contain the external boundary of the geometry that denes the neutronic
problem, the boundary conditions equations are imposed.
In nuclear reactor diusion theory [5], it is usual to make the ux vanish at a certain distance from
the external surfaces called extrapolation length. However, for common reactor sizes, this length is
negligible enough to assume it is zero. Thus, ux equal to zero at the external surfaces is the common
boundary condition. For symmetric problems, it is also customary to solve only a part of the problem
and impose mirror boundary conditions on the ux. The boundary conditions supported by milonga
:
milonga v0.1
Figure 2.12: For the spatial domain of gure 2.5, cells that are completely inside the domain (green) solve the
diusion problem. Cells that contain the border (orange) impose the problem boundary conditions. The rest
of the cells (black) are forced to have a null ux.
are introduced in the following subsections, stating the actual discrete equations that implement them
numerically.
2.3.1 External planar surfaces
External planar surfaces include one-dimensional slab boundaries, two-dimensional straight lines and
three-dimensional planar surfaces where the ux is ought to be equal to zero. In each case, there is a
well-dened outward direction. Without loss of generality, assume it is the negative r direction, as if
a null boundary condition is applied at r = 0 in a one-dimensional slab.
Let i
0
be the index of the cell that should impose the boundary condition equation. In general,
the external boundary will be at an algebraic distance r (i.e. r 0 if the surface is at the right
and conversely) from the cell center r
i
0
. The condition (r
i
0
+ r) = 0 is implemented by requiring
that a linear interpolation (or extrapolation for r < 0) of the cell uxes at i
0
and its rst neighbor
in the inward direction vanishes at r = r
i
0
+ r (gure 2.13).
Making use of approximation (2.16), further assume that inside cell i
0
the ux can be written as
(r
i
0
+ r) = (r
i
0
) +

r

x
i
0
r
(r
i
0
+ r) = (i
0
) +
(i
0
+ 1) (i
0
)
r
r
The condition (r
i
0
+ r) = 0 is attained if
(i
0
) +

r
r
1
r
r

(i
0
+ 1) = 0
In particular, if the boundary condition has to be applied at r = 0, then r = 12r and the
boundary condition yields
:8
milonga v0.1
Figure 2.13: Planar boundary conditions in the rst cell of the x direction. Note that in this case, the
external surface is located between the bare external surface and the rst cell center, so x < 0. In the case
shown, i
0
= 1
(1) =
1
3
(2)
meaning that the ux at the rst cell has to be one-third of the ux in the rst neighbor in order for
the linear extrapolation to vanish at the boundary of the cell (try to make a mental picture and see
the similar triangles with ratio three to one).
It is important to note that if the boundary lies to the right of the cell center (r 0), then the
ux (i
0
) has to be negative to make the linear interpolation between (i
0
) and (i
0
+1) pass through
zero as shown in gure 2.14. If this fact is understood as a mathematical artifact to handle discrete
boundary conditions and the results are properly interpreted, the cell ux can be left negative as
computed. However, ssion power is usually computed from the neutron uxes and negative powers
cannot be allowed based on physical grounds. Milonga can be told to force negative uxes to zero so
no articial power sinks appear, at the expense of slightly changing the form of the neutron ux near
the borders.
Had the outward direction been the positive r direction, then the equation to impose the boundary
condition would have been
(i
0
)

r
r
1 +
r
r

(i
0
1) = 0
with r 0 still meaning that the external surface is located to the right of cell i
0
, and conversely.
For two and three dimensions, the idea is extended to all the possible directions.
2.3.2 Cylindrical surfaces
For cylindrical external surfaces, the only available boundary condition is null ux. Assume that the
cylinder axis is parallel to the . axis, then
(r. n) = 0
for (r. n) in the external boundary.
The discrete boundary condition requires a linear expansion of the ux to be equal to zero at the
point in the circumference that lies in the circle radius that passes through the cell center. Let (r
0
. n
0
)
:o
milonga v0.1
Figure 2.14: If the external surface is located between two adjacent nodes, to make the linear interpolation of
the ux pass through zero at the external surface, one of the uxes has to be negative. This is a mathematical
artifact to handle discrete boundary conditions, and should be understood as such.
be the coordinates of the center of the cell (i
0
. ,
0
) through which the circumference with center (r
c
. n
c
)
and radius 1 passes by (gure 2.15). The point (r

. n

) at which the expansion has to vanish is


Figure 2.15: Discrete boundary condition in a cylindrical external surface
r

= r
c
1cos
n

= n
c
1sin
with the sign chosen according to the quadrant (r
0
. n
0
) is with respect to (r
c
. n
c
) and
= arctan

[n
0
n
c
[
[r
0
n
c
[

The linear expansion is a rst-order Taylor series around the cell center
(r. n) (r
0
. n
0
) +

r

x
0
,y
0
(r r
0
) +

n

x
0
,y
0
(n n
0
)
o
milonga v0.1
The partial derivatives are approximated as

x
0
,y
0

(i
0
1. ,
0
) (i
0
. ,
0
)
r

x
0
,y
0

(i
0
. ,
0
1) (i
0
. ,
0
)
n
where again the signs are selected according to the quadrant with respect to the circle center the point
(r
0
. n
0
) is. To x ideas, assume it is in the rst quadrant. Then, the discrete boundary condition is
0 =

1 +
r
c
r
0
+ 1cos
r
+
n
c
n
0
+ 1sin
n

(i
0
. ,
0
)

r
c
r
0
+ 1cos
r
(i
0
1. ,
0
)
n
c
n
0
+ 1sin
n
(i
0
. ,
0
1)
with similar equations for the other three quadrants.
Note that depending on the relative location of the cell center (r
0
. n
0
) and the point (r

. n

), the
boundary equation may require the ux (i
0
. ,
0
) to be negative as with the planar surfaces discussed
above. Again, this is a mathematical artifact that hast to be taken into account in the nodalization
of a problem.
2.3.3 Spherical surfaces
To be done.
2.3.4 Mirror conditions
Symmetry conditions at a planar surfaces are implemented by requiring a null partial derivative in the
normal direction. Independently from the actual location of the surface with respect to the cells i
0
and i
0
1, this condition reads
(i
0
) (i
0
+ 1) = 0
or
(i
0
) (i
0
1) = 0
according to the outward direction of the surface with the mirror condition.
2.3.5 Sharp edges
In milongas context, a sharp edge means a geometric object that belongs to the external boundary of
the spatial domain that has at least two degrees of dimension less than the domain. For example, in
three dimensions corner points and external surfaces edges are considered sharp (gure 2.16a). In two
dimensions, the vertex of the intersection of two planar external surfaces are sharp edges (gure 2.16b).
In one dimension there are no sharp edges.
When a cell contains a sharp edge, instead of solving the diusion equation a boundary condition
equation is applied to it. As there is no denite outward direction, the condition in milonga is that
the ux at the cell should be equal to the average ux of its non-vacuum neighbors. This choice of
boundary condition works well both with null and mirror conditions for the planar surfaces.
1
milonga v0.1
(a) In three dimensions,
sharp edges include corner
and surfaces intersections
(b) In two dimensions, sharp
edges are corners.
Figure 2.16: Boundary conditions at sharp edges. Cells that contain a sharp edge have boundary conditions
equations.
2.4 The eigenvalue problem
As assumed throughout this chapter, in the absence of xed independent sourcesi.e. not associated
to ssionthe steady-state multigroup neutron diusion equation can be written as a generalized
eigenvalue problem. In eect, the G dierential equations (2.14) have the same dependency on the
multiplicative factor /
e
, and can be casted in matrix form as
1

=
1
/
e
1

(2.37)
where 1

and 1

are square matrices of size GG that contain dierential operators and functions
of the spatial coordinate r R
m
, and is the vector of size G
=

(r. 1)
(r. 2)
.
.
.
(r. G)

The star notation means that these matrices represent the dierential formulation, while we leave
the non-star notation for the spatial-discretized problem that is milongas main subject. Matrices 1

and 1

are named after removal and ssion, respectively. The left member of equation (2.37) gives
the net rate of disappearance of neutrons, while the right member gives the rate of neutron births
by ssion. By using the mathematical artifact of dividing this rate by the eective multiplication
factor, an articial critical reactor is obtained, with the eigenvector representing the articial ux
distribution. Equation (2.37) can be written as a standard eigenvalue problem as
1
1
1

= /
e
(2.38)
It is possible to show that 1
1
exists for any physically real set of cross sections [4], so the
eigenvalue problem is well-dened. Now, in general there are G pairs of eigenvalues and eigenvectors
that satisfy the eigenvalue problem. Even though most of them may be negative, complex or give
rise to negative uxes, for problems based on a physical ground it is possible to prove [4, section 3.3,
page 73] that
1. There is a unique real positive eigenvalue greater in magnitude than any other eigenvalue
2. All the elements of the eigenvector corresponding to that eigenvalue are real and positive
3. All other eigenvectors either have some elements that are zero or have elements that dier in
sign from each other
:
milonga v0.1
The eigenvalue form (2.37) is maintained for the spatial-discretized formulation derived in sec-
tions (2.1.2) and (2.1.3)either onenow having
1 =
1
/
e
1 (2.39)
where the size of the problem is G, and the elements of the eigenvector are (i. o):
=

(1. 1)
(1. 2)
.
.
.
(1. G)
(2. 1)
.
.
.
(2. G)
(3. 1)
.
.
.
(. G)

Matrices 1 and 1 are square GG matrices. Their elements are real numbers, namely all the
coecients that multiply each of the uxes (i. o) that were derived in sections (2.1.2) and (2.1.3). If a
coecient is not divided by /
e
, it is incorporated into 1 and into 1 otherwise. The row corresponds
to the index of the cell and group of the discretized equation it appears in, and the column corresponds
to the index of the cell and group of the ux that it is multiplying to.
In the discretized problem (2.39), in addition to some approximation of the G eigenvalue and
eigenvector pairs present in the continuous problem (2.37), there appear (G1) new eigenvalues.
Nonetheless, the three mathematical properties stated above also hold for equation (2.39).
The direct storage of a matrix of size GG for values of of interest in nuclear reactor analysis
is intractable with computational resources available nowadays
1
. Luckily, matrices 1 and 1 are
sparsewhile 1

and 1

in general are notas both the discretized multigruoup diusion equations


and the boundary conditions depend only on rst neighbors in space and on the uxes of the other
energy groups in the spatial cell evaluated. However, if the generalized eigenvalue problem (2.39) is
to be written as a standard eigenvalue problem either as
1
1
1 =
1
/
e

or as
1
1
1 = /
e

in addition to the problem of nding inverse matricesthat, by the way, may not exists as is the
usual case for 1
1
there appears at least one big dense matrix that cannot be eciently handled.
Therefore, to solve the neutron steady-state diusion equation, methods for solving a generalized
eigenvalue problem in the form of equation (2.39) ought to be used.
Milonga uses the PETSc
2
[11, 12] library to build and handle , 1 and 1, and the SLEPc [13, 14]
library to solve the generalized eigenvalue problem given by equation (2.39) to obtain /
e
and the
associated critical reactor ux distribution. SLEPc solves either the standard or the generalized
eigenvalue problem maintaining the sparsity of the formulation using a variety of ecient iterative
methods, from which milongas user can choose. In particular, given
x = 1x (2.40)
1
For the record, this sentence was rst written in 2011.
2
Although the current version does not utilize all the potential this library provides, especially the parallelization
capabiltities. Future versions will be fully optimized with scalability in mind.

milonga v0.1
SLEPc tries to nd combinations (. x) that make the equation hold. Moreover, it can be told to nd
only a few large or small eigenvalues, or to search for solutions located only in a certain region of the
complex plane. As in the diusion problem, due to the properties of equation (2.38) stated in page 32,
only one eigenvalue-eigenvector pair is the solution sought for in the neutron diusion equation, this
feature is particularly convenient.
On the one hand, depending on the kind of physical problem being solved, some solution methods
are more suitable than others. On the other hand, some methods work betterand may even not
work at allwhen one of 1 or 1 takes place of the matrix in SLEPcs equation (2.40). Thus,
essentially two versions of the generalized problem can be used, either
1 = /
e
1 (2.41)
or
1 =
1
/
e
1 (2.42)
In the rst case, = 1/
e
and the eigenvalue sought for is the smaller in magnitude, and con-
versely. Equation (2.41) as the direct /
e
formulation and equation (2.42) is referred to as the
inverse /
e
formulation. The user can request to solve the problem using either one, depending on
the particularities of the problem and the solver method.
2.4.1 Iterations tolerance
All the eigensolvers provided by SLEPc are iterative in nature, meaning that the solutions are (usually)
improved at each iteration until they are suciently accurate, that is, until convergence is achieved [15].
Thus, a criterion for stopping the iterative process is needed. It can be given as a maximum number
of iterations or as a tolerance for the solution convergence.
Note that this tolerance is a measure of the error committed by the numerical method used to solve
the eigenvalue problem (2.42) (or (2.41)). In addition, there exist an error related to the discretization
both in space and energy of the diusion equation 2.5, that in turn has uncertainties in the macroscopic
cross-sections. Moreover, the diusion equation is an approximation that holds only up to a certain
degree only in special cases of nuclear reactor geometries and material compositions. Keep in mind
gure 2.1 with this respect.
SLEPc considers that the eigenvalue problem is solved whenever a certain residual is less than some
small positive value. There are three possible criteria, namely absolute residual, relative residual with
respect to the eigenvalue and relative residual with respect to the matrix norms. As the selection
of this tolerance is of vital importance for the performance of the numerical solution of the diusion
problem, a trade-o between high accuracy and a reasonable computation speed is needed.
According to the SLEPc manual [15], the provided convergence criteria for the generalized eigen-
value problem (2.40) are based on the absolute residual vector dened as
: = x

1 x
where

and x represent the computed eigenpair. For Hermitian problemswhich is not the case
for 1 and 1it is possible to prove, as stated in [15], that

|:|
2
This is not the case in general problems, so there is no simple relationship between the residual
norm and the actual error committed by the numerical method. Nevertheless, |:|
2
stills should give
a measure of the distance between the real eigenvalue and the approximate solution .
As |:| depends on the size of the problem, in general a ner discretization will lead to more
iterations for the eigenvalue problem. To avoid this escalation, milonga uses as a measure of the
convergence the residual norm with respect to the matrices norm, namely
i
milonga v0.1
|:
rel
| =
|:|
2
||
2
+[[|1|
2
(2.43)
so convergence is considered as achieved whenever |:
rel
| is less than a certain tolerance. The default
tolerance value used by milonga is the default used by SLEPc that is 10
7
. The impact of this gure
on the overall behavior with respect of accuracy and running time of milonga when solving a particular
problem has to be determined by the user in a by-case basis.
2.4.2 Flux and power
In the absence of external independent sources, the linear diusion problem (2.5) is homogeneous,
and so is the associated discretized eigenvalue problem (2.39). Therefore the solution is dened up to
a multiplicative constant. That is, if
1
is a solution, then
2
=
1
is also a solution. To be able
to compare solutions obtained by dierent methods, a normalization procedure is desired. Milonga
computes the solution of the eigenvalue problem (2.39) such that the mean value is equal to one
unit of ux, i.e.


0
(r. 1) d1 d
m
r

V
d
m
r
= 1
Using equations (2.6) and (2.15), this condition can be written as

V
G

g=1
(r. o) d
m
r

V
d
m
r
= 1
G

g=1

V
(r. o) d
m
r

V
d
m
r
= 1
G

g=1
N

i=1
(i. o)

V
i
d
m
r

V
d
m
r
= 1
that for uniformly distributed cells, reduces to
G

g=1
N

i=1
(i. o) = 1
In real reactors, feedback eectssuch as temperature or xenonrender the problem nonlinear
and the solution cannot be modulated at will, but the ux distribution is unique. To be able to cope
with these eects, a desired power level has to be given in order to normalize the ux distribution to
the correct value. If the power setpoint is 1

, for a three-dimensional reactor, this condition reads


0
1
f
(r. 1) (r. 1) d1 d
3
r = 1

where 1
f
is the product of energy released in one single ssion times the macroscopic ssion cross
section. Note that if the desired power level 1

refers to the prompt ssion power, then 1


f
has
j
milonga v0.1
to include the prompt energy only, while if 1

is the total powerssion plus delayedthen all the


contributions to the ssion energy by the ssion product decay chain should be taken into account.
Otherwise, a correction factor to take into account delayed power has to be incorporated either in 1

or in 1
f
.
Three-dimensional reactors occupy a nite volume in space, and thus 1

is the reactor power,


either total or ssion according to the denition of 1
f
. But one and two-dimensional reactors are
essentially innite, and thus the dissipated power is also innite. For one dimension, 1

is the power
density per unit area perpendicular to the r axis, and for two dimensions it is the power density per
unit length perpendicular to the r-n plane. Note that 1
f
has units of energy length
3
. Units
consistency is expected.
When a power setpoint is dened, the ux is normalized such that


0
1
f
(r. 1) (r. 1) d1 d
3
r = 1

V
G

g=1
1
f
(r. o) (r. o) d
3
r = 1

g=1
N

i=1

V
i
1
f
(r. o) (r. o) d
3
r = 1

g=1
N

i=1
1
f
(i. o) (i. o)

V
i
d
3
r = 1

where equation (2.15) was used, and the multigroup property 1


f
was denedas with
t
in equa-
tion (2.7)as
1
f
(r. o) =

E
g1
E
g
1
f
(r. 1) (r. 1) d1

E
g1
E
g
(r. 1) d1
and then associated to a particular cell 1
f
(i. o) with one of the methods discussed in section 2.2.
Note that the integrals over the spatial domain were replaced by sums by using equation (2.15),
and thus are mathematically exact from this point of view. However, if using nite dierences, (i. o)
is not the mean value of the ux in a cell but the value of the ux at the cell center. Therefore, in
this case the replacement of the integral by the sum is exact up to order r
2
i.e. as accurate as an
integration by the trapezoids methodgiven by the the approximation (2.16).
2.5 Xenon poisoning
Depending on the ux level distribution, ssion power reactors get poisoned by the appearance of
ssion products. Of all the possible isotopes, the mos important from the neutronic point of view
is
135
Xe, and it is usually the only one taken into account in core calculations. Milonga is capable
of handling the eects of xenon in the power distribution, using the models and equations discussed
below.
The mechanisms of appearance and removal of the isotope
135
Xe are illustrated in gure 2.17. On
the one hand, it can appear as a direct ssion product with a yield
Xe
the mean number of nuclides
of this isotope that appear promptly after a single ssionor as a daughter of
135
I, that decays into
xenon with a time constant
I
. In turn,
135
I appears as a daughter of
135
Te that is a ssion product.
However, as the beta decay of tellurium is so fast with respect to the decay of iodine,
135
I is considered
6
milonga v0.1
to appear as a prompt ssion product. On the other hand,
135
Xe disappears because of beta decay
into caesium and because of neutron absorption, transforming into
136
Xe at a rate that depends on
the local ux.
ssion
Figure 2.17: Mechanisms of appearance and removal of
135
as modeled by milonga.
At a point r in the reactor, the iodine concentration I(r. t) is assumed to follow the balance equation
I(r. t)
t
=
I

f
(r. 1. t) (r. 1. t) d1
I
I(r. t) (2.44)
and the
135
Xe is given by
Xe(r. t)
t
=
Xe

f
(r. 1. t) (r. 1. t) d1 +
I
I(r. t)

Xe
Xe(r. t)

aXe
(r. 1. t) (r. 1. t) d1 (2.45)
The total ssions can be computed from the group uxes as

f
(r. 1. t) (r. 1. t) d1 =
1

g=1

f
(r. o. t) (r. o. t)
where a mean number of neutrons emitted per ssion was used in order to avoid introducing a new
nuclear parameter
f
.
The macroscopic cross section of xenon can be separated into

aXe
(r. 1. t) =
aXe
(1) Xe(r. t)
as the xenon is assumed to be so diluted that its microscopic absorption cross section
aXe
depends
only on energy. Therefore, the rate of removal of
135
Xe due to neutron absorption in equation (2.45)
can be written as

aXe
(r. 1. t) (r. 1. t) d1 =

aXe
(1) Xe(r. t) (r. 1. t) (r. 1. t) d1
= Xe(r. t)
G

i=1

aXe
(o) (r. o. t)
The xed point of equations (2.44) and (2.45) gives the steady state xenon concentration Xe

(r),
that in terms of the multigroup uxes is

milonga v0.1
Xe

(r) =

I
+
Xe

g=1

f
(r. o) (r. o)

Xe
+
G

g=1

aXe
(o) (r. o)
In particular, at the i-th cell center the steady-state xenon concentration is
Xe

(i) =

I
+
Xe

g=1

f
(i. o) (i. o)

Xe
+
G

g=1

aXe
(o) (i. o)
(2.46)
This concentration distribution usually modies the macroscopic cross sections that appear as co-
ecients in the diusion equation (2.1), rendering the problem non-linear. Thus, a iterative procedure
is needed to solve for the actual ux distribution taking into account the eects of xenon poisoning, as
discussed in page 9. Note that the xenon concentration depends on the absolute value of the neutron
ux, thus a power setpoint is needed in order to correctly normalize the solution of the eigenvalue
problem to dimensional quantities, as explained in section 2.4.2. Concentrations have units of inverse
cubed length, decay constants inverse time and microscopic cross sections inverse squared length.
Yields and the mean number of neutrons emitted by a single ssion are dimensionless numbers.
Bibliography
[1] D. Knuth. The art of computer programming Volume 1: Fundamental Algorithms. Addison-
Wesley, 3rd edition, 1997.
[2] K. H. Beckurts and K. Wirtz. Neutron physics. Springer, 1964.
[3] S. Glasstone and G. Bell. Nuclear reactor theory. Van Nostrand Reinhold Co, New York, 1970.
[4] A. F. Henry. Nuclear reactor analysis. MIT, Cambridge, 1975.
[5] J. J. Duderstadt and L. J. Hamilton. Nuclear reactor analysis. Wiley, New York, 1976.
[6] A. Prinja, E. Larser, and D. G. Cacuci (editor). Handbook of Nuclear Engineering, volume I,
chapter General Principles of Neutron Transport, pages 430542. Springer, 2010.
[7] J. Lamarsh. Introduction to Nuclear reactor theory. Addison Wesley, 1966.
[8] W. H. Press amd S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery. Numerical Recipes: The
Art of Scientic Computing. Cambridge University Press, 3rd edition, 2007.
[9] R. J. Leveque. Finite Volume Methods for Hyperbolic Problems. Cambridge University Press,
2002.
[10] T. Gallouet R. Eymard and R. Herbin. Handbook of Numerical Analysis, volume VII, chapter
Finite Volume Methods. North Holland, 2005.
[11] Satish Balay, Jed Brown, , Kris Buschelman, Victor Eijkhout, William D. Gropp, Dinesh Kaushik,
Matthew G. Knepley, Lois Curfman McInnes, Barry F. Smith, and Hong Zhang. PETSc users
manual. Technical Report ANL-95/11 - Revision 3.1, Argonne National Laboratory, 2010.
[12] Satish Balay, William D. Gropp, Lois Curfman McInnes, and Barry F. Smith. Ecient manage-
ment of parallelism in object oriented numerical software libraries. In E. Arge, A. M. Bruaset,
and H. P. Langtangen, editors, Modern Software Tools in Scientic Computing, pages 163202.
Birkhauser Press, 1997.
8
milonga v0.1
[13] Vicente Hernandez, Jose E. Roman, and Vicente Vidal. SLEPc: A scalable and exible toolkit for
the solution of eigenvalue problems. ACM Transactions on Mathematical Software, 31(3):351362,
September 2005.
[14] V. Hernandez, J. E. Roman, and V. Vidal. SLEPc: Scalable Library for Eigenvalue Problem
Computations. Lecture Notes in Computer Science, 2565:377391, 2003.
[15] J. E. Roman, E. Romero, and A. Tomas. SLEPc users manual. Technical Report DSIC-II/24/02
- Revision 3.1, D. Sistemas Informaticos y Computacion, Universidad Politecnica de Valencia,
2010.
o
Chapter III
Input preparation
Science is what we understand well enough to explain to a computer.
Art is everything else we do.
Donald Knuth, Foreword to the book A=B, 1996
This chapter is about imagination. It is about asking a dumb computer to solve a set of equations
that somehow represent a nuclear reactor. And according to milongas design basis, chances are that
this nuclear reactor exists nowhere but in your mind. If after reading this chapter you still cannot ask
milonga to help you with your fancy state-of-the-art reactor design, please do one of the following two
things: contact the author to comply about the lack of the features you feel you are needing, oreven
betterhack into the source code and add the feature by yourself. And of course, distribute the
modied code under the terms of the GNU Public License oreven bettershare your modications
with the author to have them appended into the ocial milonga distribution.
Although milonga has a lot of options that can be tweaked, it comes with a great deal of default
values that should satisfy most needs. That is why input les can be either very small or arbitrary
large. For instance, the following input is the very smallest one that gets the program to perform a
useful calculation:
PROBLEM DIMENSIONS 1 GROUPS 1
x b ar e l e ng t h = 100
x c e l l s = 100
ZONE f ue l MATERIAL f ue l
MATERIAL f ue l D 1 1 SigmaA 1 1e2 nuSigmaF 1 1. 2 e2
The rest of this chapter is devoted to explaining how to build your own input les to, hopefully,
solve the problem you have at hand.
3.1 Input les
Being built on top of wasoras framework, milonga provides all the basic functionality in wasora plus
specic options and settings for milonga. A detailed description of the keywords associated to the
common framework can be found in wasoras documentation. Nevertheless, a quick explanation of
the basic wasoras features is given here for completeness.
Milongas normal behavior is to read one or more input les dening the problem, solve it and
then output the requested resultsif anyin dierent possible ways. The input les are plain text
les containing keywords, parameters and or numerical data. There should be one main input le
than can optionally include further input les.
There are primary and secondary keywords. Primary keywords should appear as the rst token in
a line. Secondary keywords are usually optional and should appear in the same line after a primary
milonga v0.1
keyword. One primary keyword may be followed by zero or more secondary keywords. The order of
the secondary keywords does not matter, while the order in which the primary keywords appear in
the input le may or may not matter. Keywords are case insensitive, but for clarity they are written
in uppercase throughout this document, except for the secondary keywords of MATERIAL that dene
the nuclear properties.
Both primary and secondary keywords may take zero or more parameters. Each parameter should
be a single token delimited by spaces or tabs. If spaces are needed as a part of the parameter, it
should be enclosed in double quotes.
Blank lines and characters appearing after a hash # symbol are treated as separators or comments
and are ignored. For readability reasons, if a denition is too long to t neatly in a single line, it can
be enclosed in braces and spanning dierent le lines. From milongas point of view, whatever
appears enclosed in braces is treated as belonging to the same line.
The following examples illustrates the general keyword syntax:
# t h i s i s an exampl e of t he gener al synt ax expect ed i n i nput f i l e s
PRIMARY_KEYWORD KEYWORD1 argument1 KEYWORD2 one s i ng l e argument
# t he above l i ne coul d al s o be wr i t t en as
PRIMARY_KEYWORD {
KEYWORD1 argument1 # wi t h comments between l i ne s
KEYWORD2 one s i ng l e argument
}
There are keywords that are common to all the packages belonging to the wasora suitei.e. the
common frameworkand keywords that are specic to milonga. Special stress is given to specic
keywords, although as some reference to common keywords is done, a basic explanation about the
frameworks features is also provided.
Some information is given to milonga by giving arguments to keywords, and others by dening
special variables to take certain values. This is the case for information about the problem that may
either be given from external sources or needed after the computation is given. For example, the
number of energy groups is a rather xed parameter and is entered as a keyword argument, while the
number of spacial cells in a certain direction is given as a variable because this value may be part of
a parametric study and/or needed to be used as an output or to request the ux distribution at the
computed points to avoid interpolation.
In any case, most of the parameters are entered by using algebraic expressions accepted by the
wasora framework. These expressions are a combination of numeric constants, variables, functions
and operators. A complete description can be found in wasoras documentation, but valid expressions
are fairly intuitive:
x b ar e l e ng t h = 100
x c e l l s = round(random( 1 , 100) )
pi = 4 atan( 1)
buckl i ng = ( pi / x b ar e l e ng t h ) 2
PRINT TEXT buckl i ng = buckl i ng
PRINT TEXT de l t a x = x b ar e l e ng t h / x c e l l s
In this example, x bare length and x cells are special variables that are used by milonga to
dene the problem, as explained below. The bare length is xed to one hundred, but the number of
cells is a random integer number between one and one hundred. Then, the number is computed
by using the arc-tangent of one, and nally the geometric buckling is calculated. As an example
of information given as keywords arguments, consider the last two lines. Keyword PRINT accepts
expressions as arguments. The rst instruction has a single variable as the argument to be printed,
but the second one has a quotient.
i1
milonga v0.1
Note that the expressions that appear after the equal sign = in assignments can have blanks and
spaces as desired, as long as the whole expression ts in a single line (or is enclosed in brackets). When
appearing as keyword arguments, there should be no intermediate blanks and the whole expression
should be a single token. If not, the expression should be enclosed in double quotes.
In any location of an input le, another input le can be included with the keyword
INCLUDE f i l e
where file is either a relative or absolute path. The eect is as if the included le was pasted right
in the place where the keyword was inserted in the original input le. Nested inclusions, i.e. INCLUDE
keywords in included les, are possible.
During this chapter, optional constructions are presented as enclosed in square brackets [ and ].
Whenever only one of several keywords is to be selected, all the possible keywords are enclosed in
parenthesis ( and ) separated by a vertical line [. Keywords arguments are written in lowercase,
and if the content and meaning is not explained in the surrounding paragraphs, it should be inferred
by the context.
As with the example about variables and keyword arguments above, the rest of this chapter contains
partial examples of the usage of the feature being discussed. However, they are just illustrative and
by no means provide real or ready-to-use inputs. Chapter 4 contains several stand-alone examples
of input les that span a lot of dierent kinds of problems and conditions. They are arranged in
increasing order of complexity, and the inputs shown should be fairly intuitive and self explanatory. If
there is a doubt about the usage of a certain feature, these complete examples should give the correct
answer about how to use the code.
3.2 Problem denition
The rst denition that ought to be provided to milonga is the number of spatial dimensions and the
number of energy groups. This information is given by the primary keyword PROBLEM, that takes the
secondary keywords DIMENSIONS and GROUPS. Each one takes one integer argument, thus dening
the dimension of the problem phase space
PROBLEM DIMENSIONS m GROUPS g
This information is mandatory and should appear before any other of milongas specic keywords.
For example, to dene a two-dimensional problem with three energy groups:
PROBLEM DIMENSIONS 2 GROUPS 3
To dene the geometry, you start with an :-dimensional bare prism and then you dene one or
more material zones inside it. This prism is characterized by : lengths, called the bare lengths. These
lengths are entered as three variables, one for each direction:
x b ar e l e ng t h
y b ar e l e ng t h
z b a r e l e ng t h
For two-dimensional problems, z bare length is ignored and does not need to be entered. The
same applies for y bare length in one-dimensional problems. The units of these variables are to be
decided by the user. However, it is important to note that the entered values ought to have the same
units, consistent with the cross sections entered in the material denition (section 3.5). That is, if the
macroscopic cross sections are in cm
1
, then the bare lengths should be in cm. For non-dimensional
problems, the consistency between the nondimensionalization of the lengths and the cross sections is
up to the user.
i:
milonga v0.1
To dene a three-dimensional bare prism from which to start dening the reactor geometry with
a size of 100100100 of a certain units consistent with the cross sections, say centimeters, enter
x b ar e l e ng t h = 100
y b ar e l e ng t h = 100
z b a r e l e ng t h = 100
The expressions can be any valid mathematical expression. For example, in a two-dimensional
problem, to make sure the bare prism is a always a square, write
x b ar e l e ng t h = a
y b ar e l e ng t h = x b ar e l e ng t h
The last thing that milonga should know about the problem is the spatial nodalization. This
version only supports uniformly distributed cells, so the number of cells in each direction has to be
given. To do so, use the following variables:
x c e l l s
y c e l l s
z c e l l s
These variables should be non-dimensional integers. If any of these values is non-integral, it will
be rounded to the nearest integer. A valid construction is
x c e l l s = 100
y c e l l s = 50
z c e l l s = 40
Again, any expression can be used, so the actual nodalization can be entered as a cell length
instead of cell numbers as:
de l t a x = 1
de l t a y = 2
de l t a z = 2. 5
x c e l l s = x b ar e l e ng t h / de l t a x
y c e l l s = x b ar e l e ng t h / de l t a y
z c e l l s = y b ar e l e ng t h / de l t a z
This information should be entered before the denition of the material zones, that is explained
in section 3.3.
Milonga assumes that there is a single ssionable isotope or, equivalently, that all the available
isotopes have the same ssion spectrum. The default ssion spectrum is thermal, i.e., all the neutrons
are born in the last energy group. If this behavior is to be changed, the elements of the vector
chi
have to be entered, according to equation (2.10). Elements of a vector in wasora are accessed by
appending an underscore plus the element number, starting in one. Thus, in a three group problem,
the default ssion spectrum is taken as if the user had entered
chi 1 = 0
chi 2 = 0
chi 3 = 1
It is the users responsibility to ensure that the sum of the components of vector to sum up to
one, as required by the normalization condition given in equation (2.12).
i
milonga v0.1
3.3 Zones
The actual reactor geometry is dened by entering one or more material zones. This is accomplished
by using the ZONE primary keyword. It takes one mandatory argument that denes an identication
string and the mandatory MATERIAL secondary keyword that associates a material to the zone. Then,
there may be zero or more optional secondary keywords with arguments that dene the geometric
place of the zone. There is also one optional secondary keyword INCREMENTAL.
ZONE name MATERIAL mat [ X_MIN expr ] [ X_MAX expr ] [ Y_MIN expr ] [ Y_MIN expr ] [
Z_MIN expr ] [ Z_MAX expr ] [ X_CENTER expr ] [ Y_CENTER expr ] [ INNER_RADIUS
expr ] [ OUTER_RADIUS expr ] [ INCREMENTAL ]
The identication name should be unique for each zone. Milonga gives an error if two zones have
the same name. The material should be one dened with a MATERIAL primary keyword (section 3.5),
and the name is case sensitive. It is not needed to have the material dened before the zone in the
input le, so the material denitions can be left to the end of the leor maintained in an INCLUDEd
lefor readability.
By default, if no geometry keywords are entered, the zone spans the whole bare prism. Currently,
only prisms with faces parallel to the bare prisms and circles in the r-n plane are supported in this
version. The limits can be given as expressions, as long as there are no intermediate blanks. Use quotes
if needed, as explained in section 3.1. The units should be the same as the units of x bare length.
If the min or max keywords are given, the zone is limited by a plane perpendicular to the specied
axis, otherwise the zone extends up to the bare prism limit in that direction. In two dimensions, a
circle can be entered by giving the coordinates of the center and the radius. An annulus is entered by
giving also a value for the inner radius.
Zones entered last in the input le overwrite zones previously dened. If the optional keyword
INCREMENTAL is given, then the cross sections of the material associated are algebraically added to
whatever zones are existing under the new one.
For example, to dene one single region that spans the whole bare prism with a material named
fuel, write
ZONE cor e MATERIAL f ue l
To dene a 2010 (in whatever units x bare length is) rectangle centered in the bare square,
enter
ZONE r ec MATERIAL f ue l { X_MIN x b ar e l e ng t h /210 X_MAX x b ar e l e ng t h /2+10
Y_MIN y b ar e l e ng t h /25 Y_MAX y b ar e l e ng t h /2+5 }
If a zone is to have a circular shape, X CENTER, Y CENTER and OUTER RADIUS have to be given.
To make an annulus, provide also INNER RADIUS. To illustrate this and the overlapping logic, consider
these two equivalent denitions:
ZONE r e f l MATERIAL r e f l e c t o r X_CENTER 200 Y_CENTER 200 OUTER_RADIUS 200
ZONE cor e MATERIAL f ue l X_CENTER 200 Y_CENTER 200 OUTER_RADIUS 180
ZONE cor e MATERIAL f ue l X_CENTER 200 Y_CENTER 200 OUTER_RADIUS 180
ZONE r e f l MATERIAL r e f l e c t o r X_CENTER 200 Y_CENTER 200 OUTER_RADIUS 200
INNER_RADIUS 180
Note that currently milonga does not support internal vacuum zones, i.e. zones that are surrounded
with materials but that are not assigned to any material themselves.
ii
milonga v0.1
3.4 Boundary conditions
To set the problem boundary conditions, milonga detects the external surfaces of the zones dened
that may or may not coincide with the bare prism external surfacesand applies the equations
described in section section 2.3 to the corresponding cells. The default boundary condition is to
require null ux at the external surfaces. This version supports either this default behavior or mirror
conditions on planar surfaces. Circular external surfaces always have null ux conditions.
To change from null to mirror conditions, use the primary keyword BOUNDARY CONDITIONS. This
keyword takes optional secondary keywords that dene the kind of boundary condition for each axis
and for each direction
BOUNDARY_CONDITIONS [ X_MIN ( NULL | MIRROR) ] [ X_MAX ( NULL | MIRROR) ] [ Y_MIN (
NULL | MIRROR) ] [ Y_MAX ( NULL | MIRROR) ] [ Z_MIN ( NULL | MIRROR) ] [ Z_MAX (
NULL | MIRROR) ]
The order in the input le at which the BOUNDARY CONDITIONS keyword appears is irrelevant. If
one secondary keyword is omitted, the corresponding boundary condition is taken as NULL by default.
For example, in one dimension to have mirror conditions in the left and null ux in the right, use
BOUNDARY_CONDITIONS X_MIN MIRROR
Even though external circular surfaces are forced to have null ux, the bare prism surfaces may
belong to a circle and have mirror conditions as well. For example, to implement a quarter of a
symmetric circular core dene
PROBLEM DIMENSIONS 2 GROUPS 1
x b ar e l e ng t h = 50
y b ar e l e ng t h = 50
ZONE cor e MATERIAL f ue l X_CENTER 0 Y_CENTER 0 OUTER_RADIUS 50
BOUNDARY_CONDITIONS X_MIN MIRROR Y_MIN MIRROR
Keep in mind that the requirement of null uxes in a discrete domain may lead to articial negative
cell uxes depending on the relative position of the cell center and the external surface, as explained
in page 29 and depicted in gure 2.14.
3.5 Materials
The zones discussed in section 3.3 have one associated material, that is dened with the MATERIAL
primary keyword. Note that one zone has only one associated material, but one material can be
associated to more than one zone. The order at which the materials are dened in the input le is
irrelevant.
MATERIAL name [ D 1 expr ] [ D 2 expr ] [ . . . ] ( [ SigmaA 1 expr ] [ SigmaA 2 expr ]
[ . . . ] | [ SigmaT 1 expr ] [ SigmaT 2 expr ] [ . . . ] ) [ nuSigmaF 1 expr ] [
nuSigmaF 1 expr ] [ . . . ] [ SigmaS 1 . 1 expr ] [ SigmaS 1 . 2 expr ] [ . . . ] [ SigmaS 2
. 1 expr ] [ SigmaS 2 . 2 expr ] [ . . . ] [ . . . ] [ ESigmaF 1 expr ] [ ESigmaF 2 expr ]
[ . . . ]
The identication name should be unique for each material. Milonga gives an error if two materials
have the same name. The name is case sensitive. Secondary keywords dene the nuclear parameters
that characterize the material. If no information is entered about a certain parameter, it is taken as
being identically equal to zero.
These secondary keywords have a main name that represents the kind of nuclear parameter, fol-
lowed by an underscore and then a group number, except SigmaS that have two group numbers
ij
milonga v0.1
Keyword Symbol Description Units
D 1 Diusion coecient length
SigmaA
a
Absorption macroscopic cross section length
1
SigmaT
t
Total macroscopic cross section length
1
nuSigmaF
f
Product of the mean number of neutrons born in a
ssion times the ssion macroscopic cross section
length
1
SigmaS
s
Scattering macroscopic cross section length
1
ESigmaF 1
f
Product of the mean energy released in a ssion times
the ssion macroscopic cross section
energy length
1
Table 3.1: Secondary keywords for the primary keyword MATERIAL. The symbols are the ones used throughout
chapter 2. Units of length have to be consistent with the geometry denition and units of energy have to be
consistent with the power setpoint, if given. Also, the character of the energy (prompt or total) should also
be consistent with the character of the power setpoint.
separated by a point .. Table 3.1 lists the main names, the description and the units of the expected
argument. The dots [. . . ] in the above syntax mean that one keyword for each energy group is
expected. For the scattering cross sections, all the G
2
groups combinations can be entered.
Milonga uses the total macroscopic cross sections for the multigroup formulation (2.14). However,
lattice codes usually output the absorption cross section instead. As these two parameters are related
by

t
(o) =
a
(o) +
G

=1

s
(o o

)
the total cross section can be computed by milonga from the absorption and scattering cross sections.
The nuclear parameters entered should be consistent with the mathematical development discussed
in section 2.1.1. Again, it is stressed that it is the users responsibility to assure that the macroscopic
cross sections are as expected by milonga according to its multigroup formulation.
The scattering cross sections keywords are formed with two group numbers separated by a point.
The rst number is the energy group of the impinging neutrons and the second is the energy of the
scattered neutrons. That is to say, SigmaS 1.2 is the scattering cross section from group one to
group two, i.e., the down-scattering cross section when taking as usual the rst group as the thermal
one in a two-group formulation. Note that when entering the absorption cross section instead of the
total cross section, the value of the self-scattering cross section is irrelevant, as it appears both in a
positive and in a negative term in equation (2.14) and cancels out.
When giving a power setpoint, the ESigmaF keywords should also be given for at least one material.
This values represent the product of the energy released in a single ssion times the macroscopic ssion
cross section for each group, and is used to compute the reactor power as explained in section 2.4.2.
It is important to note that consistency is expected both in the units and in the sense of prompt or
total character of the ssion energy and the power setpoint values as discussed in page 35.
Of course, nuclear properties may change within the same material because the parameters on
which the cross sections depend may have non-trivial spatial distributions. This dependence can be
taken into account by employing mathematical expressions instead of numerical constants as argu-
ments to the secondary keywords of MATERIAL. These expressions can be explicit or implicit functions
of the special variables x, y and z, that will be replaced by milonga with the components of the po-
sition vector r when evaluating the cell nuclear properties as explained in section 2.2. In general,
macroscopic cross sections depend on certain parameterssuch as temperatures or burn-upthat, in
turn, have a certain spatial distribution.
i6
milonga v0.1
For example, if
a
depends on the fuel temperature T
cool
and the coolant temperature T
cool
as a
two-dimensional scalar eld 1(T
fuel
. T
cool
) and, in turn, the spatial distribution of the fuel and coolant
temperature is given by o(r. n. .) and /(r. n. .) repectively, then

a
(r. n. .) = 1

o (r. n. .) . /(r. n. .)

To implement this in milonga, assume you have dened multidimensional functions 1(T
fuel
. T
cool
),
o(r. n. .) and /(r. n. .) that interpolate scattered data provided in a text le using wasoras common
framework keywords:
FUNCTION f ( t f ue l , t c ool ) FILE si gmaa . dat
FUNCTION g ( x , y , z ) FILE t f ue l di s t . dat
FUNCTION h( x , y , z ) FILE t cool di s t . dat
Then, the appropriate expression for the absorption cross section within the material denition
would be
MATERIAL f ue l SigmaA 1 f ( g ( x , y , z ) , h( x , y , z ) ) [ . . . ]
One big deal of milongas exibility discussed in section 1.2 appears around the collection of
available ways to enter this distributions. The expressions for the nuclear properties should provide
functions of rthrough r, n and .that are continuous in the sense that they should be prone
to be evaluated at any arbitrary point of the spatial domain, and not be limited to be computed
only at discrete points. These expressions can use any of the wasoras features related to function
manipulation. Functions can be provided algebraically or read from scattered data from les or
from external codes trough shared memory objects. Many interpolation methods for one and more
dimensions are available, and further operations on functions such as integration or dierentiation can
be done.
To illustrate the joint usage of the MATERIAL keyword with continuous functions, consider the
following denition, where a one-dimensional fuel and temperature distributions are assumed and the
cross sections of the fuel are entered as central values plus partial derivatives multiplied by parameters
increments:
FUNCTION Tf uel ( x ) = 400 + 200 si n ( x pi /300)
FUNCTION Tcool ( x ) = 250 25cos ( x pi /300)
MATERIAL f ue l {
D 1 1
SigmaA 1 1. 0 e2 + 1e 4( Tf uel ( x) 400) 5e 5( Tcool ( x) 250)
nuSigmaF 1 1. 2 e2 + 5e 5( Tf uel ( x) 400)
}
Further and complete examplesincluding multidimensional interpolation casescan be found in
chapter 4.
3.6 Collecting results
Milonga uses special variables both for gathering information to solve the problem and for giving back
the results to the user. The most important variable is called
k e f f
i
milonga v0.1
that contains the eective multiplication factor as obtained by solving the eigenvalue problem. This
variable is dened when starting the execution and initialized to one, and its content is lled with
the correct value after the rst ZONE keyword. That is to say, any algebraic expression involving
keff should appear after the last zone was dened. For example, in
rho1 = ( k e f f 1)/ k e f f
ZONE f ue l MATERIAL f ue l
rho2 = ( k e f f 1)/ k e f f
only variable rho2 contains the correct reactivity of the problem being solved, while rho1 is equal
to zero.
The other output variables given by milonga are
k e f f e r r o r
b ui l d t i me
s ol v e t i me
The rst one, keff error, gives an estimation of the absolute error committed in the solu-
tion of the eigenvalue problem, build time that gives the time needed to build the matrices and
solve time that gives the time needed to solve the eigenvalue problem. As with keff, these vari-
ables contain usable values in expressions that appear after the rst zone denition. Times are given
in seconds, and refer to the actual time elapsed and not to the CPU time used. They both may depend
on how busy the operating system scheduler is, whether memory access is cached or swapped, etc.
Information about spatial distributions are given as functions. The ux distribution for group o
is given in a function named
f l u x g
where o is supposed to be replaced by the actual group number. The rstusually the fastgroup
is number one. The functions take as many arguments as the spatial dimension of the problem.
They are point-wise dened, with the independent variable being the location of the cell center and
the independent variable being the ux of the corresponding group. Nevertheless, the functions are
linearly interpolated, and as such they can be evaluatedor integrated, dierentiated, etcat any
point.
These functions can be used wherever a function can appear in any valid expression handled by
wasora. For example, if used within a PRINT FUNCTION there is no need to provide the selected range
as by default a point-wise dened function will be printed just in the denition points. However, if a
range is specied, the function will be interpolated and evaluated at the positions asked for. Consider
for example a one-group one-dimensional problem with 20 nodes. Then
FILE nodes nodes . dat
FILE i nt e r p i nt e r po l a t i o n . dat
PRINT_FUNCTION FILE nodes f l ux 1
PRINT_FUNCTION FILE i nt e r p f l ux 1 MIN 0 MAX 100 STEP 0. 1
creates a le nodes.dat containing twenty lines with the cell center-ux pairs, while the other le,
interpolation.dat, contains one thousand lines with the intermediate interpolated values in a
ready-to-plot text format. If no power setpoint is given (section 3.7), uxes are in dimensionless units
such that the mean valueas discussed in section 2.4.2is equal to one. Otherwise, uxes have units
of inverse squared length and inverse time.
Even though the functions are point-wise dened, they can be evaluated at any point in space. For
example, if there is a neutron detector located at r = (153. 241. 308) then its reading may be assigned
to a variable by
i8
milonga v0.1
de t e c t or 1 = f l ux 2 ( 153 , 241 , 308)
although there may not be a cell located at that point. Details about function interpolation can be
found in wasora documentation.
Information about the resulting cell cross sections values can be obtained by using the functions
D g
SigmaT g
SigmaA g
nuSigmaF g
ESigmaF g
They are also linear-interpolated point-wise dened functions containing the macroscopic cross
section associated to the cell discussed in section 2.2, according to the selected method as explained
in section 3.8.
There is one function named
bc
that is also point-wise dened that shows which cells contain boundary condition equations instead of
the diusion equation. It is non-zero only for the location of the cells that have boundary conditions
equations. The actual value is not important, as is an internal identication number for each type of
condition.
There are ve additional functions which give information about the actual original continuous
spatial cross sections distributions, i.e. before the association to the discrete cells:
cD
cSigmaT
cSigmaA
cnuSigmaF
cESigmaF
The c in the name means continuous, and it is included because it is not so common to ask
milonga for the continuous cross section distribution as having variables called D or nuSigmaF. Thus,
the extra c avoids name conicts. Note that these functions do not incorporate the group number
in its name. Rather, they take + 1 arguments, being the rst one the group number and the rest
the spatial position. For example, to evaluate the total cross section at point r = (10.5. 25.2. 4.3) of
group number 3, ask for
PRINT cSigmaT( 3 , 1 0 . 5 , 2 5 . 2 , 4 . 3 )
They are not point-wise dened, so when using them within a PRINT FUNCTION keyword, a range
is mandatory, as explained below.
In general, one or more of these functions are part the desired output of milonga. This information
might be passed forward to other codes for further calculation or might be written to les for analysis
and interpretation (as in the last step of gure 2.1). These features are part of the common wasora
framework, and are explained in the associated documentation. However, for completeness, a brief
summary of output keywords is presented. In order to write information into a le, rst the FILE
primary keyword has to used
FILE i d path [ STEP ]
io
milonga v0.1
The two mandatory arguments are an internal identication string and the actual le path, which
can be either absolute or relative to the actual directory. If the optional secondary keyword STEP is
given, then one dierent le for each step is created, appending the step number to the le path. In
any case, if the le already exists, it is overwritten.
The keywords used to print data are
PRINT [ FILE i d ] [ CONDITION expr ] [ expr1 | TEXT s t r i ng1 ] [ expr2 | TEXT s t r i ng2 ]
[ . . . ]
PRINT_FUNCTION [ FILE i d ] [ CONDITION expr ] f unct i on1 [ f unct i on2 ] [ f unct i on3 ]
[ . . . ] [ MIN x min [ y min [ z mi n ] ] MAX x max [ y max [ z max ] ] STEP x s t ep [
y s t ep [ z s t e p ] ] ]
If no le is given, default is to write to standard output. If a condition is given, the argument
expression is evaluated and the print instruction is executed only if it is nonzero. For the PRINT
keyword, a list of expressions or text strings are expected. Each PRINT keyword produces a single
line. For the PRINT FUNCTION keyword, a list of functions is expected. All the requested functions
ought to have the same number of arguments. The PRINT FUNCTION produces one line for each
requested point, with the values of the independent variables in the rst columns and then one
column for each requested function with the value the function evaluates to at that point. If the
rst function is point-wise dened, it is not needed to give the range with the MIN, MAX and STEP
secondary keywords, and the output points are the denition points of the rst function, even if the
other functions are not point-wise dened. Anyway, the output points can be dened giving minimum,
maximum and increment values for the independent variables, according to the number of arguments
of the functions. If the rst function is not point-wise dened (for example given by an algebraic
expression) the the range is mandatory. Actually, these primary keywords can take more optional
secondary keywords. See the wasora documentation for further information.
For example, valid constructions for the PRINT keyword are
PRINT 1+1
PRINT TEXT the e i ge val ue problem insumed s ol v e t i me TEXT seconds
FILE output outputs / r e s u l t s . t xt
PRINT FILE output ( k e f f 1)/ k e f f s ol v e t i me
PRINT CONDITION greater ( k e f f , 1 ) TEXT the r e ac t or i s s u p e r c r i t i a l
To produce a text le containing the fast and thermal ux distribution, simply enter
FILE f l ux f l ux . dat
PRINT_FUNCTION FILE f l ux f l ux 1 f l u x 2
To obtain the continuous macroscopic cross sections, a range is mandatory because they are not
point-wise dened. For example, in a two-dimensional problem, one may want to do
PRINT_FUNCTION cSigmaA 1 cnuSigmaF 2 MIN 1 0 0 MAX 1 x b ar e l e ng t h
y b ar e l e ng t h STEP 1 0. 1 x b ar e l e ng t h / x c e l l s 0. 1 y b ar e l e ng t h / x c e l l s
to obtain a representation of the absorption and nu-ssion cross sections with a resolution of 10 10
grid for each cell. Chapter 4 has a lot of further examples and applications of these two keywords.
3.7 Power and xenon distribution
By default, milonga normalizes the eigenvector obtained by solving the discrete multigroup diusion
problem to obtain a dimensionless ux distribution with mean value equal to one unit of ux, as
discussed in section 2.4.2. To obtain a dimensional ux distribution with physical meaning, a power
jo
milonga v0.1
setpoint has to be given. Also, values for 1
f
for at least one zone has to be given, in order to
compute the normalization factor. The power setpoint is entered by means of the special variable
power
The units of the setpoint power given in variable power depend on the number of spatial dimen-
sions of the problem. For three-dimensional cases, units are power, i.e., energy and inverse time. In
two dimensions, power is a power density per unit length perpendicular to the r-n plane in energy
inverse time inverse length. In one dimension, it is a density per unit area perpendicular to the r axis
in units of energy inverse time inverse squared length.
If the power variable is set to a non-zero value, two functions of space are dened:
power dens i t y
xenon
The rst one gives the power density dissipated locally at position r in units of energy inverse times
inverse cubed length. As with the uxes, this function is linearly-interpolated point-wise dened, and
can be used to coupled milonga with thermalhydraulic or plant codesas with any other function or
variable within the wasora framework. It can also be used the power peak factor, for example in one
dimension:
peak = max( power dens i t y ( x ) , x , 0 , x b ar e l e ng t h ) /( power/ x b ar e l e ng t h )
The other function is called xenon, and contains the steady-state xenon concentration distribution
associated to the last computed neutron ux distribution, in units of inverse cubed length. To compute
this function, equation (2.46) is used. There are some defaults for the yields, the xenon decay constant
and the number of neutrons emitted in one ssion, but they can be changed by means of the following
variables
gamma I
gamma Xe
l ambda I
lambda Xe
nu
whose default values are
gamma I = 6. 386 e2
gamma Xe = 2. 28 e3
l ambda I = 2. 878 e5 # [ 1/ sec ]
lambda Xe = 2. 10 e5 # [ 1/ sec ]
nu = 2. 4
Note that the steady-state xenon concentration does not depend on
I
, so this variable is not used
in this version. Iodine and xenon yieldsi.e. how many nuclei of
135
I and of
135
Xe appear promptly
by a single ssionand may be changed according to the type of fuel used in the problem. The
decay constantswhose default value is given in inverse secondsare physical constants rather than
variables, but the user may want to change
Xe
to study and try to understand how xenon poisoning
works while in college or while having to develop a power distribution control algorithm, or to use a
time unit dierent than seconds.
The microscopic neutron absorption of
135
Xe is entered as a vector of size G named
sigmaAXe
j1
milonga v0.1
whose individual elements can be set as with the chi vector. The default behavior is to have zero
absorption for every group except for the last oneconsidered the thermal group. Assuming a two-
group problem, vector sigmaAXe is set to
sigmaAXe 1 = 0
sigmaAXe 2 = 2e18 # 1/cm2
that corresponds to a value of two million barns when lengths are measured in centimeters.
If the nuclear parameters given in the MATERIALS keywords do not depend on the xenon distribu-
tion, then the function xenon is only informative and does not need further treating. However, ifas
usualmacroscopic cross sections depend on the xenon distribution by means of direct reference to
the xenon function, an iterative calculation is needed.
As discussed in page 9, xenon and power distributions depend on each other. In the rst calculation,
it is assumed that there is no xenon in the reactor core. If xenon eects are to be taken into account, a
new power calculation is needed, giving rise to a new xenon concentration, and so on. To tell milonga
to make an iterative calculation, the special variable
s t a t i c i t e r a t i o n s
has to be set to a value greater than one. The current iteration number can be read from the content
of the special variable
s t a t i c s t e p
Convergence in the sense of equation (2.4) is not checked for. The user has to estimate a reasonable
value for static iterations. However, an explicit converge check can be made from within the
input le, setting the special wasora variable done to non-zero when a certain condition holds:
# [ . . . ]
# probl em d e f i ni t i o n
# [ . . . ]
s t a t i c i t e r a t i o n s = 20
# keep t he k e f f found i n t he pr evi ous s t ep
kol d = k e f f
# def i ne zones here so t he t he new k e f f i s computed at t h i s poi nt
ZONE f ue l MATERIAL f ue l
# g i v e t he user some f eedback i n st andard out put
PRINT s t a t i c s t e p k e f f
# s e t done t o t rue i f convergence i s at t ai ned
done = l ess ( abs ( k e f f kol d ) , 1e 6)
When printing distributions in an iterative calculation, output les should be dened using the
secondary keyword STEP to the primary keyword FILE. See the examples in the next chapter.
3.8 Numerical scheme settings
The basic numerical scheme and selections about how to associate cross sections to cells and how to
evaluate the leakage term are given by using the primary keyword SCHEME along with its secondary
keywords:
SCHEME [ VOLUMES | DIFFERENCES ] [ XS_MEAN | XS_CENTER ] [ [ D_EPSILON | D_MEAN ] | [
GRAD_D_LOCAL | GRAD_D_NEIGHBORS ] ] [ NO_NEGATIVE_FLUX | ALLOW_NEGATIVE_FLUX ]
j:
milonga v0.1
If the VOLUMES keyword is given, the leakage term is treated with the nite-volumes based method
as described in section 2.1.2, while DIFFERENCES keywords selects the nite-dierences method of sec-
tion (2.1.3). XS MEAN associates cross sections to cells according to equation (2.35) and XS CENTER
uses equation (2.36). For nite volumes, D EPSILON computes the diusion coecients at a dis-
tance c of the cell border, i.e. 1(r c), while D MEAN uses mean values in the proper half of the cell,
i.e. '1(r c)`. For nite dierences, GRAD D LOCAL makes milonga to evaluate the gradient of the
diusion coecient in equation (2.34) by locally dierentiating the continuous expressions of 1(r).
On the other hand, GRAD D NEIGHBORS computes the gradient by a nite-dierence approximation
using rst neighbors. When keyword NO NEGATIVE FLUX is given, if a ux happens to be negative
because of the application of discrete boundary conditions (gure 2.14), it is forced to be zero. Oth-
erwise, if keyword ALLOW NEGATIVE FLUX is entered, negative uxes are kept as computed by the
eigenvalue problem solver.
If no SCHEME keyword is entered, the default behavior is as if
SCHEME VOLUMES XS_MEAN D_MEAN NO_NEGATIVE_FLUX
was entered. For nite dierences, default is GRAD D NEIGHBORS.
The value of c is taken from the special variable
e ps i l on
that has units of length and is set to 10
2
by default.
When using XS MEAN, the integral in the numerator of equation (2.35) is computed by an adaptive
method, whose convergence criteria can be modied by setting the special variable
xs mean t ol erance
that is the relative error allowed. The default value is 10
2
meaning 1% tolerance. The computational
eort needed to build the problem matrices depends heavily on this parameter.
Another keyword that controls the behavior of the solution is
SOLVER [ METHOD [ SLEPC | NONE | us er ] ] [ EIGENVALUE_K | EIGENVALUE_INVERSE_K ] [
TOLERANCE t o l ]
Method can be either SLEPC (default), NONE to skip the eigenvalue problem solution (useful when
having problems with the nodalization and preparing a new problematic input le) or a user-dened
routine, as explained in section 3.14. If EIGENVALUE K is entered, the eigenvalue problem dened
by equation (2.41) is solved (default), whilst problem (2.42) is solved for EIGENVALUE INVERSE K.
Default is direct /
e
formulation. The optional tolerance is the value the relative residual |:
rel
|
has to take in order to considered the eigenvalue solution as converged, according to equation (2.43).
Default is to take SLEPcs default value that is equal to 10
7
.
3.9 Parametric calculations
The capability to perform parametric calculations is a feature of the wasora framework, and thus just
a brief summary is given here. By a parametric calculation, it is understood a series of computation
of the problem solution with a systematic variation of one or more parameters. In the case of milonga,
one or more variables can be swept through an interval, either linearly or exponentially.
To dene a linear parametric study, the following keyword has to be entered
PARAMETRIC var i abl e minimum maximum s t ep
The values min, max are the ends of the interval to be studied and step is the increment. They
cannot be expressions, they have to be oating point constants. If there selected variable has one or
more explicit assignments in the input le, they are ignored. For example,
j
milonga v0.1
PARAMETRIC a 1 10 1
a = 5
PRINT a
will output the natural numbers up to ten instead of ten values of ve.
If more than one PARAMETRIC keyword is given, multidimensional studies can be performed. The
variable in the rst PARAMETRIC keyword is incremented up to the maximum value, then the variable
in the second PARAMETRIC keyword is incremented one step and the rst variable starts from the
minimum value again, and so on.
Instead of incrementing the variable with a xed value, a logarithmicor exponential, depending
on the point of viewstudy can be done with
PARAMETRIC_LOG var i abl e minimum maximum s t ep
In this case, step is a multiplicative constant by which is multiplied the selected variable in each
calculation.
Each calculation step is independent from the previous one, i.e., the initial conditions of step n+1
are not the last conditions of step n. By default, milonga waits for the previous step to nish before
launching the next one. However, because of this reason, this kind of calculations are especially suitable
to take advantage of multicore architectures by running simultaneously two or more parametric steps.
To have milonga run in parallel, use
MAX_DAUGHTERS n
The parameter n is an integer representing the maximum number of process that may be launched
in parallel. If it is equal to zero, the number of available cores is taken. Default is one, meaning no
parallelization.
When performing parametric calculations, output les are renamed and the number of step is
attached to it. Standard output can be shared by all the steps, but because of random uncertainties
in the operating system scheduler the order of printing may not be the expected. For example,
MAX_DAUGHTERS 8
PARAMETRIC a 0 10 1
PARAMETRIC b 0 10 1
PRINT a b a+b
may not output the [1. 1] [10. 10] square in the correct order and plotting utilities may complain
about it. To overcome this diculty, one solution is to output each line to a le and the concatenate
all of them into a single one in the correct order. First,
MAX_DAUGHTERS 8
PARAMETRIC a 0 10 1
PARAMETRIC b 0 10 1
FILE out tmp
PRINT FILE out a b a+b
and then in the terminal
ji
milonga v0.1
$ milonga square.mil
$ cat tmp.
*
> output
$ rm tmp.
*
$
Note that although some calculations may be performed either by using parametric or iterative
calculations, they are essentially dierent in their nature. Each instance of a parametric calculation is
independent from previous oneindeed, they are dierent processes and can be run in paralleland
all the variables, functions and parameters are initialized for each instance. On the other hand, each
step of a parametric calculation keeps the variables and functions computed in the previous step.
Therefore, they are not independent and they cannot be run in parallel.
3.10 Debugging and benchmarking
One of the most important issues of an engineering computer code is the the running time. There are
many parameters that aect the computational time, and more often than not they depend on the
particular problem being solved. Milonga can dump some information about the numerical scheme
that may help the user to reduce the running time or simply provide extra output.
To obtain extra debug output, use the following keyword
DEBUG filename [MATRICES_ASCII] [MATRICES_BINARY]
The filename argument should be a full or relative path to the text le with the extra information.
Variables build time and solve time are included in the debug le. If the optional secondary
keyword MATRICES ASCII is given, an ASCII representation of the matrices 1 and 1 are included in
the le. If the secondary keyword MATRICES BINARY is given, two binary les called R and F in the
execution directory are created. They contain a binary dump of the matrices as created by PETScs
PetscViewerBinaryOpen and MatView functions, that can be accessed by using MatLoad [1].
There is a lot of useful information about the problem being solved that should be dumped in the
debug le. Future versions of milonga will include further debugging and bechmkarking options.
3.11 Commandline arguments replacement
Milonga takes as a rst argument the name of the input le to process. Using a wasora feature, more
optional arguments can be given, and then replaced in the input. If a the token $1 is entered in the
input le, it will be replaced by the rst non-le commandline argument, $2 with the next one, and
so on. For example
PRINT $1
will print whatever argument is given in the commandline after the input le:
$ milonga calc.mil 1+1
2.000000e+00
$
This can be useful to provide lenames from the commandline
jj
milonga v0.1
FILE output $1
FILE distribution $2
or to choose between several options without having to modify the input
SCHEME $1
If less arguments than the required are provided, milonga fails with an error.
3.12 Advanced eigenvalue solver settings
Besides commandline argument replacement, milonga can handle generic PETSc and SLEPc argu-
ments that are to be passed to their respective options databases. Thus, run-time options can be
changed by using the standard commandline key mechanism provided by these libraries [1, 2].
For example, the eigenvalue solver and the preconditioner can be changed
$ milonga test.mil -eps_type power -st_pc_type jacobi
Note that some solvers (and preconditioners) may work only in either the direct or inverse-/
e
problem (section 3.8). See the PETSc and SLEPc manuals [1, 2] for further reference.
3.13 External coupling
To be explained.
3.14 User-dened eigenvalue solver
To be explained.
3.15 If anything goes wrong
As stated in section 1.2, one of milongas the design basis vectors is resisting inconsistent or non-
physical values of cross sections. This may lead to singular matrices, zero pivots or other mathematical
problems involving invalid operations such as divisions by zero. Depending on the particular situation,
one may want the code to behave dierently. For example, sometimes when a singularity is found it
would be desirable to tell the user that there are some problems in the physics entered in the input
and to stop the calculation. But when running parametrically or inside an optimization loop, it would
be convenient just to ignore those cases and proceed with the next iterations.
All mathematical operations performed by wasora that may give rise to an invalid resultdivision,
square roots, logarithms, etcare checked and, in case the result is not a number, a handler is called.
What the code does is controlled by the following optional keyword in the input le
ON_NAN [INFORM | BE_QUIET] [QUIT | CONTINUE]
Default behavior is to print a message to the standard error output (INFORM) and quit immediately
(QUIT), but any combination of giving the error or not and continuing the execution or quitting may
be given.
j6
milonga v0.1
As wasora uses some features from the GNU Scientic Library [3], there may be run-time errors
when accessing one of these routinesfor example divergence of an integral, inconsistent data for
interpolation, etc. When an error is raised during a GSL call, also the default behavior is to report it
to the standard error and quit. This can be changed using
ON_GSL_ERROR [INFORM | BE_QUIET] [QUIT | CONTINUE]
Finally, when working with milonga, a PETSc error may arise if the neutronic problem is not well
dened. Again, the default behavior is to report and quit. The keyword to modify this is
ON_ERROR [INFORM | BE_QUIET] [QUIT | CONTINUE]
For example,
PRINT 1/0
gives
error: NaN found
while
ON_NAN CONTINUE BE_QUIET
PRINT 1/0
results in
inf
In the same sense, for example if a zone with a diusion coecient equal to zero is entered, probably
PETSc will complain through milonga with something like
error: PETSc error 71-1 Zero pivot row 99 value 3.20577e-15 tolerance 1e-12 in
src/mat/impls/aij/seq/aijfact.c MatLUFactorNumeric_SeqAIJ:574
Note that the keywords ON
*
dene the overall behavior. They do not work in a by-block basis.
The last keyword entered is how the code will behave for the whole input. For example
ON_NAN CONTINUE BE_QUIET
PRINT 1/0
ON_NAN INFORM
PRINT sqrt(-1)
gives
j
milonga v0.1
error: NaN found
inf
error: NaN found
0.000000e+00
i.e. as if
ON_NAN CONTINUE INFORM
PRINT 1/0
PRINT sqrt(-1)
was entered. A nal example illustrating ON GSL ERROR:
ON_GSL_ERROR INFORM QUIT
PRINT integral(1/(x-1),x,0,1.5)
error: gsl error 21 bad integrand behavior found in the integration interval in
qag.c
Bibliography
[1] Satish Balay, Jed Brown, , Kris Buschelman, Victor Eijkhout, William D. Gropp, Dinesh Kaushik,
Matthew G. Knepley, Lois Curfman McInnes, Barry F. Smith, and Hong Zhang. PETSc users
manual. Technical Report ANL-95/11 - Revision 3.1, Argonne National Laboratory, 2010.
[2] J. E. Roman, E. Romero, and A. Tomas. SLEPc users manual. Technical Report DSIC-II/24/02 -
Revisi on 3.1, D. Sistemas Informaticos y Computacion, Universidad Politecnica de Valencia, 2010.
[3] M. Galassi et. al. GNU Scientic Library Reference Manual. Third edition, 2009. ISBN 0954612078,
http://www.gnu.org/software/gsl.
j8
Chapter IV
Examples
Que haces, que haces?
Che, Rafael! A donde vas?
Al cabaret, a milonguear. . .
ando buscando una mina
y no la puedo encontrar!
Retintn (milonga), 1918
Not only do these examples show what kind of problems can be tackled by milonga, but alsoand
more importanthow to solve them. To obtain the most from this chapter, a thorough comprehension
of chapters 2 and 3 is recommended. However, as articial neural networks do, people learn mainly
by examples so probably this chapter can be read as it was a standalone document.
Examples are grouped by kinds of problems and, with some luck, introduced in an increasingly
complexity order. Even though they are based on basic reactor physics ideas, they do not refer nor
apply to any real engineering condition. It should be stressed again that these examples provide the
results obtained by solving the neutron diusion equation as discussed in chapter (2) and by no means
represent to any real nuclear reactor situation.
In each case, special emphasis is given to the feature that the example is trying to illustrate,
trying to keep as simple as possible the rest of the problem conditions. Thus, most of the cases are
one-dimensionalexcept those that illustrate how to manage higher dimensions problemsin order
to avoid introducing extra complications.
The output information and gures that conform the result of the problems solved in this chapter
were generated automatically from a series of scripts. Therefore, all the examples have the same
structure. First, a brief description of the problem along with a gure is given. Then, there may be
one or more milonga runs for each case, each having an explanatory paragraph. Then, the actual
input le is shown, along with a view of a ctitious terminal where the invocation of milonga and
some further processing for generating graphical plots and results is given. In fact, the actual gures
shown in this chapter were obtained by executing the commands shown in the terminal by using the
free-as-in-beer-but-not-as-in-speech plotting program gnuplot [1]. All gures are vector-based, so they
can be zoomed in without loosing resolution. A milonga executable with debugging symbols was used
to run the examples shown, so running times may dier when using optimized versions. The milonga
and gnuplot input les are available in the distribution package, so there is no need to cut & paste from
this document to further study, modify and tweak the examples. The commands shown in the sample
terminal outputs should be reproducible using the provided les. Feedback about these examples or
other desired test cases are welcome.
Enough chitchat. It is time to milonguear!
milonga v0.1
4.1 Cases with analytical solutions
The examples shown in this rst section have two advantages that are somehow related to each other:
they are both fairly simple and have an analytical solution. Thus, they are suitable for introducing
the usage of milonga and at the same time can be used to test whether things are being done well or
not, and moreover, to what extent.
Most of the them are one-group cases, as few-group problems either do not have analytical solutions
or they are so complicated that do not serve the point of being a reference. The only two-group problem
shown here corresponds to an innite reactor. The rest of the problems are bare one-speed problems,
except for the last one that represents a two-zone slab reactor.
4.1.1 Homogeneous bare slab
This problem consists of an homogeneous one-dimensional bare reactor with constant one-group neu-
tron cross sections, whose solution by the diusion approximation is one of the rst examples of
the solution of the diusion equation in nuclear reactor theory courses (see for example [2, section
9-2] and [3, section 5.III.C]). In particular a one-meter width slab is considered, with the one-group
constants shown in the gure.
ke.mil
This example computes the the eective multiplication factor /
e
for the slab above. See the comments
in the input le for details about the implementation in milonga. As can be seen, a small number of
keywords are used and thus most of the default options are automatically selected. The only output
obtain in the terminal after the execution of the code is the multiplication factor as computed from
the numerical eigenvalue problem in the default scientic notation format.
# computati on of t he k e f f f or a onedi mensi onal
# onegroup bare s l ab wi t h const ant XS
# def i ne t he number of s p a t i a l di mensi ons and groups
PROBLEM DIMENSIONS 1 GROUPS 1
x b ar e l e ng t h = 100 # bare l e ng t h i n cm
x c e l l s = 100 # number of c e l l s
ZONE f ue l MATERIAL f ue l # a s i ng l e zone spanni ng t he whol e bare l e ng t h
# composed of mat er i al f uel , def i ned bel ow
# d e f i ni t i o n of t he f u e l XS f or t he onegroup uni t s are t hos e of
# t he i nver s e x b ar e l e ng t h , i . e . 1/cm
MATERIAL f ue l {
D 1 1
SigmaA 1 0. 010
nuSigmaF 1 0. 012
}
# pr i nt t he mul t i p l i c a t i o n f ac t or i n t he st andard out put
# wi t h t he d e f a ul t format , i . e . s c i e n t i f i c not at i on
PRINT k e f f
6o
milonga v0.1
$ milonga keff.mil
1.092211e+00
$
comparisson.mil
Taking advantage milongasactually wasorasmathematical capabilities, it is fairly easy to compare
the numerical result obtained by using a spatial discretization with 100 cells to the actual analytical
solution for the one-dimensional one-group bare reactor. In this case, the input for the numerical
problem is almost the same, but the cross sections are entered as variables and used both for the
denition of the material and for the computation of the analytical value of the eective multiplication
factor, which is
/
e
=

f

a
+ 1

2
where o is the slab width. The output is now extended to include an informative string and a decimal
format is used to show at which digit the two solutions start to dier. The absolute dierence is shown
in scientic notation. In the comments, an explanation is given about the order in which the algebraic
expressions are computed. If you are tempted to change the number of cells to see what happens with
the dierence, please do it now. Nevertheless, in the examples of parametric calculations you will get
plenty of the kind of fun you are searching for.
# comparisson between t he numeri cal and a na l y t i c a l s ol ut i ons
# f or t he onedi mensi onal bare s l ab
PROBLEM DIMENSIONS 1 GROUPS 1
x b ar e l e ng t h = 100
x c e l l s = 100
# t hes e are pl ai n v a r i a b l e s used bot h f or ent er i ng t he XS i n
# t he MATERIAL keyword and i n computing t he a na l y t i c a l s ol ut i on
D = 1
SigmaA = 0. 01
nuSigmaF = 0. 012
# t he pl ace where t he MATERIAL keywords appear i n t he i nput
# i s i r r e l e v ant , but t he pl ace where t he ZONE keywords appear
# i s not . Al l t he al g e b r ai c expr es s i ons t hat appear bef or e t he
# f i r s t ZONE are computed bef or e s ol v i ng t he ei genval ue probl em ,
# and t he r e s t are computed a f t e r s ol v i ng t he ei genval ue probl em .
# This i s i mport ant i n t h i s exampl e because t he XS are eval uat ed
# wi t h t he i nf ormat i on a v a i l a b l e bef or e t he f i r s t ZONE keyword .
# Thus , t he v a r i a b l e s cont ai ni ng t he XS have t o be eval uat ed
# bef or e t he f ol l owi ng l i ne .
ZONE f ue l MATERIAL f ue l
# t he XS can be any v a l i d mat hemat i cal expressi on , i nc l udi ng
# const ant s , v ar i ab l e s , al g e b r ai c expres s i ons , f unct i ons , et c .
# Furt her exampl es of XS wi l l be gi ven i n subsequent exampl es .
# In t h i s one , we are usi ng t he v a r i a b l e s def i ned above , t hat
# shoul d be f i l l e d bef or e t he f i r s t ZONE keyword
MATERIAL f ue l {
D 1 D
SigmaA 1 SigmaA
61
milonga v0.1
nuSigmaF 1 nuSigmaF
}
# t he a na l y t i c a l s ol ut i on can be eval uat ed now or bef or e t he
# ZONE, i t does not matter . But , i f t he k e f f v ar i ab l e i s
# r e f e r e d t o bef or e t he ZONE, i t s val ue i s equal t o one .
pi = 4atan( 1)
k = nuSigmaF/( SigmaA + D( pi / x b ar e l e ng t h ) 2)
# pr i nt t he s ol ut i ons
PRINT TEXT a na l y t i c a l k e f f = k FORMAT %.8 l f
PRINT TEXT numeri cal k e f f = k e f f FORMAT %.8 l f
PRINT TEXT d i f f e r e n c e = abs ( kk e f f )
$ milonga comparisson.mil
analytical keff = 1.09220381
numerical keff = 1.09221091
difference = 7.101524e-06
$
ux.mil
The last example regarding the bare slab shows how to easily plot a function of a single variable.
Even though the ux is computed at the cells centers, milonga provides a continuous function by
interpolating the results that can be integrated, dierentiated, etc. This example shows how to plot
the ux distribution at the computed points using the PRINT FUNCTION without the necessity of
giving the actual plot points. Other examples will deal with the continuous interpolation.
This example also shows how to compare the numerical solution with the analytical one (remember
the obtained ux has mean value equal to one):
(r) =

2
sin

o
r

for one hundred cells (examples showing how this dierence varies with the cell number are about to
come). Milonga gives as output three columns containing the r-coordinate, the numerical ux and the
analytical ux. This information can be easily plotted using gnuplot, as shown in the terminal output
by catting the les fluxes.gnuplot and diff.gnuplot. These are listed here for completeness.
In other examples the les used to obtain the output gures may or may not be shown depending
on the complexity of the gure. However, the les generated by milonga can be plotted or further
processed by any other software as they consist of tab-separated columns. In this example the ux
distribution is written to the standard output, and is redirected to a le from the commandline as
shown in the terminal output.
Note that in this example, the two plotted columns do not refer to the same quantities, as the
rst is the mean ux in each cell and the former is the continuous ux evaluated at the cell center,
as discussed in the mathematical development of the nite volumes scheme. However, the dierence
should be minimal and they are assumed to be equal as in equation (2.16).
# onedi mensi onal bare s l ab f l u x d i s t r i b u t i o n
PROBLEM DIMENSIONS 1 GROUPS 1
x b ar e l e ng t h = 100
x c e l l s = 100
D = 1
SigmaA = 0. 01
nuSigmaF = 0. 012
6:
milonga v0.1 0.0e+00 1.0e-04 2.0e-04 3.0e-04 4.0e-04 5.0e-04 6.0e-04
0 10 20 30 40 50 60 70 80 90 100 x
relative error between theoretical and numerical uxes
ZONE f ue l MATERIAL f ue l
MATERIAL f ue l {
D 1 D
SigmaA 1 SigmaA
nuSigmaF 1 nuSigmaF
}
# t he f l u x i s gi ven i n a f unct i on of t he v ar i ab l e x c a l l e d
# f l ux 1 ( x ) . I t i s def i ned f or every val ue of x by a l i ne ar
# i nt e r p o l a t i o n of t he f l u x e s computed at each c e l l . By
# de f aul t , t he f l u x i s such t hat t he mean val ue i s equal t o
# one . On t he ot her hand , an al g e b r ai c f unct i on wi t h t he
# a na l y t i c a l s ol ut i on of t he probl em havi ng a mean val ue
# equal t o one can be cons t r uct ed as f o l l o ws :
pi = 4atan( 1)
FUNCTION phi ( x ) = pi /2 si n ( pi x/ x b ar e l e ng t h )
# as f l ux 1 i s def i ned i n a f i n i t e number of abs ci s s ae ,
# by d e f a ul t i t i s pr i nt ed i n t hes e val ues of x i f no
# range i s gi ven . Function phi i s al gebr ai c , but i t uses
# t he range of t he f i r s t f unct i on i n t he l i s t .
PRINT_FUNCTION f l ux 1 phi
$ milonga flux.mil > flux.dat
$ cat fluxes.gnuplot
set terminal pdf
set output "fluxes.pdf"
set title "bare-slab flux"
set xlabel "x"
set border 3
set tics nomirror
set tics scale 0.2
set ytics format "%.1e"
plot "flux.dat" lt 3 ps 0.5 ti "numerical", "flux.dat" u 1:3 lt 7 w l ti "
analytical"
$ gnuplot fluxes.gnuplot
$ cat diff.gnuplot
set terminal pdf
set output "diff.pdf"
set title "relative error between theoretical and numerical fluxes"
set xlabel "x"
set border 3
set tics nomirror
set tics scale 0.2
set ytics format "%.1e"
set ytics 1e-4
unset key
plot "flux.dat" u 1:(($3-$2)/$3) w lp pt 2 ps 0.25
$ gnuplot diff.gnuplot
$
6
milonga v0.1
0.0e+00
2.0e-01
4.0e-01
6.0e-01
8.0e-01
1.0e+00
1.2e+00
1.4e+00
1.6e+00
0 10 20 30 40 50 60 70 80 90 100
x
bare-slab ux
numerical
analytical
0.0e+00
1.0e-04
2.0e-04
3.0e-04
4.0e-04
5.0e-04
6.0e-04
0 10 20 30 40 50 60 70 80 90 100
x
relative error between theoretical and numerical uxes
4.1.2 Homogenoeus bare square
This example is an extension to two dimensions to the bare slab. It consists of an homogeneous
one-speed bare square. The gnuplot input les are also shown in the terminal output to illustrate how
to obtain two-dimensional contour levels for the ux. The rst example has the same number of cells
in each direction, while the second one does not. Also, an illustration of how to use both the standard
output and output les using the FILE keyword is given.
6i
milonga v0.1
0 10 20 30 40 50 60 70 80 90100 0 102030405060708090100 0 0.5 1 1.5 2 2.5
ux with an uniform mesh
00.5 11.5 22.5
uniform.mil
The input that follows solves the one-group neutron diusion equation in an homogeneous square,
where the variable y bare length is set equal to x bare length. The number of cells in each
dimension is the same, by also setting the variable y cells equal to x cells. The /
e
is evaluated
both analytically and numerically, and the ux distribution is written into a le that can be directly
plotted with gnuplot or another similar tool.
# twodi mensi onal bare s l ab f l u x d i s t r i b u t i o n
PROBLEM DIMENSIONS 2 GROUPS 1
x b ar e l e ng t h = 100
y b ar e l e ng t h = x b ar e l e ng t h # t h i s f or c e s t he geometry t o be a square
x c e l l s = 100
y c e l l s = x c e l l s # t h i s f or c e s c e l l s t o be squares
D = 1
SigmaA = 0. 01
nuSigmaF = 0. 012
ZONE f ue l MATERIAL f ue l
MATERIAL f ue l {
D 1 D
SigmaA 1 SigmaA
nuSigmaF 1 nuSigmaF
}
# a na l y t i c a l e f f e c t i v e mul t i p l i c a t i o n f ac t or
pi = 4atan( 1)
k = nuSigmaF/( SigmaA + D( ( pi / x b ar e l e ng t h ) 2 + ( pi / y b ar e l e ng t h ) 2) )
# wr i t e t he f l u x d i s t r i b u t i o n t o a f i l e
FILE f l ux uni f orm . dat
# t he f l u x i s eval uat ed at t he computed poi nt s aut omat i cal l y
PRINT_FUNCTION FILE f l ux f l ux 1
# and t he k e f f t o t he screen
PRINT TEXT numeri cal k e f f = k e f f
PRINT TEXT a na l y t i c a l k e f f = k
PRINT TEXT d i f f e r e n c e = abs ( k e f f k)
$ milonga uniform.mil
numerical keff = 1.002190e+00
analytical keff = 1.002178e+00
difference = 1.195821e-05
$ cat uniform2d.gnuplot
set terminal pdf
set output "uniform2d.pdf"
set title "flux with an uniform mesh"
set size square
plot "uniform.dat" w image
$ gnuplot uniform2d.gnuplot
$ cat uniform3d.gnuplot
set terminal pdf
set output "uniform3d.pdf"
set title "flux with an uniform mesh"
set ticslevel 0
unset key
splot "uniform.dat" u 1:2:3 palette pt 59 ps 0.1
$ gnuplot uniform3d.gnuplot
$
6j
milonga v0.1
0
20
40
60
80
100
0 20 40 60 80 100
ux with an uniform mesh
"uniform.dat"
0
0.5
1
1.5
2
2.5
0
10
20
30
40
50
60
70
80
90
100
0
10
20
30
40
50
60
70
80
90
100
0
0.5
1
1.5
2
2.5
ux with an uniform mesh
0
0.5
1
1.5
2
2.5
nonuniform.mil
This example is quite similar to the previous one, but the number of cells in the n-direction is one-
fth of the number of cells in the r-direction. The ux distribution output is evaluated at the
computed points automatically by milonga. The eects of the dierent discretizations is studied in
other examples.
# onedi mensi onal bare s l ab f l u x d i s t r i b u t i o n
PROBLEM DIMENSIONS 2 GROUPS 1
x b ar e l e ng t h = 100
y b ar e l e ng t h = x b ar e l e ng t h
x c e l l s = 100
# t he f ol l owi ng l i ne s e t s t he number of y c e l l s t o
# one f i f t h of what ever x c e l l s i s s e t t o . I f t he
# r e s u l t i s not i nt e g r al , t he val ue i s rounded t o
# t he neares t i nt e g e r
y c e l l s = x c e l l s /5
D = 1
66
milonga v0.1
SigmaA = 0. 01
nuSigmaF = 0. 012
ZONE f ue l MATERIAL f ue l
MATERIAL f ue l {
D 1 D
SigmaA 1 SigmaA
nuSigmaF 1 nuSigmaF
}
pi = 4atan( 1)
k = nuSigmaF/( SigmaA + D( ( pi / x b ar e l e ng t h ) 2 + ( pi / y b ar e l e ng t h ) 2) )
FILE f l ux nonuni form . dat
# no need t o change t h i s l i ne wi t h r e s pe c t t o t he pr evi ous
# example , mil onga knows where f unct i on f l u x 1 i s def i ned
PRINT_FUNCTION FILE f l ux f l ux 1
PRINT TEXT numeri cal k e f f = k e f f
PRINT TEXT a na l y t i c a l k e f f = k
PRINT TEXT d i f f e r e n c e = abs ( k e f f k)
$ milonga nonuniform.mil
numerical keff = 1.002253e+00
analytical keff = 1.002178e+00
difference = 7.522534e-05
$ gnuplot nonuniform2d.gnuplot
$ gnuplot nonuniform3d.gnuplot
$
0
20
40
60
80
100
0 20 40 60 80 100
ux with a non-uniform mesh
"nonuniform.dat"
0
0.5
1
1.5
2
2.5
6
milonga v0.1
0
10
20
30
40
50
60
70
80
90
100
0
10
20
30
40
50
60
70
80
90
100
0
0.5
1
1.5
2
2.5
ux with a non-uniform mesh
0
0.5
1
1.5
2
2.5
4.1.3 Homogeneous bare circle
Now a bare circular one-speed reactor is solved. To dene the geometry, secondary keywords have to
be given to the primary keyword ZONE to prevent the zone to expand to the whole bare length. Note
that the error committed in the computation of /
e
is greater than that of the bare square because
of the introduction of discrete circular boundary conditions. Some capabilities of the wasoras com-
mon framework for working with multidimensional functions are also shown. The analytical solution
involves the use of the lowest-order two-dimensional Laplacian eigenfunction with null boundary con-
ditions over a circle, namely Bessels J
0
function. As wasora does not provide evaluation of Bessels
functions, the prole comparison is made by making use of gnuplot capabilities.
full.mil
This input computes the one-group ux inside a a full homogeneous circle of radius 1 = 100 cm. The
cells that are marked to have a boundary condition instead of the diusion equations are shown by
printing the bc function. This example uses the default behavior of forcing negative uxes to zero
at boundary condition cells, eect that can be seen as a discontinuity in the colors when zooming
into the border of the ux distribution contour plot. The radial ux prole is computed by den-
ing a one-dimensional function bessel from the two-dimensional ux distribution. It is compared
to the analytical solution by plotting this continuous function along with gnuplots Bessel function
implementation.
# twodi mensi onal bare c i r c l e
68
milonga v0.1
PROBLEM DIMENSIONS 2 GROUPS 1
# f i l e s t o out put t he f u l l 2D d i s t r i b u t i o n and t he r adi al
# d i s t r i b u t i o n t o compare t o t he a na l y t i c a l p r o f i l e . The
# l oc at i on of t h i s d e f i ni t i o n i ns i de t he i nput f i l e does
# not matter , onl y t he PRINT i ns t r uc t i ons are execut ed
# i n t he gi ven order
FILE f l ux f u l l . dat
FILE r a di a l r a di a l . dat
# square bare geometry and square c e l l s
x b ar e l e ng t h = 100
y b ar e l e ng t h = x b ar e l e ng t h
x c e l l s = 100
y c e l l s = x c e l l s
D = 1
SigmaA = 0. 01
nuSigmaF = 0. 012
# onl y one zone i s def i ned , a cent ered c i r c l e of radi us equal
# t o h a l f t he bare l e ng t h . Ce l l s t hat l i e out s i de t he c i r c l e
# are f or ced t o have zero f l u x
ZONE f ue l MATERIAL f ue l X_CENTER x b ar e l e ng t h /2 Y_CENTER x b ar e l e ng t h /2
RADIUS x b ar e l e ng t h /2
MATERIAL f ue l {
D 1 D
SigmaA 1 SigmaA
nuSi gmaf 1 nuSigmaF
}
# t he a na l y t i c a l mul t i p l i c a t i o n f ac t or
nu0 = 2. 4048 # f i r s t zero of b e s s e l s j 0 f unct i on
k = nuSigmaF/( SigmaA + D( nu0 /( x b ar e l e ng t h /2) ) 2)
# d e f i ni t i o n of a onedi mensi onal f unct i on equal t o t he f l u x
# d i s t r i b u t i o n eval uat ed i n an hor i z ont al radi us , i . e . t he
# r adi al p r o f i l e t o compare t o t he b e s s e l s ol ut i on
FUNCTION be s s e l ( r ) = f l ux 1 ( r+x b ar e l e ng t h /2 , x b ar e l e ng t h /2)
# wr i t e t he f l u x d i s t r i b u t i o n and which c e l l s have boundary
# condi t i ons t o one f i l e
PRINT_FUNCTION FILE f l ux f l ux 1 bc
# and t he r adi al p r o f i l e t o anot her one . Note t hat b e s s e l ( r ) i s
# an al g e b r ai c f unct i on , so a range i s mandatory . As t he s t ep i s
# l e s s than de l t a x , t h i s i s an i nt e r p o l a t i on of t he act ual f l u x .
PRINT_FUNCTION FILE r a di a l be s s e l MIN 0 MAX x b ar e l e ng t h /2 STEP 0. 5
x b ar e l e ng t h / x c e l l s
PRINT TEXT numeri cal k e f f = k e f f
PRINT TEXT a na l y t i c a l k e f f = k
PRINT TEXT d i f f e r e n c e = abs ( k e f f k)
$ milonga full.mil
numerical keff = 9.773084e-01
analytical keff = 9.745619e-01
difference = 2.746505e-03
$ gnuplot full2d.gnuplot
$ gnuplot full3d.gnuplot
$ gnuplot fullbc.gnuplot
$ cat radial.gnuplot
set terminal pdf
set output "radial.pdf"
set title "radial flux shape vs. analytical solution"
6o
milonga v0.1 0 0.5 1 1.5 2 2.5 3
0 10 20 30 40 50
radial ux shape vs. analytical solution
numerical 2.914*besj0(x/50*2.4048)
set xzeroaxis
set border 3
set tics scale 0.2
set tics nomirror
set yrange [-0.1:3]
set key bottom left Left reverse
plot "radial.dat" ps 0.5 lt 3 ti "numerical", 2.914
*
besj0(x/50
*
2.4048) lt 7
$ gnuplot radial.gnuplot
$
0
20
40
60
80
100
0 20 40 60 80 100
cells with boundary conditions
"full.dat" u 1:2:4
0
5000
10000
15000
20000
25000
30000
35000
0
20
40
60
80
100
0 20 40 60 80 100
ux
"full.dat"
0
0.5
1
1.5
2
2.5
3
o
milonga v0.1
0
10
20
30
40
50
60
70
80
90
100 0 10 20 30 40 50 60 70 80 90 100
0
0.5
1
1.5
2
2.5
3
ux
0
0.5
1
1.5
2
2.5
3
0
0.5
1
1.5
2
2.5
3
0 10 20 30 40 50
radial ux shape vs. analytical solution
numerical
2.914*besj0(x/50*2.4048)
4.1.4 Innite reactor
An innite reactor is an imaginary reactor that spans the whole universe and thus, the neutron ux
does not depend on the position. For the multigroup formulation, there is analytical expression for
the multiplicative factor, called /

. This example uses a trick to fool milonga into thinking it has to


solve an two-group innite reactor and illustrates how to obtain extra information about the problem.
kinf.mil
First, the analytical solution for a two-group innite reactor with no upscattering
/

=

f1

a1
+

f2

a2


12

a1
is computed and stored into a variable. Then, the numerical solution is computed. It involves a one-
dimensional two-group problem with three spatial cells. The boundary conditions are set to mirror in
both ends, thus forcing all the uxes to be equal as in the innite reactor. This is the rst example of
a two-group energy problem. See how the downscattering therm is entered in the MATERIAL keyword.
1
milonga v0.1
The main output of this example is the textle with the debugging information, including an ASCII
representation of the matrices of the problem, as catted in the terminal output.
# computati on of t he k i n f i n i t e val ue of a medium
# i n a 2group probl em f ormul at i on wi t h no ups c at t e r i ng
#
# twogroup XS as v a r i a b l e s
nuSigmaF1 = 5e4
SigmaA1 = 4e3
nuSigmaF2 = 5e3
SigmaA2 = 9e3
SigmaS12 = 8e3
# a na l y t i c a l s ol ut i on
#########################
a na l y t i c a l = nuSigmaF1/SigmaA1 + nuSigmaF2/SigmaA2 SigmaS12/SigmaA1
# numeri cal s ol ut i on
##########################
PROBLEM DIMENSIONS 1 GROUPS 2
# we need at l e a s t t hr ee c e l l s : two f or t he boundary
# condi t i ons and one f or t he d i f f us i o n equat i on
x c e l l s = 3
# s e t bot h l e f t and r i g h t bc t o mirror , so a l l t h e o r e t i c a l
# t hr ee c e l l s wi l l end up wi t h t he same neutron f l u x l e v e l
BOUNDARY_CONDITIONS {
X_MIN MIRROR
X_MAX MIRROR
}
# t he bare l e ng t h does not matter , because of t he
# s e l e c t e d boundary condi t i ons . However , t h i s val ue must
# be d i f f e r e nt from zero
x b ar e l e ng t h = 1
# dump i nf ormat i on i n a t e x t f i l e , i nc l udi ng an a s c i i
# r epr es ent at i on of t he mat ri ces of t he probl em
DEBUG i n f i n i t e . t xt MATRICES_ASCII
ZONE r e ac t or MATERIAL mix
# t he val ue f or t he d i f f us i o n c o e f f c i e nt i s i r r e l e v a nt
# because t he l apl ac i an of t he f l u x i s i nd e nt i c a l l y zero
# pay at t e nt i on t o t he d i f f e r e nc e between t he keywords
# and t he v a r i a b l e s bel ow
MATERIAL mix {
D 1 1
nuSigmaF 1 nuSigmaF1
SigmaT 1 SigmaA1
D 2 1
nuSigmaF 2 nuSigmaF2
SigmaT 2 SigmaA2
SigmaS 1 . 2 SigmaS12
}
PRINT TEXT a na l y t i c a l k e f f = a na l y t i c a l FORMAT %.18 f
PRINT TEXT numeri cal k e f f = k e f f FORMAT %.18 f
PRINT TEXT d i f f e r e n c e = abs ( anal yt i c al k e f f )
:
milonga v0.1
$ milonga kinf.mil
analytical keff = 1.236111111111111160
numerical keff = 1.236111111110656635
difference = 4.545253e-13
$ cat infinite.txt
------------------ ------------- ------
milonga 0.1 (linux-i686)
free nuclear reactor core analysis code
debugging and benchmarking output
-------- ------- ----- ---- ---
execution date is Sat Jul 16 12:58:58 2011
invocation commandline was
milonga kinf.mil
--------- ------- ------ ---- ---
spatial dimensions: 1
x_cells: 3
delta_x: 3.333333e-01
energy groups: 2
problem size: 6
---------- ------ ----- ----
boundary conditions
x direction
left: mirror
right: mirror
------------ ---------- --------- ------- -----
----
eigenvalue solution
solution method: krylovschur
number of requested eigenvalues: 1
number of converged eigenvalues: 6
number of iterations of the method: 1
number of linear iterations of the method: 6
stopping condition: tol=1e-07, maxit=100
residual norm
|Ax-kBx|_2 = 4.376e-15
relative error
|Ax-kBx|_2/|kx|_2 = 1.957e-15
error estimate
|k - k_real| = 1.764e-57
---------- --------- ------- ----- ---
removal matrix
+1.00e+00 0 -1.00e+00 0 0 0
0 +1.00e+00 0 -1.00e+00 0 0
-9.00e+00 0 +1.80e+01 0 -9.00e+00 0
0 -9.00e+00 -8.00e-03 +1.80e+01 0 -9.00e+00
0 0 -1.00e+00 0 +1.00e+00 0
0 0 0 -1.00e+00 0 +1.00e+00

milonga v0.1
------------- ---------- ---------- -------
fission matrix
0 0 0 0 0 0
0 0 0 0 0 0
0 0 +5.00e-04 +5.00e-03 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
----------- --------- --------- -------- ----
------------------ --------------- --------------
------
transcription of input file:
-------------- ------------- -------- ------
# computation of the k_infinite value of a medium
# in a 2-group problem formulation with no upscattering
#
# two-group XS as variables
nuSigmaF1 = 5e-4
SigmaA1 = 4e-3
nuSigmaF2 = 5e-3
SigmaA2 = 9e-3
SigmaS12 = 8e-3
# analytical solution
#########################
analytical = nuSigmaF1/SigmaA1 + nuSigmaF2/SigmaA2
*
SigmaS12/SigmaA1
# numerical solution
##########################
PROBLEM DIMENSIONS 1 GROUPS 2
# we need at least three cells: two for the boundary
# conditions and one for the diffusion equation
x_cells = 3
# set both left and right bc to mirror, so all theoretical
# three cells will end up with the same neutron flux level
BOUNDARY_CONDITIONS {
X_MIN MIRROR
X_MAX MIRROR
}
# the bare length does not matter, because of the
# selected boundary conditions. However, this value must
# be different from zero
x_bare_length = 1
# dump information in a text file, including an ascii
# representation of the matrices of the problem
DEBUG infinite.txt MATRICES_ASCII
ZONE reactor MATERIAL mix
# the value for the diffusion coeffcient is irrelevant
# because the laplacian of the flux is indentically zero
# pay attention to the difference between the keywords
# and the variables below
MATERIAL mix {
D_1 1
nuSigmaF_1 nuSigmaF1
SigmaT_1 SigmaA1
i
milonga v0.1
D_2 1
nuSigmaF_2 nuSigmaF2
SigmaT_2 SigmaA2
SigmaS_1.2 SigmaS12
}
PRINT TEXT "analytical keff = " analytical FORMAT %.18f
PRINT TEXT "numerical keff = " keff FORMAT %.18f
PRINT TEXT "difference = " abs(analytical-keff)
$
4.1.5 Slab with continuously-changing properties
The following example consists of a one-speed slab whose nuclear parameters depend on the axial
coordinate as continuous algebraic functions of r in such a way that the neutron ux can be explicitly
computed also as algebraic functions.
In particular, a non-dimensional slab reactor spanning the range [0. 1] subject to null boundary
conditions at r = 0 and mirror boundary conditions at r = 1 with the dimensionless cross sections
varying as
1(r) =
1
2
r
2

a
(r) = 2
1 r
2 r

f
(r) =
r
2
2r r
2
gives rise to a critical reactor whose dimensionless ux spatial distributionwith mean value equal
to oneis
(r) =
3
2
(2r r
2
)
as can be checked by replacing the above expressions into
d
dr

1(r)
d
dr

+ [
f
(r)
a
(r)] (r) = 0
Note that because of stability reasons, the diusion coecient has to be positive. In this case,
1(r) = 0 for r = 0, but this value is never used in the evaluation of the diusion equation.
20cells.mil
This example numerically solves the slab with continuously-changing properties and compares it to the
analytical solution. It illustrates for the rst time how to enter cross-sections as algebraic expressions
of the spatial variables. It also shows how commandline replacement works. As it may be interesting
to solve this problem using dierent schemes to compare their behavior, it would be a nice idea to be
able to select options at run-time instead of having them hard-coded in the input le. The terminal
output shows the execution of milonga with four combinations of scheme options, whose results are
redirected to dierent les and then plotted into single gures for comparison.
# onedi mensi onal onegroup s l ab wi t h
# cont i nous l y changi ng pr ope r t i e s
#
# t he numeri cal scheme opt i ons shoul d be gi ven i n
# t he commandline
#
j
milonga v0.1 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6
0 0.2 0.4 0.6 0.8 1 x
solution with nite dierences
"dierences-mean-local.dat" u 1:2 1.5*(2*x-x**2)
# t he a na l y t i c a l s ol ut i on t o t h i s probl em i s
# phi ( x ) = 3/2 ( 2x x2 )
# wi t h k e f f = 1 ( rho = 0)
#
PROBLEM DIMENSIONS 1 GROUPS 1
# t o avoi d f i x i ng t he scheme opt i ons i n t he i nput f i l e ,
# t he opt i ons can be gi ven from t he commandline
#
# $n g e t s r epl aced by t he nt h commandline argument
# a f t e r t he i nput f i l e . In t h i s case , i f l e s s than 3
# ext r a arguments are gi ven , mil onga q ui t s wi t h an error
SCHEME $1 $2 $3
BOUNDARY_CONDITIONS X_MIN NULL X_MAX MIRROR
x b ar e l e ng t h = 1 # di mens i onl es s wi dt h
x c e l l s = 20 # 20 s p a t i a l c e l l s
# smal l l e ng t h t endi ng t o 0+ t o use f or t he eval uat i on of
# t he D( x/+e ps i l on ) c o e f f i c i e n t s
e ps i l on = 1e2 x b ar e l e ng t h / x c e l l s
ZONE f ue l MATERIAL f ue l
# XS gi ven as al g e b r ai c expr es s i ons of t he coordi nat e x
MATERIAL f ue l {
D 1 0. 5 x2
SigmaA 1 2(1x ) /(2x )
nuSigmaF 1 x 2/(2xx 2)
}
# a na l y t i c a l s ol ut i on and r e l a t i v e error
FUNCTION phi ( x ) = 3/2 (2 x x 2)
FUNCTION e r r or ( x ) = ( f l ux 1 ( x ) phi ( x ) ) / phi ( x )
# numeri cal r e a c t i v i t y ( shoul d be equal t o zero )
rho = ( k e f f 1)/ k e f f
# wr i t e r e a c t i v i t y t o st andard out put but commented so
# gnupl ot i gnor es t he l i ne . Note t hat t he hash i s escaped
# t o avoi d mil onga i gnor i ng t he r e s t of t he l i ne ( i . e . i t
# i s not a comment f or mil onga , i t i s a comment f or gnupl ot )
PRINT TEXT \# rho = rho
# wr i t e f l ux e s , er r or s and XS d i s t r i b u t i o ns i nt o s t dout
PRINT_FUNCTION f l ux 1 phi e r r or D 1 SigmaA 1 nuSigmaF 1
$ milonga 20cells.mil DIFFERENCES XS_CENTER GRAD_D_NEIGHBORS > differences-center-
neighbor.dat
$ milonga 20cells.mil DIFFERENCES XS_MEAN GRAD_D_LOCAL > differences-mean-local.
dat
$ milonga 20cells.mil VOLUMES XS_CENTER D_MEAN > volumes-center-mean.dat
$ milonga 20cells.mil VOLUMES XS_MEAN D_EPSILON > volumes-mean-epsilon.dat
$ gnuplot input.gnuplot
$ gnuplot solution.gnuplot
$ gnuplot comparisson.gnuplot
$
6
milonga v0.1
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
x
input data
D(x)
SigmaA(x)
nuSigmaF(x)
0
0.2
0.4
0.6
0.8
1
1.2
1.4
1.6
0 0.2 0.4 0.6 0.8 1
x
solution with nite dierences
"dierences-mean-local.dat" u 1:2
1.5*(2*x-x**2)
-3.0e-02
-2.0e-02
-1.0e-02
0.0e+00
1.0e-02
2.0e-02
3.0e-02
4.0e-02
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
x
relative errors with respect to analytical solution
"volumes-mean-epsilon.dat" u 1:4
"volumes-center-mean.dat" u 1:4
"dierences-center-neighbor.dat" u 1:4
"dierences-mean-local.dat" u 1:4

milonga v0.1
1000cells.mil
This example is similar to the previous ones, except that one thousand cells are used to show that the
numerical solution tends to the analytical oneespecially /
e
as x cells .
PROBLEM DIMENSIONS 1 GROUPS 1
BOUNDARY_CONDITIONS X_MIN NULL X_MAX MIRROR
# even more c e l l s can be used , t r y i t !
x c e l l s = 1000
x b ar e l e ng t h = 1
ZONE f ue l MATERIAL f ue l
MATERIAL f ue l {
D 1 0. 5 x2
SigmaA 1 2(1x ) /(2x )
nuSigmaF 1 x 2/(2xx 2)
}
FUNCTION phi ( x ) = 3/2 (2 x x 2)
FUNCTION e r r or ( x ) = ( f l ux 1 ( x ) phi ( x ) ) / phi ( x )
rho = ( k e f f 1)/ k e f f
PRINT TEXT \# rho = rho k e f f
PRINT_FUNCTION f l ux 1 e r r or
$ milonga 1000cells.mil > 1000cells.dat
$ gnuplot 1000cells.gnuplot
$
0
0.2
0.4
0.6
0.8
1
1.2
1.4
1.6
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
x
solution with nite volumes using 1000 cells
numerical
analytical
4.1.6 Two-zone slab
Consider a one-dimensional one-speed two-zone slab of length /, composed of a material 1 with an
innite multiplication factor less than one for 0 < r < o and of a material 11 with /

1 for
8
milonga v0.1
o < r < / (a similar problem is discussed in reference [4]). These two materials have homogeneous
properties. It can be shown that the resulting ux distribution is
(r) =

sinh

1
1
I

fI
/
e

aI

if 0 r < o
sinh

1
1
I

fI
/
e

aI

sin

1
1
II

aII


fII
/
e

(/ o)
sin

1
1
II

aII


fII
/
e

(/ r)

if / < r /
where the eective multiplication factor /
e
is the solution of the critical condition

1
I

fI
/
e

aI

tan

1
1
II

aII


fII
/
e

(/ o)

1
II

aII


fII
/
e

tanh

1
1
I

fI
/
e

aI

= 0
If the diusion coecients are not equal, then there is a discontinuity in the ux at r = o. This
problem poses an interesting benchmark test for nodal methods.
twozone.mil
The two-zone slab problem is solved numerically with = 200 cells and the obtained solution is
compared to the analytical ux distribution. The left half of the slab contains material I and the
right half contains material II. This example shows on the one hand how to include more than one
zone in milonga and on the other some of the mathematical capabilities that wasora provides in order
to obtain the non-trivial analytical /
e
and ux distribution (r) as a continuous algebraic function.
The analytical multiplication factor is computed by using the root functional provided by wasora.
Because the critical condition has a rather bad behavior regarding discontinuities and innities, the
numerical /
e
is chosen as the initial guess and a small interval around it is given as the expected
solution range. The analytical solution is written as an ASCII representation of an algebraic function
that can be directly entered into gnuplot. Also, a text le flux.dat is created with both the
o
milonga v0.1
numerical and the analytical uxes evaluated at the cell centers. Note that in this case, the interface
coincides with a cell border. The user is encouraged to change the number of spatial cells and analyze
how the results change. In the parametric calculations section, this problem is revisited and how the
dierence between the numerical and analytical solutions changes when the interface does not coincide
with cell borders.
# t h i s probl em c ons i s t s of a onedi mensi onal onespeed twozone s l ab
PROBLEM DIMENSIONS 1 GROUPS 1
# geometry
##################################
a = 50 # wi dt h of zone Is t a r t of zone I I
b = 100 # f u l l wi dt h
x b ar e l e ng t h = b
x c e l l s = 100
# cr os s s e c t i ons
##################################
# def i ned as v a r i a b l e s t o have them a v a i l a b l e f or
# computing t he a na l y t i c a l k e f f
nu1 = 0. 010
nu2 = 0. 015
a1 = 0. 015
a2 = 0. 010
# not e t he d i f f e r e nc e between t he two d i f f us i o n
# c o e f f i c i e n t s t o s t r e s s t he di s c ont i nui t y of t he
# f l u x gr adi ent
d1 = 0. 5
d2 = 1. 5
MATERIAL f ue l {
D 1 d2
SigmaT 1 a2
nuSigmaF 1 nu2
}
MATERIAL rod {
D 1 d1
SigmaT 1 a1
nuSigmaF 1 nu1
}
# zones
##################################
ZONE rod MATERIAL rod X_MIN 0 X_MAX a
ZONE f ue l MATERIAL f ue l X_MIN a X_MAX b
# a na l y t i c a l mul t i p l i c a t i o n f ac t or
##################################
# i nt e r v a l t o l ook f or t he a na l y t i c a l k
eps = 0. 05
# eval uat e k from t he a na l y t i c a l c r i t i c a l condi t i on
# t aki ng as an i n i t i a l guess t he numeri cal k e f f
k = k e f f
k = root ( sqrt ( d1abs ( nu1/ka1 ) ) tan( sqrt ( ( 1/ d2 ) abs ( a2nu2/k) ) ( ba ) ) + sqrt
( d2abs ( a2nu2/k) ) tanh( sqrt ( ( 1/ d1 ) abs ( nu1/ka1 ) ) a ) , k , k e f f eps , k e f f
+eps )
# a na l y t i c a l f l u x d i s t r i b u t i o n
B1 = sqrt ( abs ( nu1/ka1 ) /d1 )
B2 = sqrt ( abs ( nu2/ka2 ) /d2 )
FUNCTION phi 1 ( x ) = sinh(B1x )
FUNCTION phi 2 ( x ) = sinh(B1a ) /si n (B2( ba ) ) si n (B2( bx ) )
8o
milonga v0.1
norm = b/( i ntegral ( phi 1 ( x ) , x , 0 , a ) + i ntegral ( phi 2 ( x ) , x , a , b) )
FUNCTION phi ( x ) = norm i f ( l ess ( x , a ) , phi 1 ( x ) , phi 2 ( x ) )
FUNCTION e r r or ( x ) = phi ( x )f l ux 1 ( x )
PRINT TEXT \# copy and pas t e the f ol l owi ng l i n e s i nt o gnupl ot to obt ai n
PRINT TEXT \# the conti nuous f l ux di s t r i but i o n as a f unc t i on of x
PRINT TEXT nume r i c al ke f f = k e f f FORMAT %.8 l f
PRINT TEXT a n a l y t i c a l k e f f = k FORMAT %.8 l f
PRINT TEXT phi 1 ( x) = norm TEXT s i nh ( B1 TEXT x ) SEPARATOR
PRINT TEXT phi 2 ( x) = norm TEXT s i nh ( B1a TEXT ) / s i n ( B2( ba )
TEXT ) s i n ( B2 TEXT ( b TEXT x ) ) SEPARATOR
PRINT TEXT phi ( x) = ( x < a TEXT ) ? phi 1 ( x) : phi 2 ( x) SEPARATOR
# pr i nt f l u x 1 ( x ) , phi ( x ) and error ( x )
FILE f l ux f l ux . dat
PRINT_FUNCTION FILE f l ux f l ux 1 phi e r r or
$ milonga twozone.mil
## copy and paste the following lines into gnuplot to obtain
## the continuous flux distribution as a function of x
numerical_keff = 1.14799085
analytical_keff = 1.14779361
phi1(x) = 1.316009e-02
*
sinh( 1.121395e-01
*
x )
phi2(x) = 1.316009e-02
*
sinh( 5.606974e+00 ) / sin( 2.261471e+00 )
*
sin(
4.522943e-02
*
( 1.000000e+02 -x ) )
phi(x) = ( x < 5.000000e+01 ) ? phi1(x) : phi2(x)
$ gnuplot twozone.gnuplot
$
0
0.5
1
1.5
2
2.5
0 20 40 60 80 100
x
ux distribution
analytical
numerical
81
milonga v0.1
1
1.2
1.4
1.6
1.8
2
2.2
46 48 50 52 54
x
ux distribution (zoom at the interface)
analytical
numerical
4.2 General problems
This section presents general cases that do not have analytical solution but nevertheless should be
familiar to the nuclear engineer. They mostly involve geometries with material boundaries, where the
evaluation of cell cross sections and the leakage term aect the computational eort needed and the
accuracy of the solution in non-trivial ways. No three-dimensional example is given mainly because
the current version of milonga does not handle correctly cylindrical nor spherical boundary conditions.
Only one and two-dimensional examples are shown. Nevertheless, most of the multidimensional fea-
tures of the code can be illustrated by using two spatial dimensions.
4.2.1 Reected slab
After analyzing the bare slab, reactor physics theory courses focus on the reected slab. The most
important concept to study in these kinds of problems is the loss of separability between energy and
space and the appearance of the so-called thermal shoulder due to the low absorption and heavy
downscattering in the reector material when using at least two energy groups. The example that
follows solves the classic symmetric reected slab shown in the gure, and the next two introduce
some variations to illustrate dierent aspects.
symmetric.mil
The reected slab shown in the gure using two energy groups is solved. The denition of the materials
is given in a separate le and included in the main input le to shorten its length and to share the
cross sections with other input les. The materials le is shown in the terminal window.
8:
milonga v0.1
# symmetric twogroup r e f l e c t e d s l ab
PROBLEM DIMENSIONS 1 GROUPS 2
a = 20 # r e f l e c t o r l e ng t h
x b ar e l e ng t h = 100
x c e l l s = 100
# t he XS can be conveni ent l y ent ered i nt o a s epar at e f i l e
# and t hen i ncl uded i n each probl em d e f i ni t i o n i nput
INCLUDE mat e r i al s . mi l
# f i r s t , we def i ne a zone t hat spans t he whol e s l ab
ZONE f ue l MATERIAL f ue l
# and t hen we add t he two r e f l e c t o r s
# not e t hat t he d e f a ul t behavi or i s t o r epl ace t he over l appi ng
# i nt e r v a l s wi t h t he new XS ( t o have them added use t he
# INCREMENTAL keyword )
ZONE r e f l 1 MATERIAL r e f l e c t o r X_MIN 0 X_MAX a
ZONE r e f l 2 MATERIAL r e f l e c t o r X_MIN x b ar e l e ng t h a X_MAX x b ar e l e ng t h
# pr i nt t he two f l u x e s t o t he st andard out put
PRINT_FUNCTION f l ux 1 f l u x 2
$ cat materials.mil
MATERIAL fuel {
D_1 1.500
SigmaT_1 0.010
nuSigmaF_1 0.000
D_2 0.400
SigmaT_2 0.085
nuSigmaF_2 0.135
SigmaS_1.2 0.020
}
MATERIAL reflector {
D_1 2.000
SigmaT_1 0.000
D_2 0.300
SigmaT_2 0.010
SigmaS_1.2 0.040
}
MATERIAL rod {
D_1 1.500
SigmaT_1 0.010
nuSigmaF_1 0.000
D_2 0.400
SigmaT_2 0.130
nuSigmaF_2 0.135
SigmaS_1.2 0.020
}
$ milonga symmetric.mil > symmetric.dat
$ gnuplot symmetric.gnuplot
$
8
milonga v0.1
0
0.5
1
1.5
2
2.5
3
0 10 20 30 40 50 60 70 80 90 100
x
two-group uxes
fast ux
thermal ux
asymmetric.mil
More often than not, reactors are not symmetric. If they were, there would be no point in making
full-core calculations like the one in the preceding example. A small variation to the problem above is
to study what happens when the reactor is not symmetrically reected, where a full-core calculation
is mandatory.
# asymmetric r e f l e c t e d s l ab
PROBLEM DIMENSIONS 1 GROUPS 2
a = 20 # l e f t r e f l e c t o r l e ng t h
b = 10 # r i g h t r e f l e c t o r l e ng t h
x b ar e l e ng t h = 100
x c e l l s = 100
INCLUDE mat e r i al s . mi l
ZONE f ue l MATERIAL f ue l
ZONE r e f l 1 MATERIAL r e f l e c t o r X_MIN 0 X_MAX a
ZONE r e f l 2 MATERIAL r e f l e c t o r X_MIN x b ar e l e ng t h b X_MAX x b ar e l e ng t h
PRINT_FUNCTION f l ux 1 f l u x 2
$ milonga asymmetric.mil > asymmetric.dat
$ gnuplot asymmetric.gnuplot
$
8i
milonga v0.1
0.00
0.50
1.00
1.50
2.00
2.50
3.00
0 10 20 30 40 50 60 70 80 90 100
x
two-group uxes
fast ux
thermal ux
rod.mil
A nal variation is introduced here where a small interval of the slab is replaced by a heavy absorber,
acting like a control rod. Moreover, the new material is located in a position whose limits do not
coincide with the cell boundaries. Besides the ux distribution, this example shows both the total
continuous cross section as a function of r and the cell cross sections. A zoom over the control rod
shows what happens at the cells that contain the material interfaces. As the default behavior is to
use equation (2.35), the result is that the cell cross section is the weighted average of the adjacent
materials.
# asymmetric r e f l e c t e d s l ab wi t h a c ont r ol rod
PROBLEM DIMENSIONS 1 GROUPS 2
a = 20 # l e f t r e f l e c t o r l e ng t h
b = 10 # r i g h t r e f l e c t o r l e ng t h
rod x = 40. 123 # pos i t i on of t he rod cent er
rod w = 5. 456 # t o t a l wi dt h of t he rod
# not e t hat t he c e l l s are 1cm wi dt h
x b ar e l e ng t h = 100
x c e l l s = 100
INCLUDE mat e r i al s . mi l
ZONE f ue l MATERIAL f ue l
ZONE r e f l 1 MATERIAL r e f l e c t o r X_MIN 0 X_MAX a
ZONE r e f l 2 MATERIAL r e f l e c t o r X_MIN x b ar e l e ng t h b X_MAX x b ar e l e ng t h
# t he c ont r ol r od pos i t i on ( i n t h i s case t he XS are abs ol ut e ,
# had t hey been i ncrement al , t he KEYWORD i ncrement al shoul d have
# been used )
ZONE rod MATERIAL rod X_MIN rod x 0.5 rod w X_MAX rod x +0.5 rod w
PRINT_FUNCTION f l ux 1 f l u x 2
# pr i nt t he cont i nuous t hermal SigmaA i n cont xs . dat
# and t he c e l l t hermal SigmaA i n c e l l x s . dat
FILE conti nuous contxs . dat
FILE c e l l c e l l x s . dat
# f unct i on cSigmaT needs a range and st ep , t he f i r s t argument
# i s t he energy group and t he second one i s t he x coordi nat e
8j
milonga v0.1
PRINT_FUNCTION cSigmaT MIN 2 0 MAX 2 x b ar e l e ng t h STEP 1 0. 01 FILE conti nuous
# f unct i on SigmaT 2 does not need an e x p l i c i t range
PRINT_FUNCTION SigmaT 2 FILE c e l l
$ milonga rod.mil > rod.dat
$ gnuplot rod.gnuplot
$ gnuplot xs.gnuplot
$
0.00
0.50
1.00
1.50
2.00
2.50
3.00
0 10 20 30 40 50 60 70 80 90 100
x
two-group uxes
fast ux
thermal ux
0.00
0.02
0.04
0.06
0.08
0.10
0.12
0.14
0 10 20 30 40 50 60 70 80 90 100
x
continuous and cell thermal SigmaT
continuous XS
cell XS
86
milonga v0.1
0.08
0.09
0.10
0.11
0.12
0.13
35 36 37 38 39 40 41 42 43 44 45 46 47
x
continuous and cell thermal SigmaT
continuous XS
cell XS
4.2.2 Reected circle
The next case to study is the reected circle. The eects that appear here are pretty much the same
than the ones the appeared in the reected slab. However, the fact of having a circular geometry
embedded into a rectangular grid gives rise to interesting forms of material interfaces and the solution
depends on the choice for evaluating the cell cross-sections and the leakage term.
reected.mil
This example shows the dierence of the results obtained by the two methods of evaluation cell cross
sections, namely XS CENTER and XS MEAN. By using commandline replacement, the same input solves
a reected circle with both methods and then the thermal absorption cross sections and the diusion
coecients for each cell are shown. Even though a nice anti-aliasing eect is obtained when using
XS MEAN, the computational eort to compute the mean values may be many times the eort needed
to evaluate the parameters at the cell center without giving a signicant improvement in the solution.
The usage of either method has to be studied for each particular problem to be solved.
# r e f l e c t e d c i r c l e wi t h d i f f e r e nt XS as s oc i at i on
# provi de e i t h e r XS CENTER or XS MEAN i n t he commandline
PROBLEM DIMENSIONS 2 GROUPS 2
SCHEME $1
x b ar e l e ng t h = 100
y b ar e l e ng t h = x b ar e l e ng t h
8
milonga v0.1 0 20 40 60 80 100
0 20 40 60 80 100
fast ux (cell center) "xscenter.dat" u 1:2:5
0 1 2 3 4 5 6 7
# a l ow number of c e l l s i s gi ven t o st udy t he c e l l XS
# eval uat i on scheme
x c e l l s = 40
y c e l l s = x c e l l s
# r e f l e c t o r wi dt h
a = 20
INCLUDE mat e r i al s . mi l
ZONE f ue l MATERIAL f ue l {
X_CENTER x b ar e l e ng t h /2
Y_CENTER x b ar e l e ng t h /2
OUTER_RADIUS x b ar e l e ng t h /2
}
ZONE r e f l MATERIAL r e f l e c t o r {
X_CENTER x b ar e l e ng t h /2
Y_CENTER x b ar e l e ng t h /2
INNER_RADIUS x b ar e l e ng t h /2a
OUTER_RADIUS x b ar e l e ng t h /2
}
PRINT_FUNCTION SigmaT 2 D 1 f l ux 1 f l u x 2
$ milonga reflected.mil XS_CENTER > xscenter.dat
$ milonga reflected.mil XS_MEAN > xsmean.dat
$ gnuplot xscenter.gnuplot
$ gnuplot xsmean.gnuplot
$ gnuplot 3dxscenter.gnuplot
$ gnuplot 3dxsmean.gnuplot
$
0
20
40
60
80
100
0 20 40 60 80 100
thermal absorption XS (cell center)
"xscenter.dat" u 1:2:3
0
0.01
0.02
0.03
0.04
0.05
0.06
0.07
0.08
0.09
88
milonga v0.1 0 20 40 60 80 100
0 20 40 60 80 100
thermal absorption XS (cell average) "xsmean.dat" u 1:2:3
0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09
0
20
40
60
80
100
0 20 40 60 80 100
fast diusion coecient (cell center)
"xscenter.dat" u 1:2:4
0
0.5
1
1.5
2
0
20
40
60
80
100
0 20 40 60 80 100
fast ux (cell center)
"xscenter.dat" u 1:2:5
0
1
2
3
4
5
6
7
0
20
40
60
80
100
0 20 40 60 80 100
fast ux (cell center)
"xscenter.dat" u 1:2:6
0
0.2
0.4
0.6
0.8
1
1.2
1.4
1.6
1.8
8o
milonga v0.1 0 20 40 60 80 100
0 20 40 60 80 100
fast ux (cell average) "xsmean.dat" u 1:2:6
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
0
20
40
60
80
100
0
20
40
60
80
100
0
1
2
3
4
5
6
7
uxes (cell center)
fast ux
thermal ux
0
20
40
60
80
100
0 20 40 60 80 100
thermal absorption XS (cell average)
"xsmean.dat" u 1:2:3
0
0.01
0.02
0.03
0.04
0.05
0.06
0.07
0.08
0.09
0
20
40
60
80
100
0 20 40 60 80 100
fast diusion coecient (cell average)
"xsmean.dat" u 1:2:4
0
0.5
1
1.5
2
oo
milonga v0.1
0
20
40
60
80
100
0 20 40 60 80 100
fast ux (cell average)
"xsmean.dat" u 1:2:5
0
1
2
3
4
5
6
0
20
40
60
80
100
0 20 40 60 80 100
fast ux (cell average)
"xsmean.dat" u 1:2:6
0
0.2
0.4
0.6
0.8
1
1.2
1.4
1.6
1.8
2
0
20
40
60
80
100
0
20
40
60
80
100
0
1
2
3
4
5
6
uxes (cell average)
fast ux
thermal ux
o1
milonga v0.1 0 20 40 60 80 100
0 20 40 60 80 100
thermal continuous absorption XS "cont.dat" u 2:3:4
0 0.02 0.04 0.06 0.08 0.1 0.12 0.14
rods.mil
As with the slab, there are no symmetric reactors and thus full-core calculations do not make sense.
The following example includes some absorbers that again do not coincide with cell borders, that
would represent most of the cases of interest. As with the slab, rst the continuous absorption cross
section is given, showing the real position of the absorbers. Afterward, the cell values using averages
are given, showing the antialiasing eect.
# r e f l e c t e d c i r c l e wi t h some abs or ber s
PROBLEM DIMENSIONS 2 GROUPS 2
x b ar e l e ng t h = 100
y b ar e l e ng t h = x b ar e l e ng t h
x c e l l s = 40
y c e l l s = x c e l l s
a = 20 # r e f l e c t o r wi dt h
INCLUDE mat e r i al s . mi l
ZONE f ue l MATERIAL f ue l {
X_CENTER x b ar e l e ng t h /2
Y_CENTER x b ar e l e ng t h /2
OUTER_RADIUS x b ar e l e ng t h /2
}
ZONE r e f l MATERIAL r e f l e c t o r {
X_CENTER x b ar e l e ng t h /2
Y_CENTER x b ar e l e ng t h /2
INNER_RADIUS x b ar e l e ng t h /2a
OUTER_RADIUS x b ar e l e ng t h /2
}
# t hes e zones do not coi nci de wi t h c e l l borders on purpose
ZONE rod1 MATERIAL rod {
X_MIN 51. 5 X_MAX 72. 2
Y_MIN 20. 1 Y_MAX 30. 9
}
ZONE rod2 MATERIAL rod {
X_CENTER 65 Y_CENTER 70
OUTER_RADIUS 14. 75
}
ZONE rod3 MATERIAL rod {
X_CENTER 34. 3
Y_CENTER 57. 4
OUTER_RADIUS 4. 12
}
# again , t he c e l l XS do not need range
PRINT_FUNCTION SigmaT 2 D 1 f l ux 1 f l u x 2
# t he cont i nuous XS need ranges and s t e ps . The f i r s t argument
# i s t he energy group , t he second i s x and t he t hi r d i s y
FILE cont cont . dat
PRINT_FUNCTION FILE cont cSigmaT MIN 2 0 0 MAX 2 x b ar e l e ng t h y b ar e l e ng t h
STEP 1 0. 1 x b ar e l e ng t h / x c e l l s 0. 1 y b ar e l e ng t h / x c e l l s
$ milonga rods.mil > rods.dat
$ gnuplot xsrods.gnuplot
$ gnuplot 3drods.gnuplot
$
o:
milonga v0.1 0 20 40 60 80 100
0 20 40 60 80 100
fast ux "rods.dat" u 1:2:6
0 0.5 1 1.5 2 2.5
0
20
40
60
80
100
0 20 40 60 80 100
thermal continuous absorption XS
"cont.dat" u 2:3:4
0
0.02
0.04
0.06
0.08
0.1
0.12
0.14
0
20
40
60
80
100
0 20 40 60 80 100
thermal cell absorption XS
"rods.dat" u 1:2:3
0
0.02
0.04
0.06
0.08
0.1
0.12
0.14
0
20
40
60
80
100
0 20 40 60 80 100
fast diusion coecient
"rods.dat" u 1:2:4
0
0.5
1
1.5
2
o
milonga v0.1
0
20
40
60
80
100
0 20 40 60 80 100
fast ux
"rods.dat" u 1:2:5
0
1
2
3
4
5
6
7
0
20
40
60
80
100
0 20 40 60 80 100
fast ux
"rods.dat" u 1:2:6
0
0.5
1
1.5
2
2.5
0
20
40
60
80
100
0
20
40
60
80
100
0
1
2
3
4
5
6
7
uxes
fast ux
thermal ux
oi
milonga v0.1
4.2.3 IAEA 2D PWR Benchmark
This section shows how a classic IAEA benchmark for nuclear reactor codes can be solved by milonga.
Because the current version does not work 100% with three-dimensional problems, the problem to be
solved is the so-called two-dimensional LWR Benchmark Problem with identication 11-A2 described
in reference [5]. This problem represents the mid-plane . = 190 cm of the 3D IAEA Benchmark
Problem that will be included as an example is future versions of milonga. The 3D problem is a
standard benchmark and its solution using with dierent modern codes can be found, amongst other
documents, in [6, 7, 8]. The original reference [5] provides also a collection of solutions obtained with
legacy codes.
Quoting the original problem denition [5, page 437],
Reduction of Source Situation:
1. Two-group diusion theory
2. Two-dimensions (r. n)-geometry
Two-Group Diusion Equations:
1
1

1
+ (
a1
+
12
+ 1
1
1
2
z1
)
1
=
1


f2

2
1
2

2
+ (
a2
+ 1
2
1
2
z2
)
2
=
12

1
Data (see gure).
Axial buckling 1
2
zg
= 0.8 10
4
for all regions an energy groups
Boundary conditions J
in
g
= 0 no incoming current at external boundaries. For nite
dierence diusion theory codes the following form is considered equivalent

g
n
=
0.4682
1
g

g
where n is the outward directed normal to the surface. At symmetry boundaries:

g
n
= 0
1
2
3
4
10 70 30 50 90 110 130 150 170 cm
10
70
90
130
150
170
cm
3
3
3
oj
milonga v0.1
Region
1
2
3
4
1.5
1.5
1.5
2.0
0.4
0.4
0.4
0.3
0.02
0.02
0.02
0.04
0.01
0.01
0.01
0.00
0.080
0.085
0.130
0.01
0.135
0.135
0.135
0.000
Fuel 1
Fuel 2
Fuel 2 + rod
Reector
Material
Two-group Constants
iaea2dpwr.mil
The following input le solves the 2D IAEA PWR benchmark described above. The original problem
asks for a number of results that can all be computed by milonga, but for simplicity reasons only the
multiplication factor, ux 2D distribution (r. n) and radial proles trough the horizontal axis (r. 0)
and through the diagonal (r. r) as a function of r are given. The axial buckling is inserted as a
modication to the absorption cross section in the material le. The diusion equation is solved using
the nite volumes scheme. As the material interfaces coincide with cell borders, cell cross sections are
computed with the center method and currents are computed using the diusion coecient evaluated
at a distance c. An analysis of how the resultsincluding calculation timeschange with the mesh
size can be easily performed by using parametric calculations over the variable c that controls the
mesh renement, as shown in the next section. Boundary conditions are set to null ux at the
external boundary and mirror conditions at r = 0 and n = 0 as to represent one quarter of the core.
The ux prole along the r axis is computed at n = n2 instead of at n = 0 to avoid spending
time interpolating by asking for the value the uxes take exactly at a cell center. The result is the
same, because the mirror boundary condition at n = 0 sets (r. n2) = (r. n2) and thus
(r. 0) = (r. n2).
# IAEA 2D PWR benchmark
# ANL7416 Suppl ement 2 , 1977 , Argonne Code Center :
# Benchmark Problem Book , page 437
# two s p a t i a l di mensi ons and two energy groups
PROBLEM DIMENSIONS 2 GROUPS 2
# as t he mat er i al i nt e r f a c e s coi nci de wi t h c e l l borders ,
# t he s e l e c t i o n of XS CENTER and XS MEAN g i v e s t he same c e l l XS
# al s o D EPSILON and DMEAN g i v e t he same cur r ent s
# t h i s opt i ons reduce computati on ti me as t hey avoi d i nt e g r at i ons
SCHEME XS_CENTER D_EPSILON
# bare l e ng t h i n cm as def i ned i n t he probl em
x b ar e l e ng t h = 170
y b ar e l e ng t h = 170
# mesh ref i nement f ac t or : t he hi gher t h i s val ue t he f i ne r t he mesh
c = 2. 0
x c e l l s = c x b ar e l e ng t h
y c e l l s = x c e l l s
del t ax = x b ar e l e ng t h / x c e l l s
del t ay = y b ar e l e ng t h / y c e l l s
# a quar t er core i n t he f i r s t xy quadrant
BOUNDARY_CONDITIONS X_MIN MIRROR X_MAX NULL Y_MIN MIRROR Y_MAX NULL
# zone de f i nt i on
# new zones over r i de pr evi ous ones when t hey over l ap
# not e t hat Y MIN d e f a ul t s t o zero
ZONE r e f l 1 MATERIAL r e f l e c t o r X_MIN 0 X_MAX 70 Y_MAX 170
o6
milonga v0.1
ZONE r e f l 2 MATERIAL r e f l e c t o r X_MIN 70 X_MAX 110 Y_MAX 150
ZONE r e f l 3 MATERIAL r e f l e c t o r X_MIN 110 X_MAX 130 Y_MAX 130
ZONE r e f l 4 MATERIAL r e f l e c t o r X_MIN 130 X_MAX 150 Y_MAX 110
ZONE r e f l 5 MATERIAL r e f l e c t o r X_MIN 150 X_MAX 170 Y_MAX 70
ZONE f ue l 2 1 MATERIAL f ue l 1 X_MIN 0 X_MAX 50 Y_MAX 150
ZONE f ue l 2 2 MATERIAL f ue l 1 X_MIN 50 X_MAX 90 Y_MAX 130
ZONE f ue l 2 3 MATERIAL f ue l 1 X_MIN 90 X_MAX 110 Y_MAX 110
ZONE f ue l 2 4 MATERIAL f ue l 1 X_MIN 110 X_MAX 130 Y_MAX 90
ZONE f ue l 2 5 MATERIAL f ue l 1 X_MIN 130 X_MAX 150 Y_MAX 50
ZONE f ue l 1 1 MATERIAL f ue l 2 X_MIN 0 X_MAX 30 Y_MAX 130
ZONE f ue l 1 2 MATERIAL f ue l 2 X_MIN 30 X_MAX 70 Y_MAX 110
ZONE f ue l 1 3 MATERIAL f ue l 2 X_MIN 70 X_MAX 110 Y_MAX 70
ZONE f ue l 1 4 MATERIAL f ue l 2 X_MIN 110 X_MAX 130 Y_MAX 30
ZONE f ue l r o d 1 MATERIAL f ue l 2r od X_MIN 0 Y_MIN 0 X_MAX 10 Y_MAX 10
ZONE f ue l r o d 2 MATERIAL f ue l 2r od X_MIN 0 Y_MIN 70 X_MAX 10 Y_MAX 90
ZONE f ue l r o d 3 MATERIAL f ue l 2r od X_MIN 70 Y_MIN 0 X_MAX 90 Y_MAX 10
ZONE f ue l r o d 4 MATERIAL f ue l 2r od X_MIN 70 Y_MIN 70 X_MAX 90 Y_MAX 90
# t he mat er i al s are i ncl uded i n a d i f f e r e nt f i l e
# i n order t o be shared between ot her i nput f i l e s
INCLUDE mat e r i al s . mi l
# e x t r ac t onedi mensi onal p r o f i l e s from t he f l u x e s
# t he de l t ay /2 i s t o save ti me i n making
# a mul t i di mensi onal i nt e r p ol a t i o n by as ki ng
# f or val ues e x ac t l y at a c e l l cent er
FUNCTION f a s t p r o f i l e ( x ) = f l ux 1 ( x , del t ay /2)
FUNCTION t he r ma l pr o f i l e ( x ) = f l ux 2 ( x , del t ay /2)
FUNCTION f as t di agonal ( x ) = f l ux 1 ( x , x )
FUNCTION t her mal di agonal ( x ) = f l ux 2 ( x , x )
# out put some i nf ormat i on t o t he screen
PRINT TEXT k e f f = k e f f FORMAT %.8 l f
PRINT TEXT bui l d t i me = b ui l d t i me TEXT seconds FORMAT %.4 l f
PRINT TEXT s ol ve t i me = s ol v e t i me TEXT seconds FORMAT %.4 l f
PRINT TEXT t ot al t i me = b ui l d t i me+s ol v e t i me TEXT seconds FORMAT %.4 l f
# twodi mensi onal f l u x d i s t r i b u t i o n and t o t a l t hermal XS
FILE f l ux f l ux . dat
PRINT_FUNCTION FILE f l ux f l ux 1 f l u x 2 SigmaT 2
# f l u x p r o f i l e s
FILE p r o f i l e p r o f i l e . dat
FILE di agonal di agonal . dat
# t hes e are al g e b r ai c f unct i ons , a range i s mandatory
# t he range and s t ep are s e l e c t e d agai n t o avoi d i nt e r p o l a t i on
PRINT_FUNCTION FILE p r o f i l e f a s t p r o f i l e t he r ma l pr o f i l e MIN del t ax /2 MAX
x b ar e l e ng t h del t ax /2 STEP del t ax
PRINT_FUNCTION FILE di agonal f as t di agonal t her mal di agonal MIN del t ax /2 MAX
x b ar e l e ng t h del t ax /2 STEP del t ax
$ cat materials.mil
# materials for the IAEA PWR benchmark problem
# a geometric bucking of 0.8e-4 in the z-direction
# is taken into account by a D B_g2 term in the
# absorption cross section
MATERIAL fuel1 {
D_1 1.500
D_2 0.400
SigmaS_1.2 0.020
o
milonga v0.1
SigmaA_1 0.010+1.5
*
0.8e-4
SigmaA_2 0.080+0.4
*
0.8e-4
nuSigmaF_2 0.135
}
MATERIAL fuel2 {
D_1 1.500
D_2 0.400
SigmaS_1.2 0.020
SigmaA_1 0.010+1.5
*
0.8e-4
SigmaA_2 0.085+0.4
*
0.8e-4
nuSigmaF_2 0.135
}
MATERIAL fuel2rod {
D_1 1.500
D_2 0.400
SigmaS_1.2 0.020
SigmaA_1 0.010+1.5
*
0.8e-4
SigmaA_2 0.130+0.4
*
0.8e-4
nuSigmaF_2 0.135
}
MATERIAL reflector {
D_1 2.000
D_2 0.300
SigmaS_1.2 0.040+2.0
*
0.8e-4
SigmaA_1 0.000+0.3
*
0.8e-4
SigmaA_2 0.010
nuSigmaF_2 0.000
}
$ milonga iaea2dpwr.mil
keff = 1.02990385
build_time = 4.1996 seconds
solve_time = 5.0606 seconds
total_time = 9.2602 seconds
$ gnuplot iaea2d.gnuplot
$ gnuplot profile.gnuplot
$
o8
milonga v0.1 0 0.5 1 1.5 2 2.5 3 3.5 4
0 20 40 60 80 100 120 140 160 n o r m a l i z e d n o n - d i m e n s i o n a l u x
x (as asked, not r)
ux proles along the diagonal fast thermal
0
20
40
60
80
100
120
140
160
0 20 40 60 80 100 120 140 160
thermal total XS
"ux.dat" u 1:2:5
0
0.02
0.04
0.06
0.08
0.1
0.12
0.14
0
20
40
60
80
100
120
140
160
0 20 40 60 80 100 120 140 160
fast ux
"ux.dat" u 1:2:3
0
0.5
1
1.5
2
2.5
3
3.5
4
0
20
40
60
80
100
120
140
160
0 20 40 60 80 100 120 140 160
thermal ux
"ux.dat" u 1:2:4
0
0.2
0.4
0.6
0.8
1
1.2
1.4
1.6
oo
milonga v0.1
0
0.5
1
1.5
2
2.5
3
3.5
4
0 20 40 60 80 100 120 140 160
n
o
r
m
a
l
i
z
e
d

n
o
n
-
d
i
m
e
n
s
i
o
n
a
l

u
x
x
ux proles along the x axis
fast
thermal
0
0.5
1
1.5
2
2.5
3
3.5
4
0 20 40 60 80 100 120 140 160
n
o
r
m
a
l
i
z
e
d

n
o
n
-
d
i
m
e
n
s
i
o
n
a
l

u
x
x (as asked, not r)
ux proles along the diagonal
fast
thermal
circle.mil
A small variation of the 2D IAEA PWR Benchmarkthat is also applicable to the 3D problemis
the replacement of the external reector boundary by a circle instead of a coarse 17 17 rectangular
approximation. Of course, this requirement was not possible thirty ve years ago, but nowadays
circular reectors should be bread and butter for core codes. This example shows one of the vectors
of milongas design basis in action, namely the Independence of the problem geometry and the spatial
nodalization. A lower mesh renement factor c = 0.5 is chosen to show how the circle is automatically
translated into the rectangular mesh. There is no need to use XS MEAN because mainly the only cells
whose cross sections will dier from the center value are those in the external boundary of the core
and thus they have boundary conditions equations and do not make use of the cell cross sections.
Note the reduction of the computation time because of the coarser mesh.
# Vari at i on of t he IAEA 2D PWR benchmark
# quar t er core wi t h c i r c ul a r r e f l e c t o r
PROBLEM DIMENSIONS 2 GROUPS 2
SCHEME XS_CENTER D_EPSILON
1oo
milonga v0.1 0 20 40 60 80 100 120 140 160
0 20 40 60 80 100 120 140 160
fast ux "circux.dat" u 1:2:3
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5
x b ar e l e ng t h = 170
y b ar e l e ng t h = 170
# mesh ref i nement f ac t or
c = 0. 5
x c e l l s = c x b ar e l e ng t h
y c e l l s = x c e l l s
del t ax = x b ar e l e ng t h / x c e l l s
BOUNDARY_CONDITIONS X_MIN MIRROR X_MAX NULL Y_MIN MIRROR Y_MAX NULL
# s t a r t wi t h a c i r c ul a r r e f l e c t o r
ZONE r e f l MATERIAL r e f l e c t o r X_CENTER 0 Y_CENTER 0 RADIUS 170
# and t hen add t he f u e l el ement s i n t h e i r correspndi ng square g r i ds
ZONE f ue l 2 1 MATERIAL f ue l 1 X_MIN 0 X_MAX 50 Y_MAX 150
ZONE f ue l 2 2 MATERIAL f ue l 1 X_MIN 50 X_MAX 90 Y_MAX 130
ZONE f ue l 2 3 MATERIAL f ue l 1 X_MIN 90 X_MAX 110 Y_MAX 110
ZONE f ue l 2 4 MATERIAL f ue l 1 X_MIN 110 X_MAX 130 Y_MAX 90
ZONE f ue l 2 5 MATERIAL f ue l 1 X_MIN 130 X_MAX 150 Y_MAX 50
ZONE f ue l 1 1 MATERIAL f ue l 2 X_MIN 0 X_MAX 30 Y_MAX 130
ZONE f ue l 1 2 MATERIAL f ue l 2 X_MIN 30 X_MAX 70 Y_MAX 110
ZONE f ue l 1 3 MATERIAL f ue l 2 X_MIN 70 X_MAX 110 Y_MAX 70
ZONE f ue l 1 4 MATERIAL f ue l 2 X_MIN 110 X_MAX 130 Y_MAX 30
ZONE f ue l r o d 1 MATERIAL f ue l 2r od X_MIN 0 Y_MIN 0 X_MAX 10 Y_MAX 10
ZONE f ue l r o d 2 MATERIAL f ue l 2r od X_MIN 0 Y_MIN 70 X_MAX 10 Y_MAX 90
ZONE f ue l r o d 3 MATERIAL f ue l 2r od X_MIN 70 Y_MIN 0 X_MAX 90 Y_MAX 10
ZONE f ue l r o d 4 MATERIAL f ue l 2r od X_MIN 70 Y_MIN 70 X_MAX 90 Y_MAX 90
INCLUDE mat e r i al s . mi l
PRINT TEXT k e f f = k e f f FORMAT %.8 l f
PRINT TEXT bui l d t i me = b ui l d t i me TEXT seconds FORMAT %.4 l f
PRINT TEXT s ol ve t i me = s ol v e t i me TEXT seconds FORMAT %.4 l f
PRINT TEXT t ot al t i me = b ui l d t i me+s ol v e t i me TEXT seconds FORMAT %.4 l f
FILE f l ux c i r c f l u x . dat
PRINT_FUNCTION FILE f l ux f l ux 1 f l u x 2 SigmaT 2
$ milonga circle.mil
keff = 1.03089876
build_time = 0.2296 seconds
solve_time = 0.1351 seconds
total_time = 0.3647 seconds
$ gnuplot circle.gnuplot
$
1o1
milonga v0.1
0
20
40
60
80
100
120
140
160
0 20 40 60 80 100 120 140 160
thermal total XS
"circux.dat" u 1:2:5
0
0.02
0.04
0.06
0.08
0.1
0.12
0.14
0
20
40
60
80
100
120
140
160
0 20 40 60 80 100 120 140 160
fast ux
"circux.dat" u 1:2:3
0
0.5
1
1.5
2
2.5
3
3.5
4
4.5
0
20
40
60
80
100
120
140
160
0 20 40 60 80 100 120 140 160
thermal ux
"circux.dat" u 1:2:4
0
0.2
0.4
0.6
0.8
1
1.2
1.4
1.6
1o:
milonga v0.1
4.2.4 Two-dimensional slice of a PHWR
The last example of the general-interest problems is a also two-dimensional slice but this time of a
ctitious Pressurized Heavy Water Reactor. This solved case shows some other features of milonga
that may be handy when tackling similar problems. Although this example is loosely based on a real
reactor, the actual data is less than random and of course the results presented here do not have any
physical signicance.
In this kind of reactors, one of the most important parameters that control the actual spatial
cross-section dependance inside the core is the fuel burnup, as the spatial distribution of this latter
property depends on the online fuel refueling and shuing strategy. The core consists of a number
of vertical channels, each representing an homogeneous mixture of fuel, coolant and moderator
that are separated in PHWRs. The macroscopic cross sections depend on several parameters such
as temperatures, xenon and fuel burnup. In this problem, only dependance on burnup is taken into
account, whilst xenon and temperatures dependance are illustrated in sections that are about to
come. There is a circular reector surrounding the core and there are four pipes for the moderator
loop, whose temperature is not taken into account. There are eighteen circular control rods, of which
only six circular are inserted at the considered plane. However, guide tubes for the withdrawn rods
are also considered. There are also fteen lances containing in-core instrumentation that introduce
extra absorbing materials in the core.
core
reector
neutron detector
inserted control rod
2dphwr.mil
First, the fuel burnup is read and interpolated from a text le that gives the location of each channel
and the burnup at the axial plane considered. One-dimensional functions of burnup are read and
interpolated from a big multi-column le containing macroscopic cross sections as a function of burnup.
Materials are dened accordingly, where burnup distribution is taken into account in the reactor core.
Then, the geometry is entered by using a mixture of absolute and relative zones. Finally, some
information is written to les while /
e
and solution time is written to the screen.
# 2D f i c t i c i o u s PHWR
PROBLEM DIMENSIONS 2 GROUPS 2
# because t he burnup i s not r e a l l y i nt e r pol at e d but cont i nuous l y
# f i l l e d wi t h t he c l o s e s t val ue ( see bel ow) , i t makes no sense
# t o waste CPU time usi ng XS MEAN
SCHEME XS_CENTER D_EPSILON
# a bare square 7m l ong
x b ar e l e ng t h = 700
y b ar e l e ng t h = 700
1o
milonga v0.1
# square c e l l s
x c e l l s = 200
y c e l l s = x c e l l s
# t he f u e l burnup i s gi ven as a cont i nuous f unct i on read from
# a f i l e , whose cont ent can be seen i n t he t ermi nal screen
# i nt e r p o l a t i o n method c l o s e s t i s s e l e c t e d t o save computati on ti me
# and avoi d e x t r apol at i on probl ems at t he out er par t s of t he core
# columns of burnup . dat are [ cm] [ cm] [MWday/ton ]
FUNCTION burnup ( x , y ) FILE burnup . dat INTERPOLATION c l o s e s t
# t hes e f unct i ons gi v e t he core cr os s s e c t i ons as a f unct i on of
# t he s i ng l e parameter burnup ( t emperat ures , xenon , et c are not
# i l l u s t r a t e d here but coul d be t aken i nt o account al s o )
# XS uni t s are 1/cm and bu uni t s are MWday/ton
FUNCTION D1( bu) FILE xs . dat INTERPOLATION s pl i ne s COLUMNS 1 2
FUNCTION D2( bu) FILE xs . dat INTERPOLATION s pl i ne s COLUMNS 1 3
FUNCTION SigmaA1( bu) FILE xs . dat INTERPOLATION s pl i ne s COLUMNS 1 4
FUNCTION SigmaS12 ( bu) FILE xs . dat INTERPOLATION s pl i ne s COLUMNS 1 5
FUNCTION SigmaS21 ( bu) FILE xs . dat INTERPOLATION s pl i ne s COLUMNS 1 6
FUNCTION SigmaA2( bu) FILE xs . dat INTERPOLATION s pl i ne s COLUMNS 1 7
FUNCTION nuSigmaF1 ( bu) FILE xs . dat INTERPOLATION s pl i ne s COLUMNS 1 8
FUNCTION nuSigmaF2 ( bu) FILE xs . dat INTERPOLATION s pl i ne s COLUMNS 1 9
# r adi al r e f l e c t o r pr ope r t i e s are homogeneous
MATERIAL r e f l e c t o r {
D 1 1. 405310E+01
D 2 9. 666628E01
SigmaA 1 4. 107654E06
SigmaS 1 . 2 1. 090063E02
SigmaS 2 . 1 1. 088030E04
SigmaA 2 4. 908041E05
}
# core pr ope r t i e s depend on burnup onl y
MATERIAL f uel mod {
D 1 D1( burnup ( x , y ) )
D 2 D2( burnup ( x , y ) )
SigmaA 1 SigmaA1( burnup ( x , y ) )
SigmaS 1 . 2 SigmaS12 ( burnup ( x , y ) )
SigmaS 2 . 1 SigmaS21 ( burnup ( x , y ) )
SigmaA 2 SigmaA2( burnup ( x , y ) )
nuSigmaF 1 nuSigmaF1 ( burnup ( x , y ) )
nuSigmaF 2 nuSigmaF2 ( burnup ( x , y ) )
}
# i ncrement al c ont r ol rod XS
MATERIAL rod {
SigmaA 1 1. 957196E03
SigmaA 2 7. 339746E03
SigmaS 1 . 2 7.986794E04
SigmaS 2 . 1 2. 732369E05
nuSigmaF 1 4.314411E05
nuSigmaF 2 5. 649112E04
}
# i ncrement al c ont r ol rod gui de t ube XS
MATERIAL gui de {
SigmaA 1 1.102107E04
SigmaA 2 9. 838934E05
SigmaS 1 . 2 1.378342E04
SigmaS 2 . 1 1. 513809E06
nuSigmaF 1 5.002725E06
nuSigmaF 2 1. 110945E05
}
# ab s oul t e XS f or t he de t e c t or s
MATERIAL de t e c t or {
D 1 1
1oi
milonga v0.1
D 2 1
SigmaA 1 1e3
SigmaA 2 1e2
SigmaS 1 . 2 1e4
SigmaS 2 . 1 0
}
# f i r s t def i ne t he r e f l e c t o r ( downcomer ) as a b i g c i r c l e
ZONE r e f l MATERIAL r e f l e c t o r X_CENTER 350 Y_CENTER 350 RADIUS 345
# f i l l e d wi t h a s mal l er c i r c l e r epr es ent i ng t he core
ZONE cor e MATERIAL f uel mod X_CENTER 350 Y_CENTER 350 RADIUS 305
# f our c i r c l e s t o hol d t he moderator pi pes
ZONE mod1 MATERIAL r e f l e c t o r X_CENTER 430 Y_CENTER 60 RADIUS 35
ZONE mod2 MATERIAL r e f l e c t o r X_CENTER 640 Y_CENTER 270 RADIUS 35
ZONE mod3 MATERIAL r e f l e c t o r X_CENTER 290 Y_CENTER 640 RADIUS 35
ZONE mod4 MATERIAL r e f l e c t o r X_CENTER 60 Y_CENTER 450 RADIUS 35
# gui de t ubes f or t he 18 c ont r ol rods
ZONE tube1 MATERIAL gui de X_CENTER 217 Y_CENTER 389 RADIUS 15 INCREMENTAL
ZONE tube2 MATERIAL gui de X_CENTER 177 Y_CENTER 353 RADIUS 15 INCREMENTAL
ZONE tube3 MATERIAL gui de X_CENTER 272 Y_CENTER 377 RADIUS 15 INCREMENTAL
ZONE tube4 MATERIAL gui de X_CENTER 299 Y_CENTER 507 RADIUS 15 INCREMENTAL
ZONE tube5 MATERIAL gui de X_CENTER 245 Y_CENTER 471 RADIUS 15 INCREMENTAL
ZONE tube6 MATERIAL gui de X_CENTER 367 Y_CENTER 495 RADIUS 15 INCREMENTAL
ZONE tube7 MATERIAL gui de X_CENTER 435 Y_CENTER 436 RADIUS 15 INCREMENTAL
ZONE tube8 MATERIAL gui de X_CENTER 449 Y_CENTER 507 RADIUS 15 INCREMENTAL
ZONE tube9 MATERIAL gui de X_CENTER 408 Y_CENTER 412 RADIUS 15 INCREMENTAL
ZONE tube10 MATERIAL gui de X_CENTER 517 Y_CENTER 318 RADIUS 15 INCREMENTAL
ZONE tube11 MATERIAL gui de X_CENTER 503 Y_CENTER 389 RADIUS 15 INCREMENTAL
ZONE tube12 MATERIAL gui de X_CENTER 463 Y_CENTER 271 RADIUS 15 INCREMENTAL
ZONE tube13 MATERIAL gui de X_CENTER 381 Y_CENTER 224 RADIUS 15 INCREMENTAL
ZONE tube14 MATERIAL gui de X_CENTER 449 Y_CENTER 212 RADIUS 15 INCREMENTAL
ZONE tube15 MATERIAL gui de X_CENTER 381 Y_CENTER 271 RADIUS 15 INCREMENTAL
ZONE tube16 MATERIAL gui de X_CENTER 258 Y_CENTER 259 RADIUS 15 INCREMENTAL
ZONE tube17 MATERIAL gui de X_CENTER 258 Y_CENTER 200 RADIUS 15 INCREMENTAL
ZONE tube18 MATERIAL gui de X_CENTER 217 Y_CENTER 294 RADIUS 15 INCREMENTAL
# s i x i ns e r t e d c ont r ol rods
ZONE rod1 MATERIAL rod X_CENTER 177 Y_CENTER 353 RADIUS 15 INCREMENTAL
ZONE rod2 MATERIAL rod X_CENTER 258 Y_CENTER 200 RADIUS 15 INCREMENTAL
ZONE rod3 MATERIAL rod X_CENTER 449 Y_CENTER 212 RADIUS 15 INCREMENTAL
ZONE rod4 MATERIAL rod X_CENTER 449 Y_CENTER 507 RADIUS 15 INCREMENTAL
ZONE rod5 MATERIAL rod X_CENTER 245 Y_CENTER 471 RADIUS 15 INCREMENTAL
ZONE rod6 MATERIAL rod X_CENTER 517 Y_CENTER 318 RADIUS 15 INCREMENTAL
# f i f t e e n incore de t e c t or s
ZONE det1 MATERIAL de t e c t or X_CENTER 299 Y_CENTER 365 RADIUS 5
ZONE det2 MATERIAL de t e c t or X_CENTER 394 Y_CENTER 389 RADIUS 5
ZONE det3 MATERIAL de t e c t or X_CENTER 367 Y_CENTER 342 RADIUS 5
ZONE det4 MATERIAL de t e c t or X_CENTER 272 Y_CENTER 318 RADIUS 5
ZONE det5 MATERIAL de t e c t or X_CENTER 367 Y_CENTER 459 RADIUS 5
ZONE det6 MATERIAL de t e c t or X_CENTER 435 Y_CENTER 294 RADIUS 5
ZONE det7 MATERIAL de t e c t or X_CENTER 231 Y_CENTER 412 RADIUS 5
ZONE det8 MATERIAL de t e c t or X_CENTER 463 Y_CENTER 436 RADIUS 5
ZONE det9 MATERIAL de t e c t or X_CENTER 326 Y_CENTER 224 RADIUS 5
ZONE det10 MATERIAL de t e c t or X_CENTER 177 Y_CENTER 483 RADIUS 5
ZONE det11 MATERIAL de t e c t or X_CENTER 558 Y_CENTER 459 RADIUS 5
ZONE det12 MATERIAL de t e c t or X_CENTER 340 Y_CENTER 129 RADIUS 5
ZONE det13 MATERIAL de t e c t or X_CENTER 190 Y_CENTER 247 RADIUS 5
ZONE det14 MATERIAL de t e c t or X_CENTER 367 Y_CENTER 554 RADIUS 5
ZONE det15 MATERIAL de t e c t or X_CENTER 531 Y_CENTER 271 RADIUS 5
# out put f i l e s
FILE xsburn xsburnup . dat # 1Ddependance of XS wi t h burnup
FILE burnup burnupi nt e r pol at e d . dat # 2D d i s t r i b u t i o n of i nt e r pol at e d burnup
FILE xs di s t xs di s t . dat # 2D d i s t r i b u t i o n of c e l l s XS
FILE s o l ut i o n s o l ut i o n . dat # 2D f l u x d i s t r i b u t i o n
1oj
milonga v0.1 0.0e+00 1.0e-03 2.0e-03 3.0e-03 4.0e-03 5.0e-03 6.0e-03 7.0e-03
0 2000 4000 6000 8000 10000
1 / c m
MWD/ton
nu-ssion XS vs burnup fast thermal
# al t houg ht range i s opt i onal , i t i s gi ven t o e x p l i c i t l y show t hat
# t hes e f unct i ons are i nt e r pol at e d as a f unct i on of t he burnup
# t hat may t ake v i r t u a l l y any range between 0 and 10000
# i n t he gnupl ot i nput , f i l e xs . dat wi t h t he act ual d e f i ni t i o n
# poi nt s i s p l o t t e d over t he cont i nuous s pl i ne i nt e r p o l a t i o n
PRINT_FUNCTION FILE xsburn SigmaA1 SigmaA2 nuSigmaF1 nuSigmaF2 SigmaS12
SigmaS21 MIN 0 MAX 10000 STEP 50
# burnup d i s t r i b u t i o n as i nt e r pol at e d from burnup . dat
# range i s opt i onal but gi ven i n order t o e x p l i c i t l y show how
# t he i nt e r po l a t i o n method c l o s e s t work
PRINT_FUNCTION FILE burnup burnup MIN 0 0 MAX x b ar e l e ng t h y b ar e l e ng t h STEP
x b ar e l e ng t h / x c e l l s y b ar e l e ng t h / y c e l l s
# c e l l XS d i s t r i b u t i o n
PRINT_FUNCTION FILE xs di s t nuSigmaF 1 nuSigmaF 2 SigmaA 1 SigmaA 2
# f l u x d i s t r i b u t i o n
PRINT_FUNCTION FILE s o l ut i o n f l ux 1 f l u x 2
PRINT TEXT k e f f = k e f f FORMAT %.6 l f
PRINT TEXT ti me = b ui l d t i me TEXT + s ol v e t i me TEXT = b ui l d t i me+
s ol v e t i me TEXT seconds FORMAT %.2 l f SEPARATOR
$ head burnup.dat
# the first columns have the location of the channels centers in
# the x-y plane, and the third one has the burnup in MW-day/ton
354 353 5144.0
381 353 9069.8
367 377 6109.6
340 377 7906.5
326 353 6500.9
340 330 8620.4
367 330 7354.4
394 377 4259.6
$ milonga 2dphwr.mil
keff = 1.003979
time = 36.07 + 1.77 = 37.84 seconds
$ gnuplot xs.gnuplot
$ gnuplot 2dxs.gnuplot
$ gnuplot solution.gnuplot
$
1o6
milonga v0.1 0 100 200 300 400 500 600 700
0 100 200 300 400 500 600 700
thermal nu-ssion XS "xsdist.dat" u 1:2:4
0 0.001 0.002 0.003 0.004 0.005 0.006 0.007
1.5e-03
2.0e-03
2.5e-03
3.0e-03
3.5e-03
4.0e-03
4.5e-03
5.0e-03
0 2000 4000 6000 8000 10000
1
/
c
m
MWD/ton
absorption XS vs burnup
fast
thermal
0.0e+00
1.0e-03
2.0e-03
3.0e-03
4.0e-03
5.0e-03
6.0e-03
7.0e-03
0 2000 4000 6000 8000 10000
1
/
c
m
MWD/ton
nu-ssion XS vs burnup
fast
thermal
8.12e-03
8.14e-03
8.16e-03
8.18e-03
8.20e-03
8.22e-03
8.24e-03
8.26e-03
8.28e-03
0 2000 4000 6000 8000 10000
1
/
c
m
MWD/ton
scattering XS vs burnup
fast to thermal
1o
milonga v0.1 0 100 200 300 400 500 600 700
0 100 200 300 400 500 600 700
thermal ux "solution.dat" u 1:2:4
0 0.5 1 1.5 2 2.5 3 3.5
0
100
200
300
400
500
600
700
0 100 200 300 400 500 600 700
burn-up distribution [MWD/ton] as interpolated from burnup.dat
"burnup-interpolated.dat"
0
1000
2000
3000
4000
5000
6000
7000
8000
9000
10000
0
100
200
300
400
500
600
700
0 100 200 300 400 500 600 700
thermal nu-ssion XS
"xsdist.dat" u 1:2:4
0
0.001
0.002
0.003
0.004
0.005
0.006
0.007
0
100
200
300
400
500
600
700
0 100 200 300 400 500 600 700
thermal absorption XS
"xsdist.dat" u 1:2:6
0
0.002
0.004
0.006
0.008
0.01
0.012
0.014
1o8
milonga v0.1
0
100
200
300
400
500
600
700
0 100 200 300 400 500 600 700
fast ux
"solution.dat" u 1:2:3
0
0.5
1
1.5
2
2.5
0
100
200
300
400
500
600
700
0 100 200 300 400 500 600 700
thermal ux
"solution.dat" u 1:2:4
0
0.5
1
1.5
2
2.5
3
3.5
4.3 Parametric problems
This section focuses on parametric calculations, i.e. systematically varying one or more parameters
to obtain results as a function of them. This feature may be used for example to perform sensitivity
analysis, build design maps and optimize parameters. The problems shown below have analytical
solutions and the parameter varied systematically has to do the geometry and the nodalization. This
way, the problems are kept simple, the expected solution is known a priori and some insights about how
milonga works and what results are to be expected are shown. Engineering analysis would include
higher dimensions and a few groups of energy making use of parametric studies on compositions,
temperatures, burnable poisons, etc. Actually, at least one PhD Thesis should be written using this
tool. The more, the merrier.
4.3.1 Grid size eects
The three examples that follow show solve again the one-speed bare slab, bare square and a bare three-
dimensional cube, but this time the numerical multiplication factor is compared to the analytical /
e
as a function of the number of cells used in the spatial discretization. All the cases use the same
1oo
milonga v0.1
materialan hypothetical fuel mixture with /

= 1.2spanning the whole bare space. In the last


example, a comparison between the results obtained for the three dimensions as a function of the
problem size is performed.
1d.mil
A one-speed one-dimensional bare homogeneous slab is solved by parametrically varying the number of
cells. The le materials.mil is shared between the three examples of this section, so it is shown in
the terminal view. For each step, the output is a single line in the standard output. It consists of eight
columns, namely the number of cells in the r-direction, the size of the problem (equal to the number
of cells in this case but dierent for higher-order problems), the numerical /
e
, the analytical /
e
(that
does not depend on x cells but is printed in each step to ease the plot procedure), the time needed
to build the matrices, the time needed to solve the eigenvalue problem and the total time. Because
no MAX DAUGHTERS keyword was entered, the calculation is done in series, i.e. each step starts only
after the last one has nished. Therefore, the output lines will be ordered by increasing x cells. If
this had not be the case, output should have been written to les and then ordered from the shell,
as explained in chapter 3. Conclusions about the results shown in the gures are up to the user, but
note that even though the problem size scales linearly, square matrices of size usually scale
as
2
.
# paramet ri c st udy of a bare s l ab wi t h r e s pe c t t o
# t he number of c e l l s
PROBLEM DIMENSIONS 1 GROUPS 1
# perform a paramet ri c st udy on x c e l l s from 10
# up t o 5000 wi t h an addi t i v e i ncrement of 50
PARAMETRIC x c e l l s 10 5000 50
SCHEME DIFFERENCES XS_CENTER GRAD_D_LOCAL
# 100 ar b i t r ar y uni t s wi dt h
x b ar e l e ng t h = 100
# t h i s assi gnment i s i gnored i n a paramet ri c
# c al c ul at i on , however i f one wants t o comment
# t he PARAMETRIC keyword above , i t i s handy t o
# mai ntai n t h i s l i ne t o prevent mil onga from f a i l i n g
x c e l l s = 100
# mat er i al s and zones
INCLUDE mat e r i al s . mi l
ZONE f ue l MATERIAL f ue l
# a na l y t i c a l s ol ut i on ( v a r i a b l e s are def i ned i n
# t he mat er i al s . mi l f i l e )
pi = 4atan( 1)
k = nuSigmaF/( SigmaA + D( pi / x b ar e l e ng t h ) 2)
# i n each s t ep pr i nt one l i ne as t he out put t o
# obt ai n how a l l t hes e s t u f f depend on x c e l l s
PRINT x c e l l s x c e l l s k e f f k k e f f k b ui l d t i me s ol v e t i me b ui l d t i me+
s ol v e t i me
$ cat materials.mil
D = 1
SigmaA = 1e-2
nuSigmaF = 1.2e-2
MATERIAL fuel {
D_1 D
SigmaA_1 SigmaA
11o
milonga v0.1
nuSigmaF_1 nuSigmaF
}
$ milonga 1d.mil > 1d.dat
$ gnuplot 1d.gnuplot
$
1.09208
1.09210
1.09212
1.09214
1.09216
1.09218
1.09220
1.09222
1.09224
0 200 400 600 800 1000
k
e

number of cells in the x direction


numerical and analytical ke vs cell number - 1D
analytical
numerical
1e-09
1e-08
1e-07
1e-06
1e-05
1e-04
1e-03
0 1000 2000 3000 4000 5000
a
b
s
o
l
u
t
e

e
r
r
o
r
number of cells in the x direction
dierence between the numerical and analytical ke
error
111
milonga v0.1
0.000
0.002
0.004
0.006
0.008
0.010
0.012
0.014
0 1000 2000 3000 4000 5000
t
i
m
e

[
s
e
g
]
number of cells in the x direction
solution time vs cell number - 1D
build time
solve time
total time
2d.mil
The two-dimensional bare slab is studied parametrically as a function of the number of cells in the
r-direction. In this case, the number of cells in the n-direction is the same as in the r-direction,
so the problem size scales as the square of x cells. Same gure as for the one-dimensional cases
are produced. For fun, compare how the results depend on the number of cells with respect to the
previous case, taking into account the same remark regarding and
2
.
# paramet ri c st udy of a bare square wi t h r e s pe c t t o
# t he number of c e l l s
PROBLEM DIMENSIONS 2 GROUPS 1
# t he probl em s i z e s c al e s wi t h x c e l l s 2 so
# t he range has t o be chosen c a r e f u l l y t o avoi d
# runni ng out of memory
PARAMETRIC x c e l l s 10 250 10
SCHEME DIFFERENCES XS_CENTER GRAD_D_LOCAL
x b ar e l e ng t h = 100
y b ar e l e ng t h = x b ar e l e ng t h
# t hes e two l i ne s are i gnored i n paramet ri c mode ,
# but agai n i t i s handy t o keep them
x c e l l s = 100
y c e l l s = x c e l l s
INCLUDE mat e r i al s . mi l
ZONE f ue l MATERIAL f ue l
pi = 4atan( 1)
k = nuSigmaF/( SigmaA + 2D( pi / x b ar e l e ng t h ) 2)
PRINT x c e l l s x c e l l s 2 k e f f k k e f f k b ui l d t i me s ol v e t i me b ui l d t i me+
s ol v e t i me
$ milonga 2d.mil > 2d.dat
$ gnuplot 2d.gnuplot
$
11:
milonga v0.1
1.00195
1.00200
1.00205
1.00210
1.00215
1.00220
1.00225
1.00230
1.00235
0 50 100 150 200 250
k
e

number of cells in the x direction


numerical and analytical ke vs cell number - 2D
analytical
numerical
1e-06
1e-05
1e-04
1e-03
0 50 100 150 200 250
a
b
s
o
l
u
t
e

e
r
r
o
r
number of cells in the x direction
dierence between the numerical and analytical ke
error
11
milonga v0.1 1e-05
1e-04
1e-03
1e-02
5 10 15 20 25 30 35 40
a b s o l u t e e r r o r
number of cells in the x direction
dierence between the numerical and analytical ke error
0.000
0.100
0.200
0.300
0.400
0.500
0.600
0.700
0.800
0 50 100 150 200 250
t
i
m
e

[
s
e
g
]
number of cells in the x direction
solution time vs cell number - 2D
build time
solve time
total time
3d.mil
Lastly, the rst three-dimensional example appears. It is a bare one-dimensional box, whose eective
multiplication factor is computed for dierent spatial nodalizations. In each direction the number of
cells are equal to x cells. After the usual three gures with the /
e
, the error and the solution times,
two gures summing up the situation for each example of the section are provided. It can be seen
how, for the same matrix size lower dimensional problems are faster and more accurate, as expected.
# paramet ri c st udy of a bare cube wi t h r e s pe c t t o
# t he number of c e l l s
PROBLEM DIMENSIONS 3 GROUPS 1
PARAMETRIC x c e l l s 5 40 1
SCHEME DIFFERENCES XS_CENTER GRAD_D_LOCAL
x b ar e l e ng t h = 100
y b ar e l e ng t h = x b ar e l e ng t h
z b a r e l e ng t h = x b ar e l e ng t h
x c e l l s = 25
y c e l l s = x c e l l s
z c e l l s = x c e l l s
INCLUDE mat e r i al s . mi l
ZONE f ue l MATERIAL f ue l
pi = 4atan( 1)
k = nuSigmaF/( SigmaA + 3D( pi / x b ar e l e ng t h ) 2)
PRINT x c e l l s x c e l l s 3 k e f f k k e f f k b ui l d t i me s ol v e t i me b ui l d t i me+
s ol v e t i me
$ milonga 3d.mil > 3d.dat
$ gnuplot 3d.gnuplot
$ gnuplot dims.gnuplot
$
11i
milonga v0.1 1e-03 1e-02 1e-01 1e+00 1e+01 1e+02
1e+02 1e+03 1e+04 1e+05
t i m e [ s e g ]
problem size
total runing time vs problem size
1D 2D 3D
0.91800
0.91900
0.92000
0.92100
0.92200
0.92300
0.92400
0.92500
0.92600
0.92700
5 10 15 20 25 30 35 40
k
e

number of cells in the x direction


numerical and analytical ke vs cell number - 3D
analytical
numerical
1e-05
1e-04
1e-03
1e-02
5 10 15 20 25 30 35 40
a
b
s
o
l
u
t
e

e
r
r
o
r
number of cells in the x direction
dierence between the numerical and analytical ke
error
0.000
2.000
4.000
6.000
8.000
10.000
12.000
14.000
16.000
18.000
20.000
5 10 15 20 25 30 35 40
t
i
m
e

[
s
e
g
]
number of cells in the x direction
solution time vs cell number - 3D
build time
solve time
total time
11j
milonga v0.1
1e-09
1e-08
1e-07
1e-06
1e-05
1e-04
1e-03
1e+02 1e+03 1e+04 1e+05
e
r
r
o
r

i
n

k
e

problem size
error vs problem size
1D
2D
3D
1e-03
1e-02
1e-01
1e+00
1e+01
1e+02
1e+02 1e+03 1e+04 1e+05
t
i
m
e

[
s
e
g
]
problem size
total runing time vs problem size
1D
2D
3D
3dinverse.mil
As a bonus track, another three-dimensional example is included. This time, an illustration of how
knowledge about numerical methods, preconditioners and over-relaxation parameters can drastically
reduce computation times. This problem passes run-time options to SLEPc in the commandline to
select the Krylov-subspace solver GMRES, a SOR preconditioner and to set some other optional
parameters, resulting in a reduction of the problem time for big problems when compared to the
previous case, as can be seen in the output gure. The SLEPc parameters shown in the terminal view
are not important per se. This example is about the inuence they have in milongas performance.
The actual meaning of the options and its impact should be addressed on the one hand by reading
SLEPcs documentation [9] and on the other hand understanding how milonga builds the associated
matrices, as explained in chapter 2 of this document.
# paramet ri c st udy of a bare cube wi t h r e s pe c t t o
# t he number of c e l l s usi ng t he i nver s e k f ormul at i on
# wi t h sor pr econdi t i oner and gmres s ol v e r
PROBLEM DIMENSIONS 3 GROUPS 1
116
milonga v0.1
PARAMETRIC x c e l l s 5 40 1
# f or t he SLEPc opt i ons i n commandline t o work , we have t o s ol v e
# t he probl em were t he ei genval ue i s equal t o 1/ k e f f
SOLVER EIGENVALUE_INVERSE_K
SCHEME DIFFERENCES XS_CENTER GRAD_D_LOCAL
x b ar e l e ng t h = 100
y b ar e l e ng t h = x b ar e l e ng t h
z b a r e l e ng t h = x b ar e l e ng t h
x c e l l s = 25
y c e l l s = x c e l l s
z c e l l s = x c e l l s
INCLUDE mat e r i al s . mi l
ZONE f ue l MATERIAL f ue l
pi = 4atan( 1)
k = nuSigmaF/( SigmaA + 3D( pi / x b ar e l e ng t h ) 2)
PRINT x c e l l s x c e l l s 3 k e f f k k e f f k b ui l d t i me s ol v e t i me b ui l d t i me+
s ol v e t i me
$ milonga 3dinverse.mil -st_ksp_type gmres -st_pc_type sor -st_type sinvert -
st_pc_sor_omega 1.7 -eps_ncv 7 > 3dinverse.dat
$ gnuplot 3dinverse.gnuplot
$
1e-03
1e-02
1e-01
1e+00
1e+01
1e+02
1e+02 1e+03 1e+04 1e+05
t
i
m
e

[
s
e
g
]
problem size
solution time vs. problem size
direct problem
inverse problem
4.3.2 Discrete boundary conditions eects
The following example presents another example of parametric calculation. Again a bare slab is solved
but this time, the number of cells and the bare length are kept constant while the width o is changed
parametrically. This leads to the general situation where the external boundary does not coincide
with cell borders, as shown in the gure. The numerical multiplicative factor is again compared to the
theoretical one. The latter depends continuously on the slab width while the second does not because
of the discrete boundary condition equations. The output gure shows how the error changes with
11
milonga v0.1
the slab width. Keep in mind that the cells are two units width and refer to gures 2.13 and 2.14
when analyzing the result.
bc.mil
This is a rather simple input. Zone fuel is dened to be in the range [0. o], while x bare length
and x cells are kept constant. Variable a is changed parametrically and the error as a function of o
is written to the standard output.
# e f f e c t of t he appl i c at i on of d i s c r e t e boundary
# condi t i ons on pl anar s ur f ac es
PROBLEM DIMENSIONS 1 GROUPS 1
# sweep t he s l ab wi dt h from 80 t o 100
PARAMETRIC a 80 100 0. 1
x b ar e l e ng t h = 100
# 50 c e l l s g i v e c e l l s of wi dt h 2
x c e l l s = 50
INCLUDE mat e r i al s . mi l
ZONE f ue l MATERIAL f ue l X_MIN 0 X_MAX a
pi = 4atan( 1)
k = nuSigmaF/( SigmaA + D( pi /a ) 2)
PRINT a k e f f k k e f f k
$ milonga bc.mil > bc.dat
$ gnuplot bc.gnuplot
$
118
milonga v0.1
1e-05
1e-04
1e-03
1e-02
1e-01
80 82 84 86 88 90 92 94 96 98 100
n
u
m
e
r
i
c
a
l

k

-

a
n
a
l
y
t
i
c
a
l

k
slab width
error in numerical ke vs bare length
4.3.3 Circle quadrature
In a similar fashion, this section shows what happens when a continuous geometry does not coincide
with a discrete mesh. This time, a bare circle with a varying radius : is solved and the multiplicative
factor vs. the radius is shown. Because of the complexity the many possible combinations of interfer-
ences between a circular domain and a square mesh, the dependance of /
e
with : is non-trivial. The
rst example uses a 50 50 mesh and the second a 200 200, to show that even though there are
ripples in the numerical solution, it should converge to the analytical one for innite number of cells.
circle50.mil
The input below solved a bare circle of radius : immersed in a square bare domain of size 100 100
discretized with a 50 50 mesh. The values of the numerical an analytical /
e
along with the relative
error are plotted as a function of the radius :.
# paramet ri c st udy on k e f f vs radi us
# i n a bare c i r c l e wi t h a square mesh
PROBLEM DIMENSIONS 2 GROUPS 1
PARAMETRIC r 30 40 0. 02
x b ar e l e ng t h = 100
y b ar e l e ng t h = x b ar e l e ng t h
x c e l l s = 50
y c e l l s = x c e l l s
INCLUDE mat e r i al s . mi l
11o
milonga v0.1
# cent ered c i r c l e of radi us r
ZONE f ue l MATERIAL f ue l X_CENTER x b ar e l e ng t h /2 Y_CENTER y b ar e l e ng t h /2
RADIUS r
k = nuSigmaF/( SigmaA + D( 2. 40483/ r ) 2)
PRINT r k e f f k ( k e f f k) /k
$ milonga circle50.mil > circle50.dat
$ gnuplot circle50.gnuplot
$
0.72
0.76
0.80
0.84
0.88
0.92
30 32 34 36 38 40
k
radius
ke vs radius
analytical
numerical
5.0e-03
1.0e-02
2.0e-02
4.0e-02
30 32 34 36 38 40
r
e
l
a
t
i
v
e

e
r
r
o
r
radius
relative error vs radius
circle200.mil
Essentially the same problem is solved using a 200 200 mesh. A comparison between the solution
found with this input with respect to the previous example is provided. Only a small interval is
1:o
milonga v0.1
studied because of running time reasons.
# paramet ri c st udy on k e f f vs radi us
# i n a bare c i r c l e wi t h a square mesh
PROBLEM DIMENSIONS 2 GROUPS 1
PARAMETRIC r 34 36 0. 02
x b ar e l e ng t h = 100
y b ar e l e ng t h = x b ar e l e ng t h
x c e l l s = 200
y c e l l s = x c e l l s
INCLUDE mat e r i al s . mi l
ZONE f ue l MATERIAL f ue l X_CENTER x b ar e l e ng t h /2 Y_CENTER y b ar e l e ng t h /2
RADIUS r
k = nuSigmaF/( SigmaA + D( 2. 40483/ r ) 2)
PRINT r k e f f k ( k e f f k) /k
$ milonga circle200.mil > circle200.dat
$ gnuplot circle200.gnuplot
$
0.795
0.800
0.805
0.810
0.815
0.820
0.825
0.830
0.835
0.840
34 34.5 35 35.5 36
k
radius
ke vs radius
analytical
50x50 mesh
200x200 mesh
1:1
milonga v0.1
2.5e-03
5.0e-03
1.0e-02
2.0e-02
4.0e-02
34 34.5 35 35.5 36
r
e
l
a
t
i
v
e

e
r
r
o
r
radius
relative error vs radius
50x50 mesh
200x200 mesh
4.3.4 Control rod cusp problem
This example is an extension to the two-zone slab introduced in section 4.1.6. Now, the width o of
the absorber material with /

< 1 is varied from 20 to 80 with and increment of 10


2
. The eective
multiplication factor as computed from the numerical problem is compared to the analytical /
e
given
by the critical condition

1
I

fI
/
e

aI

tan

1
1
II

aII


fII
/
e

(/ o)

1
II

aII


fII
/
e

tanh

1
1
I

fI
/
e

aI

= 0
Of course, /
e
(o) should be a continuous and smooth function of o. Indeed, the analytical solution
is. However, depending on the number of cells, the numerical scheme and the method of cell cross-
section association, the numerical solution may present cusps or even discontinuities with respect to o.
The user is encouraged to try dierent nodalizations and options to analyze the results, sharing her
ndings with milongas author. Actually, the problem of cross-section dilution was already studied
using SLEPc [10].
cusp.mil
The number of cells selected is rather small to stress the eects of the cusps on /
e
(o) because of the
dilution of cross sections into nite cells.
# st udy of t he e f f e c t s of t he rod cusp probl em
# usi ng mil onga s paramet ri c c a p a b i l i t i e s
PROBLEM DIMENSIONS 1 GROUPS 1
# parameter a i s var i ed from 20 t o 80 wi t h a 0. 01 s t ep
PARAMETRIC a 20 80 0. 01
# t h i s assi gnment i s i gnore when making a paramet ri c
# c a l c ul a t i o n on a
a = 50
b = 100
1::
milonga v0.1 1.04 1.06 1.08 1.10 1.12 1.14 1.16 1.18 1.20 1.22 1.24
40 45 50 55 60
k e
a
ke vs. a (zoomed) analytical numerical
x b ar e l e ng t h = b
# a smal l number of c e l l s i s s e l e c t e d i n order
# t o s t r e s s t he cusp probl em
x c e l l s = 25
# scheme opt i ons
##################################
# t he user i s urged t o t e s t a l l t hes e combi nat i ons
# and anal yze t he r e s u l t s obt ai ned accordi ng t o
# t he expl anat i on gi ven i n mil onga s documentati on
SCHEME VOLUMES XS_MEAN D_MEAN
# SCHEME VOLUMES XS MEAN D EPSILON
# SCHEME VOLUMES XS CENTER DMEAN
# SCHEME VOLUMES XS CENTER D EPSILON
# SCHEME DIFFERENCES XS MEAN GRAD D NEIGHBORS
# SCHEME DIFFERENCES XS MEAN GRAD D LOCAL
# SCHEME DIFFERENCES XS CENTER GRAD D NEIGHBORS
# SCHEME DIFFERENCES XS CENTER GRAD D LOCAL
# cr os s s e c t i ons
##################################
nu1 = 0. 010
nu2 = 0. 015
a1 = 0. 015
a2 = 0. 010
d1 = 0. 5
d2 = 1. 5
MATERIAL f ue l {
D 1 d2
SigmaT 1 a2
nuSigmaF 1 nu2
}
MATERIAL rod {
D 1 d1
SigmaT 1 a1
nuSigmaF 1 nu1
}
# zones
##################################
ZONE rod MATERIAL rod X_MIN 0 X_MAX a
ZONE f ue l MATERIAL f ue l X_MIN a X_MAX b
# a na l y t i c a l mul t i p l i c a t i o n f ac t or
##################################
# i nt e r v a l t o l ook f or t he a na l y t i c a l k
eps = 0. 02 + 0. 02( a20) /100
# eval uat e k from t he a na l y t i c a l c r i t i c a l condi t i on
# t aki ng as an i n i t i a l guess t he numeri cal k e f f
k = k e f f
k = root ( sqrt ( d1abs ( nu1/ka1 ) ) tan( sqrt ( ( 1/ d2 ) abs ( a2nu2/k) ) ( ba ) ) + sqrt
( d2abs ( a2nu2/k) ) tanh( sqrt ( ( 1/ d1 ) abs ( nu1/ka1 ) ) a ) , k , k e f f eps , k e f f
+eps )
PRINT a k e f f k
$ milonga cusp.mil > cusp.dat
$ gnuplot cusp.gnuplot
$
1:
milonga v0.1
0.70
0.80
0.90
1.00
1.10
1.20
1.30
1.40
20 30 40 50 60 70 80
k
e

a
ke vs. a
analytical
numerical
1.04
1.06
1.08
1.10
1.12
1.14
1.16
1.18
1.20
1.22
1.24
40 45 50 55 60
k
e

a
ke vs. a (zoomed)
analytical
numerical
-6e-03
-5e-03
-4e-03
-3e-03
-2e-03
-1e-03
0e+00
1e-03
2e-03
3e-03
4e-03
20 30 40 50 60 70 80
e
r
r
o
r
a
absoulte error vs. b
1:i
milonga v0.1
4.4 Non-linear problems
As stated in page 9, non-linear problems arise when the coecients of the diusion equation depend
themselves on the ux. To solve this kind of problems, an iterative scheme may be used in the hope
that it will converge to the desired solution after a number of steps. The two examples given in
this sections deal with non-linear problems. The rst one illustrates how milonga treats xenon as a
neutronic poison and the second one implements a simple algorithm to nd the position of a control
rod that renders a reactor critical. Again, these examples are just an illustration of milonga features
and do not posses any particular engineering content whatsoever.
4.4.1 Xenon eects
This example shows how to use milongas capabilities regarding xenon poisoning by solving again our
good old friend, the bare one-speed one-meter width slab. An iterative scheme is used, where the
actual ux is computed using the steady-state
135
Xe distribution computed in the previous step. A
a power setpoint and a non-zero value of 1
f
for at least one material has to be entered in order
for milonga to be able to compute a dimensional value for the ux distribution (r) and therefore
evaluate the xenon distribution this ux distribution gives. Also, function xenon(x) should be used
when giving cross sections dependance to dene the xenon feedback eects. Calculation may end after
a xed number of stepsas the case illustratedor by setting a ag when two successive /
e
s dier
less than a certain threshold.
xenon.mil
A bare slab of one meter width is solved taking into account xenon feedback eects. Units of
xenon(x) are inverse cubic length, in whatever units x bare length is. That is to say, this function
gives a density of
135
Xe nuclei per volume. Multiplicative coecients should have appropriate units
in order to recover inverse length for the macroscopic cross sections. On the other hand, 1
f
has
units of energy times inverse length, where energy units should be compatible with the units of the
power setpoint. Default values for , yields and microscopic
135
Xe neutron absorption are used. The
multiplicative factor vs. the step numberthe rst step considers no poisoningand the ux and
xenon distribution for the rst seven steps are shown as outputs. Note that the xenon distribution
for each step is the resulting distribution and not the one used when computing the ux. Again, for
step one the xenon distribution used for computing (r) is assumed to be identically zero.
# exampl e i l l u s t r a t i n g how t o i ncl ude xenon
# f eedback e f f e c t s i n mil onga
# si mpl e onespeed s l ab probl em wi t h a
# smal l number of c e l l s and cent er XS
PROBLEM DIMENSIONS 1 GROUPS 1
SCHEME VOLUMES XS_CENTER D_EPSILON
x b ar e l e ng t h = 100 # i n cm
x c e l l s = 25
# f i l e out i s def i ned as st ep , so a c t ua l l y
# one f i l e per s t ep wi l l be creat ed , c a l l e d
# out . n where n i s t he s t ep number
FILE out out STEP
# we wi l l perform f i f t e e n s t e ps
# a l t e r na t i v e l y , a convergence check can be made by
# comparing two s uc e s s i v e k e f f and s e t t i ng t he v ar i ab l e
# done t o t rue
s t a t i c i t e r a t i o n s = 15
# power s e t poi nt : bei ng a one di mensi onal probl em , i t
# i s a dens i t y per uni t area per pendi cul ar t o x ax i s
# l e ng t h are i n cm, so f or a cubi c r eact or of s i z e
1:j
milonga v0.1 1.0e+13 2.0e+13 3.0e+13 4.0e+13 5.0e+13 6.0e+13 7.0e+13 8.0e+13 9.0e+13 1.0e+14
0 10 20 30 40 50 60 70 80 90 100 x e n o n c o n c e n t r a t i o n [ 1 / c m ^ 3 ]
x
xenon distribution in the rst seven iterations step 1 step 2 step 3 step 4 step 5 step 6 step 7
# 100x100x100 wi t h a t o t a l power of 1 MW wi t h energy
# i n j o ul e s and ti me i n seconds , t he power dens i t y
# s e t poi nt shoul d be
# 1e6 /(100 x100 ) = 100
# t he power s e t poi nt i s mandatory f or xenon c a l c ul a t i o ns
power = 100
# keep t he computed k e f f i n t he l a s t s t ep ( bef or e t he
# f i r s t ZONE keyword ) t o impl ement a convergence check
kol d = k e f f
# a s i ng l e zone spanni ng t he whol e bare l e ng t h
ZONE f ue l MATERIAL f ue l
# wr i t e i nt o t he out put f i l e f l ux , xenon concent rat i on an XS
PRINT_FUNCTION FILE out f l ux 1 xenon nuSigmaF 1 SigmaA 1
# wr i t e i nt o st andard out put t he st ep , act ual k e f f and
# d i f f e r e nc e wi t h r e s pe c t t o t he l a s t one
PRINT s t a t i c s t e p k e f f k e f f kol d
# uncoment t o q ui t whenever convergence i s at t ai ned
# i ns t ead of when reachi ng s t a t i c i t e r a t i o n s
# done = l e s s ( abs ( k e f f kol d ) , 1e5)
# f unct i on xenon( x ) cont ai ns atoms per vol umet r i c uni t s
# ESigmaF has uni t s of j o ul e s /cm
MATERIAL f ue l {
D 1 1 + 5e18xenon ( x)
SigmaA 1 4e3 + 3e17xenon ( x)
nuSigmaF 1 nu4e3 5e17xenon ( x)
ESigmaF 1 200 e6 1. 6 e 19(2e3 1e17xenon ( x) /nu)
}
$ milonga xenon.mil > xe.dat
$ gnuplot xenon.gnuplot
$
0.6
0.8
1.0
1.2
1.4
1.6
1.8
2.0
0 2 4 6 8 10 12 14 16
k
e

step
ke vs. step
1:6
milonga v0.1
0.0e+00
5.0e+12
1.0e+13
1.5e+13
2.0e+13
2.5e+13
3.0e+13
0 10 20 30 40 50 60 70 80 90 100

u
x

[
1
/
(
c
m
^
2

s
)
]
x
ux distribution in the rst seven iterations
step 1
step 2
step 3
step 4
step 5
step 6
step 7
1.0e+13
2.0e+13
3.0e+13
4.0e+13
5.0e+13
6.0e+13
7.0e+13
8.0e+13
9.0e+13
1.0e+14
0 10 20 30 40 50 60 70 80 90 100
x
e
n
o
n

c
o
n
c
e
n
t
r
a
t
i
o
n

[
1
/
c
m
^
3
]
x
xenon distribution in the rst seven iterations
step 1
step 2
step 3
step 4
step 5
step 6
step 7
4.4.2 Criticallity with a control rod
The next example shows another kind of non-linear diusion problem. It consists of locating the
position of a control rod such that the resulting ensemble is as critical as possible. Again, this is
just an illustration of milongas capabilities and not a real application. The problem is a two-group
two-dimensional horizontal core with a radial reector and four control rods entering from above. Two
control rods are xed in space and the insertion of the other two is controlled by a variable that is
modied in each iteration according to the sign of the resulting static reactivity.
rod.mil
An initial position of 50% insertion is given by setting the initial condition for variable pos to 0.5 by
using the postx init. Then, after solving the eigenvalue problem with the zone corresponding to
the two control rods dened in terms of the pos variable, the insertion is updated as
pos pos + 10 (/
e
1)
and a new iteration is performed. The ux distribution is written to le flux.dat, that is not dened
as STEP but the print instruction has a condition that writes the information only if static step
1:
milonga v0.1
is equal to static iterations, i.e. only in the last step.
# exampl e of a si mpl e al gori t hm t o make a r eact or
# c r i t i c a l by moving a c ont r ol rod
PROBLEM DIMENSIONS 2 GROUPS 2
s t a t i c i t e r a t i o n s = 10 # number of s t a t i c s t e ps
# bare l e ng t hs and nodal i z at i on
x b ar e l e ng t h = 600
y b ar e l e ng t h = 650
x c e l l s = 100
y c e l l s = 108
# i n i t i a l val ue ( onl y f or s t a t i c s t e p = 1) of v ar i ab l e pos ,
# t hat i s i mp l i c i t l y def i ned by t h i s assi gnment al s o
po s i ni t = 0. 5
MATERIAL f ue l {
D 1 1. 500 D 2 0. 400
SigmaS 1 . 2 0. 020 SigmaA 1 0. 010
SigmaA 2 0. 085 nuSigmaF 2 0. 130
}
MATERIAL f ue l r od {
D 1 1. 500 D 2 0. 400
SigmaS 1 . 2 0. 020 SigmaA 1 0. 010
SigmaA 2 0. 130 nuSigmaF 2 0. 130
}
MATERIAL r e f l e c t o r {
D 1 2. 000 D 2 0. 300
SigmaS 1 . 2 0. 040 SigmaA 1 0. 000
SigmaA 2 0. 010 nuSigmaF 2 0. 000
}
# geometry d e f i ni t i o n
# out er r e f l e c t o r
ZONE r e f l MATERIAL r e f l e c t o r X_CENTER 300 Y_CENTER 300 OUTER_RADIUS 300
INNER_RADIUS 250
# r eact or core
ZONE f ue l MATERIAL f ue l X_CENTER 300 Y_CENTER 300 OUTER_RADIUS 250
# two c ont r ol rods whose i ns e r t i on i s def i ned by v ar i ab l e pos
ZONE rod1 MATERIAL f ue l r od X_MIN 200 X_MAX 240 Y_MAX 700 Y_MIN 600(1pos )
ZONE rod2 MATERIAL f ue l r od X_MIN 300 X_MAX 340 Y_MAX 700 Y_MIN 600(1pos )
# two f i x e d c ont r ol rods
ZONE rod3 MATERIAL f ue l r od X_MIN 400 X_MAX 440 Y_MAX 700 Y_MIN 250
ZONE rod4 MATERIAL f ue l r od X_MIN 150 X_MAX 160 Y_MAX 700 Y_MIN 150
# wr i t e t o st andard out put how t he r e a c t i v i t y e v ol v e s as
# t he c ont r ol rods are moved s t ep by s t ep
PRINT s t a t i c s t e p pos k e f f ( k e f f 1)/ k e f f 1 e5
# f i l e t hat wi l l cont ai n t he l a s t ( c r i t i c a l ) f l u x d i s t r i b u t i o n
# not e t hat i t i s not def i ned wi t h t he STEP keyword as t he PRINT FUNCTION
# i ns t r uc t i on bel ow makes sure onl y t he l a s t f l u x d i s t r i b u t i o n i s pr i nt ed
FILE f l ux f l ux . dat
# t he PRINT FUNCTION i s execut ed onl y i f t he condi t i on e v al uat e s
# t o t rue , i . e onl y at t he l a s t s t ep of t he i t e r a t i o n
PRINT_FUNCTION CONDITION equal ( s t a t i c s t e p , s t a t i c i t e r a t i o n s ) FILE f l ux f l ux 1
f l ux 2 SigmaA 2
# al gori t hm t o updat e t he pos i t i on of t he c ont r ol rod accordi ng
# t o t he s i gn of t he l a s t computed r e a c t i v i t y
1:8
milonga v0.1
pos = pos + 10( k e f f 1)
$ milonga rod.mil
1.000000e+00 5.000000e-01 1.007512e+00 7.456008e+02
2.000000e+00 5.000000e-01 1.007512e+00 7.456008e+02
3.000000e+00 5.751202e-01 1.005309e+00 5.281038e+02
4.000000e+00 6.282109e-01 1.002804e+00 2.796322e+02
5.000000e+00 6.562526e-01 1.000962e+00 9.608342e+01
6.000000e+00 6.658702e-01 1.000259e+00 2.592735e+01
7.000000e+00 6.684636e-01 1.000134e+00 1.337936e+01
8.000000e+00 6.698017e-01 1.000013e+00 1.254712e+00
9.000000e+00 6.699271e-01 9.999950e-01 -4.995780e-01
1.000000e+01 6.698772e-01 9.999950e-01 -4.995780e-01
$ gnuplot rod.gnuplot
$
0
100
200
300
400
500
600
0 100 200 300 400 500 600
thermal critical absorption XS
"ux.dat" u 1:2:5
0
0.02
0.04
0.06
0.08
0.1
0.12
0.14
0
100
200
300
400
500
600
0 100 200 300 400 500 600
thermal critical ux distribution
"ux.dat" u 1:2:4
0
0.5
1
1.5
2
2.5
3
3.5
4
4.5
1:o
milonga v0.1
4.5 Coupled calculations
A coupled calculation is needed whenever there is at least one parameter that inuences the solution
of the diusion equation but is outside milongas scope. Therefore, an iterative scheme should be
designed where information between milonga and one or more external codes is to be exchanged. For
sure, coupled calculations are one of the most complex task a nuclear engineer may have to perform
and, as such, this is the last section of the examples chapter. In these cases, the input les may get
rather cumbersome.
There are a number of ways of passing information from one process to another, being the most
straightforwardbut also the most inecientwriting and reading from plain les. Modern operating
systems provide inter-process communication capabilities through kernel system calls that can be
used to couple calculation codes running in the same host. Distributed coupled calculations may use
network connections to exchange information.
Although some le-based coupling may be implemented, milongas coupling schemeactually pro-
vided by the wasora frameworkis mainly based on POSIX shared memory objects and semaphores.
The main objective of this scheme is to couple codes belonging to the wasora suite. Nevertheless,
coupled calculations with ad-hoc codes is also possible. Remote coupling based on TCP connections
will be implemented in future versions.
Anyhow, presenting examples about coupled calculations is a rather dicult task as not only
should milongas features and characteristics be discussed, but also the external program computing
and coupling capabilities should be explained. This section shows one single example regarding a
coupled calculation with thermalhydraulic feedback using RELAP [11] as the plant code.
4.5.1 1D core coupled with RELAP
This example solves a very simplied problem that involves the computation of power, fuel and
coolant temperature distributions in a simplied model of a nuclear reactor core. A two-group one-
dimensional neutronic model computed by milonga is coupled to a one-dimensional thermalhydraulic
RELAP model computed. RELAP is a standard code developed by the US N.R.C. to evaluate power
reactor safety transients [11]. It has a great number of two-phase hydraulic models and heat transfer
correlations and has been widely validated with experiments.
The original version of RELAP does provide a mechanism to handle calculations coupled to the
neutronic code PARCS [12] based in the PVM libray. However, to be able to perform general coupled
calculations, an extension RELAP5CPL was developed by TECNA S.A. to exchange information
using shared memory objects [13]. Some references that used these extensions include [14] and [15].
As RELAP5CPL uses a coupling mechanism compatible with milonga, it can be used to perform
neutronic-thermalhydraulic calculations.
The problem selected to serve as an example of a coupled calculation is a simple one-dimensional
model both in the thermalhydraulic and in the neutronic problem. The RELAP inputthat is not
shownmodels a single pipe subject to a xed pressure dierence. It has some nodes that act both as
a inlet thermalhydraulic zone and as a lower reector. The active length consists of twenty volumes
that are in contact to a heat structure that represents the fuel elements. An upper reector zone is
also provided. As requested in the coupling lethat is shown in the terminal windowRELAP5CPL
writes the twenty values of the fuel temperature, coolant temperature and coolant density to shared
memory objects. This information is read by milonga and interpolated to evaluate the cross sections
associated to those distributions and to compute the ux and power distribution, that is written back
for RELAP5CPL to compute again the thermalhydraulics.
The thermalhydraulic model and the neutron cross sections dependance are made up in order
to obtain results that serve to illustrate the eects of an iterative calculation. The eects of the
temperatures and the xenon on the macroscopic cross sections are exaggerated.
1o
milonga v0.1
RELAP milonga
relap_status
coolant_temperature
coolant_density
fuel_temperature
total_power
power_distribution
20 doubles (=real*8)
system shared memory
lower reector
fuel
upper reector
core.mil
While milonga solves the steady-state neutron diusion equation, RELAP is essentially a transient
code. In the coupled scheme, RELAP exchange information once every one hundred transient time
steps, that correspond to a single static step of milonga. The objective of the coupled calculation is to
nd a power distribution that generate certain thermalhydraulic distributions that in turn give rise to
the power distribution found. The details about the thermalhydraulic model are not important. The
coupling le used is shown in the terminal, from which the general idea of the information exchanged
may be grasped. Milonga reads three vector from shared memory and constructs three continuous
functions containing the coolant temperature, coolant density and fuel temperature distributions as a
function of the axial coordinate r. Conversely, from the continuous power density function it builds
a vector of size twenty that is exported to the shared memory segment by evaluating the continuous
power density at the location of the center of the RELAP cells measured in milongas coordinates.
Milonga also import a number of administrative variables written by RELAP, one of which is a ag
to indicate that the calculation has nished. Thus, the number of static steps is set to a big value to
prevent milonga from nishing before RELAP. The macroscopic nuclear parameters of the reectors
are constant and uniform, while the cross sections of the active length are assumed to depend on the
fuel burnup distribution, on the fuel temperature, on the coolant temperature, on the coolant density
and on the xenon distribution in the form
(r) =
0

/(r)

/(r)

P
0
({ {
0
)
where
0
is the cross section evaluated at the nominal parameters, /(r) is the fuel burnup at position r
and { is the partial derivative of the cross section with respect to parameter { evaluated at the
nominal parameter {
0
.
The fuel burnup is given by the le burnup.dat and the cross sections and the derivatives are
read from xs.dat.
The terminal window shows one way of executing this coupled calculation, namely running RE-
LAP in background by passing an ampersand & in the commandline and then executing milonga
afterward. Another way may be to open two terminals and run each program in one terminal as
usual. The resulting gures show that RELAP start with at cold temperature distributions and how
they converge to their nal values as time passes by. The exaggerated eects of the thermalhydraulic
11
milonga v0.1
parameters on the cross sections, i.e. big derivatives, allow to see how the non-linear iterative scheme
in milonga makes the distributions to oscillate before converging to the nal solution.
# 1D core coupl ed wi t h a 1D core model i n RELAP
# a modi f i ed ver s i on of RELAP c a l l e d RELAP5CPL i s used
# t o coupl e t he codes t hrough shared memory ob j e c t s and
# synchroni ze them usi ng semaphores
# see r e f e r e nc e s i n t he documentati on f or f ur t he r i nf ormat i on
PROBLEM DIMENSIONS 1 GROUPS 2
# number of c e l l s i n t he RELAP nodal i z at i on of t he core
r e l a p numbe r o f c e l l s = 20
# t h i s vect or cont ai ns t he coor di nat es of t he cent er s
# of t he c e l l s t hat r epr es ent t he ac t i v e l e ng t h i n RELAP
VECTOR r e l a p c e l l 20
# t hes e v e c t or s cont ai n t he val ues t hat t he pr ope r t i e s
# t ake at t he l oc at i ons gi ven by r e l a p c e l l
# t hes e are t o be read from RELAP
VECTOR cool ant t emper at ur e 20
VECTOR c ool ant de ns i t y 20
VECTOR f ue l t e mpe r at ur e 20
# cons t r uct t hr ee cont i nuous f unct i ons usi ng t he c e l l s
# pos i t i ons and t he t hr ee v e c t or s above t hat are t o be
# read from RELAP
FUNCTION Tcool ( x ) VECTORS r e l a p c e l l cool ant t emper at ur e INTERPOLATION akima
FUNCTION Tf uel ( x ) VECTORS r e l a p c e l l f ue l t e mpe r at ur e INTERPOLATION akima
FUNCTION dcool ( x ) VECTORS r e l a p c e l l c ool ant de ns i t y INTERPOLATION akima
# t h i s vect or i s where t he power d i s t r i b u t i o n i s t o
# be wr i t t en by mi l onga f or RELAP t o read i t
VECTOR powe r di s t r i but i on 20
# t hes e v a r i a b l e s are used t o exchange admi ni s t r at i v e
# i nf ormat i on wi t h RELAP
VAR ns t s p count i s c a l l r s t r e c 0 probl emtype05 probl emopt611 restartnum
# a l ar g e number i s gi ven here because we expect
# RELAP5CPL t o t e l l us t o s t op usi ng v ar i ab l e done
s t a t i c i t e r a t i o n s = 1000
# geometry d e f i ni t i o n ( i n cm)
b o t r e f l l e n g t h = 45
t o p r e f l l e n g t h = 25
a c t i ve l e ng t h = 530
x b ar e l e ng t h = b o t r e f l l e n g t h + a c t i ve l e ng t h + t o p r e f l l e n g t h
# not e t hat t he number of c e l l s i n t he neut roni c probl em
# does not need t o be t he same as i n t he t her mal hydr aul i c model
# ac t ual l y , here t hey have an o f f s e t
x c e l l s = 100
# pos i t i on of t he cent er s of t he ac t i v e l e ng t h c e l l s i n r el ap
# measured i n mil onga s coordi nat e system
r e l a p c e l l 1 = 0. 5 a c t i ve l e ng t h / r e l a p numbe r o f c e l l s + b o t r e f l l e n g t h
r e l a p c e l l 2 = 1. 5 a c t i ve l e ng t h / r e l a p numbe r o f c e l l s + b o t r e f l l e n g t h
r e l a p c e l l 3 = 2. 5 a c t i ve l e ng t h / r e l a p numbe r o f c e l l s + b o t r e f l l e n g t h
r e l a p c e l l 4 = 3. 5 a c t i ve l e ng t h / r e l a p numbe r o f c e l l s + b o t r e f l l e n g t h
r e l a p c e l l 5 = 4. 5 a c t i ve l e ng t h / r e l a p numbe r o f c e l l s + b o t r e f l l e n g t h
r e l a p c e l l 6 = 5. 5 a c t i ve l e ng t h / r e l a p numbe r o f c e l l s + b o t r e f l l e n g t h
r e l a p c e l l 7 = 6. 5 a c t i ve l e ng t h / r e l a p numbe r o f c e l l s + b o t r e f l l e n g t h
r e l a p c e l l 8 = 7. 5 a c t i ve l e ng t h / r e l a p numbe r o f c e l l s + b o t r e f l l e n g t h
r e l a p c e l l 9 = 8. 5 a c t i ve l e ng t h / r e l a p numbe r o f c e l l s + b o t r e f l l e n g t h
r e l a p c e l l 1 0 = 9. 5 a c t i ve l e ng t h / r e l a p numbe r o f c e l l s + b o t r e f l l e n g t h
r e l a p c e l l 1 1 = 10. 5 a c t i ve l e ng t h / r e l a p numbe r o f c e l l s + b o t r e f l l e n g t h
1:
milonga v0.1
r e l a p c e l l 1 2 = 11. 5 a c t i ve l e ng t h / r e l a p numbe r o f c e l l s + b o t r e f l l e n g t h
r e l a p c e l l 1 3 = 12. 5 a c t i ve l e ng t h / r e l a p numbe r o f c e l l s + b o t r e f l l e n g t h
r e l a p c e l l 1 4 = 13. 5 a c t i ve l e ng t h / r e l a p numbe r o f c e l l s + b o t r e f l l e n g t h
r e l a p c e l l 1 5 = 14. 5 a c t i ve l e ng t h / r e l a p numbe r o f c e l l s + b o t r e f l l e n g t h
r e l a p c e l l 1 6 = 15. 5 a c t i ve l e ng t h / r e l a p numbe r o f c e l l s + b o t r e f l l e n g t h
r e l a p c e l l 1 7 = 16. 5 a c t i ve l e ng t h / r e l a p numbe r o f c e l l s + b o t r e f l l e n g t h
r e l a p c e l l 1 8 = 17. 5 a c t i ve l e ng t h / r e l a p numbe r o f c e l l s + b o t r e f l l e n g t h
r e l a p c e l l 1 9 = 18. 5 a c t i ve l e ng t h / r e l a p numbe r o f c e l l s + b o t r e f l l e n g t h
r e l a p c e l l 2 0 = 19. 5 a c t i ve l e ng t h / r e l a p numbe r o f c e l l s + b o t r e f l l e n g t h
# t he power s e t poi nt f or mil onga shoul d be i n w/cm2 f or
# f or t he xenon t o be c o r r e c t l y computed
power = 6500
# t h i s v ar i ab l e i s t he act ual t o t a l power i n wat t s t hat
# i s needed t o convert from power dens i t y t o t he act ual
# power RELAP needs
t ot al power = 5e6
# burnup i s gi ven as a f unct i on of t he a x i a l l oc at i on measured
# from t he bottom of t he ac t i v e l engt h , t o convert i t t o
# mil onga s coordi nat e system , t he l e ng t h of t he r e f l e c t o r i s
# t o be t aken i nt o account so b ( x ) i s t he burnup t o be used
# care has t o be t aken onl y t o eval uat e b ( x ) at x l oc at e d i n t he
# ac t i v e regi on , ot her wi s e e x t r apoal at e d val ues wi l l be wrong
FUNCTION b f r om cor e ( x ) FILE burnup . dat
FUNCTION b( x ) = b f r om cor e ( xb o t r e f l l e n g t h )
# nominal parameters val ues f or t he XS t a b l e s
Tf uel 0 = 637. 0+273. 15 # [ K ]
dcool 0 = 801. 9 # [ kg / m3 ]
Tcool 0 = 295. 8+273. 15 # [ K ]
# cr os s s e c t i ons at c e nt r al val ues
# v ar i ab l e bu means burnup , but i t i s a dummy v ar i ab l e j us t
# t o t e l l mil onga t hes e are s i ng l e val ue f unct i ons
# when t hes e f unt i ons are t o be eval uat ed at t he MATERIAL
# keyword , t he argument shoul d be b ( x )
FUNCTION D1( bu) FILE xs . dat COLUMNS 1 2
FUNCTION D2( bu) FILE xs . dat COLUMNS 1 3
FUNCTION abs1 ( bu) FILE xs . dat COLUMNS 1 4
FUNCTION sca12 ( bu) FILE xs . dat COLUMNS 1 5
FUNCTION sca21 ( bu) FILE xs . dat COLUMNS 1 6
FUNCTION abs2 ( bu) FILE xs . dat COLUMNS 1 7
FUNCTION nuf 1 ( bu) FILE xs . dat COLUMNS 1 8
FUNCTION nuf 2 ( bu) FILE xs . dat COLUMNS 1 9
FUNCTION Ef1 ( bu) FILE xs . dat COLUMNS 1 10
FUNCTION Ef2 ( bu) FILE xs . dat COLUMNS 1 11
# d e r i v a t i v e s wi t h r e s pe c t t o xenon
FUNCTION dabs1dXe ( bu) FILE xs . dat COLUMNS 1 14
FUNCTION dsca12dXe ( bu) FILE xs . dat COLUMNS 1 15
FUNCTION dsca21dXe ( bu) FILE xs . dat COLUMNS 1 16
FUNCTION dabs2dXe ( bu) FILE xs . dat COLUMNS 1 17
FUNCTION dnuf1dXe ( bu) FILE xs . dat COLUMNS 1 18
FUNCTION dnuf2dXe ( bu) FILE xs . dat COLUMNS 1 19
FUNCTION dEf1dXe ( bu) FILE xs . dat COLUMNS 1 20
FUNCTION dEf2dXe ( bu) FILE xs . dat COLUMNS 1 21
# wi t h r e s pe c t t o f u e l t emperat ure
FUNCTION dabs1dTf uel ( bu) FILE xs . dat COLUMNS 1 24
FUNCTION dsca12dTf uel ( bu) FILE xs . dat COLUMNS 1 25
FUNCTION dsca21dTf uel ( bu) FILE xs . dat COLUMNS 1 26
FUNCTION dabs2dTf uel ( bu) FILE xs . dat COLUMNS 1 27
FUNCTION dnuf 1dTf uel ( bu) FILE xs . dat COLUMNS 1 28
FUNCTION dnuf 2dTf uel ( bu) FILE xs . dat COLUMNS 1 29
FUNCTION dEf 1dTf uel ( bu) FILE xs . dat COLUMNS 1 30
FUNCTION dEf 2dTf uel ( bu) FILE xs . dat COLUMNS 1 31
1
milonga v0.1
# wi t h r e s pe c t t o cool ant t emperat ure
FUNCTION dabs1dTcool ( bu) FILE xs . dat COLUMNS 1 34
FUNCTION dsca12dTcool ( bu) FILE xs . dat COLUMNS 1 35
FUNCTION dsca21dTcool ( bu) FILE xs . dat COLUMNS 1 36
FUNCTION dabs2dTcool ( bu) FILE xs . dat COLUMNS 1 37
FUNCTION dnuf 1dTcool ( bu) FILE xs . dat COLUMNS 1 38
FUNCTION dnuf 2dTcool ( bu) FILE xs . dat COLUMNS 1 39
FUNCTION dEf1dTcool ( bu) FILE xs . dat COLUMNS 1 40
FUNCTION dEf2dTcool ( bu) FILE xs . dat COLUMNS 1 41
# wi t h r e s pe c t t o cool ant dens i t y
FUNCTION dabs1ddcool ( bu) FILE xs . dat COLUMNS 1 44
FUNCTION dsca12ddcool ( bu) FILE xs . dat COLUMNS 1 45
FUNCTION dsca21ddcool ( bu) FILE xs . dat COLUMNS 1 46
FUNCTION dabs2ddcool ( bu) FILE xs . dat COLUMNS 1 47
FUNCTION dnuf 1ddcool ( bu) FILE xs . dat COLUMNS 1 48
FUNCTION dnuf 2ddcool ( bu) FILE xs . dat COLUMNS 1 49
FUNCTION dEf 1ddcool ( bu) FILE xs . dat COLUMNS 1 50
FUNCTION dEf 2ddcool ( bu) FILE xs . dat COLUMNS 1 51
# read RELAP5CPL admi ni s t r at i v e i nf ormat i on i nc l udi ng v ar i ab l e
# done t hat when s e t t o nonzero makes mil onga s t op
PRINT HEADER TEXT \# wai t i ng f o r i n i t i a l semaphore from r e l ap5c pl . . .
NONEWLINE FLUSH
IMPORT SHM_OBJECT r e l a p s t a t us {
SEMAPHORE_WAIT r e l ap r e ady
t dt ns t s p count i s c a l l r s t r e c 0 done probl emtype05 probl emopt611 restartnum
}
PRINT HEADER TEXT got i t !
# read t emperat ure and dens i t y d i s t r i b u t i o ns bef or e
# s ol v i ng t he di f us s i on equat i on , i . e . bef or e t he f i r s t
# ZONE keyword
IMPORT SHM_OBJECT cool ant t emper at ur e cool ant t emper at ur e
IMPORT SHM_OBJECT c ool ant de ns i t y c ool ant de ns i t y
IMPORT SHM_OBJECT f ue l t e mpe r at ur e f ue l t e mpe r at ur e
# g i v e t he user some f eedback . . .
PRINT HEADER TEXT \# computing i n i t i a l f l ux di s t r i but i o n . . . NONEWLINE FLUSH
# core geometry
ZONE f ue l MATERIAL f ue l
ZONE r e f l bot t om MATERIAL r e f l bot t om X_MAX b o t r e f l l e n g t h
ZONE r e f l t o p MATERIAL r e f l t o p X_MIN x b ar e l e ng t h t o p r e f l l e n g t h
PRINT HEADER TEXT done !
# a f t e r computing t he power d i s t r i b u t i o n ( i . e . a f t e r t he
# l a s t ZONE) f i l l i n t he vect or t hat has t o be passed t o RELAP
# r el ap expect s powe r di s t r i b ut i on t o be normal i zed t o one and
# t he t o t a l di mensi onal power i n wat t s as a s epar at e v ar i ab l e
f = a c t i ve l e ng t h / r e l a p numbe r o f c e l l s 1/power
powe r di s t r i but i on 1 = power dens i t y ( r e l a p c e l l 1 ) f
powe r di s t r i but i on 2 = power dens i t y ( r e l a p c e l l 2 ) f
powe r di s t r i but i on 3 = power dens i t y ( r e l a p c e l l 3 ) f
powe r di s t r i but i on 4 = power dens i t y ( r e l a p c e l l 4 ) f
powe r di s t r i but i on 5 = power dens i t y ( r e l a p c e l l 5 ) f
powe r di s t r i but i on 6 = power dens i t y ( r e l a p c e l l 6 ) f
powe r di s t r i but i on 7 = power dens i t y ( r e l a p c e l l 7 ) f
powe r di s t r i but i on 8 = power dens i t y ( r e l a p c e l l 8 ) f
powe r di s t r i but i on 9 = power dens i t y ( r e l a p c e l l 9 ) f
powe r di s t r i but i on 10 = power dens i t y ( r e l a p c e l l 1 0 ) f
powe r di s t r i but i on 11 = power dens i t y ( r e l a p c e l l 1 1 ) f
powe r di s t r i but i on 12 = power dens i t y ( r e l a p c e l l 1 2 ) f
powe r di s t r i but i on 13 = power dens i t y ( r e l a p c e l l 1 3 ) f
powe r di s t r i but i on 14 = power dens i t y ( r e l a p c e l l 1 4 ) f
powe r di s t r i but i on 15 = power dens i t y ( r e l a p c e l l 1 5 ) f
powe r di s t r i but i on 16 = power dens i t y ( r e l a p c e l l 1 6 ) f
1i
milonga v0.1
powe r di s t r i but i on 17 = power dens i t y ( r e l a p c e l l 1 7 ) f
powe r di s t r i but i on 18 = power dens i t y ( r e l a p c e l l 1 8 ) f
powe r di s t r i but i on 19 = power dens i t y ( r e l a p c e l l 1 9 ) f
powe r di s t r i but i on 20 = power dens i t y ( r e l a p c e l l 2 0 ) f
# wr i t e t he di mensi onal power i nt o shared memory
EXPORT SHM_OBJECT t ot al power t ot al power
# wr i t e t he nondi mensi onal powe r di s t r i b ut i on i nt o shared memory
# and t e l l RELAP we are done wi t h our part f or t h i s s t ep
EXPORT SHM_OBJECT powe r di s t r i but i on powe r di s t r i but i on SEMAPHORE_READY
r e l ap go
PRINT HEADER TEXT \# i nf or mat i on wr i t t en and i n i t i a l semaphore s e t
# pr i nt some i nf ormat i on t o t he screen
PRINT s t a t i c s t e p t k e f f Tcool ( r e l a p c e l l 2 0 )
# dump i ns t ant aneous d i s t r i b u t i o ns t o a f i l e
FILE di s t di s t . dat STEP
PRINT_FUNCTION FILE di s t power dens i t y xenon Tcool Tf uel dcool SigmaA 1
nuSigmaF 2 f l u x 1 f l u x 2
# be pol i t e , and say goodbye t o t he user when f i ni s h e d
PRINT FOOTER TEXT \# coupl ed c a l c ul a t i o n f i ni s he d , have a ni c e day !
## mat er i al d e f i ni t i o ns
# f u e l XS are wr i t t en as a c e nt r al val ue pl us d e r i v a t i v e s t i mes
# i ncrement s wi t h r e s pe c t t o t he c e nt r al val ues
MATERIAL f ue l {
D 1 D1( b( x ) )
D 2 D2( b( x ) )
SigmaA 1 abs1 ( b( x) ) + dabs1dXe ( b( x) ) xenon ( x) + dabs1dTf uel ( b( x) ) ( Tf uel
( x)Tf uel 0 ) + dabs1dTcool ( b( x) ) ( Tcool ( x)Tcool 0 ) + dabs1ddcool ( b( x) ) (
dcool ( x)dcool 0 )
SigmaA 2 abs2 ( b( x) ) + dabs2dXe ( b( x) ) xenon ( x) + dabs2dTf uel ( b( x) ) ( Tf uel
( x)Tf uel 0 ) + dabs2dTcool ( b( x) ) ( Tcool ( x)Tcool 0 ) + dabs2ddcool ( b( x) ) (
dcool ( x)dcool 0 )
SigmaS 1 . 2 sca12 ( b( x) ) + dsca12dXe ( b( x) ) xenon ( x) + dsca12dTf uel ( b( x) ) (
Tf uel ( x)Tf uel 0 ) + dsca12dTcool ( b( x) ) ( Tcool ( x)Tcool 0 ) + dsca12ddcool ( b
( x) ) ( dcool ( x)dcool 0 )
SigmaS 2 . 1 sca21 ( b( x) ) + dsca21dXe ( b( x) ) xenon ( x) + dsca21dTf uel ( b( x) ) (
Tf uel ( x)Tf uel 0 ) + dsca21dTcool ( b( x) ) ( Tcool ( x)Tcool 0 ) + dsca21ddcool ( b
( x) ) ( dcool ( x)dcool 0 )
nuSigmaF 1 nuf 1 ( b( x) ) + dnuf1dXe ( b( x) ) xenon ( x) + dnuf 1dTf uel ( b( x) ) ( Tf uel
( x)Tf uel 0 ) + dnuf 1dTcool ( b( x) ) ( Tcool ( x)Tcool 0 ) + dnuf 1ddcool ( b( x) ) (
dcool ( x)dcool 0 )
nuSigmaF 2 nuf 2 ( b( x) ) + dnuf2dXe ( b( x) ) xenon ( x) + dnuf 2dTf uel ( b( x) ) ( Tf uel
( x)Tf uel 0 ) + dnuf 2dTcool ( b( x) ) ( Tcool ( x)Tcool 0 ) + dnuf 2ddcool ( b( x) ) (
dcool ( x)dcool 0 )
ESigmaF 1 1. 6 e 13( Ef1 ( b( x) ) + dEf1dXe ( b( x) ) xenon ( x) + dEf 1dTf uel ( b( x) )
( Tf uel ( x)Tf uel 0 ) + dEf1dTcool ( b( x) ) ( Tcool ( x)Tcool 0 ) + dEf 1ddcool ( b( x
) ) ( dcool ( x)dcool 0 ) )
ESigmaF 2 1. 6 e 13( Ef2 ( b( x) ) + dEf2dXe ( b( x) ) xenon ( x) + dEf 2dTf uel ( b( x) )
( Tf uel ( x)Tf uel 0 ) + dEf2dTcool ( b( x) ) ( Tcool ( x)Tcool 0 ) + dEf 2ddcool ( b( x
) ) ( dcool ( x)dcool 0 ) )
}
MATERIAL r e f l bot t om {
D 1 1. 35
D 2 9. 294 e01
SigmaA 1 7. 828 e05
SigmaA 2 1. 463 e02
SigmaS 1 . 2 4. 368 e05
SigmaS 2 . 1 6. 507 e04
}
1j
milonga v0.1
MATERIAL r e f l t o p {
D 1 1. 35
D 2 9. 583 e01
SigmaA 1 1. 510 e04
SigmaA 2 1. 234 e02
SigmaS 1 . 2 6. 891 e05
SigmaS 2 . 1 1. 059 e03
}
$ cat channel.cpl
RELAP_TIME_STATUS relap_status
RELAP_EXPORT {
SHARE_NAME coolant_temperature
SCALAR tempf 87 3:22
SKIP_STEP 100
}
RELAP_EXPORT {
SHARE_NAME coolant_density
SCALAR rho 87 3:22
SKIP_STEP 100
}
RELAP_EXPORT {
SHARE_NAME fuel_temperature
SCALAR htvatp 1875 1:20
SEMAPHORE_READY relap_ready
SKIP_STEP 100
}
RELAP_IMPORT {
SHARE_NAME total_power
SEMAPHORE_WAIT relap_go
SCALAR cnvarn 100 0
SKIP_STEP 100
}
RELAP_IMPORT {
SHARE_NAME power_distribution
SCALAR cnvsan 201 1
SCALAR cnvsan 202 1
SCALAR cnvsan 203 1
SCALAR cnvsan 204 1
SCALAR cnvsan 205 1
SCALAR cnvsan 206 1
SCALAR cnvsan 207 1
SCALAR cnvsan 208 1
SCALAR cnvsan 209 1
SCALAR cnvsan 210 1
SCALAR cnvsan 211 1
SCALAR cnvsan 212 1
SCALAR cnvsan 213 1
SCALAR cnvsan 214 1
SCALAR cnvsan 215 1
SCALAR cnvsan 216 1
SCALAR cnvsan 217 1
SCALAR cnvsan 218 1
SCALAR cnvsan 219 1
SCALAR cnvsan 220 1
SKIP_STEP 100
}
RELAP_IMPORT {
SHARE_NAME relap_done
16
milonga v0.1
SCALAR done 0 0
}
$ ./relap5cpl.x -i channel.inp -O channel.out -R channel.rst -a channel.cpl &
$ milonga core.mil
## waiting for initial semaphore from relap5cpl... relap5cpl: Extension de
RELAP5/MOD3.3patch3 para acoplar codigos externos
relap5cpl: gtheler@tecna.com
relap5cpl: ultima modificacion 2011-05-02 08:40:14
relap5cpl: Fecha de compilacion 2011-05-02 08:49:36 linuxgf(jeremy@barnie:x86_64)
relap5cpl: esperando semaforo "/relap_go"... got it!
## computing initial flux distribution... ok!
0======== Execute file name = ./relap5cpl.x
Input file name = channel.inp
Copyright (C) 2001-2006 Information Systems Laboratories, Inc.
Thermodynamic properties files used by this problem:
Thermodynamic properties file for d2o obtained from lfn tpfd2o,
tpfd2o version 1.0.1, tables of thermodynamic properties of heavy water
generated on 09-Jun- 9 at 15:10:20 by stgd2o 1.0 (07/22/91)
0$$$$$$$$ Input processing completed successfully.
RELAP5/3.3gl Reactor Loss Of Coolant Analysis Program
Copyright (C) 2001-2006 Information Systems Laboratories, Inc.
=
16-Jul-11 13:13:07
cpuT_(s) probTime dTime_(s) dTCournt VolCoP PresCo_MPa VoidCo emass_kg VolEr
PresEr_MPa VoidEr QualaEr NSteps Reason
0.0 0.0000 1.00E-04 0.0 03301 12.14 0.0000 0.00 03301
12.14 0.00 g 0.00 a 0
Transient terminated by end of time step cards.
At time 100.019 seconds; Step 3852
done!
## information written and initial semaphore set
1.000000e+00 0.000000e+00 1.063907e+00 5.510000e+02
2.000000e+00 1.397503e+00 8.848904e-01 5.614382e+02
3.000000e+00 4.080064e+00 8.939054e-01 5.699261e+02
4.000000e+00 6.763396e+00 8.909174e-01 5.748820e+02
5.000000e+00 9.425237e+00 8.899390e-01 5.775089e+02
6.000000e+00 1.207100e+01 8.891607e-01 5.792419e+02
7.000000e+00 1.470793e+01 8.887985e-01 5.801273e+02
8.000000e+00 1.733898e+01 8.884757e-01 5.807304e+02
9.000000e+00 1.996726e+01 8.883491e-01 5.810124e+02
1.000000e+01 2.259325e+01 8.882032e-01 5.812667e+02
1.100000e+01 2.521825e+01 8.881619e-01 5.813650e+02
1.200000e+01 2.784223e+01 8.880915e-01 5.814805e+02
1.300000e+01 3.046586e+01 8.880812e-01 5.815115e+02
1.400000e+01 3.308902e+01 8.880452e-01 5.815673e+02
1.500000e+01 3.571208e+01 8.880456e-01 5.815744e+02
1.600000e+01 3.833490e+01 8.880262e-01 5.816030e+02
1.700000e+01 4.095771e+01 8.880296e-01 5.816019e+02
1.800000e+01 4.358040e+01 8.880186e-01 5.816174e+02
1.900000e+01 4.620310e+01 8.880222e-01 5.816143e+02
2.000000e+01 4.882572e+01 8.880157e-01 5.816231e+02
2.100000e+01 5.144837e+01 8.880187e-01 5.816200e+02
2.200000e+01 5.407098e+01 8.880147e-01 5.816253e+02
2.300000e+01 5.669360e+01 8.880170e-01 5.816227e+02
2.400000e+01 5.931620e+01 8.880145e-01 5.816260e+02
2.500000e+01 6.193881e+01 8.880161e-01 5.816241e+02
2.600000e+01 6.456141e+01 8.880145e-01 5.816261e+02
2.700000e+01 6.718402e+01 8.880156e-01 5.816248e+02
2.800000e+01 6.980661e+01 8.880146e-01 5.816261e+02
2.900000e+01 7.242922e+01 8.880154e-01 5.816251e+02
3.000000e+01 7.505181e+01 8.880147e-01 5.816260e+02
1
milonga v0.1 0.00e+00 1.00e-03 2.00e-03 3.00e-03 4.00e-03 5.00e-03 6.00e-03 7.00e-03
0 100 200 300 400 500 600
t h e r m a l n u - s s i o n X S [ 1 / c m ]
axial coordinate [cm]
step 1 step 2 step 5 step 40
3.100000e+01 7.767441e+01 8.880152e-01 5.816254e+02
3.200000e+01 8.029701e+01 8.880147e-01 5.816259e+02
3.300000e+01 8.291961e+01 8.880151e-01 5.816255e+02
3.400000e+01 8.554221e+01 8.880148e-01 5.816259e+02
3.500000e+01 8.816481e+01 8.880150e-01 5.816256e+02
3.600000e+01 9.078741e+01 8.880148e-01 5.816258e+02
3.700000e+01 9.341001e+01 8.880150e-01 5.816256e+02
3.800000e+01 9.603261e+01 8.880149e-01 5.816258e+02
3.900000e+01 9.865521e+01 8.880150e-01 5.816256e+02
4.000000e+01 1.000190e+02 8.880149e-01 5.816258e+02
## coupled calculation finished, have a nice day!
$ gnuplot dists.gnuplot
$
0.00e+00
5.00e+13
1.00e+14
1.50e+14
2.00e+14
2.50e+14
0 100 200 300 400 500 600

u
x

[
c
m
^
-
2

s
^
-
1
]
axial coordinate [cm]
fast step 1
thermal step 1
fast step 2
thermal step 2
fast step 2
thermal step 2
fast step 40
thermal step 40
0.00e+00
1.00e+13
2.00e+13
3.00e+13
4.00e+13
5.00e+13
6.00e+13
7.00e+13
8.00e+13
9.00e+13
0 100 200 300 400 500 600
x
e
n
o
n

c
o
n
c
e
n
t
r
a
t
i
o
n

[
c
m
^
-
3
]
axial coordinate [cm]
step 1
step 2
step 5
step 40
18
milonga v0.1 5.50e+02 6.00e+02 6.50e+02 7.00e+02 7.50e+02 8.00e+02 8.50e+02 9.00e+02 9.50e+02 1.00e+03
100 200 300 400 500
f u e l t e m p e r a t u r e [ K ]
axial coordinate [cm]
step 1 step 2 step 5 step 40
0.00e+00
5.00e-04
1.00e-03
1.50e-03
2.00e-03
2.50e-03
0 100 200 300 400 500 600
f
a
s
t

a
b
s
o
r
p
t
i
o
n

X
S

[
1
/
c
m
]
axial coordinate [cm]
step 1
step 2
step 5
step 40
0.00e+00
1.00e-03
2.00e-03
3.00e-03
4.00e-03
5.00e-03
6.00e-03
7.00e-03
0 100 200 300 400 500 600
t
h
e
r
m
a
l

n
u
-

s
s
i
o
n

X
S

[
1
/
c
m
]
axial coordinate [cm]
step 1
step 2
step 5
step 40
0.00e+00
2.00e+00
4.00e+00
6.00e+00
8.00e+00
1.00e+01
1.20e+01
1.40e+01
1.60e+01
1.80e+01
100 200 300 400 500
p
o
w
e
r

d
e
n
s
i
t
y

[
w
/
c
m
^
3
]
axial coordinate [cm]
step 1
step 2
step 5
step 40
1o
milonga v0.1
5.50e+02
5.55e+02
5.60e+02
5.65e+02
5.70e+02
5.75e+02
5.80e+02
5.85e+02
100 200 300 400 500
c
o
o
l
a
n
t

t
e
m
p
e
r
a
t
u
r
e

[
K
]
axial coordinate [cm]
step 1
step 2
step 5
step 40
5.50e+02
6.00e+02
6.50e+02
7.00e+02
7.50e+02
8.00e+02
8.50e+02
9.00e+02
9.50e+02
1.00e+03
100 200 300 400 500
f
u
e
l

t
e
m
p
e
r
a
t
u
r
e

[
K
]
axial coordinate [cm]
step 1
step 2
step 5
step 40
7.60e+02
7.70e+02
7.80e+02
7.90e+02
8.00e+02
8.10e+02
8.20e+02
8.30e+02
8.40e+02
8.50e+02
100 200 300 400 500
c
o
o
l
a
n
t

d
e
n
s
i
t
y

[
K
]
axial coordinate [cm]
step 1
step 2
step 5
step 40
1io
milonga v0.1
Bibliography
[1] Thomas Williams, Colin Kelley, and many others. Gnuplot 4.4: an interactive plotting program.
http://www.gnuplot.info, March 2011.
[2] J. Lamarsh. Introduction to Nuclear reactor theory. Addison Wesley, 1966.
[3] J. J. Duderstadt and L. J. Hamilton. Nuclear reactor analysis. Wiley, New York, 1976.
[4] Alain Hebert and Dan Gabriel Cacuci (editor). Handbook of Nuclear Engineering, volume II,
chapter Multigroup Neutron Transport and Diusion Computations, pages 753911. Springer,
2010.
[5] Computational Benchmark Problem Comitee for the Mathematics and Computation Division
of the American Nuclear Society. Argonne Code Center: Benchmark problem book. Technical
Report ANL-7416 Supplement 2, Argonne National Laboratory, June 1977.
[6] Imelda Ariani and Doddy Kastanya. Evaluation of the IAEA 3-D PWR benchmark problem
using NESTLE code.
[7] Russel Mosteller. Static benchmarking of the NESTLE advanced nodal code. Proceedings of
the Joint International Conference on Mathematical Methods and Supercomputing for Nuclear
Applications, 2:15961605, 1997.
[8] PARCS. IAEA 3D PWR problem. https://engineering.purdue.edu/PARCS/Code/
TestSuite/CalculationMode/StandAloneMode/Eigenvalue/IAEA3DPWR.
[9] J. E. Roman, E. Romero, and A. Tomas. SLEPc users manual. Technical Report DSIC-II/24/02
- Revision 3.1, D. Sistemas Informaticos y Computacion, Universidad Politecnica de Valencia,
2010.
[10] D. Gilberta, J.E. Roman, Wm. J. Garlandc, and W. F. S. Poehlmand. Simulating control rod
and fuel assembly motion using moving meshes. Annals of Nuclear Energy, 35, 2008.
[11] Information Systems Laboratories Inc. RELAP5/MOD3.3 Code Manual Volume 1Code Struc-
ture, System Models and Solution Methods. Technical Report NUREG/CR-5535/Rev 1, Nuclear
Safety Analysis Division, 2001.
[12] Douglas A. Barber and Thomans J. Downar. Software requirements specication for the PARCS-
specic data map routine in the couple RELAP5/PARCS code. Technical Report PU/NE-98-11,
1998.
[13] G. Theler. RELAP5CPL: Extension del codigo RELAP para permitir la realizacion de sim-
ulaciones termouidodinamicas acopladas con codigos de calculo externos. Technical Report
10105-G-IT-001, TECNA S.A., 2009.
[14] G. Theler. Simulacion de experimentos de estabilidad en ujo de dos fases acoplando RELAP
a un codigo externo de control inteligente basado en logica difusa. Mecanica Computacional,
XXVIII:31693183, 2009.
[15] O. Mazzantini, M. Schivo, J. Di Cesare, R. Garbero, M. Rivero, and G. Theler. A coupled
calculation suite for Atucha II operational transient analysis. Science and Technology of Nuclear
Installations, 2011.
1i1
Chapter V
Installation and execution
Part of the inhumanity of the computer is that, once it is
competently programmed and working smoothly,
it is completely honest.
Isaac Asimov, Change!, 1983
This chapter gives instructions to perform what should be a one-time only procedure, namely to
compile and install milonga and its required libraries from scratch. This is the reason why it comes
at last: to avoid appearing in the middle of what should be a periodic-consultation reference i.e.
chapters 2, 3 and 4.
If you are much more impatient than the average user, you can get the binary versions for your
particular architecture (section 5.1) instead of trying to compile the source code (section 5.2). However,
it is recommended that you compile the source code to optimize the execution, especially according
to the detailed installation instructions given in section 5.3 to make the most out of milonga.
Milonga is a computer code that instructs a digital computer to perform certain mathematical
operations in order to obtain some results. One question arises about the type of computers the code
should instruct. Historically, engineering codes were designed to run in mainframes and supercom-
puters. As there were a variety of platforms, computer codes either had to restrict to a single family
of processors and operating systems or to provide means to conditionally include or remove pieces
of source code in order to be compiled with dierent tools. Nowadays, desktopand even laptop
Personal Computers are commonly used as engineering platforms. Even though there is a wide variety
of models, compatibility and portability between architectures is far more easy than twenty or thirty
years ago, especially if code is developed according to accepted standards.
Taking into consideration the actual conditions of processors and operating systems development,
the selected platform for developing and running milonga is a GNU/Linux box running over an Intel-
compatible processor architecture. Besides being freereason that should be enough to choose it as a
development platformthe GNU operating system with the Linux kernel
1
has reached a higher level
of maturity and eciency running over a wide variety of modern computers than any other operating
system.
Although portability per-se is not into milongas design basis, it is expected on the one hand to be
able to run the code in a reasonable spectrum of digital computers and on the other hand to be able
to scale up with both software and hardware developments during a reasonable time frame, as stated
in section 1.2. Thus, even though GNU/Linux is selected as the development platform, the code is
expected to run into other operating systems and architectures of interest.
Feedback about installation and executing issueseither positive or negativeis welcome.
1
Strictly speaking, the ocial Linux kernel release contains some portions of code that are not free in the GNU
sense. However, it is possible to obtain 100% free versions of the kernel to build free GNU/Linux distributions such as
Debian.
milonga v0.1
5.1 Very quick instructions
1. Get the binary package for your platform and uncompress it. See
http://ib.cnea.gov.ar/

thelerg/wasora/milonga
for the list of supported platforms.
$ wget http://ib.cnea.gov.ar/thelerg/wasora/downloads/milonga-0.1-linux-
amd64.tar.gz
$ tar xvzf milonga-0.1-linux-amd64.tar.gz
2. Either copy the executable le milonga to the directory where your input is or vice-versa
$ cd milonga-0.1-linux-amd64
$ cp examples/test.mil .
3. Run the program giving the input le as the rst argument
$ ./milonga test.mil
1.092211e+00
$
A few comments regarding the binaries and its execution:
GNU/Linux binaries include PETSc (with all its related libraries it needs), SLEPc and GSL
as static libraries, but some other common libraries such as libglibc, librt and libgfortran are
dynamically linked. Any modern distribution of GNU/Linux should be able to resolve them. If
not, please install the associated package.
Windows binaries were compiled using Cygwin. They include PETSc, SLEPc statically linked
in the executable. All the other needed libraries are likend dynamically, but the DLLs are
distributed inside the package under the terms of the GPLv3+.
The exact versions of libraries and compilers used to generate each executable are stated in each
tarball. Again, it is recommended to compile the source code using the actual tools installed in
the target machine.
In all the binary versions, PETSc was compiled without MPI support. Therefore, the binary
may be directly executed by invoking the lename from the shell. No MPI wrapper is needed.
The execution of milonga in Windows-based architectures is highly discouraged! The binary and
its related libraries are not designed to run natively, and thus their performance is very poor.
Microsoft Windows is not designed to run engineering codes as milonga. And besides, it is not
free software. Please try to run milonga in GNU/Linux or other unix-based architectures.
5.2 Quick instructions
Quick installation instructions for the impatient-but-not-so-much are given for Debian-based boxes,
where milonga was conceived, developed and fully tested. Nonetheless, the commands given in this
section can be applied to other UNIX variants and even Cygwin distributions where milonga is known
to compile and run, although no comprehensive testing was made on these platforms.
1i
milonga v0.1
The list of commands provided in the following sections should do the trick in a reasonable working
GNU/Linux box, i.e. bash, ability to compile programs and internet access are assumed. If no
internet connection is available (for example because your company keeps blocking what they think
are security risks sites or, even worse, do not allow to connect your GNU/Linux box to the corporate
Windows network because of security issues (sic), of course the downloading stage can be replaced by
a bare copy of the tarballs from a ash drive. In the same sense, if no Fortran compiler is available,
the PETSc compilation options can be changed to use C-based linear algebra routines. By the way, it
is always handy to have a Fortran compiler ready to go, as you never know when you may run across
a T-Rexas one that ruled the continent in page 4with some (of course non-standard) F77 code
for you to run.
Probably some tuning might needed to cope with dierent software versions. The script-kiddie
approach should be avoided as this installation procedure may help to get an image of how milonga
depends on these libraries. Commands are given as reference.
5.2.1 With root access
If you have access to superuser privileges, then some pre-compiled packages for some of the required
libraries can be easily installed using the distributions package manager. Example commands are
given for apt-get in Debian-based distributions, but equivalent commands should also be available in
other GNU/Linux distributions.
First make sure your system is able to generate binaries from C sources (and Fortran for PETSc),
has a Python interpreter (also needed to compile PETSc), manage tarballs and download les using
HTTP:
# apt-get install gcc gfortran make binutils python tar wget
Then, install the GNU Scientic Libraries (needed by the wasora framework) and LAPACK (needed
by PETSc) development version and its related dependencies:
# apt-get install libgsl0-dev liblapack-dev
For some reason, the binary distributions of PETSc and SLEPc provided in Debian do not work
with milonga, so a manual installation is needed. In any case, compiling both PETSc and SLEPc
gives a lot of exibility in terms of conguration options that this is a procedure worth learning.
Nevertheless, the following options should be enough:
$ cd
$ mkdir libs
$ cd libs
$ wget http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-lite-3.1-p8.tar.
gz
$ wget http://www.grycap.upv.es/slepc/download/distrib/slepc-3.1-p6.tgz
$ tar xvzf petsc-lite-3.1-p8.tar.gz
$ cd petsc-3.1-p8
$ ./configure --with-shared=1 --with=mpi=0 --with-x=0
[...]
$ export PETSC_DIR=$PWD
$ export PETSC_ARCH=linux-gnu-c-debug
$ make
[...]
$ cd ..
$ tar xvzf slepc-3.1p-6.tgz
$ cd slepc-3.1p-6
$ export SLEPC_DIR=$PWD
$ ./configure
[...]
$ make
1ii
milonga v0.1
[...]
$ cd
Finally download, compile and install milonga
$ wget http://ib.cnea.gov.ar/thelerg/wasora/downloads/milonga-0.1.tar.gz
$ tar xvzf milonga-0.1.tar.gz
$ cd milonga-0.1
$ ./configure
[...]
$ make
[...]
$ make install
$ cd
These steps should lead to a binary executable of milonga globally available (in /usr/local/bin)
for execution:
$ milonga
milonga 0.1
free nuclear reactor core analysis code
usage: ./milonga input [replacement arguments | PETSc & SLEPc runtime options]
$
5.2.2 Without root access
If you are planning to run milonga in a host in which you do not have superuser privileges, then
some changes care has to be taken. First, probably you will not be abe to install GSL libaries as
system-wide accesible, so you will have to compile them in you home directory. Lucklily, PETSc is
able to automatically download and LAPACK withouth further user interventino. Finally, you will
have to tell milonga where these libraries are located.
$ cd
$ mkdir libs
$ cd libs
$ wget ftp://ftp.gnu.org/gnu/gsl/gsl-1.15.tar.gz
$ wget http://ftp.mcs.anl.gov/pub/petsc/externalpackages/fblaslapack-3.1.1.tar.gz
$ wget http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-lite-3.1-p8.tar.
gz
$ wget http://www.grycap.upv.es/slepc/download/distrib/slepc-3.1-p6.tgz
$ tar xvzf gsl-1.15.tar.gz
$ cd gsl-1.15
$ ./configure
[...]
$ make
[...]
$ cd ..
$ tar xvzf petsc-lite-3.1-p8.tar.gz
$ cd petsc-3.1-p8
$ ./configure --with-shared=1 --with=mpi=0 --with-x=0 --download-f-blas-lapack
[...]
$ export PETSC_DIR=$PWD
$ export PETSC_ARCH=linux-gnu-c-debug
$ make
[...]
$ cd ..
$ tar xvzf slepc-3.1p-6.tgz
$ cd slepc-3.1p-6
1ij
milonga v0.1
$ export SLEPC_DIR=$PWD
$ ./configure
[...]
$ make
[...]
$ cd
$ wget wget http://ib.cnea.gov.ar/thelerg/wasora/milonga-0.1.tar.gz
$ tar xvzf milonga-0.1.tar.gz
$ cd milonga-0.1
$ ./configure CFLAGS="-I$HOME/libs/gsl-1.15" LDFLAGS="-L$HOME/libs/gsl-1.15/cblas
/.libs -L$HOME/libs/gsl-1.15/.libs -Wl,-rpath $HOME/libs/gsl-1.15/cblas/.libs
-Wl,-rpath $HOME/libs/gsl-1.15/.libs"
[...]
$ make
You will not be able to install the executable in the system binaries directory, but you can copy
milonga to $HOME/bin and add this directoy to the PATH environment variable:
$ mkdir $HOME/bin
$ cp milonga $HOME/bin
$ export PATH=$PATH:$HOME/bin
$ cd
$ milonga
milonga 0.1
free nuclear reactor core analysis code
usage: ./milonga input [replacement arguments | PETSc & SLEPc runtime options]
$
5.3 Detailed installation instructions
To make the most out of milonga and to understand how it works, a full installation of the required
libraries is recommended. Users familiar with GSL, PETSc and SLEPc may want to re-use their
installations or to tune conguration options.
5.3.1 Obtaining the package
Milonga should be available to download from the authors webpage located at
http://ib.cnea.gov.ar/

thelerg/wasora/milonga
Even though milonga can be redistributed under the terms of the GNU General Public License[1],
the aforementioned site should be the ocial source of distribution. Not only should this site contain
the distribution packages milonga version 0.1 but also further news and related references.
5.3.2 Required libraries
As discussed in the design basis (2), milonga relies on particular libraries that implement and per-
form mostif not allof the mathematical and numerical operations involved in solving the neutron
diusion equation. In particular, matrix handling is done by PETSc and the eigenvalue problem is
solved by SLEPc. General mathematical functions are provided by GSL and CUBATURE is used for
multidimensional adaptive integration.
GSL
The GNU Scientic Library is a free libary that provides a great deal of routines for scientic and
engineering computation. At least version 1.14 is needed. It can be obtained from
1i6
milonga v0.1
http://www.gnu.org/software/gsl/
To compile milonga, not only the compiled library is needed but also the headers should be installed
where milonga can nd them. In most GNU/Linux distributions, there are packages that provide the
needed functionality. In Debian-based distributions, installing package libgsl0-dev is enough to
be able to compile milonga.
# apt-get install libgsl0-dev
If there is no available package, GSL should be manually installed from its source code following
the standard installation instructions. To install headers system-wide and make them automatically
available to milonga, you have to be sure to execute make install as root after the compilation:
$ ./configure
[...]
$ make
[...]
$ su
Password:
# make install
# exit
$
If you do not have root access, either tell GSLs congure script to install the includes in a directory
where you have write permissions and add it to the INCLUDE environment variable or keep the tree
where the GSL source was uncompressed and congure milonga with the appropriate ags to tell the
compiler where the headers are (see section 5.3.3). Or, easier, call your system administrator and
kindly ask her to install libgsl0-dev from the distribution repository.
GSL is distributed under the terms of the GNU General Public License [1].
PETSc
PETSc, pronounced PET-see (the S is silent), is a suite of data structures and routines for the scalable
(parallel) solution of scientic applications modeled by partial dierential equations. It employs the
MPI standard for parallelism.
Milonga uses it as an ecient handler of large sparse matrices. Current version of milonga does
not use any of the parallelization mechanisms provided. At least version 3.1 is needed. Even though
most GNU/Linux distributions do provide a PETSc package, the author was not able to successfully
compile milonga with them. The PETSc source package distribution has to be downloaded, congured
and installed manually in order to milonga to work.
PETScs webpage is located at
http://www.mcs.anl.gov/petsc/petsc-as/
Detailed installation instructions can be found in the package documentation [2]. A congura-
tion script (written in Python, so a interpreter has to be installed) detects available libraries and
reads commandline options to generate appropriate makeles. Linear algebra libraries and headers
LAPACK or BLAS have to be installed (provided by package liblapack-dev, libblas-dev or
libatlas-dev), although the script can automatically download a free version of BLAS+LAPACK.
It can also detect and use Intels Math Kernel Libraries.
It is possible to have a number of PETSc libraries using dierent conguration options (using
LAPACK or ATLAS, with debug symbols or optimized, with single or double precision, etc) a target
name can be provided. If no name is provided, default is linux-gnu-c-debug.
As milonga 0.1 does not take advantage of PETScs parallelization mechanisms, it is best to avoid
messing up with MPI, at least for a rst installation.
1i
milonga v0.1
$ ./configure --with-mpi=0
===============================================================================
Configuring PETSc to compile on your system
===============================================================================
TESTING: alternateConfigureLibrary from PETSc.packages.petsc4py(config/PETSc/
packages/petsc4py.py:70) Compilers:
C Compiler: gcc -g
Fortran Compiler: gfortran -g
Linkers:
Static linker: /usr/bin/ar cr
Dynamic linker: /usr/bin/ar
X11:
Includes:
Library: -lX11
BLAS/LAPACK: -llapack -lblas
PETSc:
PETSC_ARCH: linux-gnu-c-debug
PETSC_DIR: /home/jeremy/libs/petsc-3.1-p8
Clanguage: C
Scalar type: real
Precision: double
Memory alignment: 16
shared libraries: disabled
dynamic libraries: disabled
xxx=========================================================================xxx
Configure stage complete. Now build PETSc libraries with:
make PETSC_DIR=/home/jeremy/libs/petsc-3.1-p8 PETSC_ARCH=linux-gnu-c-debug all
xxx=========================================================================xxx
$ make PETSC_DIR=/home/jeremy/libs/petsc-3.1-p8 PETSC_ARCH=linux-gnu-c-debug all
[...]
libfast in: /home/jeremy/libs/petsc-3.1-p8/tutorials/multiphysics
Completed building libraries
=========================================
Now to check if the libraries are working do:
make PETSC_DIR=/home/jeremy/libs/petsc-3.1-p8 PETSC_ARCH=linux-gnu-c-debug test
=========================================
$ make PETSC_DIR=/home/jeremy/libs/petsc-3.1-p8 PETSC_ARCH=linux-gnu-c-debug test
Running test examples to verify correct installation
C/C++ example src/snes/examples/tutorials/ex19 run successfully with 1 MPI process
Fortran example src/snes/examples/tutorials/ex5f run successfully with 1 MPI
process
Completed test examples
$
If configure complains about missing libraries, further reductions are possible. Usually, graphi-
cal X routines are not needed, so configure can be told to automatically download algebra libraries.
Also, if no debugging is needed, an optimized library can be compiled.
$ ./configure --with-mpi=0 --with-x=0 --download-f-blas-lapack=1 --with-debugging
=0
[...]
$
Additionally, shared and/or dynamic versions can be generated by using --with-shared and
--with-dynamic. This way, the milonga executable will be very much smaller than with the default
static PETSc conguration. If no Fortran compiler is available, --download-c-blas-lapack
should be given to instruct the script to download, compile and use a BLAS+LAPACK version
converted from Fortran to C using f2c.
To compile SLEPc and milonga, two environment variables have to be set. The rst one is
PETSC DIR and should contain the directory where PETSc was uncompressed. It can be easily
set by executing
1i8
milonga v0.1
$ export PETSC_DIR=$PWD
$
from the PETSc directory. The other one is called PETSC ARCH and is the selected target. In
GNU/Linux, default is linux-gnu-c-debug as reported by the congure output.
$ export PETSC_ARCH=linux-gnu-c-debug
$
Other targets can be generated by passing the --with-petsc-arch argument to configure.
For example, to compile an optimized shared version of PETSc using a C-based LAPACK library,
congure with
$ ./configure --with-petsc-arch=linux-gnu-opt --with-debugging=0 --with-mpi=0 --
with-x=0 --with-shared=1 --with-fc=0 --download-c-blas-lapack=1
===============================================================================
Configuring PETSc to compile on your system
===============================================================================
[...]
xxx=========================================================================xxx
Configure stage complete. Now build PETSc libraries with:
make PETSC_DIR=/home/jeremy/libs/petsc-3.1-p8 PETSC_ARCH=linux-gnu-opt all
xxx=========================================================================xxx
$ make PETSC_DIR=/home/jeremy/libs/petsc-3.1-p8 PETSC_ARCH=linux-gnu-opt all
[...]
$
and then set PETSC ARCH to the appropriate value
$ export PETSC_ARCH=linux-gnu-opt
$
PETSs is released under a free license developed by the University of Chicago [3].
SLEPc
SLEPc is a software library for the solution of large scale sparse eigenvalue problems on parallel com-
puters. It is an extension of PETSc and can be used for either standard or generalized eigenproblems,
with real or complex arithmetic. it can also be used for computing a partial SVD of a large, sparse,
rectangular matrix, and to solve quadratic eigenvalue problems.
It is used by milonga to solve the generalized eigenvalue problem associated to the multigroup
steady-state neutron diusion problem in a discretized spatial domain. At least version 3.1 is needed.
As with PETSc, packages provided by GNU/Linux distributions do not work with milonga. SLEPcs
webpage is
http://http://www.grycap.upv.es/slepc/
For complete instructions on the installation of SLEPc refer to its documentation[4]. It also pro-
vides a conguration script written in Python. Luckily, it reads the conguration options passed to
PETSc so normally no further arguments are needed. However, in order to be able to read PETScs
conguration, both variables PETSC DIR and PETSC ARCH have to be dened to reect the instal-
lation directory and the target architecture. For example, if PETSc was congured with the default
architecture and the steps in the previous section were followed, the execution of SLEPCs configure
should be simple
1io
milonga v0.1
$ ./configure
Checking environment...
Checking PETSc installation...
Checking LAPACK library...
================================================================================
SLEPc Configuration
================================================================================
SLEPc source directory:
/home/jeremy/libs/slepc-3.1-p6
SLEPc install directory:
/home/jeremy/libs/slepc-3.1-p6/linux-gnu-c-debug
PETSc directory:
/home/jeremy/libs/petsc-3.1-p8
Architecture "linux-gnu-c-debug" with double precision real numbers
$
Before compiling SLEPc, the SLEPC DIR variable has to be set to reect SLEPcs directory. It can
be easily lled with the current directory by using the PWD variable. A make command will compile
the library.
$ export SLEPC_DIR=$PWD
$ make
==========================================
On Fri Jul 15 19:48:34 ART 2011 on tom
Machine characteristics: Linux tom 2.6.32-5-amd64 #1 SMP Mon Mar 7 21:35:22 UTC
2011 x86_64 GNU/Linux
-----------------------------------------
Using SLEPc directory: /home/jeremy/libs/slepc-3.1-p6
Using PETSc directory: /home/jeremy/libs/petsc-3.1-p8
Using PETSc arch: linux-gnu-c-debug
-----------------------------------------
SLEPC_VERSION_RELEASE 1
[...]
libfast in: /home/jeremy/libs/slepc-3.1-p6/include/private
libfast in: /home/jeremy/libs/slepc-3.1-p6/docs
/usr/bin/ranlib /home/jeremy/libs/slepc-3.1-p6/linux-gnu-c-debug/lib/
*
.a
Completed building SLEPc libraries
=========================================
making shared libraries in /home/jeremy/libs/slepc-3.1-p6/linux-gnu-c-debug/lib
building libslepc.so
=========================================
Now to check if the libraries are working do: make test
=========================================
$ make test
Running test examples to verify correct installation
C/C++ example src/examples/ex1 run successfully with 1 MPI process
Fortran example src/examples/ex1f run successfully with 1 MPI process
Completed test examples
$
SLEPc is released under the terms of the Lesser General Public License [5].
cubature
Cubature is a simple C subroutine for adaptive multidimensional integration of vector-valued in-
tegrands over hypercubes. Of course it can handle scalar integrands as the special cases of one-
dimensional vectors. It can be obtained from
http://ab-initio.mit.edu/wiki/index.php/Cubature/
1jo
milonga v0.1
It is used by milonga to compute cell average cross sections and to compute the surface integrals
of the diusion coecients. As cubature is a small routine, it is incorporated into milonga as another
source le so actually no installation is needed.
Cubature is released under the terms of the GNU General Public License v2 or later [1].
5.3.3 Compiling milonga
Lastly, it is time to compile milonga. If GSL is installed in default the location and the PETSc and
SLEPc environment variables are set to their proper values, then the standard ./configure and
make steps should do the trick:
$ ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for PETSC_DIR environment variable... /home/jeremy/libs/petsc-3.1-p8
checking for PETSC_ARCH environment variable... linux-gnu-c-debug
checking for SLEPC_DIR environment variable... /home/jeremy/libs/slepc-3.1-p6
checking for gcc... gcc
[...]
checking for strdup... yes
checking for strstr... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/config.h
config.status: src/config.h is unchanged
config.status: executing depfiles commands
$ make
gcc -DHAVE_CONFIG_H -I. -I./src -g -O2 -I/home/jeremy/libs/petsc-3.1-p8/linux-
gnu-c-debug/include -I/home/jeremy/libs/petsc-3.1-p8/include -I/home/jeremy/
libs/petsc-3.1-p8/include/mpiuni -I/home/jeremy/libs/slepc-3.1-p6 -I/home/
jeremy/libs/slepc-3.1-p6/linux-gnu-c-debug/include -I/home/jeremy/libs/slepc
-3.1-p6/include -MT assignment.o -MD -MP -MF .deps/assignment.Tpo -c -o
assignment.o test -f src/assignment.c || echo ./src/assignment.c
mv -f .deps/assignment.Tpo .deps/assignment.Po
[...]
mv -f .deps/hello.Tpo .deps/hello.Po
gcc -g -O2 -I/home/jeremy/libs/petsc-3.1-p8/linux-gnu-c-debug/include -I/home/
jeremy/libs/petsc-3.1-p8/include -I/home/jeremy/libs/petsc-3.1-p8/include/
mpiuni -I/home/jeremy/libs/slepc-3.1-p6 -I/home/jeremy/libs/slepc-3.1-p6/
linux-gnu-c-debug/include -I/home/jeremy/libs/slepc-3.1-p6/include -o
milonga assignment.o builtinfunctionals.o builtinfunctions.o call.o cleanup.o
commoninit.o commonparser.o error.o function.o getptr.o handler.o history.o
instruction.o io.o line.o parametric.o parseaux.o print.o realtime.o shmem.o
uservars.o allocate.o boundary.o cubature.o debug.o eigen.o geometry.o init.o
matrices.o milonga.o outputs.o parser.o petschandler.o power.o printresult.o
result.o steady.o step.o version.o xenon.o xs.o hello.o -lgsl -lgslcblas -lm
-lpthread -lrt -Wl,-rpath,/home/jeremy/libs/slepc-3.1-p6/linux-gnu-c-debug/
lib -L/home/jeremy/libs/slepc-3.1-p6/linux-gnu-c-debug/lib -lslepc -Wl,-
rpath,/home/jeremy/libs/petsc-3.1-p8/linux-gnu-c-debug/lib -L/home/jeremy/libs
/petsc-3.1-p8/linux-gnu-c-debug/lib -lpetsc -llapack -lblas -lm -Wl,-rpath,/
usr/lib/gcc/x86_64-linux-gnu/4.4.5 -L/usr/lib/gcc/x86_64-linux-gnu/4.4.5 -Wl,-
rpath-rpath,/usr/lib/x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu -ldl -lgcc_s
-lgfortran -lm -lm -ldl -lgcc_s -ldl
$
If variables PETSC DIR, PETSC ARCH or SLEPC DIR are not set, conguration script will com-
plain. However, if they are set but their content is not correct, configure will run but make will
fail.
If GSL was installed either from the distributions packages or compiled from the source and
then installed as root, the header should be globally available and milongas configure should
1j1
milonga v0.1
be able to nd them. If, however, they are installed somewhere elseprobably because no root
access is availablethen you have to tell milonga where they are. For example, if you uncompressed
the source distribution into directory /libs/gsl-1.15 and performed the ./configure and
make commmands therewithout the make install stepthen you have to pass to milongas
conguration script the following arguments:
$ ./configure CFLAGS="-I$HOME/libs/gsl-1.15" LDFLAGS="-L$HOME/libs/gsl-1.15/cblas
/.libs -L$HOME/libs/gsl-1.15/.libs -Wl,-rpath $HOME/libs/gsl-1.15/cblas/.libs
-Wl,-rpath $HOME/libs/gsl-1.15/.libs"
[...]
$ make
[...]
$
If you want to have milonga as a globally-available commandand you have superuser access of
courseyou can have it installed in /usr/local/bin by issuing
# make install
#
Milonga can now be called from any directory now.
5.4 Execution
After a successful compilationor by directly downloading a binary distributionyou will end up with
an executable called milonga. Scientic codes linked against PETSc usually make use its parallelization
capabilities and, as such, they have to be run using an MPI wrapper application. However, current
version of milonga does not support parallelization, and thus it can be executed as any other regular
program.
Milonga needs as its rst argument the path of the input le containing the problem it has to
solve. If milonga is system-wide available, you can go to the directory where the input is and just call
milonga followed by the input name
$ cd examples
$ milonga test.mil
1.092211e+00
$
If milonga is not installed system-wide, either you will have to copy the executable where the input
is, provide the full path to the executable or provide the full path to the input. Keep in mind that
using the last choice that les that are included using relative paths will not be found.
For example, the examples of chapter four can be run by using the runx script provided in the
examples subdirectory of milongas distribution:
$ cd examples
$ cd 01-analytical
$ ./runx
01-bare_slab
milonga comparisson.mil
analytical keff = 1.09220381
numerical keff = 1.09221091
difference = 7.101524e-06
milonga flux.mil
5.000000e-01 2.466006e-02 2.467300e-02
1.500000e+00 7.398017e-02 7.399464e-02
1j:
milonga v0.1
2.500000e+00 1.232273e-01 1.232433e-01
[...]
06-two-zone_slab
milonga twozone.mil
## copy and paste the following lines into gnuplot to obtain
## the continuous flux distribution as a function of x
numerical_keff = 1.14799085
analytical_keff = 1.14779361
phi1(x) = 1.316009e-02
*
sinh( 1.121395e-01
*
x )
phi2(x) = 1.316009e-02
*
sinh( 5.606974e+00 ) / sin( 2.261471e+00 )
*
sin(
4.522943e-02
*
( 1.000000e+02 -x ) )
phi(x) = ( x < 5.000000e+01 ) ? phi1(x) : phi2(x)
good! no errors found!
$
5.5 Syntax highlight
Input les are used to instruct a digital computer to perform a certain task. As discussed in the design
basis in chapter 1, they should in some sense resemble the approach taken by high-level source code
compilers. This way, milongas input les should be friendly human-readable chunks of text instead
of a bunch of numbers representing perforated cards.
As with source code, to render input les even more human-friendly, it is very handy to have a
system of syntax highlight when working with milongas input les. The distribution includes a syntax
le denition for the text editor kate.
Figure 5.1: Syntax highlight in editor kate for milonga input les.
To have kate understand milongas input le, copy milonga.xml (located in subdirectory doc)
to kateparts syntax directory. You may have to create the directory if it does not exist:
$ mkdir -p $HOME/.kde/share/apps/katepart/syntax
$ cp doc/milonga.xml $HOME/.kde/share/apps/katepart/syntax
$
1j
milonga v0.1
This way, any le with extension mil opened in kate or in any other editor using kates framework
(such as kwrite) will be highlighted as shown in gure 5.1.
Bibliography
[1] GNU General Public License version 3. http://www.gnu.org/licenses.
[2] Satish Balay, Jed Brown, , Kris Buschelman, Victor Eijkhout, William D. Gropp, Dinesh Kaushik,
Matthew G. Knepley, Lois Curfman McInnes, Barry F. Smith, and Hong Zhang. PETSc users
manual. Technical Report ANL-95/11 - Revision 3.1, Argonne National Laboratory, 2010.
[3] PETSc Copyright. http://www.mcs.anl.gov/petsc/petsc-as/documentation/
copyright.html.
[4] J. E. Roman, E. Romero, and A. Tomas. SLEPc users manual. Technical Report DSIC-II/24/02 -
Revision 3.1, D. Sistemas Informaticos y Computacion, Universidad Politecnica de Valencia, 2010.
[5] GNU Lesser General Public License version 3. http://www.gnu.org/licenses/lgpl.html.
1ji
Keywords, variables and functions index
ALLOW NEGATIVE FLUX, 52
bc, 49
BE QUIET, 56
BOUNDARY CONDITIONS, 45
build time, 48
cD, 49
cESigmaF, 49
chi, 43
cnuSigmaF, 49
CONDITION, 50
CONTINUE, 56
cSigmaA, 49
cSigmaT, 49
D o, 49
D EPSILON, 52
D g, 45
D MEAN, 52
DEBUG, 55
DIFFERENCES, 52
DIMENSIONS, 42
EIGENVALUE INVERSE K, 53
EIGENVALUE K, 53
epsilon, 53
ESigmaF o, 49
ESigmaF g, 45
FILE, 49, 50
ux o, 48
gamma I, 51
gamma Xe, 51
GRAD D LOCAL, 52
GRAD D NEIGHBORS, 52
GROUPS, 42
INCLUDE, 42
INCREMENTAL, 44
INFORM, 56
INNER RADIUS, 44
ke, 47
ke error, 48
lambda I, 51
lambda Xe, 51
MATERIAL, 44, 45
MATRICES ASCII, 55
MATRICES BINARY, 55
MAX, 50
MAX DAUGHTERS, 54
METHOD, 53
MIN, 50
MIRROR, 45
NO NEGATIVE FLUX, 52
NONE, 53
nu, 51
NULL, 45
nuSigmaF o, 49
nuSigmaF g, 45
ON ERROR, 57
ON GSL ERROR, 57
ON NAN, 56
OUTER RADIUS, 44
PARAMETRIC, 53
PARAMETRIC LOG, 54
power, 51
power density, 51
PRINT, 50
PRINT FUNCTION, 50
PROBLEM, 42
QUIT, 56
SCHEME, 52
SigmaA o, 49
SigmaA g, 45
sigmaAXe, 51
SigmaS g, 45
SigmaT o, 49
SigmaT g, 45
SLEPC, 53
solve time, 48
155
milonga v0.1
SOLVER, 53
static iterations, 52
static step, 52
STEP, 50
TEXT, 50
TOLERANCE, 53
VOLUMES, 52
x bare length, 42
x cells, 43
X CENTER, 44
X MAX, 44, 45
X MIN, 44, 45
xenon, 51
XS CENTER, 52
XS MEAN, 52
xs mean tolerance, 53
y bare length, 42
y cells, 43
Y CENTER, 44
Y MAX, 44, 45
Y MIN, 44, 45
z bare length, 42
Z MAX, 44, 45
Z MIN, 44, 45
ZONE, 44
1j6
TECNA S.A.
http://www.tecna.com
Instituto Balseiro
http://www.ib.edu.ar
http://ib.cnea.gov.ar/

thelerg/wasora/milonga

Das könnte Ihnen auch gefallen