milonga

162
MILONGA version 0.1 1 a free nuclear reactor core analysis code Germ´ an 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 first serious release 1.0. Read the preface. Any kind of feedback about this version 0.1 will be highly appreciated.

Upload: jeremy-theler

Post on 08-Mar-2015

97 views

Category:

Documents


6 download

DESCRIPTION

Milonga is a free computer code that solves the steady-state multigroup neutron diffusion equation using either a finite-volumes or a finite-differences scheme.

TRANSCRIPT

Page 1: milonga

MILONGAversion 0.11

a free nuclear reactor core analysis code

German Theler

TECNA S.A.http://www.tecna.com

Instituto Balseirohttp://www.ib.edu.ar

1This is a test release aimed at getting some feedback before a preliminary version 0.9, hoping to converge to a firstserious release 1.0. Read the preface. Any kind of feedback about this version 0.1 will be highly appreciated.

Page 2: milonga

MILONGA

a free nuclear reactor core analysis code

Abstract

Milonga is a free computer code that solves the steady-state multigroup neutron diffusion equationusing either a finite-volumes or a finite-differences scheme. Not only is it designed to cope with commonreactor geometries but also to parametrically study the effect of one or more parameters in order tooptimize some aspect of the reactor design. The code is especially designed emphasizing flexibilityin the way the geometry and the cross-sections distributions are entered, including dependence onarbitrary parameters such as temperatures, burn-up, poisons, etc. This information can be enteredas algebraic expressions, multidimensional interpolated tables or from data given by external codestrough shared memory objects. Milonga can handle a wide variety of one, two and three-dimensionalcases, from simple idealized problems up to common reactor configurations, including xenon effectsand coupled calculations with thermal-hydraulics and control-logic codes. For example, milonga canbe used to solve a case with analytical solution using its built-in algebraic and differential functions,and then easily compare it to the discrete solution along with the corresponding CPU times as afunction of the number of spatial cells. The code output is completely defined by the user throughthe input. The eigenvalue problem is solved by the SLEPc+PETSc libraries, so the computationalimplementation can be scaled virtually up to the limit of current available hardware, and hopefully formany 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 beintroduced at will.

Page 3: milonga

Preface to version 0.1

This document describes version 0.1 of the free nuclear reactor analysis code milonga that is part ofthe developments made under my PhD thesis in Nuclear Engineering. In particular, this version ofthe code and especially of this document the very first not-so-public release and is aimed at gettingas much feedback as possible. The objective is to improve the code to get into a version 0.9 thathopefully should converge into a fully-usable version 1.0 in a nearby future. By not-so-public I meanthat this document was distributed mainly between friends and colleagues. Thus, if you have receivedthis document directly from me—meaning you are a friend of mine—then I firmly ask you to saysomething back. On the other hand, if you have got this document from other indirect source, you arekindly 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 itcannot 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 ofexamples 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 somesections marked as “to be done” meaning the code is lacking that particular feature. There are alsosome sections containing the text “to be explained”. In this case, the code is able to perform the taskbut it is not documented. This is closely related to the fact that milonga is part of a set of codes thatshare a common framework, conforming a suite of engineering codes called wasora that is also part ofmy 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 handlethe matrices that are the base of the multigroup diffusion problem formulation. This library providesvery efficient methods for creating, accessing and operating matrices. It is especially designed towork in parallel using MPI. The current version 0.1 of milonga does not take any advantage ofthe parallelization facilities provided by PETSc. In fact, this first version is very computationallydemanding because efficiency was not the main focus. Optimization is expected to drive my attentionas of version 1.0.

Finally, I want to say that milonga—and indeed the whole wasora suite—was conceived as freesoftware from scratch. Not only are hacking and distribution under the terms of the GNU GeneralPublic License allowed, but also encouraged. And of course, the kind gesture of giving feedback tothe original author will be highly appreciated.

Buenos Aires, July 2011

Page 4: milonga

Contents

1 Introduction 11.1 The wasora suite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.2 Milonga design basis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.3 Software license . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

2 The equations inside milonga 72.1 The neutron diffusion equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

2.1.1 Multigroup formulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102.1.2 Finite volumes spatial discretization . . . . . . . . . . . . . . . . . . . . . . . . 142.1.3 Finite differences scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

2.2 Cell cross-section computation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272.3 Boundary conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

2.3.1 External planar surfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282.3.2 Cylindrical surfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292.3.3 Spherical surfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312.3.4 Mirror conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312.3.5 Sharp edges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

2.4 The eigenvalue problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322.4.1 Iterations tolerance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342.4.2 Flux and power . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

2.5 Xenon poisoning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

3 Input preparation 403.1 Input files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403.2 Problem definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423.3 Zones . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443.4 Boundary conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453.5 Materials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453.6 Collecting results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473.7 Power and xenon distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 503.8 Numerical scheme settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 523.9 Parametric calculations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533.10 Debugging and benchmarking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 553.11 Commandline arguments replacement . . . . . . . . . . . . . . . . . . . . . . . . . . . 553.12 Advanced eigenvalue solver settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 563.13 External coupling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 563.14 User-defined eigenvalue solver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 563.15 If anything goes wrong . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58

Page 5: milonga

milonga v0.1

4 Examples 594.1 Cases with analytical solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60

4.1.1 Homogeneous bare slab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 604.1.2 Homogenoeus bare square . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 644.1.3 Homogeneous bare circle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 684.1.4 Infinite reactor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 714.1.5 Slab with continuously-changing properties . . . . . . . . . . . . . . . . . . . . 754.1.6 Two-zone slab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78

4.2 General problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 824.2.1 Reflected slab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 824.2.2 Reflected circle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 874.2.3 IAEA 2D PWR Benchmark . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 954.2.4 Two-dimensional slice of a PHWR . . . . . . . . . . . . . . . . . . . . . . . . . 103

4.3 Parametric problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1094.3.1 Grid size effects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1094.3.2 Discrete boundary conditions effects . . . . . . . . . . . . . . . . . . . . . . . . 1174.3.3 Circle quadrature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1194.3.4 Control rod cusp problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122

4.4 Non-linear problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1254.4.1 Xenon effects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1254.4.2 Criticallity with a control rod . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127

4.5 Coupled calculations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1304.5.1 1D core coupled with RELAP . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130

Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141

5 Installation and execution 1425.1 Very quick instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1435.2 Quick instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143

5.2.1 With root access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1445.2.2 Without root access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145

5.3 Detailed installation instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1465.3.1 Obtaining the package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1465.3.2 Required libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1465.3.3 Compiling milonga . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151

5.4 Execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1525.5 Syntax highlight . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154

Keywords, variables and functions index 155

v

Page 6: milonga

Chapter I

Introduction

An engineer has to think without doing anything fifty percent of the time,and do without thinking the other fifty percent of the time.

And a good engineer knows when to think without doingand when to do without thinking.

Fabian. J. Bonetto, PhD in Nuclear Engineeringcomment to the author during an engineering thesis advisory, 2007

The first thing that should be said in relation to this code is that it is an academic project part ofa PhD thesis in Nuclear Engineering. This thesis is not about software development, but about itsusage as a design optimization tool. That is to say, milonga is not the goal but the mean. The secondstatement is that as such, it is a personal research project written from scratch by someone who worksin 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 expecta lot from milonga. In particular, it should not be compared to commercial reactor codes, nor directlyapplied to real cases without a deep comprehension of both its design philosophy and the mathematicsbehind it.

No propaganda about the convenience of using milonga instead of other codes will be given in thisdocument because of three reasons. Firstly, if this code does provide some interesting features thatmaybe other program does not, its drawbacks far overcome the benefits. Secondly, there is no needto do marketing because there is no commercial interest behind milonga, as it is free software both inthe speech and in the beer senses. The implications are explained in sections 1.2 and 1.3. And lastbut not least, there is a problem with the conjunction used in the first sentence of this paragraph. Asin 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 ReactorAnalysis, that in turn is part of a PhD thesis work. It consists of a general code framework thatprovides routines and methods for engineering programs that share a common basis and may workcoupled. In particular it provides input-file keyword parsing routines and an efficient method for pars-ing and evaluating algebraic expressions. It also includes routines for accessing standard mathematicalfunctions, interpolation, root finding, integration and differentiation. Most of the mathematical meth-ods provided by wasora are implemented by the free GSL library [1]. Access to shared memory objectsand semaphores for data exchange and coupling is also provided, along with text-based output throughfiles and error handling routines. From the user’s point of view, this just means that codes built ontop of wasora work in a similar way—for example their inputs look all alike—and that they sharecertain 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 underconsideration are:

Page 7: milonga

milonga v0.1

colach a control logic analysis code to quickly design, implement and test control algorithms in thetime domain. Besides regular linear control function such as lags and integrators, matrix-vectoroperations, arbitrary transfer functions and fuzzy logic rules can be entered. A real-time versioncapable to operate with data acquisition hardware using COMEDI is under consideration.

mochin a dynamical systems solver code to numerically integrate sets of differential-algebraic initial-value equations. It uses library IDA from the SUNDIALS suite as a back-end for time-advancingthe set DAEs and the wasora framework for parsing the equations and probably coupling thecode 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 bereal-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, milonga—whose description is this tiny document—is also part of the suite. A greatdeal of milonga’s functionality directly depends on the routines and methods provided by wasora, soits documentation should complement this description. Sadly, at the time of writing the present doc-ument for the first version of milonga, there is no consistent documentation for the wasora frameworkavailable. Some explanation about the basic usage—from the user’s point of view—is given in thisdocument, but probably there may be some gaps either in the information given here or when tryingto understand some particularities of the code. Hopefully, future releases will contain a complete setof 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 hewas my BE thesis advisor [2]. Later on, he advised my Master’s thesis [3] and he is now1 one of myPhD thesis advisors. While years passed by, I have been able to understand the rationale behindthis statement. It is important to note that the implementation of this phrase actually gave rise toremarkable results all in all. Indeed, the development of milonga is an actual consequence of thisadvise. This project has a lot of time spent just in thinking rather than programming and, of course,the other way round.

Many of milonga’s features were coded just after wondering what features I wanted commercialprograms to have and how I would have liked to work with canned codes available in the nuclearindustry. Indeed, one of the reasons of the high component of “thinking without doing” comes fromthe fact that working all day long in the nuclear business takes away a lot of time that could beused in the “doing without thinking” part. Thus, a clear definition of the design basis—in thealgebraic sense of tiny vectors that span an arbitrary huge space—was done at very early stages of thedevelopment. Actually, milonga’s design basis that follows was presented at the 2010 Annual Meetingof the Argentine Nuclear Technology Association [4].

There are four main subspaces in the design basis, each spanned by several vectors, as schematicallyillustrated in figure 1.1. The first subspace is about the kind of problems to solve, the second is aboutwhat kind of features the code should have and should be able to handle, the third is about the expectedresults and how to present them to the user and the fourth is about scalability. Event though theyare somehow related to each other, they are discussed separately in the next four paragraphs. Theconstruction “should be able to” is deliberately over-used.

1As of 2011.

Page 8: milonga

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 andresearch nuclear reactors. So this is one of the main vectors to keep in mind: the ability to cope withmathematical descriptions of real cases, incorporating means to take into account the influence of eachof the different parameters that define the actual flux distribution that real reactors have. Nevertheless,milonga is part of a design optimization suite and as such, most of the cases in practice will beconceptual ideas or very crude simplifications of the final to-be-designed reactor. Thus, simplifiedcases in one or two dimensions should also be handled. Besides, because of its academic nature, thecode should also be able to solve cases with analytical solutions to benchmark numerical schemes andsolutions methods. In addition, the parameters to be optimized usually change the set of macroscopiccross sections in very diverse ways, so a very flexible way of providing their dependence on a few to-be-optimized parameters. The actual approach is discussed in the next subspace, but the importantthing to take into account in this one is that during the optimization, there may be intermediate stepswith 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 butnot least, a great deal of the design optimization process is based on parametric studies, i.e. analyzinghow certain figures 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 flexibility. It is the main subject around mi-longa’s design and—at least in these firsts versions—flexibility should have precedence over efficiency.One important part of this subspace is about the way input data is entered. A large amount ofengineering codes still rely on the card concept, that is anachronistic, obfuscated, makes no sensenowadays and renders the preparation of the problem a complex and time-consuming task withoutadding extra value. An input preparation concept based in a parser similar to how compilers translatea human-readable source code into a binary machine-readable executable should be preferred. Milongashould read one or more text files containing keywords and arguments that should be parsed and sub-sequently converted into the proper coefficients in the neutron diffusion equation. Another aspect ofthe flexibility that is desired in modern engineering computer codes, and in the same direction as thatof the parametric vector, is that the reactor geometry and the parameters spatial distribution shouldbe defined independently from the particular spatial nodalization chosen to discretize the diffusionproblem. The spatial distribution of cross sections that finally characterize the problem to be solvedshould be viewed as continuous multidimensional functions with an arbitrary dependence on otherparameters, such as temperature or burn-up distributions that, in turn, are also viewed as continuousspatial distributions. To handle varying parameters, milonga should be able to deal with auxiliaryvariables, vectors and multidimensional functions, to operate by applying algebraic or differential op-erators to them, and to use these results to evaluate either the geometry definition or cross sectionsdistributions. The basic results computed by the code should also be prone to further mathematicalmanipulation 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 flexibility of this kind of computational code is the

Page 9: milonga

milonga v0.1

set of possible sources for the information that fully define the problem (i.e. geometry, including theposition of the control rods, temperatures, burn-up and poisons distributions). They might be givenas point-wise defined 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 files or exchanged withother engineering codes using some efficient coupling mechanism.

Back when input data was entered by making holes in a card, T-Rexes ruled the continent andcalculation times were measured in weeks, computer simulation codes had to give as much outputas possible to reduce costs. In the engineering departments, it was preferred to have a large numberof sheets with a lot of tiny scientific-notation matrix-dot printed numbers stored in cabinets andshelves for eventual consultation, than to have to re-run simulations each time a particular resultwas needed. This is no longer true, especially for engineering design calculations. Nowadays, theactivity of browsing through old-fashioned huge text files looking for a needle or having to convertand process numerical data to feed graphical plotters or post-processing tools is usually far moretime consuming that the execution of the actual simulations. Moreover, as computational capacityhas grown exponentially over the last years—and of course it is expected to continue increasing—more and more detailed models are being utilized, and therefore more and more information canbe computed. If all the results are written to the output—consider transient cases of several daysof operation for example—the simulation turns into an inefficient process in terms of data storageand retrieval. Milonga should be as flexible as possible in terms of what its output is. First, nounwanted information should be obtained. Second, output post-processing and further treatment isto be reduced or even avoided. And third, means to easily compare results—either with the samecalculation method but with different parameters or with the same parameters but with differentmethods—should be taken into account in the design. Not only should the actual output routinescomply with the basis discussed in this paragraph, but also the whole code structure has to providethe needed flexibility to present to the user the proper output information.

Finally, a very important subset of the design basis is that of scalability. This concept basicallymeans that the code should be able to run efficiently not only in what are considered current scientificcomputing 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 efficiency 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, forsure, mathematicians and computer science professionals write better numerical methods routinesthan 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, asthis feature increases the chances that the code could be compiled in whatever architecture is goingto be considered standard for scientific 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 aspossible and, on the other hand, delegating non-specific tasks to available libraries that also incorpo-rate portability and scalability in their design basis. In addition, being an academic project, it wouldbe 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 newfeatures. 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 program—as for example Linuxkernel modules do—but the modularity comes from the use of so-called Fortran modules. This partic-ularity does not provide the expected benefits of a modular design—as the Linux kernel does—and,moreover, the overall coding scheme is prone to obfuscation. Also, the same functionality can beimplemented in a cleaner way using other data structures and languages like C instead of Fortran, somodularity is not part of milonga’s design basis. To help milonga to survive to changes in computingparadigms and to scale its power along future hardware availability, its source code should be freelyavailable for anyone to be able to modify it as desired, including changes due to flexibility, efficiency,portability and scalability. Of course, being milonga free software, it can only depend on free libraries,that may themselves be modified to enhance flexibility, efficiency, portability and scalability, closing

Page 10: milonga

milonga v0.1

a positive feedback loop where everyone benefits from the freedom that free software provides.

1.3 Software license

Living in a country that should be ashamed—amongst other things—about its software piracy rate [5],it seems appropriate at this point to clearly state the license under which the code is distributed. Toknow what kind of rights you are entitled to is as important as to know how to use the software.

Milonga is free software—both as in free speech and as in free beer, although the first meaningis far more important than the second one—and is distributed under the terms of the GNU GeneralPublic 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 everyuser 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 offers 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 theydo, it will be free software and stay free software, no matter who changes or distributesthe program. We call this copyleft: the software is copyrighted, but instead of using thoserights to restrict users like proprietary software does, we use them to ensure that everyuser has freedom.

Not only does milonga provide all the four basic freedoms to the software user, but also encouragesher to study, understand, analyze and hack it. And of course, to share under the terms of the GNUGPL—especially with milonga’s original author—her discoveries, suggestions, improvements and fixedbugs. To sum up:

Milonga is free software: you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe 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 ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.

You should have received a copy of the GNU General Public Licensealong with wasora. If not, see http://www.gnu.org/licenses/.

Milonga relies on a few libraries, all of them available also under different 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

Page 11: milonga

milonga v0.1

• Cubature (http://ab-initio.mit.edu/wiki/index.php/Cubature), released underthe GNU General Public License v2 or later

These libraries may depend on other free libraries themselves. Check the associated documentationfor more information.

Bibliography

[1] M. Galassi et. al. GNU Scientific 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. Bachelor’sthesis in Nuclear Engineering, Instituto Balseiro, Bariloche, Argentina, 2007.

[3] G. Theler. Analisis no lineal de inestabilidades en el problema acoplado termohidraulico-neutronico. Masters’s 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 diseno del codigo neutronico milonga. In Actas de la XXXVII Reunion Anual de laAsociacion Argentina de Tecnologıa 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.

Page 12: milonga

Chapter II

The equations inside milonga

I am not scared by this complicated scatteringkernel integral, but by the tiny divergence term.

Javier Fernandez, PhD in Mathematics,after his first looking at the diffusion 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 nomeans 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 executethe code as a black box. Moreover, the input allows certain options that can be only understood byknowing what equations milonga solves and what models and simplifications are implied within them.And last but not least, the uncertainties and errors introduced by the discretization of a continuousequation into the finite number of unknowns depend on how the input continuous parameters are alsocondensed into a finite set. All these features are thoroughly explained in this chapter and thus, it isof central importance for the practical usage of the software.

Milonga is a neutron diffusion code, i.e. it solves the steady-state—at least in this version—neutrondiffusion equation. This means that its results cannot be more accurate than the diffusion equationitself, that is already an approximation to the neutron transport problem—which might be thoughtof as another simplification of the physical problem also. Indeed, figure 2.1 shows one of the manyconceptual paths that could be taken to go from the actual real situation to the results obtained byusing a digital computer to solve the problem. Each rectangle is a source of uncertainties that shouldbe taken into account, and whose magnitude the user ought to be able to quantify when executingthe last step shown in the diagram.

Whenever an approximation is introduced in the development, an exclamation mark as the oneshown in the left margin will appear.

This chapter focuses on the particular mathematical steps that milonga takes to go from thecontinuous diffusion equation up to the numerical solution of the eigenvalue problem, specifically thethree rectangles shaded in figure 2.1. Naturally, corrections, suggestions and improvements are morethan welcome. Indeed, the usual $2.56 reward for each bug found [1] can also be discussed.

2.1 The neutron diffusion equation

The derivation of the diffusion equation from the neutron transport theory can be found in thenuclear reactor theory literature. Classical books that treat the subject paying special attention tomathematical 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 conditionswhere the diffusion approximation holds which, of course, should be met for milonga to be useful. It

Page 13: milonga

milonga v0.1

plant physics reactor physics nuclear properties

neutron transporttheory

multigroupformulation

spatialdiscretization

numericalsolution

interpretationof results

mathematicalmodels

experimentalmicroscopic XS

condensation &homogeneization

diffusiontheory

Figure 2.1: One of the many possible paths that connect the physical problem with the results obtainedin a computer. This chapter focuses just in the route that goes from the diffusion equation up to—andincluding—its numerical solution.

is assumed that the user thoroughly understands the physics behind Fick’s law and what the diffusionequation implies.

The main goal is to solve the associated critical reactor neutron diffusion equation with fissionsources, namely

0 = div[D(r, E,P) · grad

[φ(r, E)

] ]− Σt(r, E,P) · φ(r, E)

+

∫ ∞0

Σs(r, E′ → E,P) · φ(r, E′) dE′

+ χ(E)

∫ ∞0

νΣf (r, E′,P)

keff· φ(r, E′) dE′ (2.1)

for the steady-state flux distribution φ(r, E) and the effective multiplication factor keff over a m+ 1-dimensional phase space with spatial coordinates r ∈ Rm and one energy component E, as depictedin figure 2.2. The divergence and gradient operators are applied only to the spatial coordinates,and thus boundary conditions—either Dirichlet, Neumann or mixed—are needed only in the spatialdomain boundary. D(r, E,P), Σt(r, E,P) and νΣf (r, E,P) are the diffusion coefficient, total andν-fission macroscopic cross sections at the spatial position r for neutrons of energy E. They canalso depend on arbitrary parameters P that are further discussed below. The scattering kernel issuch that Σs(r, E → E′) dE dE′ gives the macroscopic cross-section in r for a scattering collision ofa neutron that changes its energy from E + dE to E′ + dE′. Equation (2.1) assumes that there isonly one fissile isotope—or equivalently, that all the fissile isotopes produce fission neutrons with thesame energy distribution, that is indeed the most common situation. The fission spectrum gives theprobability χ(E) dE for a fission neutron to be born with an energy between E and E + dE. Forsimplicity, this chapter assumes there is a single common fission spectrum.

Page 14: milonga

milonga v0.1

Figure 2.2: Four-dimensional phase space where the solution of the diffusion equation is sought for. Threecoordinates 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 reflected nuclear reactor core,including its reactivity control mechanisms and possibly taking into account the effects of temperature,density and poison spatial distributions as depicted in figure 2.3. These distributions can be enteredby 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 evaluated—and of course integratedand differentiated—at any point in space as desired.

If the macroscopic nuclear parameters D, Σt, Σs and νΣf are known functions of the space andthe energy only, then equation (2.1) is linear. However, in all practical cases the nuclear propertiesof the materials depend on other arbitrary parameters P that may themselves depend either on theactual flux 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 canbe known a priori, the calculation of the actual value of the parameters is out of milonga’s scopeand should be handled by thermal-hydraulic or control system engineering codes. Nevertheless, thisarbitrary dependence can implemented by means of successive coupled calculations until an certainflux distribution φ?(r, E) is obtained such that the corresponding parameters P? give rise to the sameflux φ?(r, E) when inserted back into equation (2.1)

φ?(r, E)→ P? → φ?(r, E) (2.2)

For example, consider the case of a reactor calculation involving the effects of xenon poisoning.The vector of nuclear parameters N at position r depend on the 135Xe concentration at r, that dependson the local neutron flux at r that of course depends on the nuclear parameters at r. To solve thisnonlinear problem, first guess an initial xenon concentration X0(r)—which may be identically zero.Now evaluate the nuclear parameters N(r, E), obtain a flux distribution φ1(r, E) and compute againthe associated equilibrium xenon concentration X1(r). Use this distribution to evaluate new nuclearparameters, calculate the flux and so on.

In some way, a mapping is defined 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 stablefixed point that attracts nearby phase-space solutions, as assumed in equation (2.2). The fixed pointis obtained when

φn+1 = φn (2.4)

The fact that there exists a fixed point and that it is stable depends on F(φ), whose behavioris quite difficult to analyze. However, under normal circumstances—i.e. usual dependence of crosssections with parameters—there is an stable fixed point that is the actual solution to the non-linearproblem.

Page 15: milonga

milonga v0.1

control rods

core

reflector

Figure 2.3: Typical problem to be tackled with milonga. The core and reflector may have different temper-atures, void fractions, poisons, burn-up distribution, etc. These parameters can be computed by other codescoupled to milonga or they can be given from the input as multidimensional tables, algebraic expressions ora combination of all of them. As a result, all the parameters are continuous functions that can be evaluatedat any point in space.

In this example case, P? was related to the equilibrium xenon concentration, but the same ideaholds for other parameters such as temperature and density distributions, boron concentration, etc.Note that these distributions are outside milonga’s scope so in order to take these effects into accounta coupled calculation between the reactor and other codes is needed.

For a definite step n of this iterative procedure with fixed parameters, the explicit dependence on Pmay be dropped and thought of as implicit in the dependence of the cross sections on the position rand the diffusion equation may be written as

0 = div[D(r, E) · grad

[φ(r, E)

] ]− Σt(r, E) · φ(r, E)

+

∫ ∞0

Σs(r, E′ → E) · φ(r, E′) dE′ + χ(E)

∫ ∞0

νΣf (r, E′)

keff· φ(r, E′) dE′ (2.5)

that is a linear and homogeneous integro-differential equation.

2.1.1 Multigroup formulation

The diffusion equation (2.1) spans several orders of magnitude in energy—typically from 10−2 up to106 eV—with the macroscopic cross sections varying greatly and abruptly also by different orders be-cause of nuclear resonances. To handle this, milonga works with the common multi-group formulationof the diffusion problem [4] which is introduced in this section.

The continuous energy dependence of both the neutron flux and the nuclear parameters can betransformed into a set of equations describing the average behavior of the neutrons inside finiteintervals of energy by using the following approach. The continuous energy domain is divided into Ggroups with cut-off values 0 = EG < EG−1 < · · · < E1 < E0 not necessarily equally-spaced, asdepicted in figure 2.4. Energy E0 should be greater than the energy of the fastest expected neutron.Energy group g is defined as the interval [Eg, Eg−1].

The flux in group g ∈ N ≤ G is defined as

Page 16: milonga

milonga v0.1

Figure 2.4: Partition of the energy range 0 < E < E0 into G discrete groups

φg(r) = φ(r, g) =

∫ Eg−1

Eg

φ(r, E) dE (2.6)

To avoid an excessive use of sub-indexes, the notation φ(r, g) will be preferred. In the analysis thatfollows, functions of the integer index g are group values. Note that the flux in group g is an integratedflux, while the continuous flux φ(r, E) is a density in energy. The former has units of inverse squaredlength 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 fluxes. Integrating equa-tion (2.5) with respect to energy between Eg and Eg−1 it is

0 =

∫ Eg−1

Eg

div[D(r, E) · grad

[φ(r, E)

] ]dE −

∫ Eg−1

Eg

Σt(r, E) · φ(r, E) dE

+

∫ Eg−1

Eg

∫ ∞0

Σs(r, E′ → E) · φ(r, E′) dE′ dE

+

∫ Eg−1

Eg

χ(E)

∫ ∞0

νΣf (r, E′)

keff· φ(r, E′) dE′ dE

Now, it is desired to express each term as a product of a group-mean parameter times a groupflux. Starting with the total removal term—which is the easiest one—one would like to write∫ Eg−1

Eg

Σt(r, E) · φ(r, E) dE = Σt(r, g) · φ(r, g)

so the mean total cross section in group g should be defined as

Σt(r, g) =

∫ Eg−1

Eg

Σt(r, E) · φ(r, E) dE∫ Eg−1

Eg

φ(r, E) dE

(2.7)

Of course, if the mean group cross section depends on the flux itself, then the proposed integrationoperation is of no help at all. However, lattice codes are able to obtain reasonable nuclear parametersfor the multi-group formulation by assuming certain energy distributions for the neutron flux. Indeed,if the flux is assumed to be constant for the whole energy interval the total cross section is just thetraditional mean value

Σt(r, g) =

∫ Eg−1

Eg

Σt(r, E) dE

Eg−1 − Eg(2.8)

From milonga’s point of view, the value of the macroscopic absorption cross section is a knownfunction of the spatial coordinates and eventually of other parameters than can be evaluated beforesolving the diffusion equation, at least for each step of the non-linear iteration (2.3). Whether thelattice code utilized to generate the macroscopic cross sections uses equation (2.7) with a certainapproximation for φ(r, E), 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 shouldbe compatible with the definition given by equation (2.7).

Page 17: milonga

milonga v0.1

The scattering term can be written as

∫ Eg−1

Eg

∫ ∞0

Σs(r, E′ → E) · φ(r, E′) dE′ dE =

∫ Eg−1

Eg

G∑g′=1

∫ Eg′−1

Eg′

Σs(r, E′ → E) · φ(r, E′) dE′ dE =

G∑g′=1

∫ Eg−1

Eg

∫ Eg′−1

Eg′

Σs(r, E′ → E) · φ(r, E′) dE′ dE =

G∑g′=1

Σs(r, g′ → g) · φ(r, g)

As the energies Eg are arbitrary, for this equality to hold the individual terms should be equal.Thus the scattering cross section from group g′ to group g is

Σs(r, g′ → g) =

∫ Eg−1

Eg

∫ Eg′−1

Eg′

Σs(r, E′ → E) · φ(r, E′) dE′ dE∫ Eg−1

Eg

φ(r, E) dE

(2.9)

Again, these G2 parameters are treated as known values prior to the solution of the diffusionequation.

The fission term can be written as

∫ Eg−1

Eg

χ(E)

∫ ∞0

νΣf (r, E′)

keff· φ(r, E′) dE′ dE =

∫ Eg−1

Eg

χ(E)

G∑g′=1

∫ Eg′−1

Eg′

νΣf (r, E′)

keff· φ(r, E′) dE′ dE =

∫ Eg−1

Eg

χ(E) dE ·G∑

g′=1

∫ Eg′−1

Eg′

νΣf (r, E′)

keff· φ(r, E′) dE′ = χ(g) ·

G∑g′=1

νΣf (r, g′)

keff· φ(r, g′)

where the fission spectrum of group g is

χ(g) =

∫ Eg−1

Eg

χ(E) dE (2.10)

and the mean ν-fission cross section is

νΣf (r, g) =

∫ Eg−1

Eg

νΣf (r, E) · φ(r, E′) dE∫ Eg−1

Eg

φ(r, E) dE

(2.11)

Note that the fission spectrum has to be normalized such that∫ ∞0

χ(E) dE = 1

and thus

G∑g=1

χ(g) = 1 (2.12)

Page 18: milonga

milonga v0.1

Finally, the leakage term—which is the trickiest—has to be written as

∫ Eg−1

Eg

div[D(r, E) · grad

[φ(r, E)

] ]dE = div

[D(r, g) · grad

[φ(r, g)

] ](2.13)

In general this equation does not have an exact solution for the multigroup diffusion coefficient.However, one workaround is to assume that the flux can be separated into energy and position

φ(r, E) = ϕ(r) · ψ(E)

so that

∫ Eg−1

Eg

div[D(r, E) · grad

[ϕ(r)ψ(E)

] ]dE = div

[D(r, g) · grad

[φ(r, g)

] ]div

[∫ Eg−1

Eg

D(r, E) · ψ(E) · grad[ϕ(r)

]dE

]= div

[D(r, g) · grad

[∫ Eg−1

Eg

ϕ(r)ψ(E) dE

] ]

div

[∫ Eg−1

Eg

D(r, E) · ψ(E) dE · grad[ϕ(r)

] ]= div

[D(r, g) · grad

[ϕ(r)

]·∫ Eg−1

Eg

ψ(E) dE

]

and thus the diffusion coefficient for the group g can be computed as

D(r, g) =

∫ Eg−1

Eg

D(r, E) · ψ(E) dE∫ Eg−1

Eg

ψ(E) dE

Another approach may be to calculate the mean transport cross section for the group g withthe same weighting procedure used in the total cross section (equation (2.7)) and then compute thediffusion coefficient from its definition

D(r, g) =1

3Σtr(r, g)=

1

∫ Eg−1

Eg

φ(r, E) dE∫ Eg−1

Eg

Σtr(r, E) · φ(r, E) dE

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 themselvesdepend on the position. So the multigroup parameters, from milonga’s point of view, are essentiallyknown continuous functions of the position r. It is the user’s responsibility to generate them from alattice code or whatever other applicable source consistently with the expected usage shown in thissection.

Collecting these results, the continuous diffusion equation (2.5) can be discretized in energy as Gcoupled differential equations in the spatial coordinates for the group neutron fluxes φ(r, g)

0 = div[D(r, g) · grad

[φ(r, g)

] ]− Σt(r, g) · φ(r, g)

+

G∑g′=1

Σs(r, g′ → g) · φ(r, g′) + χ(g)

G∑g′=1

νΣf (r, g′)

keff· φ(r, g′) (2.14)

Page 19: milonga

milonga v0.1

Provided the nuclear parameters are computed from the definitions (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 processis the detailed dependence of the flux on E inside each group. Any approximation done during thegeneration of the multi-group macroscopic parameters will induce differences between the continuouslinear energy diffusion equation (2.5) and the energy-discretized equation (2.14).

2.1.2 Finite volumes spatial discretization

To solve a partial differential equation in a digital computer, a certain discretization of the spatialcoordinates ought to be done. As one of milonga’s design goals is research and development, the codehas several different approaches to the subject, mainly for comparison and academic reasons. The codeis mainly based on a finite volumes scheme as these kind of methods are best suitable for conservationproblems than finite differences or finite elements are. Nonetheless, some finite differences schemesrecipes are also provided by milonga that are introduced in section 2.1.3.

The basis of the finite volumes spatial discretization is the division of the domain into N adjacentcells, as depicted in figure 2.5. In principle, cells can be arbitrary, but to fix ideas rectangular anduniform cells are going to be considered for the moment being, as shown in figure 2.6. The flux of thegroup g ∈ N < G in cell i ∈ N < N is defined as

φig = φ(i, g) =

∫Vi

φ(r, g) dmr∫Vi

dmr

(2.15)

where∫Vi

is to be understood as the integral over the volume of the i-th cell and dmr represents the

volume differential of the spatial coordinates in Rm. For m = 1, 2, 3 (figures 2.6a, 2.6b and 2.6c) theuniform volume Vi of the i-th cell is equal to ∆x, ∆x∆y and ∆x∆y∆z respectively.

Figure 2.5: Discretization of a two-dimensional spatial domain into a finite number of cells.

Again, the notation φ(i, g) over φig will be preferred to avoid the excessive use of sub-indexes. Theflux of group g in cell i is a scalar number, not a function. The set of the fluxes φ(i, g) for i = 1, . . . , Nand for g = 1, . . . , G is the numerical solution of the diffusion problem sought for. Note that φ(i, g) isthe mean value of the continuous flux φ(r, g) over the i-th cell and thus φ(i, g) and φ(r, g) have thesame units—as opposed to what happens between φ(r, E) and φ(r, g) given by equation (2.6)—namely,inverse squared length and inverse time.

Page 20: milonga

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 flux φ(i, g) that will be the solution to the problem isthe mean value of the continuous flux distribution over the cell, and not the value of the flux evaluatedat the cell center

φ(i, g) =

∫Vi

φ(r, g) dmr∫Vi

dmr

6= φ(ri, g)

although they are equal in the order of ∆x2, so the following approximation may be taken

φ(i, g) ≈ φ(ri, g) (2.16)

throughout the mathematical development that follows.

The multigroup diffusion equation (2.14) is now integrated throughout the volume of cell i

0 =

∫Vi

div[D(r, g) · grad

[φ(r, g)

] ]dmr−

∫Vi

Σt(r, g) · φ(r, g) dmr

+

∫Vi

G∑g′=1

Σs(r, g′ → g) · φ(r, g′) dmr +

∫Vi

χ(g)G∑

g′=1

νΣf (r, g′)

keff· φ(r, g′) dmr

and each term is analyzed separately. First, the term of the total interactions should be equal to theproduct of the mean total cross section, the mean flux and the cell volume∫

Vi

Σt(r, g) · φ(r, g) dmr = Σt(i, g) · φ(i, g)

∫Vi

dmr

so the mean cross section associated to cell i for total neutron interaction is

Σt(i, g) =

∫Vi

Σt(r, g) · φ(r, g) dmr∫Vi

φ(r, g) dmr

(2.17)

Now, this parameter is not an input to milonga but should rather be computed from the continuoustotal cross section for group g spatial dependance Σs(r, g), that is the actual input to the code. Thetotal cross section may depend on r because of materials interfaces and also because of potentialproperty changes such as temperatures throughout a single material. As the continuous flux φ(r, g)is not known, some approximation ought to be done. Milonga provides a few different methods forcomputing the integral in equation (2.17) avoiding direct references to the flux φ(r, g). These methods

Page 21: milonga

milonga v0.1

are discussed in section 2.2, and give rise to different expressions for the numerical mean cross sectionsthat should be taken into account when analyzing results. The rest of this section explicitly developsthe form of the discrete form of the diffusion equation and gives the equations that should be satisfiedby the mean cell cross sections in order for the discretization to be a faithful representation of thecontinuous equation.

The integrated scattering term is

∫Vi

G∑g′=1

Σs(r, g′ → g) · φ(r, g′) dmr =

G∑g′=1

∫Vi

Σs(r, g′ → g) · φ(r, g′) dmr =

G∑g′=1

Σs(i, g′ → g) · φ(i, g′)

∫Vi

dmr

and the mean scattering cross section from group g′ to group g for cell i is

Σs(i, g′ → g) =

∫Vi

Σs(r, g′ → g) · φ(r, g′) dmr∫

Vi

φ(r, g′) dmr

(2.18)

Similarly, the fission term should be

∫Vi

χ(g)

G∑g′=1

νΣf (r, g′)

keff· φ(r, g′) dmr =

χ(g)

keff

G∑g′=1

∫Vi

νΣf (r, g′) · φ(r, g′) dmr =χ(g)

keff

G∑g′=1

νΣf (i, g′) · φ(i, g′)

∫Vi

dmr

Therefore

νΣf (i, g) =

∫Vi

νΣf (r, g) · φ(r, g) dmr∫Vi

φ(r, g) dmr

(2.19)

The only term remaining is the net leakage out of the cell. It is in the spatial discretization of thisterm that the fun of the neutron diffusion problem pops up, so it is analyzed thoroughly for one, twoand three dimensions. An alternative approach based on the finite differences method is introducedin section 2.1.3.

One dimension

Consider a one-dimensional problem consisting of a slab of length a spanning the interval [0, a] inthe x direction surrounded by vacuum. The interval is divided into N cells of equal length, suchthat the i-th cell spans the interval [xi−1, xi], as depicted in figure 2.7. To simplify the notation,the neutron flux 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 thevalue of the mean flux in the cell (crosses) and half-integer arguments indicate fluxes evaluated at cellboundaries (squares). The first are the values computed by milonga and the latter are estimated fromthe former.

The integrated leakage term in one dimension is

Page 22: milonga

milonga v0.1

Figure 2.7: Spatial discretization of a one-dimensional domain. The fluxes with integer indexes (crosses)are the solution sought for, while the fluxes with half-integer arguments (squares) are estimations from theinteger-indexes fluxes.

Figure 2.8: Estimation of the neutron flux φ(i+ 1/2) at the cell boundary (square) from the mean cell fluxesφ(i) and φ(i+ 1). (crosses). There may be a material discontinuity at the boundary x = xi, so φ(i+ 1/2) maynot be equal to the average of the cell fluxes.

∫Vi

div[D(r) · grad

[φ(r)

] ]dr =

∫ xi

xi−1

∂x

[D(x) · ∂φ(x)

∂x

]dx

=

[D(x) · ∂φ(x)

∂x

]xi

xi−1

= D(xi) ·∂φ

∂x

∣∣∣∣x=xi

−D(xi−1) · ∂φ∂x

∣∣∣∣x=xi−1

(2.20)

It may happen that neither D(x) nor ∂φ/∂x are defined at the cell boundary if a material interfaceexists at x = xi. However, the product D(x) · ∂φ/∂x is always well-defined, as it represents the netneutron current at x. Moreover, the continuity of the current implies that

limε→0+

D(xi − ε) ·∂φ

∂x

∣∣∣∣xi−ε

= limε→0+

D(xi + ε) · ∂φ∂x

∣∣∣∣xi+ε

(2.21)

The flux φ(i+1/2) at the boundary between cells i and i+1 is defined so that a discrete first-orderversion of equation (2.21) holds

D(xi − ε)φ(i+ 1/2)− φ(i)

12∆x

= D(xi + ε)φ(i+ 1)− φ(i+ 1/2)

12∆x

for some 0 < ε� ∆x. The flux φ(i+ 1/2) as a function of the fluxes in cells i and i+ 1 is therefore

Page 23: milonga

milonga v0.1

φ(i+ 1/2) =D(xi − ε) · φ(i) +D(xi + ε) · φ(i+ 1)

D(xi − ε) +D(xi + ε)(2.22)

Note that if D(x) is continuous, the intermediate fluxes in equation (2.22) are

φ(i+ 1/2) =1

2

[φ(i) + φ(i+ 1)

]The current D(x) · ∂φ/∂x at xi can thus be approximated as

limε→0+

D(xi − ε) ·∂φ(xi − ε)

∂x≈

D(xi − ε)[φ(i+ 1/2)− φ(i)

12∆x

]=

D(xi − ε) ·2

∆x

[(D(xi − ε)

D(xi − ε) +D(xi + ε)− 1

)φ(i) +

D(xi + ε)

D(xi − ε) +D(xi + ε)· φ(i+ 1)

](2.23)

Conversely, the current at xi from the point of view of cell i+ 1 can be written as

limε→0+

D(xi + ε) · ∂φ∂x

∣∣∣∣xi+ε

D(xi + ε)

[φ(i+ 1)− φ(i+ 1/2)

12∆x

]=

D(xi + ε) · 2

∆x

[(1− D(xi + ε)

D(xi − ε) +D(xi + ε)

)φ(i+ 1)− D(xi − ε)

D(xi − ε) +D(xi + ε)· φ(i)

](2.24)

Note again that if D(x) is continuous, the current at xi is

D(xi) ·φ(i+ 1)− φ(i)

∆x

Equation (2.24) can be used to evaluate the current at i− 1/2 from the point of view of cell i byreplacing i by i− 1

limε→0+

D(xi−1 + ε) · ∂φ∂x

∣∣∣∣xi−1+ε

D(xi−1 + ε)

[φ(i)− φ(i− 1/2)

12∆x

]=

D(xi−1 + ε)2

∆x

[(1− D(xi−1 + ε)

D(xi−1 − ε) +D(xi−1 + ε)

)φ(i)− D(xi−1 − ε)

D(xi−1 − ε) +D(xi−1 + ε)· φ(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

D(xi) ·∂φ

∂x

∣∣∣∣x=xi

−D(xi−1) · ∂φ∂x

∣∣∣∣x=xi−1

2D(xi − ε)∆x

[(D(xi − ε)

D(xi − ε) +D(xi + ε)− 1

)φ(i) +

D(xi + ε)

D(xi − ε) +D(xi + ε)· φ(i+ 1)

]−

2D(xi−1 + ε)

∆x

[(1− D(xi−1 + ε)

D(xi−1 − ε) +D(xi−1 + ε)

)φ(i)− D(xi−1 − ε)

D(xi−1 − ε) +D(xi−1 + ε)· φ(i− 1)

]

Page 24: milonga

milonga v0.1

which can be cleanly rewritten in terms of the cell fluxes at i and its two first neighbors∫ xi

xi−1

∂x

[D(x) · ∂φ(x)

∂x

]dx = C−i · φ(i− 1) + Ci · φ(i) + C+

i · φ(i+ 1) (2.26)

with

Ci = − 2

∆x

[D(xi−1 − ε) ·D(xi−1 + ε)

D(xi−1 − ε) +D(xi−1 + ε)+

D(xi − ε) ·D(xi + ε)

D(xi − ε) +D(xi + ε)

]

C−i =2

∆x

D(xi−1 − ε) ·D(xi−1 + ε)

D(xi−1 − ε) +D(xi−1 + ε)

C+i =

2

∆x

D(xi − ε) ·D(xi + ε)

D(xi − ε) +D(xi + ε)(2.27)

This set of coefficients gives good results either for cases with D(x) varying smoothly with x orfor discontinuities located exactly at cell boundaries. When there are material interfaces that do notcoincide with the spatial discretization, equations (2.27) give rise to poor estimations. This is becauseif D(x) is continuous at x = xi, then the intermediate flux φ(i + 1/2) according to equation (2.22)is always the average of φ(i) and φ(i + 1) and thus the current given by equation (2.23) does notdepend explicitly on the actual position of the interface, but indirectly via the way of computing thecell-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 forthe diffusion coefficients

〈D(xi − ε)〉 =

∫ xi

xi− 12 ∆x

D(x) dx

12∆x

〈D(xi + ε)〉 =

∫ xi+12 ∆x

xi

D(x) dx

12∆x

instead of the actual values D(xi − ε) and D(xi + ε), as illustrated in figures 2.9. This way, thecurrent depends continuously on the material interface position and the solutions—for example themultiplication factor keff—also depend continuously on this position. Whether D(xi∓ε) or 〈D(xi∓ε)〉should be used depends on the particular problem being solved.

Note finally that if the diffusion coefficient is homogeneous in the whole domain, i.e. D(x) = D,the coefficients C (either using D or 〈D〉) are

Ci = −2D

∆x

C−i =D

∆x

C+i =

D

∆x

and the integrated leakage term of equation (2.26) is reduced to

Page 25: milonga

milonga v0.1

(a) (b)

Figure 2.9: Difference between the computation of D(xi ∓ ε) and D(xi ∓ ε).

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

∫ xi

xi−1

∂x

[D · ∂φ(x)

∂x

]dx ≈ D

∆x

[φ(i− 1)− 2φ(i) + φ(i+ 1)

]which is the 3-point stencil for the D times the flux Laplacian multiplied by the cell volume ∆x.

Two dimensions

Consider now a two-dimensional case, where the spatial domain is divided uniformly intoN rectangularcells of length ∆x and height ∆y, as in figure 2.6b. Each cell can be uniquely defined by means of twointeger indexes ix and iy, such that the i-th cell (also referred to as the ix-iy cell) spans the geometricplace xix−1 < x < xix and yiy−1 < y < yiy (figure 2.10). The leakage term for this cell is∫

Vi

div[D(x, y) · gradφ(x, y)

]d2r

that can be rewritten using the divergence theorem as a surface integral∫∂Vi

[D(x, y) · gradφ(x, y)

]· n(x, y) d (∂Vi)

Page 26: milonga

milonga v0.1

where ∂Vi is the i-th cell boundary and n(x, y) is the unitary outward vector normal to the boundaryat r = (x, y) ∈ ∂Vi. For the cell in figure 2.10, it is

∫∂Vi

[D(r) · gradφ(r)

]· n(r) d (∂Vi) = +

∫ yiy

yiy−1

D(xix , y) · ∂φ∂x

(xix , y) dy

−∫ yiy

yiy−1

D(xix−1, y) · ∂φ∂x

(xix−1, y) dy

+

∫ xi

xix−1

D(x, yiy ) · ∂φ∂y

(x, yiy ) dx

−∫ xi

xix−1

D(x, yiy−1) · ∂φ∂y

(x, yiy−1) dx (2.28)

Even though these four integrals ought to be solved individually, they all have the same structureand can be reduced to results that somehow resemble the one-dimensional case. Take for examplethe first 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 netincoming (i.e. also to the right) neutron current through the left boundary in cell (ix + 1)-iy. And,because there may be a material interface at the boundary, proceeding like in the previous section, itshould be∫ yiy

yiy−1

D(xix − ε, y) · ∂φ∂x

(xix − ε, y) dy =

∫ yiy

yiy−1

D(xix + ε, y) · ∂φ∂x

(xix + ε, y) dy (2.29)

for some 0 < ε� ∆x.

To obtain a finite volumes scheme using only four neighbors, is must be assumed that the netcurrent can be written as

∫ yiy

yiy−1

D(xix − ε, y) · ∂φ∂x

(xix − ε, y) dy ≈ ∂φ

∂x

(xix −

∆x

2− ε, yiy

)·∫ yiy

yiy−1

D(xix − ε, y) dy (2.30)

This approximation is correct up to order ∆y2. To simplify the notation in the development thatfollows, use the nomenclature defined in figure 2.10

φ(ix, iy) = φ

(xix −

∆x

2, yiy −

∆y

2

)φ(ix − 1/2, iy) = φ

(xix−1, yiy −

∆y

2

)φ(ix + 1/2, iy) = φ

(xix , yiy −

∆y

2

)φ(ix, iy − 1/2) = φ

(xix −

∆x

2, yiy−1

)φ(ix, iy + 1/2) = φ

(xix −

∆x

2, yiy−1

)

as the mean flux in the ix-iy cell and the mean fluxes in each side of the rectangle, and let

Page 27: milonga

milonga v0.1

D(x, iy) =

∫ yiy

yiy−1

D(x, y) dy

D(ix, y) =

∫ xix

xix−1

D(x, y) dx

Note that x, y ∈ R and ix, iy ∈ N, so the first expression is a function of x for a fixed iy and thesecond is a function of y for a fixed ix.

By using the approximation (2.30) in equation (2.29) the current continuity implies the identity

D(xix − ε, iy) · ∂φ∂y

(xix − ε, iy) = D(xix + ε, iy) · ∂φ∂y

(xix + ε, iy)

In the same spirit of equation (2.21), the derivatives are approximated by half increments suchthat

D(xix − ε, iy) · φ(ix + 1/2, iy)− φ(ix, iy)12∆x

= D(xix + ε, iy) · φ(ix + 1, iy)− φ(ix + 1/2, iy)12∆x

The intermediate flux φ(ix + 1/2, iy) as a function of the cell fluxes is thus

φ(ix + 1/2, iy) =D(xix − ε, iy) · φ(ix, iy) + D(xix + ε, iy) · φ(ix, iy + 1)

D(xix − ε, iy) + D(xix + ε, iy)

and the flux derivative at the boundary cell ix-iy is

∂φ

∂x(xix − ε, iy) ≈ 2

∆x

[(D(xix − ε, iy)

D(xix − ε, iy) + D(xix + ε, iy)− 1

)· φ(ix, iy)

+D(xix−1 + ε, iy)

D(xix − ε, iy) + D(xix + ε, iy)· φ(ix + 1, iy)

](2.31)

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

∫ yiy

yiy−1

D(xix , y) · ∂φ∂x

(xix , y) dy ≈

2D(xix − ε, iy)

∆x

[(D(xix − ε, iy)

D(xix − ε, iy) + D(xix + ε, iy)− 1

)φ(ix, iy)

+D(xix + ε, iy)

D(xix − ε, iy) + D(xix + ε, iy)· φ(ix + 1, ix)

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

∫ yiy

yiy−1

D(xix−1, y) · ∂φ∂x

(xix−1, y) dy ≈

2D(xix−1 + ε, iy)

∆x

[(1− D(xix−1 + ε, iy)

D(xix−1 − ε, iy) + D(xix−1 + ε, iy)

)φ(ix, iy)

− D(xix−1 − ε, iy)

D(xix−1 − ε, iy) + D(xix−1 + ε, iy)· φ(ix − 1, iy)

]

Page 28: milonga

milonga v0.1

∫ xix

xix−1

D(x, yiy ) · ∂φ∂y

(x, yiy ) dx ≈

2D(ix, yiy − ε)∆y

[(D(ix, yiy − ε)

D(ix, yiy − ε) + D(ix, yiy + ε)− 1

)φ(ix, iy)

+D(ix, yiy + ε)

D(ix, yiy − ε) + D(ix, yiy + ε)· φ(ix, iy + 1)

]

∫ xix

xix−1

D(x, yiy−1) · ∂φ∂y

(x, yiy−1) dx ≈

2D(ix, yiy−1 + ε)

∆y

[(1−

D(ix, yiy−1 + ε)

D(ix, yiy−1 − ε) + D(ix, yiy−1 + ε)

)φ(ix, iy)

−D(ix, yiy−1 − ε)

D(ix, yiy−1 − ε) + D(ix, yiy−1 + ε)· φ(ix, iy − 1)

]

Having derived these expressions, the two-dimensional leakage term in cell ix-iy can be written asa linear combination of the cell fluxes at ix-iy and its four first neighbors

∫Vi

div[D(x, y) · gradφ(x, y)

]d2r =Cix,iy φ(ix, iy) + Cx−ix,iy φ(ix − 1, iy) + Cx+

ix,iyφ(ix + 1, iy)

+ Cy−ix,iy φ(ix, iy − 1) + Cy+ix,iy

φ(ix, iy + 1)

with the coefficients

Cix,iy =− 2

∆x

[D(xix−1 − ε, iy) · D(xix−1 + ε, iy)

D(xix−1 − ε, iy) + D(xix−1 + ε, iy)+

D(xix − ε, iy) · D(xix + ε, iy)

D(xix − ε, iy) + D(xix + ε, iy)

]

− 2

∆y

[D(ix, yiy−1 + ε) · D(ix, yiy−1 + ε)

D(ix, yiy−1 − ε) + D(ix, yiy−1 + ε)+D(ix, yiy − ε) · D(ix, yiy − ε, iy)

D(ix, yiy − ε) + D(ix, yiy + ε)

]

Cx−ix,iy =2

∆x

D(xix−1 − ε, iy) · D(xix−1 + ε, iy)

D(xix−1 − ε, iy) + D(xix−1 + ε, iy)

Cy−ix,iy =2

∆y

D(ix, yiy−1 − ε) · D(ix, yiy−1 + ε)

D(ix, yiy−1 − ε) + D(ix, yiy−1 + ε)

Cx+ix,iy

=2

∆x

D(xix − ε, iy) · D(xix + ε, iy)

D(xix − ε, iy) + D(xix + ε, iy)

Cy+ix,iy

=2

∆y

D(ix, yiy − ε) · D(ix, yiy + ε)

D(ix, yiy − ε) + D(ix, yiy + ε)(2.32)

As in the previous section, D(x, y) may have a discontinuity that does not coincide with a cellborder, so instead of using the line integral along xi − ε to evaluate the net flux through the right,an average value using the surface integral over the right half of the cell can be used. For example,D(xi − ε, iy) may be replaced by

⟨D(xi − ε)

⟩=

∫ xiy

xix−1/2∆x

D(x, iy) dx

12∆x

=

∫ xiy

xix−1/2∆x

∫ yiy

yiy−1

D(x, y) dy dx

12∆x

Page 29: milonga

milonga v0.1

with similar expressions for the rest of the diffusion coefficients in equations (2.32).

If the diffusion coefficient is homogeneous over the whole spatial domain D(x, y) = D, then theleakage term in two dimensions is

∫Vi

div[D(x, y) · gradφ(x, y)

]d2r ≈ D ·

[∆y

(φ(ix − 1, iy)− 2φ(ix, iy) + φ(ix + 1, iy)

∆x

)+∆x

(φ(ix, iy − 1)− 2φ(ix, iy) + φ(ix, iy + 1)

∆y

)]that is the expression of D∇2φ∆x∆y 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 forthree-dimensional problems are presented as a generalization of equations (2.32):

∫Vi

div[D(x, y, z) · gradφ(x, y, z)

]d3r =Cix,iy,iz φ(ix, iy, iz)

+ Cx−ix,iy,iz φ(ix − 1, iy, iz) + Cx+ix,iy,iz

φ(ix + 1, iy, iz)

+ Cy−ix,iy,iz φ(ix, iy − 1, iz) + Cy+ix,iy,iz

φ(ix, iy + 1, iz)

+ Cz−ix,iy,iz φ(ix, iy, iz − 1) + Cz+ix,iy,iz φ(ix, iy, iz + 1)

Cix,iy =− 2

∆x

[D(xix−1 + ε, iy, iz) · D(xix−1 − ε, iy, iz)D(xix−1 − ε, iy, iz) + D(xix−1 + ε, iy, iz)

+D(xix − ε, iy, iz) · D(xix + ε, iy, iz)

D(xix − ε, iy, iz) + D(xix + ε, iy, iz)

]

− 2

∆y

[D(ix, yiy−1 − ε, iz) · D(ix, yiy−1 + ε, iz)

D(ix, yiy−1 − ε, iz) + D(ix, yiy−1 + ε, iz)+

D(ix, yiy − ε, iz) · D(ix, yiy − ε, iz)D(ix, yiy − ε, iz) + D(ix, yiy + ε, iz)

]

− 2

∆z

[D(ix, iy, ziz−1 − ε) · D(ix, iy, ziz−1 + ε)

D(ix, iy, ziz−1 − ε) + D(ix, iy, ziz−1 + ε)+

D(ix, iy, ziz − ε) · D(ix, iy, ziz + ε)

D(ix, iy, ziz − ε) + D(ix, iy, ziz + ε)

]

Cx−ix,iy,iz =2

∆x

D(xix−1 − ε, iy, iz) · D(xix−1 + ε, iy, iz)

D(xix−1 − ε, iy, iz) + D(xix−1 + ε, iy, iz)

Cy−ix,iy,iz =2

∆y

D(ix, yiy−1 − ε, iz) · D(ix, yiy−1 + ε, iz)

D(ix, yiy−1 − ε, iz) + D(ix, yiy−1 + ε, iz)

Cz−ix,iy,iz =2

∆y

D(ix, iy, ziz−1 − ε) · D(ix, iy, ziz−1 + ε)

D(ix, iy, ziz−1 − ε) + D(ix, iy, ziz−1 + ε)

Cx+ix,iy,iz

=2

∆x

D(xix − ε, iy, iz) · D(xix + ε, iy, iz)

D(xix − ε, iy, iz) + D(xix + ε, iy, iz)

Cy+ix,iy,iz

=2

∆y

D(ix, yiy − ε, iz) · D(ix, yiy + ε, iz)

D(ix, yiy − ε, iz) + D(ix, yiy + ε, iz)

Cz+ix,iy,iz =2

∆y

D(ix, iy, ziz − ε) · D(ix, iy, ziz + ε)

D(ix, iy, ziz − ε) + D(ix, iy, ziz + ε)(2.33)

2.1.3 Finite differences scheme

Instead of a finite volumes scheme, an approach based on the finite differences method can be usedto discretize the neutron diffusion equation. In this case, the spatial domain is also divided in a finite

Page 30: milonga

milonga v0.1

number N of cells, but instead of working with cell-averaged values, the flux is computed at the cellcenters that are taken as the problem nodes as depicted in figure 2.11.

Figure 2.11: Finite-differences approach to the discretization of the spatial domain introduced in figure 2.5.The properties and the flux are evaluated at nodes (filled circles) instead of representing cell (squares) meanvalues. For convenience, the nodes are taken as the finite-volumes cells centers.

The finite differences scheme consists in replacing the G continuous multigroup diffusion equa-tions (2.14)

0 = div[D(r, g) · grad

[φ(r, g)

] ]− Σt(r, g) · φ(r, g)

+

G∑g′=1

Σs(r, g′ → g) · φ(r, g′) + χ(g)

G∑g′=1

νΣf (r, g′)

keff· φ(r, g′)

by NG equations with the cross sections evaluated in each cell and the divergence term replaced bya differences approximation. Denote by the integer argument i the properties evaluated at the centerof the i-th cell in an m-dimensional spatial domain. As equation (2.14) holds for every point in thespatial domain, then in particular it must hold for the N cell centers ri

0 = div[D(i, g) · grad

[φ(i, g)

] ]− Σt(i, g) · φ(i, g)

+

G∑g′=1

Σs(i, g′ → g) · φ(i, g′) + χ(g)

G∑g′=1

νΣf (i, g′)

keff· φ(i, g′)

The first term can be expanded as

div[D(i, g) · grad

[φ(i, g)

] ]= D(i, g) · ∇2φ(i, g) + grad

[D(i, g)

]· grad

[φ(i, g)

](2.34)

The finite differences scheme proposed consists of approximating both the flux Laplacian andgradient by first-neighbors differences expressions. In one dimension, it is

Page 31: milonga

milonga v0.1

div[D(i, g) grad

[φ(i, g)

] ]≈ D(i, g) · φ(i+ 1, g)− 2φ(i, g) + φ(i− 1, g)

∆x2

+∂D(i, g)

∂x· φ(i+ 1, g)− φ(i− 1, g)

2∆x

In two dimensions, using the ix-iy nomenclature introduced in section 2.1.2, the scheme is

div[D(ix, iy, g) · grad

[φ(ix, iy, g)

] ]≈ D(ix, iy, g)

φ(ix + 1, iy, g)− 2φ(ix, iy, g) + φ(ix − 1, iy, g)

∆x2

+D(ix, iy, g)φ(ix, iy + 1, g)− 2φ(ix, iy, g) + φ(ix, iy − 1, g)

∆y2

+∂D(ix, iy, g)

∂x· φ(ix + 1, iy, g)− φ(ix − 1, iy, g)

2∆x

+∂D(ix, iy, g)

∂y· φ(ix, iy + 1, g)− φ(ix, iy − 1, g)

2∆y

and for three dimensions

div[D(ix, iy, iz, g) · grad

[φ(ix, iy, iz, g)

] ]≈

D(ix, iy, iz, g)φ(ix + 1, iy, iz, g)− 2φ(ix, iy, iz, g) + φ(ix − 1, iy, iz, g)

∆x2

+D(ix, iy, iz, g)φ(ix, iy + 1, iz, g)− 2φ(ix, iy, iz, g) + φ(ix, iy − 1, iz, g)

∆y2

+D(ix, iy, iz, g)φ(ix, iy, iz + 1, g)− 2φ(ix, iy, iz, g) + φ(ix, iy, iz − 1, g)

∆z2

+∂D(ix, iy, iz, g)

∂x· φ(ix + 1, iy, iz, g)− φ(ix − 1, iy, iz, g)

2∆x

+∂D(ix, iy, iz, g)

∂y· φ(ix, iy + 1, iz, g)− φ(ix, iy − 1, iz, g)

2∆y

+∂D(ix, iy, iz, g)

∂y· φ(ix, iy, iz + 1, g)− φ(ix, iy, iz − 1, g)

2∆z

Because of the differential nature of the method, only local effects are retained in this formulationand variations of parameters within cells are usually damped an even neglected. To somehow takeinto account these effects, two things can be done. The first one is to use cell-averaged propertiesinstead of the values evaluated at the centers (see section 2.2), and the second one is to compute thegradient of the diffusion coefficient also as a finite-difference approximation instead of using the actualderivative 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 diffusion coefficient D(r) is notdifferentiable at some point rd, then equation (2.14) does not hold at rd. If this point happens tocoincide with a cell center ri, the numerical method is not consistent. Moreover, even if rd does notcoincide with a cell center, the fluxes in the neighboring cells will have unphysical results because theoriginal equation (2.14) is not valid. If one wants to find the solution to the differential equation all inall, current continuity conditions have to be solved at rd instead of the diffusion equation. The finitevolumes scheme proposed in section 2.1.2 includes both the diffusion equation and current continuityin its formulation, so it is expected to give better results than the finite differences approximation—atleast without using ad-hoc correction factors. For example, if there is a discontinuity in the distributionof the diffusion coefficient then the evaluation of gradφ may depend on the size of the cells.Also notethat while the finite differences scheme solves the differential diffusion equation, the finite volumesscheme solves the diffusion equation integrated over the cell volume.

Page 32: milonga

milonga v0.1

2.2 Cell cross-section computation

The discretized multigroup equations give a relationship between the expected neutron flux in eachcell for each energy group (the φ’s) and some parameters that depend on the nuclear properties of thematerials present in the diffusive media (the Σ’s). Strictly speaking, these macroscopic cross sectionsdepend on the local flux distribution as shown by the exact equation (2.17) derived for the totalmacroscopic cross section:

Σt(i, g) =

∫Vi

Σt(r, g) · φ(r, g) dmr∫Vi

φ(r, g) dmr

(2.17)

However, it is clear that for the formulation to be useful, the coefficients ought not to depend onthe flux itself.

Up to a first order approximation, two approaches can be taken to take out the fluxes of thecross-section expression. The first is to assume a flat profile inside each cell. Call it φ(r, g) = ϕ forr ∈ cell i. Then

Σt(i, g) =

∫Vi

Σt(r, g) · ϕdmr∫Vi

ϕdmr

=

∫Vi

Σt(r, g) dmr∫Vi

dmr

(2.35)

and the cell total macroscopic cross section is the mean value of the continuous macroscopic crosssection distribution inside the cell.

The second—and rather extreme–approach is to assume that somehow the flux is concentrated inthe center of the cell φ(r, g) = ϕ · δ(ri) where ri is the location of the i-th cell center. Thus

Σt(i, g) =

∫Vi

Σt(r, g) · ϕ δ(ri) dmr∫Vi

ϕ δ(ri) dmr

= Σt(ri, g) (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 lesscomputational effort. However, for discontinuous properties—especially if they do not coincide withcell borders—equation (2.35) should be used. If the cross section distribution is homogeneous insidethe cell, both formulations coincide.

2.3 Boundary conditions

To fully define the diffusion problem, boundary conditions on the spatial domain must be given. Thesecan be Dirichlet, Neumann or mixed, i.e. specify the flux, the derivative in the normal direction or alinear combination of them at the domain boundary. In the discretized diffusion problem, as illustratedfor a two-dimensional case in figure 2.12, in those cells that are completely contained in the domainthe diffusion equation is solved. In those that are completely outside the domain, the flux is forced tobe null. And in those that contain the external boundary of the geometry that defines the neutronicproblem, the boundary conditions equations are imposed.

In nuclear reactor diffusion theory [5], it is usual to make the flux vanish at a certain distance fromthe external surfaces called extrapolation length. However, for common reactor sizes, this length isnegligible enough to assume it is zero. Thus, flux equal to zero at the external surfaces is the commonboundary condition. For symmetric problems, it is also customary to solve only a part of the problemand impose mirror boundary conditions on the flux. The boundary conditions supported by milonga

Page 33: milonga

milonga v0.1

Figure 2.12: For the spatial domain of figure 2.5, cells that are completely inside the domain (green) solve thediffusion problem. Cells that contain the border (orange) impose the problem boundary conditions. The restof the cells (black) are forced to have a null flux.

are introduced in the following subsections, stating the actual discrete equations that implement themnumerically.

2.3.1 External planar surfaces

External planar surfaces include one-dimensional slab boundaries, two-dimensional straight lines andthree-dimensional planar surfaces where the flux is ought to be equal to zero. In each case, there is awell-defined outward direction. Without loss of generality, assume it is the negative x direction, as ifa null boundary condition is applied at x = 0 in a one-dimensional slab.

Let i0 be the index of the cell that should impose the boundary condition equation. In general,the external boundary will be at an algebraic distance δx (i.e. δx > 0 if the surface is at the rightand conversely) from the cell center xi0 . The condition φ(xi0 + δx) = 0 is implemented by requiringthat a linear interpolation (or extrapolation for δx < 0) of the cell fluxes at i0 and its first neighborin the inward direction vanishes at x = xi0 + δx (figure 2.13).

Making use of approximation (2.16), further assume that inside cell i0 the flux can be written as

φ(xi0 + δx) = φ(xi0) +∂φ

∂x

∣∣∣∣xi0

· δx

φ(xi0 + δx) = φ(i0) +φ(i0 + 1)− φ(i0)

∆x· δx

The condition φ(xi0 + δx) = 0 is attained if

φ(i0) +

δx

∆x

1− δx

∆x

· φ(i0 + 1) = 0

In particular, if the boundary condition has to be applied at x = 0, then δx = −1/2∆x and theboundary condition yields

Page 34: milonga

milonga v0.1

Figure 2.13: Planar boundary conditions in the first cell of the x direction. Note that in this case, theexternal surface is located between the bare external surface and the first cell center, so δx < 0. In the caseshown, i0 = 1

φ(1) =1

3φ(2)

meaning that the flux at the first cell has to be one-third of the flux in the first neighbor in order forthe linear extrapolation to vanish at the boundary of the cell (try to make a mental picture and seethe similar triangles with ratio three to one).

It is important to note that if the boundary lies to the right of the cell center (δx > 0), then theflux φ(i0) has to be negative to make the linear interpolation between φ(i0) and φ(i0 +1) pass throughzero as shown in figure 2.14. If this fact is understood as a mathematical artifact to handle discreteboundary conditions and the results are properly interpreted, the cell flux can be left negative ascomputed. However, fission power is usually computed from the neutron fluxes and negative powerscannot be allowed based on physical grounds. Milonga can be told to force negative fluxes to zero sono artificial power sinks appear, at the expense of slightly changing the form of the neutron flux nearthe borders.

Had the outward direction been the positive x direction, then the equation to impose the boundarycondition would have been

φ(i0)−

δx

∆x

1 +δx

∆x

· φ(i0 − 1) = 0

with δx > 0 still meaning that the external surface is located to the right of cell i0, 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 flux. Assume that thecylinder axis is parallel to the z axis, then

φ(x, y) = 0

for (x, y) in the external boundary.The discrete boundary condition requires a linear expansion of the flux to be equal to zero at the

point in the circumference that lies in the circle radius that passes through the cell center. Let (x0, y0)

Page 35: milonga

milonga v0.1

Figure 2.14: If the external surface is located between two adjacent nodes, to make the linear interpolation ofthe flux pass through zero at the external surface, one of the fluxes has to be negative. This is a mathematicalartifact to handle discrete boundary conditions, and should be understood as such.

be the coordinates of the center of the cell (i0, j0) through which the circumference with center (xc, yc)and radius R passes by (figure 2.15). The point (x?, y?) at which the expansion has to vanish is

Figure 2.15: Discrete boundary condition in a cylindrical external surface

x? = xc ±R cos θ

y? = yc ±R sin θ

with the sign chosen according to the quadrant (x0, y0) is with respect to (xc, yc) and

θ = arctan

(|y0 − yc||x0 − yc|

)The linear expansion is a first-order Taylor series around the cell center

φ(x, y) ≈ φ(x0, y0) +∂φ

∂x

∣∣∣∣x0,y0

· (x− x0) +∂φ

∂y

∣∣∣∣x0,y0

· (y − y0)

Page 36: milonga

milonga v0.1

The partial derivatives are approximated as

∂φ

∂x

∣∣∣∣x0,y0

≈ φ(i0 ± 1, j0)∓ φ(i0, j0)

∆x

∂φ

∂y

∣∣∣∣x0,y0

≈ φ(i0, j0 ± 1)∓ φ(i0, j0)

∆y

where again the signs are selected according to the quadrant with respect to the circle center the point(x0, y0) is. To fix ideas, assume it is in the first quadrant. Then, the discrete boundary condition is

0 =

[1 +

xc − x0 +R cos θ

∆x+yc − y0 +R sin θ

∆y

]· φ(i0, j0)

− xc − x0 +R cos θ

∆x· φ(i0 − 1, j0)− yc − y0 +R sin θ

∆y· φ(i0, j0 − 1)

with similar equations for the other three quadrants.

Note that depending on the relative location of the cell center (x0, y0) and the point (x?, y?), theboundary equation may require the flux φ(i0, j0) to be negative as with the planar surfaces discussedabove. Again, this is a mathematical artifact that hast to be taken into account in the nodalizationof 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 thenormal direction. Independently from the actual location of the surface with respect to the cells i0and i0 ± 1, this condition reads

φ(i0)− φ(i0 + 1) = 0

orφ(i0)− φ(i0 − 1) = 0

according to the outward direction of the surface with the mirror condition.

2.3.5 Sharp edges

In milonga’s context, a sharp edge means a geometric object that belongs to the external boundary ofthe spatial domain that has at least two degrees of dimension less than the domain. For example, inthree dimensions corner points and external surfaces edges are considered sharp (figure 2.16a). In twodimensions, the vertex of the intersection of two planar external surfaces are sharp edges (figure 2.16b).In one dimension there are no sharp edges.

When a cell contains a sharp edge, instead of solving the diffusion equation a boundary conditionequation is applied to it. As there is no definite outward direction, the condition in milonga is thatthe flux at the cell should be equal to the average flux of its non-vacuum neighbors. This choice ofboundary condition works well both with null and mirror conditions for the planar surfaces.

Page 37: milonga

milonga v0.1

(a) In three dimensions,sharp edges include cornerand surfaces intersections

(b) In two dimensions, sharpedges are corners.

Figure 2.16: Boundary conditions at sharp edges. Cells that contain a sharp edge have boundary conditionsequations.

2.4 The eigenvalue problem

As assumed throughout this chapter, in the absence of fixed independent sources—i.e. not associatedto fission—the steady-state multigroup neutron diffusion equation can be written as a generalizedeigenvalue problem. In effect, the G differential equations (2.14) have the same dependency on themultiplicative factor keff, and can be casted in matrix form as

R? ·ϕ =1

keffF ? ·ϕ (2.37)

where R? and F ? are square matrices of size G×G that contain differential operators and functionsof the spatial coordinate r ∈ Rm, and ϕ is the vector of size G

ϕ =

φ(r, 1)φ(r, 2)

...φ(r, G)

The star notation means that these matrices represent the differential formulation, while we leave

the non-star notation for the spatial-discretized problem that is milonga’s main subject. Matrices R?

and F ? are named after removal and fission, respectively. The left member of equation (2.37) givesthe net rate of disappearance of neutrons, while the right member gives the rate of neutron birthsby fission. By using the mathematical artifact of dividing this rate by the effective multiplicationfactor, an artificial critical reactor is obtained, with the eigenvector representing the artificial fluxdistribution. Equation (2.37) can be written as a standard eigenvalue problem as

R?−1F ? ·ϕ = keff ·ϕ (2.38)

It is possible to show that R−1 exists for any physically real set of cross sections [4], so theeigenvalue problem is well-defined. Now, in general there are G pairs of eigenvalues and eigenvectorsthat satisfy the eigenvalue problem. Even though most of them may be negative, complex or giverise to negative fluxes, 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 differ insign from each other

Page 38: milonga

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 one—now having

R · φ =1

keffF · φ (2.39)

where the size of the problem is N ·G, and the elements of the eigenvector are φ(i, g):

φ =

φ(1, 1)φ(1, 2)

...φ(1, G)φ(2, 1)

...φ(2, G)φ(3, 1)

...φ(N,G)

Matrices R and F are square NG×NG matrices. Their elements are real numbers, namely all the

coefficients that multiply each of the fluxes φ(i, g) that were derived in sections (2.1.2) and (2.1.3). If acoefficient is not divided by keff, it is incorporated into R and into F otherwise. The row correspondsto the index of the cell and group of the discretized equation it appears in, and the column correspondsto the index of the cell and group of the flux that it is multiplying to.

In the discretized problem (2.39), in addition to some approximation of the G eigenvalue andeigenvector pairs present in the continuous problem (2.37), there appear N · (G− 1) new eigenvalues.Nonetheless, the three mathematical properties stated above also hold for equation (2.39).

The direct storage of a matrix of size NG×NG for values of N of interest in nuclear reactor analysisis intractable with computational resources available nowadays1. Luckily, matrices R and F aresparse—while R? and B? in general are not—as both the discretized multigruoup diffusion equationsand the boundary conditions depend only on first neighbors in space and on the fluxes of the otherenergy groups in the spatial cell evaluated. However, if the generalized eigenvalue problem (2.39) isto be written as a standard eigenvalue problem either as

F−1R · φ =1

keff· φ

or as

R−1F · φ = keff · φ

in addition to the problem of finding inverse matrices—that, by the way, may not exists as is theusual case for F−1—there appears at least one big dense matrix that cannot be efficiently handled.Therefore, to solve the neutron steady-state diffusion equation, methods for solving a generalizedeigenvalue problem in the form of equation (2.39) ought to be used.

Milonga uses the PETSc2 [11, 12] library to build and handle φ, R and F , and the SLEPc [13, 14]library to solve the generalized eigenvalue problem given by equation (2.39) to obtain keff and theassociated critical reactor flux distribution. SLEPc solves either the standard or the generalizedeigenvalue problem maintaining the sparsity of the formulation using a variety of efficient iterativemethods, from which milonga’s user can choose. In particular, given

Ax = λBx (2.40)

1For the record, this sentence was first written in 2011.2Although 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.

Page 39: milonga

milonga v0.1

SLEPc tries to find combinations (λ,x) that make the equation hold. Moreover, it can be told to findonly a few large or small eigenvalues, or to search for solutions located only in a certain region of thecomplex plane. As in the diffusion 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 diffusion equation, thisfeature is particularly convenient.

On the one hand, depending on the kind of physical problem being solved, some solution methodsare more suitable than others. On the other hand, some methods work better—and may even notwork at all—when one of R or F takes place of the matrix A in SLEPc’s equation (2.40). Thus,essentially two versions of the generalized problem can be used, either

F · φ = keffR · φ (2.41)

or

R · φ =1

keffF · φ (2.42)

In the first case, λ = 1/keff and the eigenvalue sought for is the smaller in magnitude, and con-versely. Equation (2.41) as the “direct keff formulation” and equation (2.42) is referred to as the“inverse keff formulation”. The user can request to solve the problem using either one, depending onthe 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 sufficiently 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 numberof 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 solvethe eigenvalue problem (2.42) (or (2.41)). In addition, there exist an error related to the discretizationboth in space and energy of the diffusion equation 2.5, that in turn has uncertainties in the macroscopiccross-sections. Moreover, the diffusion equation is an approximation that holds only up to a certaindegree only in special cases of nuclear reactor geometries and material compositions. Keep in mindfigure 2.1 with this respect.

SLEPc considers that the eigenvalue problem is solved whenever a certain residual is less than somesmall positive value. There are three possible criteria, namely absolute residual, relative residual withrespect to the eigenvalue and relative residual with respect to the matrix norms. As the selectionof this tolerance is of vital importance for the performance of the numerical solution of the diffusionproblem, a trade-off 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 defined as

r = A · x− λ B · x

where λ and x represent the computed eigenpair. For Hermitian problems—which is not the casefor R and F—it is possible to prove, as stated in [15], that∣∣∣λ− λ∣∣∣ ≤ ‖r‖2

This is not the case in general problems, so there is no simple relationship between the residualnorm and the actual error committed by the numerical method. Nevertheless, ‖r‖2 stills should givea measure of the distance between the real eigenvalue λ and the approximate solution λ.

As ‖r‖ depends on the size of the problem, in general a finer discretization will lead to moreiterations for the eigenvalue problem. To avoid this escalation, milonga uses as a measure of theconvergence the residual norm with respect to the matrices norm, namely

Page 40: milonga

milonga v0.1

‖rrel‖ =‖r‖2

‖A‖2 + |λ|‖B‖2(2.43)

so convergence is considered as achieved whenever ‖rrel‖ is less than a certain tolerance. The defaulttolerance value used by milonga is the default used by SLEPc that is 10−7. The impact of this figureon the overall behavior with respect of accuracy and running time of milonga when solving a particularproblem 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 diffusion problem (2.5) is homogeneous,and so is the associated discretized eigenvalue problem (2.39). Therefore the solution is defined up toa multiplicative constant. That is, if φ1 is a solution, then φ2 = αφ1 is also a solution. To be ableto compare solutions obtained by different methods, a normalization procedure is desired. Milongacomputes the solution φ of the eigenvalue problem (2.39) such that the mean value is equal to oneunit of flux, i.e. ∫

V

∫ ∞0

φ(r, E) dE dmr∫V

dmr

= 1

Using equations (2.6) and (2.15), this condition can be written as

∫V

G∑g=1

φ(r, g) dmr∫V

dmr

= 1

G∑g=1

∫V

φ(r, g) dmr∫V

dmr

= 1

G∑g=1

N∑i=1

φ(i, g)

∫Vi

dmr∫V

dmr

= 1

that for uniformly distributed cells, reduces to

G∑g=1

N∑i=1

φ(i, g) = 1

In real reactors, feedback effects—such as temperature or xenon—render the problem nonlinearand the solution cannot be modulated at will, but the flux distribution is unique. To be able to copewith these effects, a desired power level has to be given in order to normalize the flux distribution tothe correct value. If the power setpoint is P ?, for a three-dimensional reactor, this condition reads∫

V

∫ ∞0

EΣf (r, E) · φ(r, E) dE d3r = P ?

where EΣf is the product of energy released in one single fission times the macroscopic fission crosssection. Note that if the desired power level P ? refers to the prompt fission power, then EΣf has

Page 41: milonga

milonga v0.1

to include the prompt energy only, while if P ? is the total power—fission plus delayed—then all thecontributions to the fission energy by the fission product decay chain should be taken into account.Otherwise, a correction factor to take into account delayed power has to be incorporated either in P ?

or in EΣf .

Three-dimensional reactors occupy a finite volume in space, and thus P ? is the reactor power,either total or fission according to the definition of EΣf . But one and two-dimensional reactors areessentially infinite, and thus the dissipated power is also infinite. For one dimension, P ? is the powerdensity per unit area perpendicular to the x axis, and for two dimensions it is the power density perunit length perpendicular to the x-y plane. Note that EΣf · φ has units of energy · length−3. Unitsconsistency is expected.

When a power setpoint is defined, the flux is normalized such that

∫V

∫ ∞0

EΣf (r, E) · φ(r, E) dE d3r = P ?∫V

G∑g=1

EΣf (r, g) · φ(r, g) d3r = P ?

G∑g=1

N∑i=1

∫Vi

EΣf (r, g) · φ(r, g) d3r = P ?

G∑g=1

N∑i=1

EΣf (i, g) · φ(i, g)

∫Vi

d3r = P ?

where equation (2.15) was used, and the multigroup property EΣf was defined—as with Σt in equa-tion (2.7)—as

EΣf (r, g) =

∫ Eg−1

Eg

EΣf (r, E) · φ(r, E) dE∫ Eg−1

Eg

φ(r, E) dE

and then associated to a particular cell EΣf (i, g) 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 finite differences, φ(i, g)is not the mean value of the flux in a cell but the value of the flux at the cell center. Therefore, inthis case the replacement of the integral by the sum is exact up to order ∆x2—i.e. as accurate as anintegration by the trapezoids method—given by the the approximation (2.16).

2.5 Xenon poisoning

Depending on the flux level distribution, fission power reactors get poisoned by the appearance offission products. Of all the possible isotopes, the mos important from the neutronic point of viewis 135Xe, and it is usually the only one taken into account in core calculations. Milonga is capableof handling the effects of xenon in the power distribution, using the models and equations discussedbelow.

The mechanisms of appearance and removal of the isotope 135Xe are illustrated in figure 2.17. Onthe one hand, it can appear as a direct fission product with a yield γXe—the mean number of nuclidesof this isotope that appear promptly after a single fission—or as a daughter of 135I, that decays intoxenon with a time constant λI. In turn, 135I appears as a daughter of 135Te that is a fission product.However, as the beta decay of tellurium is so fast with respect to the decay of iodine, 135I is considered

Page 42: milonga

milonga v0.1

to appear as a prompt fission product. On the other hand, 135Xe disappears because of beta decayinto caesium and because of neutron absorption, transforming into 136Xe at a rate that depends onthe local flux.

fission

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 ·

∫ ∞0

Σf (r, E, t) · φ(r, E, t) dE − λI · I(r, t) (2.44)

and the 135Xe is given by

∂Xe(r, t)

∂t= γXe ·

∫ ∞0

Σf (r, E, t) · φ(r, E, t) dE + λI · I(r, t)

− λXe ·Xe(r, t)−∫ ∞

0

ΣaXe(r, E, t) · φ(r, E, t) dE (2.45)

The total fissions can be computed from the group fluxes as∫ ∞0

Σf (r, E, t) · φ(r, E, t) dE =1

ν

G∑g=1

νΣf (r, g, t) · φ(r, g, t)

where a mean number of neutrons emitted per fission was used in order to avoid introducing a newnuclear parameter Σf .

The macroscopic cross section of xenon can be separated into

ΣaXe(r, E, t) = σaXe(E) ·Xe(r, t)

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

∫ ∞0

ΣaXe(r, E, t) · φ(r, E, t) dE =

∫ ∞0

σaXe(E) ·Xe(r, t) · (r, E, t) · φ(r, E, t) dE

= Xe(r, t) ·G∑i=1

σaXe(g) · φ(r, g, t)

The fixed point of equations (2.44) and (2.45) gives the steady state xenon concentration Xe?(r),that in terms of the multigroup fluxes is

Page 43: milonga

milonga v0.1

Xe?(r) =

(γI + γXe

)· 1

ν

G∑g=1

νΣf (r, g) · φ(r, g)

λXe +

G∑g=1

σaXe(g) · φ(r, g)

In particular, at the i-th cell center the steady-state xenon concentration is

Xe?(i) =

(γI + γXe

)· 1

ν

G∑g=1

νΣf (i, g) · φ(i, g)

λXe +

G∑g=1

σaXe(g) · φ(i, g)

(2.46)

This concentration distribution usually modifies the macroscopic cross sections that appear as co-efficients in the diffusion equation (2.1), rendering the problem non-linear. Thus, a iterative procedureis needed to solve for the actual flux distribution taking into account the effects of xenon poisoning, asdiscussed in page 9. Note that the xenon concentration depends on the absolute value of the neutronflux, thus a power setpoint is needed in order to correctly normalize the solution of the eigenvalueproblem to dimensional quantities, as explained in section 2.4.2. Concentrations have units of inversecubed length, decay constants inverse time and microscopic cross sections inverse squared length.Yields and the mean number of neutrons emitted by a single fission 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 430–542. 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: TheArt of Scientific 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, chapterFinite 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 usersmanual. 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. Efficient 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 Scientific Computing, pages 163–202.Birkhauser Press, 1997.

Page 44: milonga

milonga v0.1

[13] Vicente Hernandez, Jose E. Roman, and Vicente Vidal. SLEPc: A scalable and flexible toolkit forthe solution of eigenvalue problems. ACM Transactions on Mathematical Software, 31(3):351–362,September 2005.

[14] V. Hernandez, J. E. Roman, and V. Vidal. SLEPc: Scalable Library for Eigenvalue ProblemComputations. Lecture Notes in Computer Science, 2565:377–391, 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.

Page 45: milonga

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 equationsthat somehow represent a nuclear reactor. And according to milonga’s design basis, chances are thatthis nuclear reactor exists nowhere but in your mind. If after reading this chapter you still cannot askmilonga to help you with your fancy state-of-the-art reactor design, please do one of the following twothings: contact the author to comply about the lack of the features you feel you are needing, or—evenbetter—hack into the source code and add the feature by yourself. And of course, distribute themodified code under the terms of the GNU Public License or—even better—share your modificationswith the author to have them appended into the official milonga distribution.

Although milonga has a lot of options that can be tweaked, it comes with a great deal of defaultvalues that should satisfy most needs. That is why input files can be either very small or arbitrarylarge. For instance, the following input is the very smallest one that gets the program to perform auseful calculation:

PROBLEM DIMENSIONS 1 GROUPS 1x b a r e l e n g t h = 100x c e l l s = 100ZONE f u e l MATERIAL f u e lMATERIAL f u e l D 1 1 SigmaA 1 1e−2 nuSigmaF 1 1 .2 e−2

The rest of this chapter is devoted to explaining how to build your own input files to, hopefully,solve the problem you have at hand.

3.1 Input files

Being built on top of wasora’s framework, milonga provides all the basic functionality in wasora plusspecific options and settings for milonga. A detailed description of the keywords associated to thecommon framework can be found in wasora’s documentation. Nevertheless, a quick explanation ofthe basic wasora’s features is given here for completeness.

Milonga’s normal behavior is to read one or more input files defining the problem, solve it andthen output the requested results—if any—in different possible ways. The input files are plain textfiles containing keywords, parameters and or numerical data. There should be one main input filethan can optionally include further input files.

There are primary and secondary keywords. Primary keywords should appear as the first token ina line. Secondary keywords are usually optional and should appear in the same line after a primary

Page 46: milonga

milonga v0.1

keyword. One primary keyword may be followed by zero or more secondary keywords. The order ofthe secondary keywords does not matter, while the order in which the primary keywords appear inthe input file may or may not matter. Keywords are case insensitive, but for clarity they are writtenin uppercase throughout this document, except for the secondary keywords of MATERIAL that definethe nuclear properties.

Both primary and secondary keywords may take zero or more parameters. Each parameter shouldbe a single token delimited by spaces or tabs. If spaces are needed as a part of the parameter, itshould be enclosed in double quotes.

Blank lines and characters appearing after a hash ’#’ symbol are treated as separators or commentsand are ignored. For readability reasons, if a definition is too long to fit neatly in a single line, it canbe enclosed in braces ’{’ and ’}’ spanning different file lines. From milonga’s point of view, whateverappears 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 example o f the genera l syntax expec ted in input f i l e sPRIMARY_KEYWORD KEYWORD1 argument1 KEYWORD2 ”one s i n g l e argument”

# the above l i n e cou ld a l s o be wr i t t en asPRIMARY_KEYWORD {

KEYWORD1 argument1 # with comments between l i n e sKEYWORD2 ”one s i n g l e argument”

}

There are keywords that are common to all the packages belonging to the wasora suite—i.e. thecommon framework—and keywords that are specific to milonga. Special stress is given to specifickeywords, although as some reference to common keywords is done, a basic explanation about theframework’s features is also provided.

Some information is given to milonga by giving arguments to keywords, and others by definingspecial variables to take certain values. This is the case for information about the problem that mayeither be given from external sources or needed after the computation is given. For example, thenumber of energy groups is a rather fixed parameter and is entered as a keyword argument, while thenumber of spacial cells in a certain direction is given as a variable because this value may be part ofa parametric study and/or needed to be used as an output or to request the flux distribution at thecomputed points to avoid interpolation.

In any case, most of the parameters are entered by using algebraic expressions accepted by thewasora framework. These expressions are a combination of numeric constants, variables, functionsand operators. A complete description can be found in wasora’s documentation, but valid expressionsare fairly intuitive:

x b a r e l e n g t h = 100x c e l l s = round(random(1 , 100) )p i = 4 ∗ atan (1 )buck l ing = ( p i / x b a r e l e n g t h ) ˆ2

PRINT TEXT ” buck l ing = ” buck l ingPRINT TEXT ” de l t a x = ” x b a r e l e n g 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 todefine the problem, as explained below. The bare length is fixed to one hundred, but the number ofcells is a random integer number between one and one hundred. Then, the number π is computedby using the arc-tangent of one, and finally the geometric buckling is calculated. As an exampleof information given as keywords arguments, consider the last two lines. Keyword PRINT acceptsexpressions as arguments. The first instruction has a single variable as the argument to be printed,but the second one has a quotient.

Page 47: milonga

milonga v0.1

Note that the expressions that appear after the equal sign ’=’ in assignments can have blanks andspaces as desired, as long as the whole expression fits in a single line (or is enclosed in brackets). Whenappearing as keyword arguments, there should be no intermediate blanks and the whole expressionshould be a single token. If not, the expression should be enclosed in double quotes.

In any location of an input file, another input file can be included with the keyword

INCLUDE f i l e

where file is either a relative or absolute path. The effect is as if the included file was pasted rightin the place where the keyword was inserted in the original input file. Nested inclusions, i.e. INCLUDEkeywords in included files, 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 inparenthesis ’(’ 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 inferredby the context.

As with the example about variables and keyword arguments above, the rest of this chapter containspartial examples of the usage of the feature being discussed. However, they are just illustrative andby no means provide real or ready-to-use inputs. Chapter 4 contains several stand-alone examplesof input files that span a lot of different kinds of problems and conditions. They are arranged inincreasing order of complexity, and the inputs shown should be fairly intuitive and self explanatory. Ifthere is a doubt about the usage of a certain feature, these complete examples should give the correctanswer about how to use the code.

3.2 Problem definition

The first definition that ought to be provided to milonga is the number of spatial dimensions and thenumber of energy groups. This information is given by the primary keyword PROBLEM, that takes thesecondary keywords DIMENSIONS and GROUPS. Each one takes one integer argument, thus definingthe dimension of the problem phase space

PROBLEM DIMENSIONS m GROUPS g

This information is mandatory and should appear before any other of milonga’s specific keywords.For example, to define a two-dimensional problem with three energy groups:

PROBLEM DIMENSIONS 2 GROUPS 3

To define the geometry, you start with an m-dimensional bare prism and then you define one ormore material zones inside it. This prism is characterized by m lengths, called the bare lengths. Theselengths are entered as three variables, one for each direction:

x b a r e l e n g t hy b a r e l e n g t hz b a r e l e n g t h

For two-dimensional problems, z bare length is ignored and does not need to be entered. Thesame applies for y bare length in one-dimensional problems. The units of these variables are to bedecided by the user. However, it is important to note that the entered values ought to have the sameunits, consistent with the cross sections entered in the material definition (section 3.5). That is, if themacroscopic cross sections are in cm−1, then the bare lengths should be in cm. For non-dimensionalproblems, the consistency between the nondimensionalization of the lengths and the cross sections isup to the user.

Page 48: milonga

milonga v0.1

To define a three-dimensional bare prism from which to start defining the reactor geometry witha size of 100×100×100 of a certain units consistent with the cross sections, say centimeters, enter

x b a r e l e n g t h = 100y ba r e l e n g t h = 100z b a r e l e n g t h = 100

The expressions can be any valid mathematical expression. For example, in a two-dimensionalproblem, to make sure the bare prism is a always a square, write

x b a r e l e n g t h = ay ba r e l e n g t h = x b a r e l e n g t h

The last thing that milonga should know about the problem is the spatial nodalization. Thisversion only supports uniformly distributed cells, so the number of cells in each direction has to begiven. To do so, use the following variables:

x c e l l sy c e l l sz c e l l s

These variables should be non-dimensional integers. If any of these values is non-integral, it willbe rounded to the nearest integer. A valid construction is

x c e l l s = 100y c e l l s = 50z c e l l s = 40

Again, any expression can be used, so the actual nodalization can be entered as a cell lengthinstead of cell numbers as:

d e l t a x = 1d e l t a y = 2d e l t a z = 2 .5x c e l l s = x b a r e l e n g t h / d e l t a xy c e l l s = x b a r e l e n g t h / d e l t a yz c e l l s = y ba r e l e n g t h / d e l t a z

This information should be entered before the definition of the material zones, that is explainedin section 3.3.

Milonga assumes that there is a single fissionable isotope or, equivalently, that all the availableisotopes have the same fission spectrum. The default fission spectrum is thermal, i.e., all the neutronsare born in the last energy group. If this behavior is to be changed, the elements of the vector

ch i

have to be entered, according to equation (2.10). Elements of a vector in wasora are accessed byappending an underscore ’ ’ plus the element number, starting in one. Thus, in a three group problem,the default fission spectrum is taken as if the user had entered

ch i 1 = 0ch i 2 = 0ch i 3 = 1

It is the user’s responsibility to ensure that the sum of the components of vector χ to sum up toone, as required by the normalization condition given in equation (2.12).

Page 49: milonga

milonga v0.1

3.3 Zones

The actual reactor geometry is defined by entering one or more material zones. This is accomplishedby using the ZONE primary keyword. It takes one mandatory argument that defines an identificationstring 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 define the geometricplace 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 identification name should be unique for each zone. Milonga gives an error if two zones havethe same name. The material should be one defined with a MATERIAL primary keyword (section 3.5),and the name is case sensitive. It is not needed to have the material defined before the zone in theinput file, so the material definitions can be left to the end of the file—or maintained in an INCLUDE’dfile—for 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 x-y plane are supported in thisversion. The limits can be given as expressions, as long as there are no intermediate blanks. Use quotesif 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 specifiedaxis, otherwise the zone extends up to the bare prism limit in that direction. In two dimensions, acircle can be entered by giving the coordinates of the center and the radius. An annulus is entered bygiving also a value for the inner radius.

Zones entered last in the input file overwrite zones previously defined. If the optional keywordINCREMENTAL is given, then the cross sections of the material associated are algebraically added towhatever zones are existing under the new one.

For example, to define one single region that spans the whole bare prism with a material named“fuel”, write

ZONE core MATERIAL f u e l

To define a 20×10 (in whatever units x bare length is) rectangle centered in the bare square,enter

ZONE r e c MATERIAL f u e l { X_MIN x b a r e l e n g t h /2−10 X_MAX x b a r e l e n g t h /2+10Y_MIN y ba r e l e n g t h /2−5 Y_MAX y ba r e l e n g 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, considerthese two equivalent definitions:

ZONE r e f l MATERIAL r e f l e c t o r X_CENTER 200 Y_CENTER 200 OUTER_RADIUS 200ZONE core MATERIAL f u e l X_CENTER 200 Y_CENTER 200 OUTER_RADIUS 180

ZONE core MATERIAL f u e l X_CENTER 200 Y_CENTER 200 OUTER_RADIUS 180ZONE 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 surroundedwith materials but that are not assigned to any material themselves.

Page 50: milonga

milonga v0.1

3.4 Boundary conditions

To set the problem boundary conditions, milonga detects the external surfaces of the zones defined—that may or may not coincide with the bare prism external surfaces—and applies the equationsdescribed in section section 2.3 to the corresponding cells. The default boundary condition is torequire null flux at the external surfaces. This version supports either this default behavior or mirrorconditions on planar surfaces. Circular external surfaces always have null flux conditions.

To change from null to mirror conditions, use the primary keyword BOUNDARY CONDITIONS. Thiskeyword takes optional secondary keywords that define the kind of boundary condition for each axisand 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 file at which the BOUNDARY CONDITIONS keyword appears is irrelevant. Ifone 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 flux in the right, use

BOUNDARY_CONDITIONS X_MIN MIRROR

Even though external circular surfaces are forced to have null flux, the bare prism surfaces maybelong to a circle and have mirror conditions as well. For example, to implement a quarter of asymmetric circular core define

PROBLEM DIMENSIONS 2 GROUPS 1x b a r e l e n g t h = 50y ba r e l e n g t h = 50

ZONE core MATERIAL f u e 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 fluxes in a discrete domain may lead to artificial negativecell fluxes depending on the relative position of the cell center and the external surface, as explainedin page 29 and depicted in figure 2.14.

3.5 Materials

The zones discussed in section 3.3 have one associated material, that is defined with the MATERIALprimary keyword. Note that one zone has only one associated material, but one material can beassociated to more than one zone. The order at which the materials are defined in the input file isirrelevant.

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 identification name should be unique for each material. Milonga gives an error if two materialshave the same name. The name is case sensitive. Secondary keywords define the nuclear parametersthat characterize the material. If no information is entered about a certain parameter, it is taken asbeing 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

Page 51: milonga

milonga v0.1

Keyword Symbol Description UnitsD D Diffusion coefficient 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 afission times the fission macroscopic cross section

length−1

SigmaS Σs Scattering macroscopic cross section length−1

ESigmaF EΣf Product of the mean energy released in a fission timesthe fission macroscopic cross section

energy · length−1

Table 3.1: Secondary keywords for the primary keyword MATERIAL. The symbols are the ones used throughoutchapter 2. Units of length have to be consistent with the geometry definition and units of energy have to beconsistent with the power setpoint, if given. Also, the character of the energy (prompt or total) should alsobe 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 expectedargument. The dots ’[. . . ]’ in the above syntax mean that one keyword for each energy group isexpected. For the scattering cross sections, all the G2 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 relatedby

Σt(g) = Σa(g) +

G∑g′=1

Σs(g → g′)

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 discussedin section 2.1.1. Again, it is stressed that it is the user’s responsibility to assure that the macroscopiccross 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 first number is the energy group of the impinging neutrons and the second is the energy of thescattered neutrons. That is to say, SigmaS 1.2 is the scattering cross section from group one togroup two, i.e., the down-scattering cross section when taking as usual the first group as the thermalone in a two-group formulation. Note that when entering the absorption cross section instead of thetotal cross section, the value of the self-scattering cross section is irrelevant, as it appears both in apositive 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 fission times the macroscopic fissioncross 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 ortotal character of the fission energy and the power setpoint values as discussed in page 35.

Of course, nuclear properties may change within the same material because the parameters onwhich the cross sections depend may have non-trivial spatial distributions. This dependence can betaken 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 functionsof 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 parameters—such as temperatures or burn-up—that, inturn, have a certain spatial distribution.

Page 52: milonga

milonga v0.1

For example, if Σa depends on the fuel temperature Tcool and the coolant temperature Tcool as atwo-dimensional scalar field f(Tfuel, Tcool) and, in turn, the spatial distribution of the fuel and coolanttemperature is given by g(x, y, z) and h(x, y, z) repectively, then

Σa(x, y, z) = f(g (x, y, z) , h (x, y, z)

)To implement this in milonga, assume you have defined multidimensional functions f(Tfuel, Tcool),

g(x, y, z) and h(x, y, z) that interpolate scattered data provided in a text file using wasora’s commonframework keywords:

FUNCTION f ( t f u e l , t c o o l ) FILE sigmaa . datFUNCTION g ( x , y , z ) FILE t f u e l−d i s t . datFUNCTION h( x , y , z ) FILE t coo l−d i s t . dat

Then, the appropriate expression for the absorption cross section within the material definitionwould be

MATERIAL f u e l SigmaA 1 f ( g ( x , y , z ) ,h ( x , y , z ) ) [ . . . ]

One big deal of milonga’s flexibility discussed in section 1.2 appears around the collection ofavailable ways to enter this distributions. The expressions for the nuclear properties should providefunctions of r—through x, y and z—that are continuous in the sense that they should be proneto be evaluated at any arbitrary point of the spatial domain, and not be limited to be computedonly at discrete points. These expressions can use any of the wasora’s features related to functionmanipulation. Functions can be provided algebraically or read from scattered data from files orfrom external codes trough shared memory objects. Many interpolation methods for one and moredimensions are available, and further operations on functions such as integration or differentiation canbe done.

To illustrate the joint usage of the MATERIAL keyword with continuous functions, consider thefollowing definition, where a one-dimensional fuel and temperature distributions are assumed and thecross sections of the fuel are entered as central values plus partial derivatives multiplied by parametersincrements:

FUNCTION Tfue l ( x ) = 400 + 200∗ sin ( x∗ pi /300)FUNCTION Tcool ( x ) = 250 − 25∗cos ( x∗ pi /300)

MATERIAL f u e l {D 1 1SigmaA 1 ” 1 .0 e−2 + 1e−4∗( Tfue l ( x ) − 400) − 5e−5∗( Tcool ( x ) − 250) ”nuSigmaF 1 ” 1 .2 e−2 + 5e−5∗( Tfue l ( x ) − 400) ”

}

Further and complete examples—including multidimensional interpolation cases—can be found inchapter 4.

3.6 Collecting results

Milonga uses special variables both for gathering information to solve the problem and for giving backthe results to the user. The most important variable is called

k e f f

Page 53: milonga

milonga v0.1

that contains the effective multiplication factor as obtained by solving the eigenvalue problem. Thisvariable is defined when starting the execution and initialized to one, and its content is “filled” withthe correct value after the first ZONE keyword. That is to say, any algebraic expression involvingkeff should appear after the last zone was defined. For example, in

rho1 = ( k e f f −1)/ k e f fZONE f u e l MATERIAL f u e lrho2 = ( k e f f −1)/ k e f f

only variable rho2 contains the correct reactivity of the problem being solved, while rho1 is equalto zero.

The other output variables given by milonga are

k e f f e r r o rbu i l d t imeso l v e t ime

The first 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 andsolve 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 first zone definition. Times are givenin seconds, and refer to the actual time elapsed and not to the CPU time used. They both may dependon how busy the operating system scheduler is, whether memory access is cached or swapped, etc.

Information about spatial distributions are given as functions. The flux distribution for group gis given in a function named

f l u x g

where g is supposed to be replaced by the actual group number. The first—usually the fast—groupis number one. The functions take as many arguments as the spatial dimension of the problem.They are point-wise defined, with the independent variable being the location of the cell center andthe independent variable being the flux of the corresponding group. Nevertheless, the functions arelinearly interpolated, and as such they can be evaluated—or integrated, differentiated, etc—at anypoint.

These functions can be used wherever a function can appear in any valid expression handled bywasora. For example, if used within a PRINT FUNCTION there is no need to provide the selected rangeas by default a point-wise defined function will be printed just in the definition points. However, if arange is specified, the function will be interpolated and evaluated at the positions asked for. Considerfor example a one-group one-dimensional problem with 20 nodes. Then

FILE nodes nodes . datFILE i n t e r p i n t e r p o l a t i o n . datPRINT_FUNCTION FILE nodes f l u x 1PRINT_FUNCTION FILE i n t e r p f l u x 1 MIN 0 MAX 100 STEP 0 .1

creates a file nodes.dat containing twenty lines with the cell center-flux pairs, while the other file,interpolation.dat, contains one thousand lines with the intermediate interpolated values in aready-to-plot text format. If no power setpoint is given (section 3.7), fluxes are in dimensionless unitssuch that the mean value—as discussed in section 2.4.2—is equal to one. Otherwise, fluxes have unitsof inverse squared length and inverse time.

Even though the functions are point-wise defined, they can be evaluated at any point in space. Forexample, if there is a neutron detector located at r = (153, 241, 308) then its reading may be assignedto a variable by

Page 54: milonga

milonga v0.1

de t e c to r1 = f l u x 2 (153 , 241 , 308)

although there may not be a cell located at that point. Details about function interpolation can befound in wasora documentation.

Information about the resulting cell cross sections values can be obtained by using the functions

D gSigmaT gSigmaA gnuSigmaF gESigmaF g

They are also linear-interpolated point-wise defined functions containing the macroscopic crosssection associated to the cell discussed in section 2.2, according to the selected method as explainedin section 3.8.

There is one function named

bc

that is also point-wise defined that shows which cells contain boundary condition equations instead ofthe diffusion equation. It is non-zero only for the location of the cells that have boundary conditionsequations. The actual value is not important, as is an internal identification number for each type ofcondition.

There are five additional functions which give information about the actual original continuousspatial cross sections distributions, i.e. before the association to the discrete cells:

cDcSigmaTcSigmaAcnuSigmaFcESigmaF

The ’c’ in the name means “continuous”, and it is included because it is not so common to askmilonga for the continuous cross section distribution as having variables called D or nuSigmaF. Thus,the extra ’c’ avoids name conflicts. Note that these functions do not incorporate the group numberin its name. Rather, they take N + 1 arguments, being the first one the group number and the restthe spatial position. For example, to evaluate the total cross section at point r = (10.5, 25.2, 4.3) ofgroup number 3, ask for

PRINT cSigmaT ( 3 , 1 0 . 5 , 2 5 . 2 , 4 . 3 )

They are not point-wise defined, so when using them within a PRINT FUNCTION keyword, a rangeis mandatory, as explained below.

In general, one or more of these functions are part the desired output of milonga. This informationmight be passed forward to other codes for further calculation or might be written to files for analysisand interpretation (as in the last step of figure 2.1). These features are part of the common wasoraframework, and are explained in the associated documentation. However, for completeness, a briefsummary of output keywords is presented. In order to write information into a file, first the FILEprimary keyword has to used

FILE id path [ STEP ]

Page 55: milonga

milonga v0.1

The two mandatory arguments are an internal identification string and the actual file path, whichcan be either absolute or relative to the actual directory. If the optional secondary keyword STEP isgiven, then one different file for each step is created, appending the step number to the file path. Inany case, if the file already exists, it is overwritten.

The keywords used to print data are

PRINT [ FILE id ] [ CONDITION expr ] [ expr1 | TEXT s t r i n g 1 ] [ expr2 | TEXT s t r i n g 2 ] ←↩[ . . . ]

PRINT_FUNCTION [ FILE id ] [ CONDITION expr ] func t i on1 [ func t i on2 ] [ f unc t i on3 ] ←↩[ . . . ] [ MIN x min [ y min [ z min ] ] MAX x max [ y max [ z max ] ] STEP x s t ep [ ←↩y s t ep [ z s t e p ] ] ]

If no file is given, default is to write to standard output. If a condition is given, the argumentexpression is evaluated and the print instruction is executed only if it is nonzero. For the PRINTkeyword, a list of expressions or text strings are expected. Each PRINT keyword produces a singleline. For the PRINT FUNCTION keyword, a list of functions is expected. All the requested functionsought to have the same number of arguments. The PRINT FUNCTION produces one line for eachrequested point, with the values of the independent variables in the first columns and then onecolumn for each requested function with the value the function evaluates to at that point. If thefirst function is point-wise defined, it is not needed to give the range with the MIN, MAX and STEPsecondary keywords, and the output points are the definition points of the first function, even if theother functions are not point-wise defined. Anyway, the output points can be defined giving minimum,maximum and increment values for the independent variables, according to the number of argumentsof the functions. If the first function is not point-wise defined (for example given by an algebraicexpression) the the range is mandatory. Actually, these primary keywords can take more optionalsecondary keywords. See the wasora documentation for further information.

For example, valid constructions for the PRINT keyword are

PRINT 1+1PRINT TEXT ” the e i g e v a l u e problem insumed” s o l v e t ime TEXT ” seconds ”FILE output outputs / r e s u l t s . txtPRINT FILE output ( k e f f −1)/ k e f f s o l v e t imePRINT CONDITION greater ( k e f f , 1 ) TEXT ” the r e a c t o r i s s u p e r c r i t i a l ”

To produce a text file containing the fast and thermal flux distribution, simply enter

FILE f l u x f l u x . datPRINT_FUNCTION FILE f l u x f l u x 1 f l u x 2

To obtain the continuous macroscopic cross sections, a range is mandatory because they are notpoint-wise defined. 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 a r e l e n g t h ←↩y ba r e l e n g t h STEP 1 0 .1∗ x b a r e l e n g t h / x c e l l s 0 .1∗ y ba r e l e n g t h / x c e l l s

to obtain a representation of the absorption and nu-fission cross sections with a resolution of 10× 10grid 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 diffusionproblem to obtain a dimensionless flux distribution with mean value equal to one unit of flux, asdiscussed in section 2.4.2. To obtain a dimensional flux distribution with physical meaning, a power

Page 56: milonga

milonga v0.1

setpoint has to be given. Also, values for EΣf for at least one zone has to be given, in order tocompute 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. Intwo dimensions, power is a power density per unit length perpendicular to the x-y plane in energyinverse time inverse length. In one dimension, it is a density per unit area perpendicular to the x axisin units of energy inverse time inverse squared length.

If the power variable is set to a non-zero value, two functions of space are defined:

power dens i tyxenon

The first one gives the power density dissipated locally at position r in units of energy inverse timesinverse cubed length. As with the fluxes, this function is linearly-interpolated point-wise defined, andcan be used to coupled milonga with thermalhydraulic or plant codes—as with any other function orvariable within the wasora framework. It can also be used the power peak factor, for example in onedimension:

peak = max( power dens i ty ( x ) , x , 0 , x b a r e l e n g t h ) /( power/ x b a r e l e n g t h )

The other function is called xenon, and contains the steady-state xenon concentration distributionassociated to the last computed neutron flux distribution, in units of inverse cubed length. To computethis function, equation (2.46) is used. There are some defaults for the yields, the xenon decay constantand the number of neutrons emitted in one fission, but they can be changed by means of the followingvariables

gamma Igamma Xelambda Ilambda Xenu

whose default values are

gamma I = 6.386 e−2gamma Xe = 2.28 e−3lambda I = 2.878 e−5 # [1/ sec ]lambda Xe = 2.10 e−5 # [1/ sec ]nu = 2.4

Note that the steady-state xenon concentration does not depend on λI, so this variable is not usedin this version. Iodine and xenon yields—i.e. how many nuclei of 135I and of 135Xe appear promptlyby a single fission—and ν may be changed according to the type of fuel used in the problem. Thedecay constants—whose default value is given in inverse seconds—are physical constants rather thanvariables, but the user may want to change λXe to study and try to understand how xenon poisoningworks while in college or while having to develop a power distribution control algorithm, or to use atime unit different than seconds.

The microscopic neutron absorption of 135Xe is entered as a vector of size G named

sigmaAXe

Page 57: milonga

milonga v0.1

whose individual elements can be set as with the chi vector. The default behavior is to have zeroabsorption for every group except for the last one—considered the thermal group. Assuming a two-group problem, vector sigmaAXe is set to

sigmaAXe 1 = 0sigmaAXe 2 = 2e−18 # 1/cmˆ2

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, if—asusual—macroscopic cross sections depend on the xenon distribution by means of direct reference tothe xenon function, an iterative calculation is needed.

As discussed in page 9, xenon and power distributions depend on each other. In the first calculation,it is assumed that there is no xenon in the reactor core. If xenon effects are to be taken into account, anew power calculation is needed, giving rise to a new xenon concentration, and so on. To tell milongato 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 contentof 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 reasonablevalue for static iterations. However, an explicit converge check can be made from within theinput file, setting the special wasora variable done to non-zero when a certain condition holds:

# [ . . . ]# problem d e f i n i t i o n# [ . . . ]

s t a t i c i t e r a t i o n s = 20

# keep the k e f f found in the prev ious s t epkold = k e f f

# de f ine zones here so the the new k e f f i s computed at t h i s po in tZONE f u e l MATERIAL f u e l

# give the user some feedback in standard outputPRINT s t a t i c s t e p k e f f

# s e t done to t rue i f convergence i s a t t a ineddone = l ess (abs ( k e f f−kold ) , 1e−6)

When printing distributions in an iterative calculation, output files should be defined using thesecondary 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 toevaluate the leakage term are given by using the primary keyword SCHEME along with its secondarykeywords:

SCHEME [ VOLUMES | DIFFERENCES ] [ XS_MEAN | XS_CENTER ] [ [ D_EPSILON | D_MEAN ] | [ ←↩GRAD_D_LOCAL | GRAD_D_NEIGHBORS ] ] [ NO_NEGATIVE_FLUX | ALLOW_NEGATIVE_FLUX ]

Page 58: milonga

milonga v0.1

If the VOLUMES keyword is given, the leakage term is treated with the finite-volumes based methodas described in section 2.1.2, while DIFFERENCES keywords selects the finite-differences method of sec-tion (2.1.3). XS MEAN associates cross sections to cells according to equation (2.35) and XS CENTERuses equation (2.36). For finite volumes, D EPSILON computes the diffusion coefficients at a dis-tance ε of the cell border, i.e. D(x± ε), while D MEAN uses mean values in the proper half of the cell,i.e. 〈D(x± ε)〉. For finite differences, GRAD D LOCAL makes milonga to evaluate the gradient of thediffusion coefficient in equation (2.34) by locally differentiating the continuous expressions of D(r).On the other hand, GRAD D NEIGHBORS computes the gradient by a finite-difference approximationusing first neighbors. When keyword NO NEGATIVE FLUX is given, if a flux happens to be negativebecause of the application of discrete boundary conditions (figure 2.14), it is forced to be zero. Oth-erwise, if keyword ALLOW NEGATIVE FLUX is entered, negative fluxes are kept as computed by theeigenvalue 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 finite differences, default is GRAD D NEIGHBORS.

The value of ε is taken from the special variable

ep s 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 modified by setting the special variable

xs mean to lerance

that is the relative error allowed. The default value is 10−2 meaning 1% tolerance. The computationaleffort 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 | user ] ] [ EIGENVALUE_K | EIGENVALUE_INVERSE_K ] [ ←↩TOLERANCE t o l ]

Method can be either SLEPC (default), NONE to skip the eigenvalue problem solution (useful whenhaving problems with the nodalization and preparing a new problematic input file) or a user-definedroutine, as explained in section 3.14. If EIGENVALUE K is entered, the eigenvalue problem definedby equation (2.41) is solved (default), whilst problem (2.42) is solved for EIGENVALUE INVERSE K.Default is “direct keff formulation”. The optional tolerance is the value the relative residual ‖rrel‖has to take in order to considered the eigenvalue solution as converged, according to equation (2.43).Default is to take SLEPc’s 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 justa brief summary is given here. By a parametric calculation, it is understood a series of computationof 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 define a linear parametric study, the following keyword has to be entered

PARAMETRIC v a r i a b l e minimum maximum step

The values min, max are the ends of the interval to be studied and step is the increment. Theycannot be expressions, they have to be floating point constants. If there selected variable has one ormore explicit assignments in the input file, they are ignored. For example,

Page 59: milonga

milonga v0.1

PARAMETRIC a 1 10 1a = 5PRINT a

will output the natural numbers up to ten instead of ten values of five.If more than one PARAMETRIC keyword is given, multidimensional studies can be performed. The

variable in the first PARAMETRIC keyword is incremented up to the maximum value, then the variablein the second PARAMETRIC keyword is incremented one step and the first variable starts from theminimum value again, and so on.

Instead of incrementing the variable with a fixed value, a logarithmic—or exponential, dependingon the point of view—study can be done with

PARAMETRIC_LOG v a r i a b l e minimum maximum step

In this case, step is a multiplicative constant by which is multiplied the selected variable in eachcalculation.

Each calculation step is independent from the previous one, i.e., the initial conditions of step n+ 1are not the last conditions of step n. By default, milonga waits for the previous step to finish beforelaunching the next one. However, because of this reason, this kind of calculations are especially suitableto 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 launchedin parallel. If it is equal to zero, the number of available cores is taken. Default is one, meaning noparallelization.

When performing parametric calculations, output files are renamed and the number of step isattached to it. Standard output can be shared by all the steps, but because of random uncertaintiesin the operating system scheduler the order of printing may not be the expected. For example,

MAX_DAUGHTERS 8PARAMETRIC a 0 10 1PARAMETRIC b 0 10 1PRINT a b a+b

may not output the [1, 1] × [10, 10] square in the correct order and plotting utilities may complainabout it. To overcome this difficulty, one solution is to output each line to a file and the concatenateall of them into a single one in the correct order. First,

MAX_DAUGHTERS 8PARAMETRIC a 0 10 1PARAMETRIC b 0 10 1FILE out tmpPRINT FILE out a b a+b

and then in the terminal

Page 60: milonga

milonga v0.1

$ milonga square.mil$ cat tmp.* > output$ rm tmp.*$

Note that although some calculations may be performed either by using parametric or iterativecalculations, they are essentially different in their nature. Each instance of a parametric calculation isindependent from previous one—indeed, they are different processes and can be run in parallel—andall the variables, functions and parameters are initialized for each instance. On the other hand, eachstep 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 aremany parameters that affect the computational time, and more often than not they depend on theparticular problem being solved. Milonga can dump some information about the numerical schemethat 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 file with the extra information.Variables build time and solve time are included in the debug file. If the optional secondarykeyword MATRICES ASCII is given, an ASCII representation of the matrices R and F are included inthe file. If the secondary keyword MATRICES BINARY is given, two binary files called R and F in theexecution directory are created. They contain a binary dump of the matrices as created by PETSc’sPetscViewerBinaryOpen 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 thedebug file. Future versions of milonga will include further debugging and bechmkarking options.

3.11 Commandline arguments replacement

Milonga takes as a first argument the name of the input file to process. Using a wasora feature, moreoptional arguments can be given, and then replaced in the input. If a the token $1 is entered in theinput file, it will be replaced by the first non-file commandline argument, $2 with the next one, andso on. For example

PRINT $1

will print whatever argument is given in the commandline after the input file:

$ milonga calc.mil 1+12.000000e+00$

This can be useful to provide filenames from the commandline

Page 61: milonga

milonga v0.1

FILE output $1FILE 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 bechanged 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-keff

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-defined eigenvalue solver

To be explained.

3.15 If anything goes wrong

As stated in section 1.2, one of milonga’s the design basis vectors is “resisting” inconsistent or non-physical values of cross sections. This may lead to singular matrices, zero pivots or other mathematicalproblems involving invalid operations such as divisions by zero. Depending on the particular situation,one may want the code to behave differently. For example, sometimes when a singularity is found itwould be desirable to tell the user that there are some problems in the physics entered in the inputand to stop the calculation. But when running parametrically or inside an optimization loop, it wouldbe 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 result—division,square roots, logarithms, etc—are 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 file

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 maybe given.

Page 62: milonga

milonga v0.1

As wasora uses some features from the GNU Scientific Library [3], there may be run-time errorswhen accessing one of these routines—for example divergence of an integral, inconsistent data forinterpolation, etc. When an error is raised during a GSL call, also the default behavior is to report itto 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 welldefined. 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_QUIETPRINT 1/0

results in

inf

In the same sense, for example if a zone with a diffusion coefficient equal to zero is entered, probablyPETSc 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 * define 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_QUIETPRINT 1/0ON_NAN INFORMPRINT sqrt(-1)

gives

Page 63: milonga

milonga v0.1

error: NaN foundinferror: NaN found0.000000e+00

i.e. as if

ON_NAN CONTINUE INFORMPRINT 1/0PRINT sqrt(-1)

was entered. A final example illustrating ON GSL ERROR:

ON_GSL_ERROR INFORM QUITPRINT 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 usersmanual. 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 -Revision 3.1, D. Sistemas Informaticos y Computacion, Universidad Politecnica de Valencia, 2010.

[3] M. Galassi et. al. GNU Scientific Library Reference Manual. Third edition, 2009. ISBN 0954612078,http://www.gnu.org/software/gsl.

Page 64: milonga

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!

Retintın (milonga), 1918

Not only do these examples show what kind of problems can be tackled by milonga, but also—andmore important—how to solve them. To obtain the most from this chapter, a thorough comprehensionof chapters 2 and 3 is recommended. However, as artificial neural networks do, people learn mainlyby 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 increasinglycomplexity order. Even though they are based on basic reactor physics ideas, they do not refer norapply to any real engineering condition. It should be stressed again that these examples provide theresults obtained by solving the neutron diffusion equation as discussed in chapter (2) and by no meansrepresent 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 areone-dimensional—except those that illustrate how to manage higher dimensions problems—in orderto avoid introducing extra complications.

The output information and figures that conform the result of the problems solved in this chapterwere generated automatically from a series of scripts. Therefore, all the examples have the samestructure. First, a brief description of the problem along with a figure is given. Then, there may beone or more milonga runs for each case, each having an explanatory paragraph. Then, the actualinput file is shown, along with a view of a fictitious terminal where the invocation of milonga andsome further processing for generating graphical plots and results is given. In fact, the actual figuresshown in this chapter were obtained by executing the commands shown in the terminal by using thefree-as-in-beer-but-not-as-in-speech plotting program gnuplot [1]. All figures are vector-based, so theycan be zoomed in without loosing resolution. A milonga executable with debugging symbols was usedto run the examples shown, so running times may differ when using optimized versions. The milongaand gnuplot input files are available in the distribution package, so there is no need to cut & paste fromthis document to further study, modify and tweak the examples. The commands shown in the sampleterminal outputs should be reproducible using the provided files. Feedback about these examples orother desired test cases are welcome.

Enough chitchat. It is time to milonguear !

Page 65: milonga

milonga v0.1

4.1 Cases with analytical solutions

The examples shown in this first 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 introducingthe usage of milonga and at the same time can be used to test whether things are being done well ornot, and moreover, to what extent.

Most of the them are one-group cases, as few-group problems either do not have analytical solutionsor they are so complicated that do not serve the point of being a reference. The only two-group problemshown here corresponds to an infinite 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 diffusion approximation is one of the first examples ofthe solution of the diffusion equation in nuclear reactor theory courses (see for example [2, section9-2] and [3, section 5.III.C]). In particular a one-meter width slab is considered, with the one-groupconstants shown in the figure.

keff.mil

This example computes the the effective multiplication factor keff for the slab above. See the commentsin the input file for details about the implementation in milonga. As can be seen, a small number ofkeywords are used and thus most of the default options are automatically selected. The only outputobtain in the terminal after the execution of the code is the multiplication factor as computed fromthe numerical eigenvalue problem in the default scientific notation format.

# computation o f the k e f f f o r a one−dimensional# one−group bare s l a b with constant XS

# de f ine the number o f s p a t i a l dimensions and groupsPROBLEM DIMENSIONS 1 GROUPS 1

x b a r e l e n g t h = 100 # bare l eng t h in cmx c e l l s = 100 # number o f c e l l s

ZONE f u e l MATERIAL f u e l # a s i n g l e zone spanning the whole bare l eng t h# composed o f mater ia l f u e l , de f ined below

# d e f i n i t i o n o f the f u e l XS fo r the one−group un i t s are those o f# the inve r s e x ba r e l eng t h , i . e . 1/cmMATERIAL f u e l {

D 1 1SigmaA 1 0 .010nuSigmaF 1 0 .012

}

# pr in t the mu l t i p l i c a t i o n f a c t o r in the standard output# with the d e f a u l t format , i . e . s c i e n t i f i c no ta t ionPRINT k e f f

Page 66: milonga

milonga v0.1

$ milonga keff.mil1.092211e+00$

comparisson.mil

Taking advantage milonga’s—actually wasora’s—mathematical capabilities, it is fairly easy to comparethe numerical result obtained by using a spatial discretization with 100 cells to the actual analyticalsolution for the one-dimensional one-group bare reactor. In this case, the input for the numericalproblem is almost the same, but the cross sections are entered as variables and used both for thedefinition of the material and for the computation of the analytical value of the effective multiplicationfactor, which is

keff =νΣf

Σa +D(πa

)2

where a is the slab width. The output is now extended to include an informative string and a decimalformat is used to show at which digit the two solutions start to differ. The absolute difference is shownin scientific notation. In the comments, an explanation is given about the order in which the algebraicexpressions are computed. If you are tempted to change the number of cells to see what happens withthe difference, please do it now. Nevertheless, in the examples of parametric calculations you will getplenty of the kind of fun you are searching for.

# comparisson between the numerical and an a l y t i c a l s o l u t i o n s# for the one−dimensional bare s l a b

PROBLEM DIMENSIONS 1 GROUPS 1x b a r e l e n g t h = 100x c e l l s = 100

# these are p l a in v a r i a b l e s used both f o r en te r ing the XS in# the MATERIAL keyword and in computing the a n a l y t i c a l s o l u t i onD = 1SigmaA = 0.01nuSigmaF = 0.012

# the p lace where the MATERIAL keywords appear in the input# i s i r r e l e v an t , but the p lace where the ZONE keywords appear# i s not . A l l the a l g e b r a i c expre s s i ons t ha t appear be f o r e the# f i r s t ZONE are computed be fo r e s o l v i n g the e i g enva lue problem ,# and the r e s t are computed a f t e r s o l v i n g the e i g enva lue problem .# This i s important in t h i s example because the XS are eva lua t ed# with the informat ion a v a i l a b l e b e f o r e the f i r s t ZONE keyword .# Thus , the v a r i a b l e s conta in ing the XS have to be eva lua t ed# be fo r e the f o l l ow i n g l i n e .ZONE f u e l MATERIAL f u e l

# the XS can be any v a l i d mathematical express ion , i n c l ud ing# constants , v a r i a b l e s , a l g e b r a i c express ions , func t ions , e t c .# Further examples o f XS w i l l be g iven in subsequent examples .# In t h i s one , we are us ing the v a r i a b l e s de f ined above , t ha t# shou ld be ” f i l l e d ” be f o r e the f i r s t ZONE keywordMATERIAL f u e l {

D 1 DSigmaA 1 SigmaA

Page 67: milonga

milonga v0.1

nuSigmaF 1 nuSigmaF}

# the an a l y t i c a l s o l u t i on can be eva lua t ed now or be f o r e the# ZONE, i t does not matter . But , i f the k e f f v a r i a b l e i s# re f e r ed to be f o r e the ZONE, i t s va lue i s equa l to one .pi = 4∗atan (1 )k = nuSigmaF /(SigmaA + D∗( p i / x b a r e l e n g t h ) ˆ2)

# pr in t the s o l u t i o n sPRINT TEXT ” a n a l y t i c a l k e f f = ” k FORMAT %.8 l fPRINT TEXT ” numerica l k e f f = ” k e f f FORMAT %.8 l fPRINT TEXT ” d i f f e r e n c e = ” abs (k−k e f f )

$ milonga comparisson.milanalytical keff = 1.09220381numerical keff = 1.09221091

difference = 7.101524e-06$

flux.mil

The last example regarding the bare slab shows how to easily plot a function of a single variable.Even though the flux is computed at the cells centers, milonga provides a continuous function byinterpolating the results that can be integrated, differentiated, etc. This example shows how to plotthe flux distribution at the computed points using the PRINT FUNCTION without the necessity ofgiving 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 (rememberthe obtained flux has mean value equal to one):

φ(x) =π

2sin(πa· x)

for one hundred cells (examples showing how this difference varies with the cell number are about tocome). Milonga gives as output three columns containing the x-coordinate, the numerical flux and theanalytical flux. This information can be easily plotted using gnuplot, as shown in the terminal outputby catting the files fluxes.gnuplot and diff.gnuplot. These are listed here for completeness.In other examples the files used to obtain the output figures may or may not be shown dependingon the complexity of the figure. However, the files generated by milonga can be plotted or furtherprocessed by any other software as they consist of tab-separated columns. In this example the fluxdistribution is written to the standard output, and is redirected to a file from the commandline asshown in the terminal output.

Note that in this example, the two plotted columns do not refer to the same quantities, as thefirst is the mean flux in each cell and the former is the continuous flux evaluated at the cell center,as discussed in the mathematical development of the finite volumes scheme. However, the differenceshould be minimal and they are assumed to be equal as in equation (2.16).

# one−dimensional bare s l a b f l u x d i s t r i b u t i o n

PROBLEM DIMENSIONS 1 GROUPS 1x b a r e l e n g t h = 100x c e l l s = 100D = 1SigmaA = 0.01nuSigmaF = 0.012

Page 68: milonga

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 fluxes

ZONE f u e l MATERIAL f u e l

MATERIAL f u e l {D 1 DSigmaA 1 SigmaAnuSigmaF 1 nuSigmaF

}

# the f l u x i s g iven in a func t i on o f the v a r i a b l e x c a l l e d# f l u x 1 ( x ) . I t i s de f ined f o r every va lue o f x by a l i n e a r# in t e r p o l a t i o n o f the f l u x e s computed at each c e l l . By# de fau l t , the f l u x i s such tha t the mean va lue i s equa l to# one . On the other hand , an a l g e b r a i c func t i on with the# ana l y t i c a l s o l u t i on o f the problem having a mean va lue# equa l to one can be cons t ruc ted as f o l l ow s :pi = 4∗atan (1 )FUNCTION phi ( x ) = pi /2∗ sin ( p i ∗x/ x b a r e l e n g t h )

# as f l u x 1 i s de f ined in a f i n i t e number o f absc i s sae ,# by d e f a u l t i t i s p r in t ed in the se va lue s o f x i f no# range i s g iven . Function phi i s a l g e b ra i c , but i t uses# the range o f the f i r s t func t i on in the l i s t .PRINT_FUNCTION f l u x 1 phi

$ milonga flux.mil > flux.dat$ cat fluxes.gnuplotset terminal pdfset output "fluxes.pdf"set title "bare-slab flux"set xlabel "x"set border 3set tics nomirrorset tics scale 0.2set 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.gnuplotset terminal pdfset output "diff.pdf"set title "relative error between theoretical and numerical fluxes"set xlabel "x"set border 3set tics nomirrorset tics scale 0.2set ytics format "%.1e"set ytics 1e-4unset keyplot "flux.dat" u 1:(($3-$2)/$3) w lp pt 2 ps 0.25$ gnuplot diff.gnuplot$

Page 69: milonga

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 flux

numericalanalytical

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 fluxes

4.1.2 Homogenoeus bare square

This example is an extension to two dimensions to the bare slab. It consists of an homogeneousone-speed bare square. The gnuplot input files are also shown in the terminal output to illustrate howto obtain two-dimensional contour levels for the flux. The first example has the same number of cellsin each direction, while the second one does not. Also, an illustration of how to use both the standardoutput and output files using the FILE keyword is given.

Page 70: milonga

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

flux with an uniform mesh

0

0.5

1

1.5

2

2.5

uniform.mil

The input that follows solves the one-group neutron diffusion equation in an homogeneous square,where the variable y bare length is set equal to x bare length. The number of cells in eachdimension is the same, by also setting the variable y cells equal to x cells. The keff is evaluatedboth analytically and numerically, and the flux distribution is written into a file that can be directlyplotted with gnuplot or another similar tool.

# two−dimensional bare s l a b f l u x d i s t r i b u t i o n

PROBLEM DIMENSIONS 2 GROUPS 1x b a r e l e n g t h = 100y ba r e l e n g t h = x b a r e l e n g t h # t h i s f o r c e s the geometry to be a squarex c e l l s = 100y c e l l s = x c e l l s # t h i s f o r c e s c e l l s to be squares

D = 1SigmaA = 0.01nuSigmaF = 0.012

ZONE f u e l MATERIAL f u e l

MATERIAL f u e l {D 1 DSigmaA 1 SigmaAnuSigmaF 1 nuSigmaF

}

# ana l y t i c a l e f f e c t i v e mu l t i p l i c a t i o n f a c t o rpi = 4∗atan (1 )k = nuSigmaF /(SigmaA + D∗ ( ( p i / x b a r e l e n g t h ) ˆ2 + ( p i / y ba r e l e n g t h ) ˆ2) )

# wri t e the f l u x d i s t r i b u t i o n to a f i l eFILE f l u x uniform . dat# the f l u x i s eva lua t ed at the computed po in t s au tomat i ca l l yPRINT_FUNCTION FILE f l u x f l u x 1

# and the k e f f to the screenPRINT TEXT ” numerica l k e f f =” k e f fPRINT TEXT ” a n a l y t i c a l k e f f =” kPRINT TEXT ” d i f f e r e n c e =” abs ( k e f f−k )

$ milonga uniform.milnumerical keff = 1.002190e+00analytical keff = 1.002178e+00

difference = 1.195821e-05$ cat uniform2d.gnuplotset terminal pdfset output "uniform2d.pdf"set title "flux with an uniform mesh"set size squareplot "uniform.dat" w image$ gnuplot uniform2d.gnuplot$ cat uniform3d.gnuplotset terminal pdfset output "uniform3d.pdf"set title "flux with an uniform mesh"set ticslevel 0unset keysplot "uniform.dat" u 1:2:3 palette pt 59 ps 0.1$ gnuplot uniform3d.gnuplot$

Page 71: milonga

milonga v0.1

0

20

40

60

80

100

0 20 40 60 80 100

flux 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

flux 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 y-direction is one-fifth of the number of cells in the x-direction. The flux distribution output is evaluated at thecomputed points automatically by milonga. The effects of the different discretizations is studied inother examples.

# one−dimensional bare s l a b f l u x d i s t r i b u t i o n

PROBLEM DIMENSIONS 2 GROUPS 1x b a r e l e n g t h = 100y ba r e l e n g t h = x b a r e l e n g t hx c e l l s = 100# the f o l l ow i n g l i n e s e t s the number o f y c e l l s to# one f i f t h o f whatever x c e l l s i s s e t to . I f the# r e s u l t i s not i n t e g r a l , the va lue i s rounded to# the neares t i n t e g e ry c e l l s = x c e l l s /5

D = 1

Page 72: milonga

milonga v0.1

SigmaA = 0.01nuSigmaF = 0.012

ZONE f u e l MATERIAL f u e l

MATERIAL f u e l {D 1 DSigmaA 1 SigmaAnuSigmaF 1 nuSigmaF

}

pi = 4∗atan (1 )k = nuSigmaF /(SigmaA + D∗ ( ( p i / x b a r e l e n g t h ) ˆ2 + ( p i / y ba r e l e n g t h ) ˆ2) )

FILE f l u x nonuniform . dat# no need to change t h i s l i n e with r e spec t to the prev ious# example , milonga knows where func t i on f l u x 1 i s de f inedPRINT_FUNCTION FILE f l u x f l u x 1

PRINT TEXT ” numerica l k e f f =” k e f fPRINT TEXT ” a n a l y t i c a l k e f f =” kPRINT TEXT ” d i f f e r e n c e =” abs ( k e f f−k )

$ milonga nonuniform.milnumerical keff = 1.002253e+00analytical 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

flux with a non-uniform mesh

"nonuniform.dat"

0

0.5

1

1.5

2

2.5

Page 73: milonga

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

flux 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 define the geometry, secondary keywords have tobe given to the primary keyword ZONE to prevent the zone to expand to the whole bare length. Notethat the error committed in the computation of keff is greater than that of the bare square becauseof the introduction of discrete circular boundary conditions. Some capabilities of the wasora’s com-mon framework for working with multidimensional functions are also shown. The analytical solutioninvolves the use of the lowest-order two-dimensional Laplacian eigenfunction with null boundary con-ditions over a circle, namely Bessel’s J0 function. As wasora does not provide evaluation of Bessel’sfunctions, the profile comparison is made by making use of gnuplot capabilities.

full.mil

This input computes the one-group flux inside a a full homogeneous circle of radius R = 100 cm. Thecells that are marked to have a boundary condition instead of the diffusion equations are shown byprinting the bc function. This example uses the default behavior of forcing negative fluxes to zeroat boundary condition cells, effect that can be seen as a discontinuity in the colors when zoominginto the border of the flux distribution contour plot. The radial flux profile is computed by defin-ing a one-dimensional function bessel from the two-dimensional flux distribution. It is comparedto the analytical solution by plotting this continuous function along with gnuplot’s Bessel functionimplementation.

# two−dimensional bare c i r c l e

Page 74: milonga

milonga v0.1

PROBLEM DIMENSIONS 2 GROUPS 1

# f i l e s to output the f u l l 2D d i s t r i b u t i o n and the r a d i a l# d i s t r i b u t i o n to compare to the a n a l y t i c a l p r o f i l e . The# lo ca t i on o f t h i s d e f i n i t i o n in s i d e the input f i l e does# not matter , only the PRINT in s t r u c t i o n s are executed# in the g iven orderFILE f l u x f u l l . datFILE r a d i a l r a d i a l . dat

# square bare geometry and square c e l l sx b a r e l e n g t h = 100y ba r e l e n g t h = x b a r e l e n g t hx c e l l s = 100y c e l l s = x c e l l s

D = 1SigmaA = 0.01nuSigmaF = 0.012

# only one zone i s de f ined , a centered c i r c l e o f rad ius equa l# to h a l f the bare l eng t h . Ce l l s t ha t l i e ou t s i d e the c i r c l e# are forced to have zero f l u xZONE f u e l MATERIAL f u e l X_CENTER x b a r e l e n g t h /2 Y_CENTER x b a r e l e n g t h /2 ←↩

RADIUS x b a r e l e n g t h /2

MATERIAL f u e l {D 1 DSigmaA 1 SigmaAnuSigmaf 1 nuSigmaF

}

# the an a l y t i c a l mu l t i p l i c a t i o n f a c t o rnu0 = 2.4048 # f i r s t zero o f b e s s e l ’ s j0 func t i onk = nuSigmaF /(SigmaA + D∗( nu0 /( x b a r e l e n g t h /2) ) ˆ2)

# de f i n i t i o n o f a one−dimensional func t i on equa l to the f l u x# d i s t r i b u t i o n eva lua t ed in an ho r i z on t a l radius , i . e . the# rad i a l p r o f i l e to compare to the b e s s e l s o l u t i onFUNCTION b e s s e l ( r ) = f l u x 1 ( r+x b a r e l e n g t h /2 , x b a r e l e n g t h /2)

# wri t e the 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# cond i t i ons to one f i l ePRINT_FUNCTION FILE f l u x f l u x 1 bc# and the r a d i a l p r o f i l e to another one . Note t ha t b e s s e l ( r ) i s# an a l g e b r a i c funct ion , so a range i s mandatory . As the s t ep i s# l e s s than de l t a x , t h i s i s an i n t e r p o l a t i o n o f the ac tua l f l u x .PRINT_FUNCTION FILE r a d i a l b e s s e l MIN 0 MAX x b a r e l e n g t h /2 STEP 0 .5∗ ←↩

x b a r e l e n g t h / x c e l l s

PRINT TEXT ” numerica l k e f f =” k e f fPRINT TEXT ” a n a l y t i c a l k e f f =” kPRINT TEXT ” d i f f e r e n c e =” abs ( k e f f−k )

$ milonga full.milnumerical keff = 9.773084e-01analytical keff = 9.745619e-01

difference = 2.746505e-03$ gnuplot full2d.gnuplot$ gnuplot full3d.gnuplot$ gnuplot fullbc.gnuplot$ cat radial.gnuplotset terminal pdfset output "radial.pdf"set title "radial flux shape vs. analytical solution"

Page 75: milonga

milonga v0.1 0

0.5

1

1.5

2

2.5

3

0 10 20 30 40 50

radial flux shape vs. analytical solution

numerical2.914*besj0(x/50*2.4048)

set xzeroaxisset border 3set tics scale 0.2set tics nomirrorset yrange [-0.1:3]set key bottom left Left reverseplot "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

flux

"full.dat"

0

0.5

1

1.5

2

2.5

3

Page 76: milonga

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

flux

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 flux shape vs. analytical solution

numerical2.914*besj0(x/50*2.4048)

4.1.4 Infinite reactor

An infinite reactor is an imaginary reactor that spans the whole universe and thus, the neutron fluxdoes not depend on the position. For the multigroup formulation, there is analytical expression forthe multiplicative factor, called k∞. This example uses a trick to fool milonga into thinking it has tosolve an two-group infinite reactor and illustrates how to obtain extra information about the problem.

kinf.mil

First, the analytical solution for a two-group infinite reactor with no upscattering

k∞ =νΣ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 inboth ends, thus forcing all the fluxes to be equal as in the infinite reactor. This is the first example ofa two-group energy problem. See how the downscattering therm is entered in the MATERIAL keyword.

Page 77: milonga

milonga v0.1

The main output of this example is the textfile with the debugging information, including an ASCIIrepresentation of the matrices of the problem, as catted in the terminal output.

# computation o f the k i n f i n i t e va lue o f a medium# in a 2−group problem formula t ion with no up s ca t t e r i n g#

# two−group XS as v a r i a b l e snuSigmaF1 = 5e−4SigmaA1 = 4e−3nuSigmaF2 = 5e−3SigmaA2 = 9e−3SigmaS12 = 8e−3

# ana l y t i c a l s o l u t i on#########################a n a l y t i c a l = nuSigmaF1/SigmaA1 + nuSigmaF2/SigmaA2 ∗ SigmaS12/SigmaA1

# numerical s o l u t i on##########################PROBLEM DIMENSIONS 1 GROUPS 2

# we need at l e a s t t h ree c e l l s : two fo r the boundary# cond i t i ons and one fo r the d i f f u s i o n equat ionx c e l l s = 3

# se t both l e f t and r i g h t bc to mirror , so a l l t h e o r e t i c a l# three c e l l s w i l l end up with the same neutron f l u x l e v e lBOUNDARY_CONDITIONS {X_MIN MIRRORX_MAX MIRROR}

# the bare l eng t h does not matter , because o f the# s e l e c t e d boundary cond i t i ons . However , t h i s va lue must# be d i f f e r e n t from zerox b a r e l e n g t h = 1

# dump informat ion in a t e x t f i l e , i n c l ud ing an a s c i i# repre s en ta t i on o f the matr ices o f the problemDEBUG i n f i n i t e . txt MATRICES_ASCII

ZONE r e a c t o r MATERIAL mix

# the va lue f o r the d i f f u s i o n c o e f f c i e n t i s i r r e l e v a n t# because the l a p l a c i an o f the f l u x i s i n d e n t i c a l l y zero# pay a t t en t i on to the d i f f e r e n c e between the keywords# and the v a r i a b l e s belowMATERIAL mix {

D 1 1nuSigmaF 1 nuSigmaF1SigmaT 1 SigmaA1

D 2 1nuSigmaF 2 nuSigmaF2SigmaT 2 SigmaA2

SigmaS 1 . 2 SigmaS12}

PRINT TEXT ” a n a l y t i c a l k e f f = ” a n a l y t i c a l FORMAT %.18 fPRINT TEXT ” numerica l k e f f = ” k e f f FORMAT %.18 fPRINT TEXT ” d i f f e r e n c e = ” abs ( a n a l y t i c a l−k e f f )

Page 78: milonga

milonga v0.1

$ milonga kinf.milanalytical keff = 1.236111111111111160numerical keff = 1.236111111110656635difference = 4.545253e-13$ cat infinite.txt------------------ ------------- ------milonga 0.1 (linux-i686)free nuclear reactor core analysis codedebugging and benchmarking output-------- ------- ----- ---- ---

execution date is Sat Jul 16 12:58:58 2011

invocation commandline was

milonga kinf.mil

--------- ------- ------ ---- ---spatial dimensions: 1

x_cells: 3delta_x: 3.333333e-01

energy groups: 2

problem size: 6

---------- ------ ----- ----boundary conditions

x directionleft: mirrorright: mirror

------------ ---------- --------- ------- ----- ←↩----

eigenvalue solution

solution method: krylovschur

number of requested eigenvalues: 1number of converged eigenvalues: 6

number of iterations of the method: 1number 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+000 0 -1.00e+00 0 +1.00e+00 00 0 0 -1.00e+00 0 +1.00e+00

Page 79: milonga

milonga v0.1

------------- ---------- ---------- -------fission matrix

0 0 0 0 0 00 0 0 0 0 00 0 +5.00e-04 +5.00e-03 0 00 0 0 0 0 00 0 0 0 0 00 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 variablesnuSigmaF1 = 5e-4SigmaA1 = 4e-3nuSigmaF2 = 5e-3SigmaA2 = 9e-3SigmaS12 = 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 equationx_cells = 3

# set both left and right bc to mirror, so all theoretical# three cells will end up with the same neutron flux levelBOUNDARY_CONDITIONS {X_MIN MIRRORX_MAX MIRROR}

# the bare length does not matter, because of the# selected boundary conditions. However, this value must# be different from zerox_bare_length = 1

# dump information in a text file, including an ascii# representation of the matrices of the problemDEBUG 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 belowMATERIAL mix {

D_1 1nuSigmaF_1 nuSigmaF1SigmaT_1 SigmaA1

Page 80: milonga

milonga v0.1

D_2 1nuSigmaF_2 nuSigmaF2SigmaT_2 SigmaA2

SigmaS_1.2 SigmaS12}

PRINT TEXT "analytical keff = " analytical FORMAT %.18fPRINT TEXT "numerical keff = " keff FORMAT %.18fPRINT 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 axialcoordinate as continuous algebraic functions of x in such a way that the neutron flux can be explicitlycomputed also as algebraic functions.

In particular, a non-dimensional slab reactor spanning the range [0, 1] subject to null boundaryconditions at x = 0 and mirror boundary conditions at x = 1 with the dimensionless cross sectionsvarying as

D(x) =1

2x2

Σa(x) = 21− x2− x

νΣf (x) =x2

2x− x2

gives rise to a critical reactor whose dimensionless flux spatial distribution—with mean value equalto one—is

φ(x) =3

2(2x− x2)

as can be checked by replacing the above expressions into

d

dx

(D(x) · dφ

dx

)+ [νΣf (x)− Σa(x)] · φ(x) = 0

Note that because of stability reasons, the diffusion coefficient has to be positive. In this case,D(x) = 0 for x = 0, but this value is never used in the evaluation of the diffusion equation.

20cells.mil

This example numerically solves the slab with continuously-changing properties and compares it to theanalytical solution. It illustrates for the first time how to enter cross-sections as algebraic expressionsof the spatial variables. It also shows how commandline replacement works. As it may be interestingto solve this problem using different schemes to compare their behavior, it would be a nice idea to beable to select options at run-time instead of having them hard-coded in the input file. The terminaloutput shows the execution of milonga with four combinations of scheme options, whose results areredirected to different files and then plotted into single figures for comparison.

# one−dimensional one−group s l a b with# cont inous ly−changing p rop e r t i e s## the numerical scheme opt ions shou ld be g iven in# the commandline#

Page 81: milonga

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 finite differences

"differences-mean-local.dat" u 1:21.5*(2*x-x**2)

# the an a l y t i c a l s o l u t i on to t h i s problem i s# phi ( x ) = 3/2 ∗ ( 2x − xˆ2 )# with k e f f = 1 ( rho = 0)#

PROBLEM DIMENSIONS 1 GROUPS 1

# to avoid f i x i n g the scheme opt ions in the input f i l e ,# the op t ions can be g iven from the commandline## $n ge t s rep laced by the n−th commandline argument# a f t e r the input f i l e . In t h i s case , i f l e s s than 3# ex t ra arguments are given , milonga q u i t s with an errorSCHEME $1 $2 $3

BOUNDARY_CONDITIONS X_MIN NULL X_MAX MIRROR

x b a r e l e n g t h = 1 # dimens ion les s widthx c e l l s = 20 # 20 s p a t i a l c e l l s

# smal l l en g t h tending to 0+ to use f o r the eva lua t i on o f# the D(x−/+ep s i l on ) c o e f f i c i e n t se p s i l on = 1e−2∗ x b a r e l e n g t h / x c e l l s

ZONE f u e l MATERIAL f u e l

# XS given as a l g e b r a i c expre s s i ons o f the coord inate xMATERIAL f u e l {

D 1 0 .5∗ xˆ2SigmaA 1 2∗(1−x ) /(2−x )nuSigmaF 1 x ˆ2/(2∗ x−x ˆ2)

}

# ana l y t i c a l s o l u t i on and r e l a t i v e errorFUNCTION phi ( x ) = 3/2 ∗ (2∗ x − x ˆ2)FUNCTION e r r o r ( x ) = ( f l u x 1 ( x ) − phi ( x ) ) / phi ( x )

# numerical r e a c t i v i t y ( shou ld be equa l to 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 to standard output but commented so# gnup lo t i gnores the l i n e . Note t ha t the hash i s escaped# to avoid milonga ignor ing the r e s t o f the l i n e ( i . e . i t# i s not a comment f o r milonga , i t i s a comment f o r gnup lo t )PRINT TEXT ”\# rho =” rho

# wri t e f l u x e s , e r ror s and XS d i s t r i b u t i o n s in to s tdou tPRINT_FUNCTION f l u x 1 phi e r r o r 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$

Page 82: milonga

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 finite differences

"differences-mean-local.dat" u 1:21.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

"differences-center-neighbor.dat" u 1:4"differences-mean-local.dat" u 1:4

Page 83: milonga

milonga v0.1

1000cells.mil

This example is similar to the previous ones, except that one thousand cells are used to show that thenumerical solution tends to the analytical one—especially keff—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 = 1000x b a r e l e n g t h = 1

ZONE f u e l MATERIAL f u e l

MATERIAL f u e l {D 1 0 .5∗ xˆ2SigmaA 1 2∗(1−x ) /(2−x )nuSigmaF 1 x ˆ2/(2∗ x−x ˆ2)

}

FUNCTION phi ( x ) = 3/2 ∗ (2∗ x − x ˆ2)FUNCTION e r r o r ( x ) = ( f l u x 1 ( x ) − phi ( x ) ) / phi ( x )

rho = ( k e f f −1)/ k e f f

PRINT TEXT ”\# rho =” rho k e f fPRINT_FUNCTION f l u x 1 e r r o r

$ 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 finite volumes using 1000 cells

numericalanalytical

4.1.6 Two-zone slab

Consider a one-dimensional one-speed two-zone slab of length b, composed of a material I with aninfinite multiplication factor less than one for 0 < x < a and of a material II with k∞ > 1 for

Page 84: milonga

milonga v0.1

a < x < b (a similar problem is discussed in reference [4]). These two materials have homogeneousproperties. It can be shown that the resulting flux distribution is

φ(x) =

sinh

[√1

DI

(νΣfI

keff− ΣaI

)· x

]if 0 ≤ x < a

sinh

[√1

DI

(νΣfI

keff− ΣaI

)· a

]

sin

[√1

DII

(ΣaII −

νΣfII

keff

)· (b− a)

] · sin[√

1

DII

(ΣaII −

νΣfII

keff

)· (b− x)

]if b < x ≤ b

where the effective multiplication factor keff is the solution of the critical condition

√DI

(νΣfI

keff− ΣaI

)· tan

[√1

DII

(ΣaII −

νΣfII

keff

)· (b− a)

]+√

DII

(ΣaII −

νΣfII

keff

)· tanh

[√1

DI

(νΣfI

keff− ΣaI

)· a

]= 0

If the diffusion coefficients are not equal, then there is a discontinuity in the flux at x = a. Thisproblem poses an interesting benchmark test for nodal methods.

twozone.mil

The two-zone slab problem is solved numerically with N = 200 cells and the obtained solution iscompared to the analytical flux distribution. The left half of the slab contains material I and theright half contains material II. This example shows on the one hand how to include more than onezone in milonga and on the other some of the mathematical capabilities that wasora provides in orderto obtain the non-trivial analytical keff and flux distribution φ(x) 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 infinities, thenumerical keff is chosen as the initial guess and a small interval around it is given as the expectedsolution range. The analytical solution is written as an ASCII representation of an algebraic functionthat can be directly entered into gnuplot. Also, a text file flux.dat is created with both the

Page 85: milonga

milonga v0.1

numerical and the analytical fluxes evaluated at the cell centers. Note that in this case, the interfacecoincides with a cell border. The user is encouraged to change the number of spatial cells and analyzehow the results change. In the parametric calculations section, this problem is revisited and how thedifference between the numerical and analytical solutions changes when the interface does not coincidewith cell borders.

# t h i s problem con s i s t s o f a one−dimensional one−speed two−zone s l a bPROBLEM DIMENSIONS 1 GROUPS 1

# geometry##################################a = 50 # width o f zone I−s t a r t o f zone I Ib = 100 # f u l l width

x b a r e l e n g t h = b

x c e l l s = 100

# cross s e c t i on s################################### de f ined as v a r i a b l e s to have them a v a i l a b l e f o r# computing the a n a l y t i c a l k e f fnu1 = 0.010nu2 = 0.015a1 = 0.015a2 = 0.010# note the d i f f e r e n c e between the two d i f f u s i o n# c o e f f i c i e n t s to s t r e s s the d i s c on t i nu i t y o f the# f l u x g rad i en td1 = 0 .5d2 = 1 .5

MATERIAL f u e l {D 1 d2SigmaT 1 a2nuSigmaF 1 nu2

}

MATERIAL rod {D 1 d1SigmaT 1 a1nuSigmaF 1 nu1

}

# zones##################################ZONE rod MATERIAL rod X_MIN 0 X_MAX aZONE f u e l MATERIAL f u e l X_MIN a X_MAX b

# ana l y t i c a l mu l t i p l i c a t i o n f a c t o r################################### in t e r v a l to look f o r the a n a l y t i c a l keps = 0.05

# eva lua t e k from the an a l y t i c a l c r i t i c a l cond i t i on# tak ing as an i n i t i a l guess the numerical k e f fk = k e f fk = root ( sqrt ( d1∗abs ( nu1/k−a1 ) ) ∗ tan ( sqrt ( (1/ d2 ) ∗abs ( a2−nu2/k ) ) ∗(b−a ) ) + sqrt ←↩

( d2∗abs ( a2−nu2/k ) ) ∗ tanh ( sqrt ( (1/ d1 ) ∗abs ( nu1/k−a1 ) ) ∗a ) , k , k e f f−eps , k e f f ←↩+eps )

# ana l y t i c a l f l u x d i s t r i b u t i o nB1 = sqrt (abs ( nu1/k−a1 ) /d1 )B2 = sqrt (abs ( nu2/k−a2 ) /d2 )FUNCTION phi1 ( x ) = sinh (B1∗x )FUNCTION phi2 ( x ) = sinh (B1∗a ) / sin (B2∗(b−a ) ) ∗ sin (B2∗(b−x ) )

Page 86: milonga

milonga v0.1

norm = b/( integral ( phi1 ( x ) , x , 0 , a ) + integral ( phi2 ( x ) , x , a , b ) )FUNCTION phi ( x ) = norm ∗ i f ( l ess ( x , a ) , phi1 ( x ) , phi2 ( x ) )FUNCTION e r r o r ( x ) = phi ( x )− f l u x 1 ( x )

PRINT TEXT ”\# copy and paste the f o l l o w i n g l i n e s in to gnuplot to obta in ”PRINT TEXT ”\# the cont inuous f l u x d i s t r i b u t i o n as a func t i on o f x”PRINT TEXT ” n u m e r i c a l k e f f =” k e f f FORMAT %.8 l fPRINT TEXT ” a n a l y t i c a l k e f f =” k FORMAT %.8 l fPRINT TEXT ” phi1 ( x ) = ” norm TEXT ” ∗ s inh ( ” B1 TEXT ” ∗ x ) ” SEPARATOR ” ”PRINT TEXT ” phi2 ( x ) = ” norm TEXT ” ∗ s inh ( ” B1∗a TEXT ” ) / s i n ( ” B2∗(b−a ) ←↩

TEXT ” ) ∗ s i n ( ” B2 TEXT ” ∗( ” b TEXT ”−x ) ) ” SEPARATOR ” ”PRINT TEXT ” phi ( x ) = ( x <” a TEXT ” ) ? phi1 ( x ) : phi2 ( x ) ” SEPARATOR ” ”

# pr in t f l u x 1 ( x ) , phi ( x ) and error ( x )FILE f l u x f l u x . datPRINT_FUNCTION FILE f l u x f l u x 1 phi e r r o r

$ milonga twozone.mil## copy and paste the following lines into gnuplot to obtain## the continuous flux distribution as a function of xnumerical_keff = 1.14799085analytical_keff = 1.14779361phi1(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

flux distribution

analyticalnumerical

Page 87: milonga

milonga v0.1

1

1.2

1.4

1.6

1.8

2

2.2

46 48 50 52 54

x

flux distribution (zoom at the interface)

analyticalnumerical

4.2 General problems

This section presents general cases that do not have analytical solution but nevertheless should befamiliar to the nuclear engineer. They mostly involve geometries with material boundaries, where theevaluation of cell cross sections and the leakage term affect the computational effort needed and theaccuracy of the solution in non-trivial ways. No three-dimensional example is given mainly becausethe 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 Reflected slab

After analyzing the bare slab, reactor physics theory courses focus on the reflected slab. The mostimportant concept to study in these kinds of problems is the loss of separability between energy andspace and the appearance of the so-called “thermal shoulder” due to the low absorption and heavydownscattering in the reflector material when using at least two energy groups. The example thatfollows solves the classic symmetric reflected slab shown in the figure, and the next two introducesome variations to illustrate different aspects.

symmetric.mil

The reflected slab shown in the figure using two energy groups is solved. The definition of the materialsis given in a separate file and included in the main input file to shorten its length and to share thecross sections with other input files. The materials file is shown in the terminal window.

Page 88: milonga

milonga v0.1

# symmetric two−group r e f l e c t e d s l a b

PROBLEM DIMENSIONS 1 GROUPS 2

a = 20 # r e f l e c t o r l eng t hx b a r e l e n g t h = 100x c e l l s = 100

# the XS can be conven i en t l y entered in to a separa te f i l e# and then inc luded in each problem d e f i n i t i o n inputINCLUDE m a t e r i a l s . mil

# f i r s t , we de f ine a zone tha t spans the whole s l a bZONE f u e l MATERIAL f u e l# and then we add the two r e f l e c t o r s# note t ha t the d e f a u l t behav ior i s to r ep l a ce the over l app ing# i n t e r v a l s wi th the new XS ( to have them added use the# INCREMENTAL keyword )ZONE r e f l 1 MATERIAL r e f l e c t o r X_MIN 0 X_MAX aZONE r e f l 2 MATERIAL r e f l e c t o r X_MIN x ba r e l eng t h−a X_MAX x b a r e l e n g t h

# pr in t the two f l u x e s to the standard outputPRINT_FUNCTION f l u x 1 f l u x 2

$ cat materials.milMATERIAL fuel {

D_1 1.500SigmaT_1 0.010nuSigmaF_1 0.000

D_2 0.400SigmaT_2 0.085nuSigmaF_2 0.135

SigmaS_1.2 0.020}

MATERIAL reflector {D_1 2.000SigmaT_1 0.000

D_2 0.300SigmaT_2 0.010

SigmaS_1.2 0.040}

MATERIAL rod {D_1 1.500SigmaT_1 0.010nuSigmaF_1 0.000

D_2 0.400SigmaT_2 0.130nuSigmaF_2 0.135

SigmaS_1.2 0.020}$ milonga symmetric.mil > symmetric.dat$ gnuplot symmetric.gnuplot$

Page 89: milonga

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 fluxes

fast fluxthermal flux

asymmetric.mil

More often than not, reactors are not symmetric. If they were, there would be no point in makingfull-core calculations like the one in the preceding example. A small variation to the problem above isto study what happens when the reactor is not symmetrically reflected, where a full-core calculationis mandatory.

# asymmetric r e f l e c t e d s l a b

PROBLEM DIMENSIONS 1 GROUPS 2

a = 20 # l e f t r e f l e c t o r l eng t hb = 10 # r i g h t r e f l e c t o r l eng t hx b a r e l e n g t h = 100x c e l l s = 100

INCLUDE m a t e r i a l s . mil

ZONE f u e l MATERIAL f u e lZONE r e f l 1 MATERIAL r e f l e c t o r X_MIN 0 X_MAX aZONE r e f l 2 MATERIAL r e f l e c t o r X_MIN x ba r e l eng t h−b X_MAX x b a r e l e n g t h

PRINT_FUNCTION f l u x 1 f l u x 2

$ milonga asymmetric.mil > asymmetric.dat$ gnuplot asymmetric.gnuplot$

Page 90: milonga

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 fluxes

fast fluxthermal flux

rod.mil

A final 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 notcoincide with the cell boundaries. Besides the flux distribution, this example shows both the totalcontinuous cross section as a function of x and the cell cross sections. A zoom over the control rodshows what happens at the cells that contain the material interfaces. As the default behavior is touse equation (2.35), the result is that the cell cross section is the weighted average of the adjacentmaterials.

# asymmetric r e f l e c t e d s l a b with a con t ro l rod

PROBLEM DIMENSIONS 1 GROUPS 2

a = 20 # l e f t r e f l e c t o r l eng t hb = 10 # r i g h t r e f l e c t o r l eng t hrod x = 40.123 # pos i t i on o f the rod centerrod w = 5.456 # t o t a l width o f the rod

# note t ha t the c e l l s are 1cm widthx b a r e l e n g t h = 100x c e l l s = 100

INCLUDE m a t e r i a l s . mil

ZONE f u e l MATERIAL f u e lZONE r e f l 1 MATERIAL r e f l e c t o r X_MIN 0 X_MAX aZONE r e f l 2 MATERIAL r e f l e c t o r X_MIN x ba r e l eng t h−b X_MAX x b a r e l e n g t h# the con t ro l r od po s i t i on ( in t h i s case the XS are abso lu te ,# had they been incremental , the KEYWORD incrementa l shou ld 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 u x 1 f l u x 2

# pr in t the continuous thermal SigmaA in contxs . dat# and the c e l l thermal SigmaA in c e l l x s . datFILE cont inuous contxs . datFILE c e l l c e l l x s . dat

# func t ion cSigmaT needs a range and step , the f i r s t argument# i s the energy group and the second one i s the x coord inate

Page 91: milonga

milonga v0.1

PRINT_FUNCTION cSigmaT MIN 2 0 MAX 2 x b a r e l e n g t h STEP 1 0 .01 FILE cont inuous

# func t ion SigmaT 2 does not need an e x p l i c i t rangePRINT_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 fluxes

fast fluxthermal flux

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 XScell XS

Page 92: milonga

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 XScell XS

4.2.2 Reflected circle

The next case to study is the reflected circle. The effects that appear here are pretty much the samethan the ones the appeared in the reflected slab. However, the fact of having a circular geometryembedded into a rectangular grid gives rise to interesting forms of material interfaces and the solutiondepends on the choice for evaluating the cell cross-sections and the leakage term.

reflected.mil

This example shows the difference of the results obtained by the two methods of evaluation cell crosssections, namely XS CENTER and XS MEAN. By using commandline replacement, the same input solvesa reflected circle with both methods and then the thermal absorption cross sections and the diffusioncoefficients for each cell are shown. Even though a nice “anti-aliasing” effect is obtained when usingXS MEAN, the computational effort to compute the mean values may be many times the effort neededto evaluate the parameters at the cell center without giving a significant 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 with d i f f e r e n t XS as so c i a t i on# prov ide e i t h e r XS CENTER or XS MEAN in the commandline

PROBLEM DIMENSIONS 2 GROUPS 2

SCHEME $1

x b a r e l e n g t h = 100y ba r e l e n g t h = x b a r e l e n g t h

Page 93: milonga

milonga v0.1 0

20

40

60

80

100

0 20 40 60 80 100

fast flux (cell center)

"xscenter.dat" u 1:2:5

0

1

2

3

4

5

6

7

# a low number o f c e l l s i s g iven to s tudy the c e l l XS# eva lua t i on schemex c e l l s = 40y c e l l s = x c e l l s

# r e f l e c t o r widtha = 20

INCLUDE m a t e r i a l s . mil

ZONE f u e l MATERIAL f u e l {X_CENTER x b a r e l e n g t h /2Y_CENTER x b a r e l e n g t h /2OUTER_RADIUS x b a r e l e n g t h /2

}

ZONE r e f l MATERIAL r e f l e c t o r {X_CENTER x b a r e l e n g t h /2Y_CENTER x b a r e l e n g t h /2INNER_RADIUS x b a r e l e n g t h /2−aOUTER_RADIUS x b a r e l e n g t h /2

}

PRINT_FUNCTION SigmaT 2 D 1 f l u x 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

Page 94: milonga

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 diffusion coefficient (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 flux (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 flux (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

Page 95: milonga

milonga v0.1 0

20

40

60

80

100

0 20 40 60 80 100

fast flux (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

fluxes (cell center)

fast fluxthermal flux

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 diffusion coefficient (cell average)

"xsmean.dat" u 1:2:4

0

0.5

1

1.5

2

Page 96: milonga

milonga v0.1

0

20

40

60

80

100

0 20 40 60 80 100

fast flux (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 flux (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

fluxes (cell average)

fast fluxthermal flux

Page 97: milonga

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, thatwould represent most of the cases of interest. As with the slab, first the continuous absorption crosssection is given, showing the real position of the absorbers. Afterward, the cell values using averagesare given, showing the antialiasing effect.

# r e f l e c t e d c i r c l e with some absorber sPROBLEM DIMENSIONS 2 GROUPS 2

x b a r e l e n g t h = 100y ba r e l e n g t h = x b a r e l e n g t hx c e l l s = 40y c e l l s = x c e l l s

a = 20 # r e f l e c t o r width

INCLUDE m a t e r i a l s . mil

ZONE f u e l MATERIAL f u e l {X_CENTER x b a r e l e n g t h /2Y_CENTER x b a r e l e n g t h /2OUTER_RADIUS x b a r e l e n g t h /2

}

ZONE r e f l MATERIAL r e f l e c t o r {X_CENTER x b a r e l e n g t h /2Y_CENTER x b a r e l e n g t h /2INNER_RADIUS x b a r e l e n g t h /2−aOUTER_RADIUS x b a r e l e n g t h /2

}

# these zones do not co inc ide with c e l l borders on purposeZONE rod1 MATERIAL rod {

X_MIN 51 .5 X_MAX 72 .2Y_MIN 20 .1 Y_MAX 30 .9

}

ZONE rod2 MATERIAL rod {X_CENTER 65 Y_CENTER 70OUTER_RADIUS 14 .75

}

ZONE rod3 MATERIAL rod {X_CENTER 34 .3Y_CENTER 57 .4OUTER_RADIUS 4 .12

}

# again , the c e l l XS do not need rangePRINT_FUNCTION SigmaT 2 D 1 f l u x 1 f l u x 2

# the continuous XS need ranges and s t e p s . The f i r s t argument# i s the energy group , the second i s x and the t h i r d i s yFILE cont cont . datPRINT_FUNCTION FILE cont cSigmaT MIN 2 0 0 MAX 2 x b a r e l e n g t h y b a r e l e n g t h ←↩

STEP 1 0 .1∗ x b a r e l e n g t h / x c e l l s 0 .1∗ y ba r e l e n g t h / x c e l l s

$ milonga rods.mil > rods.dat$ gnuplot xsrods.gnuplot$ gnuplot 3drods.gnuplot$

Page 98: milonga

milonga v0.1 0

20

40

60

80

100

0 20 40 60 80 100

fast flux

"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 diffusion coefficient

"rods.dat" u 1:2:4

0

0.5

1

1.5

2

Page 99: milonga

milonga v0.1

0

20

40

60

80

100

0 20 40 60 80 100

fast flux

"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 flux

"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

fluxes

fast fluxthermal flux

Page 100: milonga

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 besolved is the so-called two-dimensional LWR Benchmark Problem with identification 11-A2 describedin reference [5]. This problem represents the mid-plane z = 190 cm of the 3D IAEA BenchmarkProblem that will be included as an example is future versions of milonga. The 3D problem is astandard benchmark and its solution using with different modern codes can be found, amongst otherdocuments, in [6, 7, 8]. The original reference [5] provides also a collection of solutions obtained withlegacy codes.

Quoting the original problem definition [5, page 437],

Reduction of Source Situation:

1. Two-group diffusion theory

2. Two-dimensions (x, y)-geometry

Two-Group Diffusion Equations:

−∇D1∇φ1 + (Σa1 + Σ1→2 +D1B2z1)φ1 =

1

λνΣf2 φ2

−∇D2∇φ2 + (Σa2 +D2B2z2)φ2 = Σ1→2φ1

Data (see figure).Axial buckling B2

zg = 0.8 · 10−4 for all regions an energy groups

Boundary conditions J ing = 0 no incoming current at external boundaries. For finite

difference diffusion theory codes the following form is considered equivalent

∂φg∂n

= −0.4682

Dgφg

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

∂φg∂n

= 0

1

23

4

10 7030 50 90 110 130 150 170 cm

10

70

90

130

150

170

cm

3

3 3

Page 101: milonga

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

Reflector

Material

Two-group Constants

iaea2dpwr.mil

The following input file solves the 2D IAEA PWR benchmark described above. The original problemasks for a number of results that can all be computed by milonga, but for simplicity reasons only themultiplication factor, flux 2D distribution φ(x, y) and radial profiles trough the horizontal axis φ(x, 0)and through the diagonal φ(x, x) as a function of x are given. The axial buckling is inserted as amodification to the absorption cross section in the material file. The diffusion equation is solved usingthe finite volumes scheme. As the material interfaces coincide with cell borders, cell cross sections arecomputed with the center method and currents are computed using the diffusion coefficient evaluatedat a distance ε. An analysis of how the results—including calculation times–change with the meshsize can be easily performed by using parametric calculations over the variable c that controls themesh refinement, as shown in the next section. Boundary conditions are set to null flux at theexternal boundary and mirror conditions at x = 0 and y = 0 as to represent one quarter of the core.The flux profile along the x axis is computed at y = ∆y/2 instead of at y = 0 to avoid spendingtime interpolating by asking for the value the fluxes take exactly at a cell center. The result is thesame, because the mirror boundary condition at y = 0 sets φ(x,−∆y/2) = φ(x,∆y/2) and thusφ(x, 0) = φ(x,∆y/2).

# IAEA 2D PWR benchmark# ANL−7416 Supplement 2 , 1977 , Argonne Code Center :# Benchmark Problem Book , page 437

# two s p a t i a l dimensions and two energy groupsPROBLEM DIMENSIONS 2 GROUPS 2

# as the mater ia l i n t e r f a c e s co inc ide with c e l l borders ,# the s e l e c t i o n o f XS CENTER and XS MEAN g i v e s the same c e l l XS# a l so D EPSILON and DMEAN g i v e the same curren t s# t h i s op t ions reduce computation time as they avoid i n t e g r a t i o n sSCHEME XS_CENTER D_EPSILON

# bare l eng t h in cm as de f ined in the problemx ba r e l e n g t h = 170y ba r e l e n g t h = 170

# mesh ref inement f a c t o r : the h igher t h i s va lue the f i n e r the meshc = 2 .0

x c e l l s = c∗ x b a r e l e n g t hy c e l l s = x c e l l sde l tax = x b a r e l e n g t h / x c e l l sde l tay = y ba r e l e n g t h / y c e l l s

# a quar ter core in the f i r s t x−y quadrantBOUNDARY_CONDITIONS X_MIN MIRROR X_MAX NULL Y_MIN MIRROR Y_MAX NULL

# zone d e f i n t i o n# new zones ove r r i de prev ious ones when they over lap# note t ha t Y MIN d e f a u l t s to zeroZONE r e f l 1 MATERIAL r e f l e c t o r X_MIN 0 X_MAX 70 Y_MAX 170

Page 102: milonga

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 150ZONE r e f l 3 MATERIAL r e f l e c t o r X_MIN 110 X_MAX 130 Y_MAX 130ZONE r e f l 4 MATERIAL r e f l e c t o r X_MIN 130 X_MAX 150 Y_MAX 110ZONE 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 u e l 2 1 MATERIAL f u e l 1 X_MIN 0 X_MAX 50 Y_MAX 150ZONE f u e l 2 2 MATERIAL f u e l 1 X_MIN 50 X_MAX 90 Y_MAX 130ZONE f u e l 2 3 MATERIAL f u e l 1 X_MIN 90 X_MAX 110 Y_MAX 110ZONE f u e l 2 4 MATERIAL f u e l 1 X_MIN 110 X_MAX 130 Y_MAX 90ZONE f u e l 2 5 MATERIAL f u e l 1 X_MIN 130 X_MAX 150 Y_MAX 50

ZONE f u e l 1 1 MATERIAL f u e l 2 X_MIN 0 X_MAX 30 Y_MAX 130ZONE f u e l 1 2 MATERIAL f u e l 2 X_MIN 30 X_MAX 70 Y_MAX 110ZONE f u e l 1 3 MATERIAL f u e l 2 X_MIN 70 X_MAX 110 Y_MAX 70ZONE f u e l 1 4 MATERIAL f u e l 2 X_MIN 110 X_MAX 130 Y_MAX 30

ZONE f u e l r o d 1 MATERIAL f u e l 2 r o d X_MIN 0 Y_MIN 0 X_MAX 10 Y_MAX 10ZONE f u e l r o d 2 MATERIAL f u e l 2 r o d X_MIN 0 Y_MIN 70 X_MAX 10 Y_MAX 90ZONE f u e l r o d 3 MATERIAL f u e l 2 r o d X_MIN 70 Y_MIN 0 X_MAX 90 Y_MAX 10ZONE f u e l r o d 4 MATERIAL f u e l 2 r o d X_MIN 70 Y_MIN 70 X_MAX 90 Y_MAX 90

# the mate r ia l s are inc luded in a d i f f e r e n t f i l e# in order to be shared between other input f i l e sINCLUDE m a t e r i a l s . mil

# ex t r a c t one−dimensional p r o f i l e s from the f l u x e s# the d e l t a y /2 i s to save time in making# a mul t id imens iona l i n t e r p o l a t i o n by ask ing# for va lue s e x a c t l y at a c e l l cen terFUNCTION f a s t p r o f i l e ( x ) = f l u x 1 ( x , d e l tay /2)FUNCTION t h e r m a l p r o f i l e ( x ) = f l u x 2 ( x , d e l tay /2)

FUNCTION f a s t d i a g o n a l ( x ) = f l u x 1 ( x , x )FUNCTION thermald iagona l ( x ) = f l u x 2 ( x , x )

# output some informat ion to the screenPRINT TEXT ” k e f f = ” k e f f FORMAT %.8 l fPRINT TEXT ” bu i ld t ime = ” bu i l d t ime TEXT ” seconds ” FORMAT %.4 l fPRINT TEXT ” s o l v e t i m e = ” s o l v e t ime TEXT ” seconds ” FORMAT %.4 l fPRINT TEXT ” t o t a l t i m e = ” bu i l d t ime+s o l v e t ime TEXT ” seconds ” FORMAT %.4 l f

# two−dimensional f l u x d i s t r i b u t i o n and t o t a l thermal XSFILE f l u x f l u x . datPRINT_FUNCTION FILE f l u x f l u x 1 f l u x 2 SigmaT 2

# f l u x p r o f i l e sFILE p r o f i l e p r o f i l e . datFILE d iagona l d iagona l . dat

# these are a l g e b r a i c func t ions , a range i s mandatory# the range and s t ep are s e l e c t e d again to avoid i n t e r p o l a t i o nPRINT_FUNCTION FILE p r o f i l e f a s t p r o f i l e t h e r m a l p r o f i l e MIN de l tax /2 MAX ←↩

x ba r e l eng t h−de l tax /2 STEP de l taxPRINT_FUNCTION FILE d iagona l f a s t d i a g o n a l thermald iagona l MIN de l tax /2 MAX ←↩

x ba r e l eng t h−de l tax /2 STEP de l tax

$ 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_gˆ2 term in the# absorption cross section

MATERIAL fuel1 {D_1 1.500D_2 0.400SigmaS_1.2 0.020

Page 103: milonga

milonga v0.1

SigmaA_1 0.010+1.5*0.8e-4SigmaA_2 0.080+0.4*0.8e-4nuSigmaF_2 0.135

}

MATERIAL fuel2 {D_1 1.500D_2 0.400SigmaS_1.2 0.020SigmaA_1 0.010+1.5*0.8e-4SigmaA_2 0.085+0.4*0.8e-4nuSigmaF_2 0.135

}

MATERIAL fuel2rod {D_1 1.500D_2 0.400SigmaS_1.2 0.020SigmaA_1 0.010+1.5*0.8e-4SigmaA_2 0.130+0.4*0.8e-4nuSigmaF_2 0.135

}

MATERIAL reflector {D_1 2.000D_2 0.300SigmaS_1.2 0.040+2.0*0.8e-4SigmaA_1 0.000+0.3*0.8e-4SigmaA_2 0.010nuSigmaF_2 0.000

}$ milonga iaea2dpwr.milkeff = 1.02990385build_time = 4.1996 secondssolve_time = 5.0606 secondstotal_time = 9.2602 seconds$ gnuplot iaea2d.gnuplot$ gnuplot profile.gnuplot$

Page 104: milonga

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

norm

aliz

ed

non

-dim

en

sion

al flu

x

x (as asked, not r)

flux profiles along the diagonal

fastthermal

0

20

40

60

80

100

120

140

160

0 20 40 60 80 100 120 140 160

thermal total XS

"flux.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 flux

"flux.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 flux

"flux.dat" u 1:2:4

0

0.2

0.4

0.6

0.8

1

1.2

1.4

1.6

Page 105: milonga

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

norm

aliz

ed

non-d

imensi

onal flux

x

flux profiles along the x axis

fastthermal

0

0.5

1

1.5

2

2.5

3

3.5

4

0 20 40 60 80 100 120 140 160

norm

aliz

ed n

on-d

imensi

onal flux

x (as asked, not r)

flux profiles along the diagonal

fastthermal

circle.mil

A small variation of the 2D IAEA PWR Benchmark—that is also applicable to the 3D problem—isthe replacement of the external reflector boundary by a circle instead of a coarse 17× 17 rectangularapproximation. Of course, this requirement was not possible thirty five years ago, but nowadayscircular reflectors should be bread and butter for core codes. This example shows one of the vectorsof milonga’s design basis in action, namely the Independence of the problem geometry and the spatialnodalization. A lower mesh refinement factor c = 0.5 is chosen to show how the circle is automaticallytranslated into the rectangular mesh. There is no need to use XS MEAN because mainly the only cellswhose cross sections will differ from the center value are those in the external boundary of the coreand 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.

# Variat ion o f the IAEA 2D PWR benchmark# quar ter core with c i r c u l a r r e f l e c t o r

PROBLEM DIMENSIONS 2 GROUPS 2SCHEME XS_CENTER D_EPSILON

Page 106: milonga

milonga v0.1 0

20

40

60

80

100

120

140

160

0 20 40 60 80 100 120 140 160

fast flux

"circflux.dat" u 1:2:3

0

0.5

1

1.5

2

2.5

3

3.5

4

4.5

x b a r e l e n g t h = 170y ba r e l e n g t h = 170

# mesh ref inement f a c t o rc = 0 .5

x c e l l s = c∗ x b a r e l e n g t hy c e l l s = x c e l l sde l tax = x b a r e l e n g 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 th a c i r c u l a r r e f l e c t o rZONE r e f l MATERIAL r e f l e c t o r X_CENTER 0 Y_CENTER 0 RADIUS 170

# and then add the f u e l e lements in t h e i r correspnding square g r i d sZONE f u e l 2 1 MATERIAL f u e l 1 X_MIN 0 X_MAX 50 Y_MAX 150ZONE f u e l 2 2 MATERIAL f u e l 1 X_MIN 50 X_MAX 90 Y_MAX 130ZONE f u e l 2 3 MATERIAL f u e l 1 X_MIN 90 X_MAX 110 Y_MAX 110ZONE f u e l 2 4 MATERIAL f u e l 1 X_MIN 110 X_MAX 130 Y_MAX 90ZONE f u e l 2 5 MATERIAL f u e l 1 X_MIN 130 X_MAX 150 Y_MAX 50

ZONE f u e l 1 1 MATERIAL f u e l 2 X_MIN 0 X_MAX 30 Y_MAX 130ZONE f u e l 1 2 MATERIAL f u e l 2 X_MIN 30 X_MAX 70 Y_MAX 110ZONE f u e l 1 3 MATERIAL f u e l 2 X_MIN 70 X_MAX 110 Y_MAX 70ZONE f u e l 1 4 MATERIAL f u e l 2 X_MIN 110 X_MAX 130 Y_MAX 30

ZONE f u e l r o d 1 MATERIAL f u e l 2 r o d X_MIN 0 Y_MIN 0 X_MAX 10 Y_MAX 10ZONE f u e l r o d 2 MATERIAL f u e l 2 r o d X_MIN 0 Y_MIN 70 X_MAX 10 Y_MAX 90ZONE f u e l r o d 3 MATERIAL f u e l 2 r o d X_MIN 70 Y_MIN 0 X_MAX 90 Y_MAX 10ZONE f u e l r o d 4 MATERIAL f u e l 2 r o d X_MIN 70 Y_MIN 70 X_MAX 90 Y_MAX 90

INCLUDE m a t e r i a l s . mil

PRINT TEXT ” k e f f = ” k e f f FORMAT %.8 l fPRINT TEXT ” bu i ld t ime = ” bu i l d t ime TEXT ” seconds ” FORMAT %.4 l fPRINT TEXT ” s o l v e t i m e = ” s o l v e t ime TEXT ” seconds ” FORMAT %.4 l fPRINT TEXT ” t o t a l t i m e = ” bu i l d t ime+s o l v e t ime TEXT ” seconds ” FORMAT %.4 l f

FILE f l u x c i r c f l u x . datPRINT_FUNCTION FILE f l u x f l u x 1 f l u x 2 SigmaT 2

$ milonga circle.milkeff = 1.03089876build_time = 0.2296 secondssolve_time = 0.1351 secondstotal_time = 0.3647 seconds$ gnuplot circle.gnuplot$

Page 107: milonga

milonga v0.1

0

20

40

60

80

100

120

140

160

0 20 40 60 80 100 120 140 160

thermal total XS

"circflux.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 flux

"circflux.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 flux

"circflux.dat" u 1:2:4

0

0.2

0.4

0.6

0.8

1

1.2

1.4

1.6

Page 108: milonga

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 afictitious Pressurized Heavy Water Reactor. This solved case shows some other features of milongathat may be handy when tackling similar problems. Although this example is loosely based on a realreactor, the actual data is less than random and of course the results presented here do not have anyphysical significance.

In this kind of reactors, one of the most important parameters that control the actual spatialcross-section dependance inside the core is the fuel burnup, as the spatial distribution of this latterproperty depends on the online fuel refueling and shuffling strategy. The core consists of a numberof 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 suchas temperatures, xenon and fuel burnup. In this problem, only dependance on burnup is taken intoaccount, whilst xenon and temperatures dependance are illustrated in sections that are about tocome. There is a circular reflector surrounding the core and there are four pipes for the moderatorloop, whose temperature is not taken into account. There are eighteen circular control rods, of whichonly six circular are inserted at the considered plane. However, guide tubes for the withdrawn rodsare also considered. There are also fifteen lances containing in-core instrumentation that introduceextra absorbing materials in the core.

core

reflector

neutron detector

inserted control rod

2dphwr.mil

First, the fuel burnup is read and interpolated from a text file that gives the location of each channeland the burnup at the axial plane considered. One-dimensional functions of burnup are read andinterpolated from a big multi-column file containing macroscopic cross sections as a function of burnup.Materials are defined 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, someinformation is written to files while keff 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 the burnup i s not r e a l l y i n t e r p o l a t e d but con t inuous l y# f i l l e d with the c l o s e s t va lue ( see below ) , i t makes no sense# to waste CPU time using XS MEANSCHEME XS_CENTER D_EPSILON

# a bare square 7m longx b a r e l e n g t h = 700y ba r e l e n g t h = 700

Page 109: milonga

milonga v0.1

# square c e l l sx c e l l s = 200y c e l l s = x c e l l s

# the f u e l burnup i s g iven as a continuous func t i on read from# a f i l e , whose content can be seen in the termina l screen# in t 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 to save computation time# and avoid e x t r apo l a t i on problems at the outer par t s o f the core# columns o f burnup . dat are [cm] [cm] [MWday/ ton ]FUNCTION burnup ( x , y ) FILE burnup . dat INTERPOLATION c l o s e s t

# these func t i ons g i v e the core cross s e c t i on s as a func t i on o f# the s i n g l e parameter burnup ( temperatures , xenon , e t c are not# i l l u s t r a t e d here but cou ld be taken in to account a l s o )# XS un i t s are 1/cm and bu un i t s are MWday/ tonFUNCTION D1(bu) FILE xs . dat INTERPOLATION s p l i n e s COLUMNS 1 2FUNCTION D2(bu) FILE xs . dat INTERPOLATION s p l i n e s COLUMNS 1 3FUNCTION SigmaA1 (bu) FILE xs . dat INTERPOLATION s p l i n e s COLUMNS 1 4FUNCTION SigmaS12 (bu) FILE xs . dat INTERPOLATION s p l i n e s COLUMNS 1 5FUNCTION SigmaS21 (bu) FILE xs . dat INTERPOLATION s p l i n e s COLUMNS 1 6FUNCTION SigmaA2 (bu) FILE xs . dat INTERPOLATION s p l i n e s COLUMNS 1 7FUNCTION nuSigmaF1 (bu) FILE xs . dat INTERPOLATION s p l i n e s COLUMNS 1 8FUNCTION nuSigmaF2 (bu) FILE xs . dat INTERPOLATION s p l i n e s COLUMNS 1 9

# rad i a l r e f l e c t o r p r op e r t i e s are homogeneousMATERIAL r e f l e c t o r {D 1 1.405310E+01D 2 9.666628E−01SigmaA 1 4.107654E−06SigmaS 1 . 2 1 .090063E−02SigmaS 2 . 1 1 .088030E−04SigmaA 2 4.908041E−05}

# core p rop e r t i e s depend on burnup onlyMATERIAL fuelmod {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 ) )}

# incrementa l con t ro l rod XSMATERIAL rod {

SigmaA 1 1.957196E−03SigmaA 2 7.339746E−03SigmaS 1 . 2 −7.986794E−04SigmaS 2 . 1 2 .732369E−05nuSigmaF 1 −4.314411E−05nuSigmaF 2 5.649112E−04

}

# incrementa l con t ro l rod guide tube XSMATERIAL guide {

SigmaA 1 −1.102107E−04SigmaA 2 9.838934E−05SigmaS 1 . 2 −1.378342E−04SigmaS 2 . 1 1 .513809E−06nuSigmaF 1 −5.002725E−06nuSigmaF 2 1.110945E−05

}

# absou l t e XS fo r the d e t e c t o r sMATERIAL de t e c t o r {

D 1 1

Page 110: milonga

milonga v0.1

D 2 1SigmaA 1 1e−3SigmaA 2 1e−2SigmaS 1 . 2 1e−4SigmaS 2 . 1 0

}

# f i r s t d e f i ne the r e f l e c t o r (downcomer) as a b i g c i r c l eZONE 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 with a sma l l e r c i r c l e r ep re s en t ing the coreZONE core MATERIAL fuelmod X_CENTER 350 Y_CENTER 350 RADIUS 305# four c i r c l e s to ho ld the moderator p ipesZONE mod1 MATERIAL r e f l e c t o r X_CENTER 430 Y_CENTER 60 RADIUS 35ZONE mod2 MATERIAL r e f l e c t o r X_CENTER 640 Y_CENTER 270 RADIUS 35ZONE mod3 MATERIAL r e f l e c t o r X_CENTER 290 Y_CENTER 640 RADIUS 35ZONE mod4 MATERIAL r e f l e c t o r X_CENTER 60 Y_CENTER 450 RADIUS 35

# guide tubes f o r the 18 con t ro l rodsZONE tube1 MATERIAL guide X_CENTER 217 Y_CENTER 389 RADIUS 15 INCREMENTALZONE tube2 MATERIAL guide X_CENTER 177 Y_CENTER 353 RADIUS 15 INCREMENTALZONE tube3 MATERIAL guide X_CENTER 272 Y_CENTER 377 RADIUS 15 INCREMENTALZONE tube4 MATERIAL guide X_CENTER 299 Y_CENTER 507 RADIUS 15 INCREMENTALZONE tube5 MATERIAL guide X_CENTER 245 Y_CENTER 471 RADIUS 15 INCREMENTALZONE tube6 MATERIAL guide X_CENTER 367 Y_CENTER 495 RADIUS 15 INCREMENTALZONE tube7 MATERIAL guide X_CENTER 435 Y_CENTER 436 RADIUS 15 INCREMENTALZONE tube8 MATERIAL guide X_CENTER 449 Y_CENTER 507 RADIUS 15 INCREMENTALZONE tube9 MATERIAL guide X_CENTER 408 Y_CENTER 412 RADIUS 15 INCREMENTALZONE tube10 MATERIAL guide X_CENTER 517 Y_CENTER 318 RADIUS 15 INCREMENTALZONE tube11 MATERIAL guide X_CENTER 503 Y_CENTER 389 RADIUS 15 INCREMENTALZONE tube12 MATERIAL guide X_CENTER 463 Y_CENTER 271 RADIUS 15 INCREMENTALZONE tube13 MATERIAL guide X_CENTER 381 Y_CENTER 224 RADIUS 15 INCREMENTALZONE tube14 MATERIAL guide X_CENTER 449 Y_CENTER 212 RADIUS 15 INCREMENTALZONE tube15 MATERIAL guide X_CENTER 381 Y_CENTER 271 RADIUS 15 INCREMENTALZONE tube16 MATERIAL guide X_CENTER 258 Y_CENTER 259 RADIUS 15 INCREMENTALZONE tube17 MATERIAL guide X_CENTER 258 Y_CENTER 200 RADIUS 15 INCREMENTALZONE tube18 MATERIAL guide X_CENTER 217 Y_CENTER 294 RADIUS 15 INCREMENTAL

# s i x i n s e r t e d con t ro l rodsZONE rod1 MATERIAL rod X_CENTER 177 Y_CENTER 353 RADIUS 15 INCREMENTALZONE rod2 MATERIAL rod X_CENTER 258 Y_CENTER 200 RADIUS 15 INCREMENTALZONE rod3 MATERIAL rod X_CENTER 449 Y_CENTER 212 RADIUS 15 INCREMENTALZONE rod4 MATERIAL rod X_CENTER 449 Y_CENTER 507 RADIUS 15 INCREMENTALZONE rod5 MATERIAL rod X_CENTER 245 Y_CENTER 471 RADIUS 15 INCREMENTALZONE rod6 MATERIAL rod X_CENTER 517 Y_CENTER 318 RADIUS 15 INCREMENTAL

# f i f t e e n in−core d e t e c t o r sZONE det1 MATERIAL de t e c t o r X_CENTER 299 Y_CENTER 365 RADIUS 5ZONE det2 MATERIAL de t e c t o r X_CENTER 394 Y_CENTER 389 RADIUS 5ZONE det3 MATERIAL de t e c t o r X_CENTER 367 Y_CENTER 342 RADIUS 5ZONE det4 MATERIAL de t e c t o r X_CENTER 272 Y_CENTER 318 RADIUS 5ZONE det5 MATERIAL de t e c t o r X_CENTER 367 Y_CENTER 459 RADIUS 5ZONE det6 MATERIAL de t e c t o r X_CENTER 435 Y_CENTER 294 RADIUS 5ZONE det7 MATERIAL de t e c t o r X_CENTER 231 Y_CENTER 412 RADIUS 5ZONE det8 MATERIAL de t e c t o r X_CENTER 463 Y_CENTER 436 RADIUS 5ZONE det9 MATERIAL de t e c t o r X_CENTER 326 Y_CENTER 224 RADIUS 5ZONE det10 MATERIAL de t e c t o r X_CENTER 177 Y_CENTER 483 RADIUS 5ZONE det11 MATERIAL de t e c t o r X_CENTER 558 Y_CENTER 459 RADIUS 5ZONE det12 MATERIAL de t e c t o r X_CENTER 340 Y_CENTER 129 RADIUS 5ZONE det13 MATERIAL de t e c t o r X_CENTER 190 Y_CENTER 247 RADIUS 5ZONE det14 MATERIAL de t e c t o r X_CENTER 367 Y_CENTER 554 RADIUS 5ZONE det15 MATERIAL de t e c t o r X_CENTER 531 Y_CENTER 271 RADIUS 5

# output f i l e sFILE xsburn xsburnup . dat # 1D−dependance o f XS with burnupFILE burnup burnup−i n t e r p o l a t e d . dat # 2D d i s t r i b u t i o n o f i n t e r p o l a t e d burnupFILE x s d i s t x s d i s t . dat # 2D d i s t r i b u t i o n o f c e l l s XSFILE s o l u t i o n s o l u t i o n . dat # 2D f l u x d i s t r i b u t i o n

Page 111: milonga

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-fission XS vs burnup

fastthermal

# a l t hough t range i s op t iona l , i t i s g iven to e x p l i c i t l y show tha t# the se func t i ons are i n t e r p o l a t e d as a func t i on o f the burnup# tha t may take v i r t u a l l y any range between 0 and 10000# in the gnup lo t input , f i l e xs . dat with the ac tua l d e f i n i t i o n# po in t s i s p l o t t e d over the continuous s p l i n e i n t e r p o l a t i o nPRINT_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 n t e r p o l a t e d from burnup . dat# range i s op t i ona l but g iven in order to e x p l i c i t l y show how# the i n t e r p o l a t i o n method ” c l o s e s t ” workPRINT_FUNCTION FILE burnup burnup MIN 0 0 MAX x b a r e l e n g t h y b a r e l e n g t h STEP ←↩

x b a r e l e n g t h / x c e l l s y b a r e l e n g t h / y c e l l s

# c e l l XS d i s t r i b u t i o nPRINT_FUNCTION FILE x s d i 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 nPRINT_FUNCTION FILE s o l u t i o n f l u x 1 f l u x 2

PRINT TEXT ” k e f f = ” k e f f FORMAT %.6 l fPRINT TEXT ” time = ” bu i l d t ime TEXT ” + ” s o l v e t ime TEXT ” = ” bu i l d t ime+ ←↩

s o l v e t ime 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/ton354 353 5144.0381 353 9069.8367 377 6109.6340 377 7906.5326 353 6500.9340 330 8620.4367 330 7354.4394 377 4259.6$ milonga 2dphwr.milkeff = 1.003979time = 36.07 + 1.77 = 37.84 seconds$ gnuplot xs.gnuplot$ gnuplot 2dxs.gnuplot$ gnuplot solution.gnuplot$

Page 112: milonga

milonga v0.1 0

100

200

300

400

500

600

700

0 100 200 300 400 500 600 700

thermal nu-fission 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

fastthermal

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-fission XS vs burnup

fastthermal

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

Page 113: milonga

milonga v0.1 0

100

200

300

400

500

600

700

0 100 200 300 400 500 600 700

thermal flux

"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-fission 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

Page 114: milonga

milonga v0.1

0

100

200

300

400

500

600

700

0 100 200 300 400 500 600 700

fast flux

"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 flux

"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 parametersto obtain results as a function of them. This feature may be used for example to perform sensitivityanalysis, build design maps and optimize parameters. The problems shown below have analyticalsolutions and the parameter varied systematically has to do the geometry and the nodalization. Thisway, the problems are kept simple, the expected solution is known a priori and some insights about howmilonga works and what results are to be expected are shown. Engineering analysis would includehigher 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 thistool. The more, the merrier.

4.3.1 Grid size effects

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 keff

as a function of the number of cells used in the spatial discretization. All the cases use the same

Page 115: milonga

milonga v0.1

material—an hypothetical fuel mixture with k∞ = 1.2—spanning the whole bare space. In the lastexample, a comparison between the results obtained for the three dimensions as a function of theproblem size is performed.

1d.mil

A one-speed one-dimensional bare homogeneous slab is solved by parametrically varying the number ofcells. The file materials.mil is shared between the three examples of this section, so it is shown inthe terminal view. For each step, the output is a single line in the standard output. It consists of eightcolumns, namely the number of cells in the x-direction, the size of the problem (equal to the numberof cells in this case but different for higher-order problems), the numerical keff, the analytical keff (thatdoes not depend on x cells but is printed in each step to ease the plot procedure), the time neededto build the matrices, the time needed to solve the eigenvalue problem and the total time. Becauseno MAX DAUGHTERS keyword was entered, the calculation is done in series, i.e. each step starts onlyafter the last one has finished. Therefore, the output lines will be ordered by increasing x cells. Ifthis had not be the case, output should have been written to files and then ordered from the shell,as explained in chapter 3. Conclusions about the results shown in the figures are up to the user, butnote that even though the problem size scales linearly, square matrices of size N × N usually scaleas N2.

# parametric s tudy o f a bare s l a b with r e spec t to# the number o f c e l l sPROBLEM DIMENSIONS 1 GROUPS 1

# perform a parametric s tudy on x c e l l s from 10# up to 5000 with an add i t i v e increment o f 50PARAMETRIC x c e l l s 10 5000 50

SCHEME DIFFERENCES XS_CENTER GRAD_D_LOCAL

# 100 a r b i t r a r y un i t s widthx b a r e l e n g t h = 100# t h i s assignment i s ignored in a parametric# ca l cu l a t i on , however i f one wants to comment# the PARAMETRIC keyword above , i t i s handy to# maintain t h i s l i n e to prevent milonga from f a i l i n gx c e l l s = 100

# mater ia l s and zonesINCLUDE m a t e r i a l s . milZONE f u e l MATERIAL f u e l

# ana l y t i c a l s o l u t i on ( v a r i a b l e s are de f ined in# the mate r ia l s . mil f i l e )pi = 4∗atan (1 )k = nuSigmaF /(SigmaA + D∗( p i / x b a r e l e n g t h ) ˆ2)

# in each s t ep p r in t one l i n e as the output to# obta in how a l l t h e se s t u f f depend on x c e l l sPRINT x c e l l s x c e l l s k e f f k k e f f−k bu i l d t ime so l v e t ime bu i l d t ime+ ←↩

s o l v e t ime

$ cat materials.milD = 1SigmaA = 1e-2nuSigmaF = 1.2e-2

MATERIAL fuel {D_1 DSigmaA_1 SigmaA

Page 116: milonga

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

keff

number of cells in the x direction

numerical and analytical keff vs cell number - 1D

analyticalnumerical

1e-09

1e-08

1e-07

1e-06

1e-05

1e-04

1e-03

0 1000 2000 3000 4000 5000

abso

lute

err

or

number of cells in the x direction

difference between the numerical and analytical keff

error

Page 117: milonga

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

tim

e [

seg

]

number of cells in the x direction

solution time vs cell number - 1D

build timesolve timetotal time

2d.mil

The two-dimensional bare slab is studied parametrically as a function of the number of cells in thex-direction. In this case, the number of cells in the y-direction is the same as in the x-direction,so the problem size scales as the square of x cells. Same figure as for the one-dimensional casesare produced. For fun, compare how the results depend on the number of cells with respect to theprevious case, taking into account the same remark regarding N ×N and N2.

# parametric s tudy o f a bare square with r e spec t to# the number o f c e l l sPROBLEM DIMENSIONS 2 GROUPS 1

# the problem s i z e s c a l e s with x c e l l s ˆ2 so# the range has to be chosen c a r e f u l l y to avoid# running out o f memoryPARAMETRIC x c e l l s 10 250 10

SCHEME DIFFERENCES XS_CENTER GRAD_D_LOCAL

x b a r e l e n g t h = 100y ba r e l e n g t h = x b a r e l e n g t h

# the se two l i n e s are ignored in parametric mode ,# but again i t i s handy to keep themx c e l l s = 100y c e l l s = x c e l l s

INCLUDE m a t e r i a l s . milZONE f u e l MATERIAL f u e l

p i = 4∗atan (1 )k = nuSigmaF /(SigmaA + 2∗D∗( p i / x b a r e l e n g 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 bu i l d t ime so l v e t ime bu i l d t ime+ ←↩s o l v e t ime

$ milonga 2d.mil > 2d.dat$ gnuplot 2d.gnuplot$

Page 118: milonga

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

keff

number of cells in the x direction

numerical and analytical keff vs cell number - 2D

analyticalnumerical

1e-06

1e-05

1e-04

1e-03

0 50 100 150 200 250

abso

lute

err

or

number of cells in the x direction

difference between the numerical and analytical keff

error

Page 119: milonga

milonga v0.1 1e-05

1e-04

1e-03

1e-02

5 10 15 20 25 30 35 40

ab

solu

te e

rror

number of cells in the x direction

difference between the numerical and analytical keff

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

tim

e [

seg

]

number of cells in the x direction

solution time vs cell number - 2D

build timesolve timetotal time

3d.mil

Lastly, the first three-dimensional example appears. It is a bare one-dimensional box, whose effectivemultiplication factor is computed for different spatial nodalizations. In each direction the number ofcells are equal to x cells. After the usual three figures with the keff, the error and the solution times,two figures summing up the situation for each example of the section are provided. It can be seenhow, for the same matrix size lower dimensional problems are faster and more accurate, as expected.

# parametric s tudy o f a bare cube with r e spec t to# the number o f c e l l sPROBLEM DIMENSIONS 3 GROUPS 1

PARAMETRIC x c e l l s 5 40 1

SCHEME DIFFERENCES XS_CENTER GRAD_D_LOCAL

x b a r e l e n g t h = 100y ba r e l e n g t h = x b a r e l e n g t hz b a r e l e n g t h = x b a r e l e n g t h

x c e l l s = 25y c e l l s = x c e l l sz c e l l s = x c e l l s

INCLUDE m a t e r i a l s . milZONE f u e l MATERIAL f u e l

p i = 4∗atan (1 )k = nuSigmaF /(SigmaA + 3∗D∗( p i / x b a r e l e n g 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 bu i l d t ime so l v e t ime bu i l d t ime+ ←↩s o l v e t ime

$ milonga 3d.mil > 3d.dat$ gnuplot 3d.gnuplot$ gnuplot dims.gnuplot$

Page 120: milonga

milonga v0.1 1e-03

1e-02

1e-01

1e+00

1e+01

1e+02

1e+02 1e+03 1e+04 1e+05

tim

e [

seg

]

problem size

total runing time vs problem size

1D2D3D

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

keff

number of cells in the x direction

numerical and analytical keff vs cell number - 3D

analyticalnumerical

1e-05

1e-04

1e-03

1e-02

5 10 15 20 25 30 35 40

abso

lute

err

or

number of cells in the x direction

difference between the numerical and analytical keff

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

tim

e [

seg

]

number of cells in the x direction

solution time vs cell number - 3D

build timesolve timetotal time

Page 121: milonga

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

err

or

in k

eff

problem size

error vs problem size

1D2D3D

1e-03

1e-02

1e-01

1e+00

1e+01

1e+02

1e+02 1e+03 1e+04 1e+05

tim

e [

seg]

problem size

total runing time vs problem size

1D2D3D

3dinverse.mil

As a bonus track, another three-dimensional example is included. This time, an illustration of howknowledge about numerical methods, preconditioners and over-relaxation parameters can drasticallyreduce computation times. This problem passes run-time options to SLEPc in the commandline toselect the Krylov-subspace solver GMRES, a SOR preconditioner and to set some other optionalparameters, resulting in a reduction of the problem time for big problems when compared to theprevious case, as can be seen in the output figure. The SLEPc parameters shown in the terminal vieware not important per se. This example is about the influence they have in milonga’s performance.The actual meaning of the options and its impact should be addressed on the one hand by readingSLEPc’s documentation [9] and on the other hand understanding how milonga builds the associatedmatrices, as explained in chapter 2 of this document.

# parametric s tudy o f a bare cube with r e spec t to# the number o f c e l l s us ing the ” inve r s e k” formula t ion# with sor precond i t i oner and gmres s o l v e rPROBLEM DIMENSIONS 3 GROUPS 1

Page 122: milonga

milonga v0.1

PARAMETRIC x c e l l s 5 40 1

# for the SLEPc opt ions in commandline to work , we have to s o l v e# the problem were the e i g enva lue i s equa l to 1/ k e f fSOLVER EIGENVALUE_INVERSE_KSCHEME DIFFERENCES XS_CENTER GRAD_D_LOCAL

x b a r e l e n g t h = 100y ba r e l e n g t h = x b a r e l e n g t hz b a r e l e n g t h = x b a r e l e n g t h

x c e l l s = 25y c e l l s = x c e l l sz c e l l s = x c e l l s

INCLUDE m a t e r i a l s . milZONE f u e l MATERIAL f u e l

p i = 4∗atan (1 )k = nuSigmaF /(SigmaA + 3∗D∗( p i / x b a r e l e n g 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 bu i l d t ime so l v e t ime bu i l d t ime+ ←↩s o l v e t ime

$ 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

tim

e [

seg]

problem size

solution time vs. problem size

direct probleminverse problem

4.3.2 Discrete boundary conditions effects

The following example presents another example of parametric calculation. Again a bare slab is solvedbut this time, the number of cells and the bare length are kept constant while the width a is changedparametrically. This leads to the general situation where the external boundary does not coincidewith cell borders, as shown in the figure. The numerical multiplicative factor is again compared to thetheoretical one. The latter depends continuously on the slab width while the second does not becauseof the discrete boundary condition equations. The output figure shows how the error changes with

Page 123: milonga

milonga v0.1

the slab width. Keep in mind that the cells are two units width and refer to figures 2.13 and 2.14when analyzing the result.

bc.mil

This is a rather simple input. Zone fuel is defined to be in the range [0, a], while x bare lengthand x cells are kept constant. Variable a is changed parametrically and the error as a function of ais written to the standard output.

# e f f e c t o f the app l i c a t i on o f d i s c r e t e boundary# cond i t i ons on planar su r f a c e sPROBLEM DIMENSIONS 1 GROUPS 1

# sweep the s l a b width from 80 to 100PARAMETRIC a 80 100 0 .1

x b a r e l e n g t h = 100# 50 c e l l s g i v e c e l l s o f width 2x c e l l s = 50

INCLUDE m a t e r i a l s . milZONE f u e l MATERIAL f u e l X_MIN 0 X_MAX a

p i = 4∗atan (1 )k = nuSigmaF /(SigmaA + D∗( p i /a ) ˆ2)

PRINT a k e f f k k e f f−k

$ milonga bc.mil > bc.dat$ gnuplot bc.gnuplot$

Page 124: milonga

milonga v0.1

1e-05

1e-04

1e-03

1e-02

1e-01

80 82 84 86 88 90 92 94 96 98 100

num

eri

cal k

- analy

tica

l k

slab width

error in numerical keff vs bare length

4.3.3 Circle quadrature

In a similar fashion, this section shows what happens when a continuous geometry does not coincidewith a discrete mesh. This time, a bare circle with a varying radius r is solved and the multiplicativefactor 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 keff with r is non-trivial. Thefirst example uses a 50 × 50 mesh and the second a 200 × 200, to show that even though there areripples in the numerical solution, it should converge to the analytical one for infinite number of cells.

circle50.mil

The input below solved a bare circle of radius r immersed in a square bare domain of size 100× 100discretized with a 50× 50 mesh. The values of the numerical an analytical keff along with the relativeerror are plotted as a function of the radius r.

# parametric s tudy on k e f f vs rad ius# in a bare c i r c l e with a square meshPROBLEM DIMENSIONS 2 GROUPS 1

PARAMETRIC r 30 40 0 .02

x b a r e l e n g t h = 100y ba r e l e n g t h = x b a r e l e n g t h

x c e l l s = 50y c e l l s = x c e l l s

INCLUDE m a t e r i a l s . mil

Page 125: milonga

milonga v0.1

# centered c i r c l e o f rad ius rZONE f u e l MATERIAL f u e l X_CENTER x b a r e l e n g t h /2 Y_CENTER y ba r e l e n g 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

keff vs radius

analyticalnumerical

5.0e-03

1.0e-02

2.0e-02

4.0e-02

30 32 34 36 38 40

rela

tive e

rror

radius

relative error vs radius

circle200.mil

Essentially the same problem is solved using a 200 × 200 mesh. A comparison between the solutionfound with this input with respect to the previous example is provided. Only a small interval is

Page 126: milonga

milonga v0.1

studied because of running time reasons.

# parametric s tudy on k e f f vs rad ius# in a bare c i r c l e with a square meshPROBLEM DIMENSIONS 2 GROUPS 1

PARAMETRIC r 34 36 0 .02

x b a r e l e n g t h = 100y ba r e l e n g t h = x b a r e l e n g t h

x c e l l s = 200y c e l l s = x c e l l s

INCLUDE m a t e r i a l s . milZONE f u e l MATERIAL f u e l X_CENTER x b a r e l e n g t h /2 Y_CENTER y ba r e l e n g 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

keff vs radius

analytical50x50 mesh

200x200 mesh

Page 127: milonga

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

rela

tive e

rror

radius

relative error vs radius

50x50 mesh200x200 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 a ofthe absorber material with k∞ < 1 is varied from 20 to 80 with and increment of 10−2. The effectivemultiplication factor as computed from the numerical problem is compared to the analytical keff givenby the critical condition

√DI

(νΣfI

keff− ΣaI

)· tan

[√1

DII

(ΣaII −

νΣfII

keff

)· (b− a)

]+√

DII

(ΣaII −

νΣfII

keff

)· tanh

[√1

DI

(νΣfI

keff− ΣaI

)· a

]= 0

Of course, keff(a) should be a continuous and smooth function of a. Indeed, the analytical solutionis. 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 a.The user is encouraged to try different nodalizations and options to analyze the results, sharing herfindings with milonga’s author. Actually, the problem of cross-section dilution was already studiedusing SLEPc [10].

cusp.mil

The number of cells selected is rather small to stress the effects of the cusps on keff(a) because of thedilution of cross sections into finite cells.

# study o f the e f f e c t s o f the rod cusp problem# using milonga ’ s parametric 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 to 80 with a 0.01 s t epPARAMETRIC a 20 80 0 .01

# t h i s assignment i s ignore when making a parametric# ca l c u l a t i o n on aa = 50b = 100

Page 128: milonga

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

keff

a

keff vs. a (zoomed)

analyticalnumerical

x b a r e l e n g t h = b

# a smal l number o f c e l l s i s s e l e c t e d in order# to s t r e s s the cusp problemx c e l l s = 25

# scheme opt ions################################### the user i s urged to t e s t a l l t h e s e combinations# and ana lyze the r e s u l t s ob ta ined according to# the exp lana t ion g iven in milonga ’ s documentationSCHEME VOLUMES XS_MEAN D_MEAN# SCHEME VOLUMES XSMEAN D EPSILON# SCHEME VOLUMES XS CENTER DMEAN# SCHEME VOLUMES XS CENTER D EPSILON# SCHEME DIFFERENCES XSMEAN GRAD D NEIGHBORS# SCHEME DIFFERENCES XSMEAN GRAD D LOCAL# SCHEME DIFFERENCES XS CENTER GRAD D NEIGHBORS# SCHEME DIFFERENCES XS CENTER GRAD D LOCAL

# cross s e c t i on s##################################nu1 = 0.010nu2 = 0.015a1 = 0.015a2 = 0.010d1 = 0 .5d2 = 1 .5

MATERIAL f u e l {D 1 d2SigmaT 1 a2nuSigmaF 1 nu2

}

MATERIAL rod {D 1 d1SigmaT 1 a1nuSigmaF 1 nu1

}

# zones##################################ZONE rod MATERIAL rod X_MIN 0 X_MAX aZONE f u e l MATERIAL f u e l X_MIN a X_MAX b

# ana l y t i c a l mu l t i p l i c a t i o n f a c t o r################################### in t e r v a l to look f o r the a n a l y t i c a l keps = 0.02 + 0 .02∗ ( a−20)/100

# eva lua t e k from the an a l y t i c a l c r i t i c a l cond i t i on# tak ing as an i n i t i a l guess the numerical k e f fk = k e f fk = root ( sqrt ( d1∗abs ( nu1/k−a1 ) ) ∗ tan ( sqrt ( (1/ d2 ) ∗abs ( a2−nu2/k ) ) ∗(b−a ) ) + sqrt ←↩

( d2∗abs ( a2−nu2/k ) ) ∗ tanh ( sqrt ( (1/ d1 ) ∗abs ( nu1/k−a1 ) ) ∗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$

Page 129: milonga

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

keff

a

keff vs. a

analyticalnumerical

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

keff

a

keff vs. a (zoomed)

analyticalnumerical

-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

err

or

a

absoulte error vs. b

Page 130: milonga

milonga v0.1

4.4 Non-linear problems

As stated in page 9, non-linear problems arise when the coefficients of the diffusion equation dependthemselves on the flux. To solve this kind of problems, an iterative scheme may be used in the hopethat it will converge to the desired solution after a number of steps. The two examples given inthis sections deal with non-linear problems. The first one illustrates how milonga treats xenon as aneutronic poison and the second one implements a simple algorithm to find the position of a controlrod that renders a reactor critical. Again, these examples are just an illustration of milonga featuresand do not posses any particular engineering content whatsoever.

4.4.1 Xenon effects

This example shows how to use milonga’s capabilities regarding xenon poisoning by solving again ourgood old friend, the bare one-speed one-meter width slab. An iterative scheme is used, where theactual flux is computed using the steady-state 135Xe distribution computed in the previous step. Aa power setpoint and a non-zero value of EΣf for at least one material has to be entered in orderfor milonga to be able to compute a dimensional value for the flux distribution φ(r) and thereforeevaluate the xenon distribution this flux distribution gives. Also, function xenon(x) should be usedwhen giving cross sections dependance to define the xenon feedback effects. Calculation may end aftera fixed number of steps—as the case illustrated—or by setting a flag when two successive keff’s differless than a certain threshold.

xenon.mil

A bare slab of one meter width is solved taking into account xenon feedback effects. Units ofxenon(x) are inverse cubic length, in whatever units x bare length is. That is to say, this functiongives a density of 135Xe nuclei per volume. Multiplicative coefficients should have appropriate unitsin order to recover inverse length for the macroscopic cross sections. On the other hand, EΣf hasunits of energy times inverse length, where energy units should be compatible with the units of thepower setpoint. Default values for ν, yields and microscopic 135Xe neutron absorption are used. Themultiplicative factor vs. the step number—the first step considers no poisoning—and the flux andxenon distribution for the first seven steps are shown as outputs. Note that the xenon distributionfor each step is the resulting distribution and not the one used when computing the flux. Again, forstep one the xenon distribution used for computing φ(x) is assumed to be identically zero.

# example i l l u s t r a t i n g how to inc lude xenon# feedback e f f e c t s in milonga

# simple one−speed s l a b problem with a# smal l number o f c e l l s and center XSPROBLEM DIMENSIONS 1 GROUPS 1SCHEME VOLUMES XS_CENTER D_EPSILONx b a r e l e n g t h = 100 # in cmx c e l l s = 25

# f i l e out i s de f ined as step , so a c t u a l l y# one f i l e per s t ep w i l l be created , c a l l e d# out . n where n i s the s t ep numberFILE out out STEP

# we w i l l perform f i f t e e n s t e p s# a l t e r n a t i v e l y , a convergence check can be made by# comparing two suc e s s i v e k e f f and s e t t i n g the v a r i a b l e# done to t rues t a t i c i t e r a t i o n s = 15

# power s e t p o i n t : be ing a one dimensional problem , i t# i s a dens i t y per un i t area perpend icu lar to x ax i s# l eng t h are in cm, so f o r a cub ic reac tor o f s i z e

Page 131: milonga

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

xen

on

con

cen

trati

on

[1

/cm

^3

]

x

xenon distribution in the first seven iterations

step 1step 2step 3step 4step 5step 6step 7

# 100x100x100 with a t o t a l power o f 1 MW with energy# in j o u l e s and time in seconds , the power dens i t y# s e t p o i n t shou ld be# 1e6 /(100 x100 ) = 100# the power s e t p o i n t i s mandatory f o r xenon c a l c u l a t i o n spower = 100

# keep the computed k e f f in the l a s t s t ep ( be f o r e the# f i r s t ZONE keyword ) to implement a convergence checkkold = k e f f

# a s i n g l e zone spanning the whole bare l eng t hZONE f u e l MATERIAL f u e l

# wri t e in to the output f i l e f l u x , xenon concentra t ion an XSPRINT_FUNCTION FILE out f l u x 1 xenon nuSigmaF 1 SigmaA 1# wr i t e in to standard output the step , a c tua l k e f f and# d i f f e r e n c e with r e spec t to the l a s t onePRINT s t a t i c s t e p k e f f k e f f−kold

# uncoment to qu i t whenever convergence i s a t t a ined# ins t ead o f when reaching 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−ko ld ) , 1e−5)

# func t ion xenon ( x ) conta ins atoms per vo lumetr i c un i t s# ESigmaF has un i t s o f j o u l e s /cmMATERIAL f u e l {

D 1 ”1 + 5e−18∗xenon ( x ) ”SigmaA 1 ”4e−3 + 3e−17∗xenon ( x ) ”nuSigmaF 1 ”nu∗4e−3 − 5e−17∗xenon ( x ) ”ESigmaF 1 ”200 e6 ∗1 .6 e−19∗(2e−3 − 1e−17∗xenon ( 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

keff

step

keff vs. step

Page 132: milonga

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

flux [

1/(

cm^

2 s

)]

x

flux distribution in the first seven iterations

step 1step 2step 3step 4step 5step 6step 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

xenon c

once

ntr

ati

on [

1/c

m^

3]

x

xenon distribution in the first seven iterations

step 1step 2step 3step 4step 5step 6step 7

4.4.2 Criticallity with a control rod

The next example shows another kind of non-linear diffusion problem. It consists of locating theposition of a control rod such that the resulting ensemble is as critical as possible. Again, this isjust an illustration of milonga’s capabilities and not a real application. The problem is a two-grouptwo-dimensional horizontal core with a radial reflector and four control rods entering from above. Twocontrol rods are fixed in space and the insertion of the other two is controlled by a variable that ismodified 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 byusing the postfix init. Then, after solving the eigenvalue problem with the zone corresponding tothe two control rods defined in terms of the pos variable, the insertion is updated as

pos← pos + 10 · (keff − 1)

and a new iteration is performed. The flux distribution is written to file flux.dat, that is not definedas STEP but the print instruction has a condition that writes the information only if static step

Page 133: milonga

milonga v0.1

is equal to static iterations, i.e. only in the last step.

# example o f a s imple a lgor i thm to make a reac tor# c r i t i c a l by moving a con t ro l rod

PROBLEM DIMENSIONS 2 GROUPS 2

s t a t i c i t e r a t i o n s = 10 # number o f s t a t i c s t e p s

# bare l e n g t h s and noda l i z a t i onx b a r e l e n g t h = 600y ba r e l e n g t h = 650x c e l l s = 100y c e l l s = 108

# i n i t i a l va lue ( only f o r s t a t i c s t e p = 1) o f v a r i a b l e pos ,# tha t i s im p l i c i t l y de f ined by t h i s assignment a l s op o s i n i t = 0 .5

MATERIAL f u e l {D 1 1 .500 D 2 0 .400SigmaS 1 . 2 0 .020 SigmaA 1 0 .010SigmaA 2 0 .085 nuSigmaF 2 0 .130

}

MATERIAL f u e l r o d {D 1 1 .500 D 2 0 .400SigmaS 1 . 2 0 .020 SigmaA 1 0 .010SigmaA 2 0 .130 nuSigmaF 2 0 .130

}

MATERIAL r e f l e c t o r {D 1 2 .000 D 2 0 .300SigmaS 1 . 2 0 .040 SigmaA 1 0 .000SigmaA 2 0 .010 nuSigmaF 2 0 .000

}

# geometry d e f i n i t i o n# outer r e f l e c t o rZONE 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# reac tor coreZONE f u e l MATERIAL f u e l X_CENTER 300 Y_CENTER 300 OUTER_RADIUS 250

# two con t ro l rods whose i n s e r t i on i s de f ined by v a r i a b l e posZONE rod1 MATERIAL f u e l r o d X_MIN 200 X_MAX 240 Y_MAX 700 Y_MIN 600∗(1−pos )ZONE rod2 MATERIAL f u e l r o d X_MIN 300 X_MAX 340 Y_MAX 700 Y_MIN 600∗(1−pos )

# two f i x e d con t ro l rodsZONE rod3 MATERIAL f u e l r o d X_MIN 400 X_MAX 440 Y_MAX 700 Y_MIN 250ZONE rod4 MATERIAL f u e l r o d X_MIN 150 X_MAX 160 Y_MAX 700 Y_MIN 150

# wri t e to standard output how the r e a c t i v i t y e vo l v e s as# the con t ro l rods are moved s t ep by s t epPRINT 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 ha t w i l l contain the 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# note t ha t i t i s not de f ined with the STEP keyword as the PRINT FUNCTION# in s t r u c t i on below makes sure only the l a s t f l u x d i s t r i b u t i o n i s pr in t edFILE f l u x f l u x . dat

# the PRINT FUNCTION i s executed only i f the cond i t i on e va l ua t e s# to true , i . e only at the l a s t s t ep o f the i t e r a t i o nPRINT_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 u x f l u x 1 ←↩

f l u x 2 SigmaA 2

# algor i thm to update the po s i t i on o f the con t ro l rod according# to the s i gn o f the l a s t computed r e a c t i v i t y

Page 134: milonga

milonga v0.1

pos = pos + 10∗( k e f f −1)

$ milonga rod.mil1.000000e+00 5.000000e-01 1.007512e+00 7.456008e+022.000000e+00 5.000000e-01 1.007512e+00 7.456008e+023.000000e+00 5.751202e-01 1.005309e+00 5.281038e+024.000000e+00 6.282109e-01 1.002804e+00 2.796322e+025.000000e+00 6.562526e-01 1.000962e+00 9.608342e+016.000000e+00 6.658702e-01 1.000259e+00 2.592735e+017.000000e+00 6.684636e-01 1.000134e+00 1.337936e+018.000000e+00 6.698017e-01 1.000013e+00 1.254712e+009.000000e+00 6.699271e-01 9.999950e-01 -4.995780e-011.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

"flux.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 flux distribution

"flux.dat" u 1:2:4

0

0.5

1

1.5

2

2.5

3

3.5

4

4.5

Page 135: milonga

milonga v0.1

4.5 Coupled calculations

A coupled calculation is needed whenever there is at least one parameter that influences the solutionof the diffusion equation but is outside milonga’s scope. Therefore, an iterative scheme should bedesigned where information between milonga and one or more external codes is to be exchanged. Forsure, coupled calculations are one of the most complex task a nuclear engineer may have to performand, as such, this is the last section of the examples chapter. In these cases, the input files may getrather cumbersome.

There are a number of ways of passing information from one process to another, being the moststraightforward—but also the most inefficient—writing and reading from plain files. Modern operatingsystems provide inter-process communication capabilities through kernel system calls that can beused to couple calculation codes running in the same host. Distributed coupled calculations may usenetwork connections to exchange information.

Although some file-based coupling may be implemented, milonga’s coupling scheme—actually pro-vided by the wasora framework—is 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 connectionswill be implemented in future versions.

Anyhow, presenting examples about coupled calculations is a rather difficult task as not onlyshould milonga’s features and characteristics be discussed, but also the external program computingand coupling capabilities should be explained. This section shows one single example regarding acoupled calculation with thermalhydraulic feedback using RELAP [11] as the plant code.

4.5.1 1D core coupled with RELAP

This example solves a very simplified problem that involves the computation of power, fuel andcoolant temperature distributions in a simplified model of a nuclear reactor core. A two-group one-dimensional neutronic model computed by milonga is coupled to a one-dimensional thermalhydraulicRELAP model computed. RELAP is a standard code developed by the US N.R.C. to evaluate powerreactor safety transients [11]. It has a great number of two-phase hydraulic models and heat transfercorrelations and has been widely validated with experiments.

The original version of RELAP does provide a mechanism to handle calculations coupled to theneutronic code PARCS [12] based in the PVM libray. However, to be able to perform general coupledcalculations, an extension RELAP5CPL was developed by TECNA S.A. to exchange informationusing 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 performneutronic-thermalhydraulic calculations.

The problem selected to serve as an example of a coupled calculation is a simple one-dimensionalmodel both in the thermalhydraulic and in the neutronic problem. The RELAP input—that is notshown—models a single pipe subject to a fixed pressure difference. It has some nodes that act both asa inlet thermalhydraulic zone and as a lower reflector. The active length consists of twenty volumesthat are in contact to a heat structure that represents the fuel elements. An upper reflector zone isalso provided. As requested in the coupling file—that is shown in the terminal window—RELAP5CPLwrites the twenty values of the fuel temperature, coolant temperature and coolant density to sharedmemory objects. This information is read by milonga and interpolated to evaluate the cross sectionsassociated to those distributions and to compute the flux and power distribution, that is written backfor RELAP5CPL to compute again the thermalhydraulics.

The thermalhydraulic model and the neutron cross sections dependance are made up in orderto obtain results that serve to illustrate the effects of an iterative calculation. The effects of thetemperatures and the xenon on the macroscopic cross sections are exaggerated.

Page 136: milonga

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 reflector

fuel

upper reflector

core.mil

While milonga solves the steady-state neutron diffusion equation, RELAP is essentially a transientcode. In the coupled scheme, RELAP exchange information once every one hundred transient timesteps, that correspond to a single static step of milonga. The objective of the coupled calculation is tofind a power distribution that generate certain thermalhydraulic distributions that in turn give rise tothe power distribution found. The details about the thermalhydraulic model are not important. Thecoupling file used is shown in the terminal, from which the general idea of the information exchangedmay be grasped. Milonga reads three vector from shared memory and constructs three continuousfunctions containing the coolant temperature, coolant density and fuel temperature distributions as afunction of the axial coordinate x. Conversely, from the continuous power density function it buildsa vector of size twenty that is exported to the shared memory segment by evaluating the continuouspower density at the location of the center of the RELAP cells measured in milonga’s coordinates.Milonga also import a number of administrative variables written by RELAP, one of which is a flagto indicate that the calculation has finished. Thus, the number of static steps is set to a big value toprevent milonga from finishing before RELAP. The macroscopic nuclear parameters of the reflectorsare constant and uniform, while the cross sections of the active length are assumed to depend on thefuel burnup distribution, on the fuel temperature, on the coolant temperature, on the coolant densityand on the xenon distribution in the form

Σ(x) = Σ0

(b(x)

)+∑ ∂Σ

(b(x)

)∂P

∣∣∣∣∣P0

· (P − P0)

where Σ0 is the cross section evaluated at the nominal parameters, b(x) is the fuel burnup at position xand ∂Σ/∂P is the partial derivative of the cross section with respect to parameter P evaluated at thenominal parameter P0.

The fuel burnup is given by the file burnup.dat and the cross sections and the derivatives areread 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 milongaafterward. Another way may be to open two terminals and run each program in one terminal asusual. The resulting figures show that RELAP start with flat cold temperature distributions and howthey converge to their final values as time passes by. The exaggerated effects of the thermalhydraulic

Page 137: milonga

milonga v0.1

parameters on the cross sections, i.e. big derivatives, allow to see how the non-linear iterative schemein milonga makes the distributions to oscillate before converging to the final solution.

# 1D core coupled with a 1D core model in RELAP# a modi f ied ver s ion o f RELAP ca l l e d RELAP5CPL i s used# to coup le the codes through shared memory o b j e c t s and# synchronize them using semaphores# see r e f e r ence s in the documentation fo r f u r t h e r informat ion

PROBLEM DIMENSIONS 1 GROUPS 2

# number o f c e l l s in the RELAP noda l i z a t i on o f the corer e l a p n u m b e r o f c e l l s = 20

# t h i s vec to r conta ins the coord ina te s o f the cen te r s# of the c e l l s t ha t repre sen t the a c t i v e l eng t h in RELAPVECTOR r e l a p c e l l 20

# these v ec t o r s contain the va lue s t ha t the p r op e r t i e s# take at the l o c a t i on s g iven by r e l a p c e l l# the se are to be read from RELAPVECTOR coo lant temperature 20VECTOR c o o l a n t d e n s i t y 20VECTOR f u e l t empe ra tu r e 20

# cons t ruc t th ree continuous func t i ons us ing the c e l l s# po s i t i o n s and the three v e c t o r s above t ha t are to be# read from RELAPFUNCTION Tcool ( x ) VECTORS r e l a p c e l l coo lant temperature INTERPOLATION akimaFUNCTION Tfue l ( x ) VECTORS r e l a p c e l l f u e l t empe ra tu r e INTERPOLATION akimaFUNCTION dcoo l ( x ) VECTORS r e l a p c e l l c o o l a n t d e n s i t y INTERPOLATION akima

# t h i s vec to r i s where the power d i s t r i b u t i o n i s to# be wr i t t en by milonga fo r RELAP to read i tVECTOR p o w e r d i s t r i b u t i o n 20

# these v a r i a b l e s are used to exchange admin i s t r a t i v e# informat ion with RELAPVAR nstsp count i s c a l l r s t r e c 0 problemtype05 problemopt611 restartnum

# a la r g e number i s g iven here because we expec t# RELAP5CPL to t e l l us to s top us ing v a r i a b l e dones t a t i c i t e r a t i o n s = 1000

# geometry d e f i n i t i o n ( in cm)b o t r e f l l e n g t h = 45t o p r e f l l e n g t h = 25a c t i v e l e n g t h = 530x b a r e l e n g t h = b o t r e f l l e n g t h + a c t i v e l e n g t h + t o p r e f l l e n g t h

# note t ha t the number o f c e l l s in the neutronic problem# does not need to be the same as in the therma lhydrau l i c model# ac tua l l y , here they have an o f f s e tx c e l l s = 100

# pos i t i on o f the cen t e r s o f the a c t i v e l eng t h c e l l s in r e l ap# measured in milonga ’ s coord inate systemr e l a p c e l l 1 = 0 .5∗ a c t i v e l e n g t h / r e l a p n u m b e r o f c e l l s + b o t r e f l l e n g t hr e l a p c e l l 2 = 1 .5∗ a c t i v e l e n g t h / r e l a p n u m b e r o f c e l l s + b o t r e f l l e n g t hr e l a p c e l l 3 = 2 .5∗ a c t i v e l e n g t h / r e l a p n u m b e r o f c e l l s + b o t r e f l l e n g t hr e l a p c e l l 4 = 3 .5∗ a c t i v e l e n g t h / r e l a p n u m b e r o f c e l l s + b o t r e f l l e n g t hr e l a p c e l l 5 = 4 .5∗ a c t i v e l e n g t h / r e l a p n u m b e r o f c e l l s + b o t r e f l l e n g t hr e l a p c e l l 6 = 5 .5∗ a c t i v e l e n g t h / r e l a p n u m b e r o f c e l l s + b o t r e f l l e n g t hr e l a p c e l l 7 = 6 .5∗ a c t i v e l e n g t h / r e l a p n u m b e r o f c e l l s + b o t r e f l l e n g t hr e l a p c e l l 8 = 7 .5∗ a c t i v e l e n g t h / r e l a p n u m b e r o f c e l l s + b o t r e f l l e n g t hr e l a p c e l l 9 = 8 .5∗ a c t i v e l e n g t h / r e l a p n u m b e r o f c e l l s + b o t r e f l l e n g t hr e l a p c e l l 1 0 = 9.5∗ a c t i v e l e n g t h / r e l a p n u m b e r o f c e l l s + b o t r e f l l e n g t hr e l a p c e l l 1 1 = 10.5∗ a c t i v e l e n g t h / r e l a p n u m b e r o f c e l l s + b o t r e f l l e n g t h

Page 138: milonga

milonga v0.1

r e l a p c e l l 1 2 = 11.5∗ a c t i v e l e n g t h / r e l a p n u m b e r o f c e l l s + b o t r e f l l e n g t hr e l a p c e l l 1 3 = 12.5∗ a c t i v e l e n g t h / r e l a p n u m b e r o f c e l l s + b o t r e f l l e n g t hr e l a p c e l l 1 4 = 13.5∗ a c t i v e l e n g t h / r e l a p n u m b e r o f c e l l s + b o t r e f l l e n g t hr e l a p c e l l 1 5 = 14.5∗ a c t i v e l e n g t h / r e l a p n u m b e r o f c e l l s + b o t r e f l l e n g t hr e l a p c e l l 1 6 = 15.5∗ a c t i v e l e n g t h / r e l a p n u m b e r o f c e l l s + b o t r e f l l e n g t hr e l a p c e l l 1 7 = 16.5∗ a c t i v e l e n g t h / r e l a p n u m b e r o f c e l l s + b o t r e f l l e n g t hr e l a p c e l l 1 8 = 17.5∗ a c t i v e l e n g t h / r e l a p n u m b e r o f c e l l s + b o t r e f l l e n g t hr e l a p c e l l 1 9 = 18.5∗ a c t i v e l e n g t h / r e l a p n u m b e r o f c e l l s + b o t r e f l l e n g t hr e l a p c e l l 2 0 = 19.5∗ a c t i v e l e n g t h / r e l a p n u m b e r o f c e l l s + b o t r e f l l e n g t h

# the power s e t p o i n t f o r milonga shou ld be in w/cmˆ2 fo r# for the xenon to be c o r r e c t l y computedpower = 6500

# t h i s v a r i a b l e i s the ac tua l t o t a l power in wat t s t ha t# i s needed to conver t from power dens i t y to the ac tua l# power RELAP needsto ta l power = 5e6

# burnup i s g iven as a func t i on o f the a x i a l l o c a t i on measured# from the bottom of the a c t i v e l eng th , to conver t i t to# milonga ’ s coord inate system , the l eng t h o f the r e f l e c t o r i s# to be taken in to account so b ( x ) i s the burnup to be used# care has to be taken only to eva l ua t e b ( x ) at x l o ca t ed in the# ac t i v e region , o therwi se e x t r apoa l a t ed va lue s w i l l be wrongFUNCTION b f rom core ( x ) FILE burnup . datFUNCTION b( x ) = b f rom core ( x−b o t r e f l l e n g t h )

# nominal parameters va lue s f o r the XS t a b l e sTfuel0 = 637.0+273.15 # [ K ]dcoo l0 = 801 .9 # [ kg / mˆ3 ]Tcool0 = 295.8+273.15 # [ K ]

# cross s e c t i on s at c en t r a l va lue s# va r i a b l e bu means burnup , but i t i s a dummy va r i a b l e j u s t# to t e l l milonga the se are s ing l e−va lue func t i ons# when the se fun t i ons are to be eva lua t ed at the MATERIAL# keyword , the argument shou ld be b ( x )FUNCTION D1(bu) FILE xs . dat COLUMNS 1 2FUNCTION D2(bu) FILE xs . dat COLUMNS 1 3FUNCTION abs1 (bu) FILE xs . dat COLUMNS 1 4FUNCTION sca12 (bu) FILE xs . dat COLUMNS 1 5FUNCTION sca21 (bu) FILE xs . dat COLUMNS 1 6FUNCTION abs2 (bu) FILE xs . dat COLUMNS 1 7FUNCTION nuf1 (bu) FILE xs . dat COLUMNS 1 8FUNCTION nuf2 (bu) FILE xs . dat COLUMNS 1 9FUNCTION Ef1 (bu) FILE xs . dat COLUMNS 1 10FUNCTION Ef2 (bu) FILE xs . dat COLUMNS 1 11

# de r i v a t i v e s with r e spec t to xenonFUNCTION dabs1dXe (bu) FILE xs . dat COLUMNS 1 14FUNCTION dsca12dXe (bu) FILE xs . dat COLUMNS 1 15FUNCTION dsca21dXe (bu) FILE xs . dat COLUMNS 1 16FUNCTION dabs2dXe (bu) FILE xs . dat COLUMNS 1 17FUNCTION dnuf1dXe (bu) FILE xs . dat COLUMNS 1 18FUNCTION dnuf2dXe (bu) FILE xs . dat COLUMNS 1 19FUNCTION dEf1dXe (bu) FILE xs . dat COLUMNS 1 20FUNCTION dEf2dXe (bu) FILE xs . dat COLUMNS 1 21

# with r e spec t to f u e l temperatureFUNCTION dabs1dTfuel (bu ) FILE xs . dat COLUMNS 1 24FUNCTION dsca12dTfuel (bu ) FILE xs . dat COLUMNS 1 25FUNCTION dsca21dTfuel (bu ) FILE xs . dat COLUMNS 1 26FUNCTION dabs2dTfuel (bu ) FILE xs . dat COLUMNS 1 27FUNCTION dnuf1dTfuel (bu) FILE xs . dat COLUMNS 1 28FUNCTION dnuf2dTfuel (bu) FILE xs . dat COLUMNS 1 29FUNCTION dEf1dTfuel (bu ) FILE xs . dat COLUMNS 1 30FUNCTION dEf2dTfuel (bu ) FILE xs . dat COLUMNS 1 31

Page 139: milonga

milonga v0.1

# with r e spec t to coo lan t temperatureFUNCTION dabs1dTcool (bu ) FILE xs . dat COLUMNS 1 34FUNCTION dsca12dTcool (bu) FILE xs . dat COLUMNS 1 35FUNCTION dsca21dTcool (bu) FILE xs . dat COLUMNS 1 36FUNCTION dabs2dTcool (bu ) FILE xs . dat COLUMNS 1 37FUNCTION dnuf1dTcool (bu) FILE xs . dat COLUMNS 1 38FUNCTION dnuf2dTcool (bu) FILE xs . dat COLUMNS 1 39FUNCTION dEf1dTcool (bu ) FILE xs . dat COLUMNS 1 40FUNCTION dEf2dTcool (bu ) FILE xs . dat COLUMNS 1 41

# with r e spec t to coo lan t dens i t yFUNCTION dabs1ddcool (bu ) FILE xs . dat COLUMNS 1 44FUNCTION dsca12ddcool (bu ) FILE xs . dat COLUMNS 1 45FUNCTION dsca21ddcool (bu ) FILE xs . dat COLUMNS 1 46FUNCTION dabs2ddcool (bu ) FILE xs . dat COLUMNS 1 47FUNCTION dnuf1ddcool (bu) FILE xs . dat COLUMNS 1 48FUNCTION dnuf2ddcool (bu) FILE xs . dat COLUMNS 1 49FUNCTION dEf1ddcool (bu ) FILE xs . dat COLUMNS 1 50FUNCTION dEf2ddcool (bu ) FILE xs . dat COLUMNS 1 51

# read RELAP5CPL admin i s t r a t i v e informat ion inc l ud ing v a r i a b l e# done tha t when s e t to nonzero makes milonga s topPRINT HEADER TEXT ”\# wait ing f o r i n i t i a l semaphore from r e l a p 5 c p l . . . ” ←↩

NONEWLINE FLUSHIMPORT SHM_OBJECT r e l a p s t a t u s {SEMAPHORE_WAIT r e l ap r eadyt d t nstsp count i s c a l l r s t r e c 0 done problemtype05 problemopt611 restartnum}PRINT HEADER TEXT ” got i t ! ”

# read temperature and dens i t y d i s t r i b u t i o n s be f o r e# so l v i n g the d i f u s s i on equation , i . e . b e f o r e the f i r s t# ZONE keywordIMPORT SHM_OBJECT coo lant temperature coo lant temperatureIMPORT SHM_OBJECT c o o l a n t d e n s i t y c o o l a n t d e n s i t yIMPORT SHM_OBJECT f u e l t empe ra tu r e fu e l t empe ra tu r e

# give the user some feedback . . .PRINT HEADER TEXT ”\# computing i n i t i a l f l u x d i s t r i b u t i o n . . . ” NONEWLINE FLUSH

# core geometryZONE f u e l MATERIAL f u e lZONE r e f l bo t t om MATERIAL r e f l bo t t om X_MAX b o t r e f l l e n g t hZONE r e f l t o p MATERIAL r e f l t o p X_MIN x ba r e l eng t h−t o p r e f l l e n g t hPRINT HEADER TEXT ”done ! ”

# a f t e r computing the power d i s t r i b u t i o n ( i . e . a f t e r the# l a s t ZONE) f i l l in the vec to r t ha t has to be passed to RELAP# re l ap expec t s p owe r d i s t r i b u t i on to be normalized to one and# the t o t a l dimensional power in wat t s as a separa te v a r i a b l ef = a c t i v e l e n g t h / r e l a p n u m b e r o f c e l l s ∗ 1/powerp o w e r d i s t r i b u t i o n 1 = power dens i ty ( r e l a p c e l l 1 ) ∗ fp o w e r d i s t r i b u t i o n 2 = power dens i ty ( r e l a p c e l l 2 ) ∗ fp o w e r d i s t r i b u t i o n 3 = power dens i ty ( r e l a p c e l l 3 ) ∗ fp o w e r d i s t r i b u t i o n 4 = power dens i ty ( r e l a p c e l l 4 ) ∗ fp o w e r d i s t r i b u t i o n 5 = power dens i ty ( r e l a p c e l l 5 ) ∗ fp o w e r d i s t r i b u t i o n 6 = power dens i ty ( r e l a p c e l l 6 ) ∗ fp o w e r d i s t r i b u t i o n 7 = power dens i ty ( r e l a p c e l l 7 ) ∗ fp o w e r d i s t r i b u t i o n 8 = power dens i ty ( r e l a p c e l l 8 ) ∗ fp o w e r d i s t r i b u t i o n 9 = power dens i ty ( r e l a p c e l l 9 ) ∗ fp o w e r d i s t r i b u t i o n 1 0 = power dens i ty ( r e l a p c e l l 1 0 ) ∗ fp o w e r d i s t r i b u t i o n 1 1 = power dens i ty ( r e l a p c e l l 1 1 ) ∗ fp o w e r d i s t r i b u t i o n 1 2 = power dens i ty ( r e l a p c e l l 1 2 ) ∗ fp o w e r d i s t r i b u t i o n 1 3 = power dens i ty ( r e l a p c e l l 1 3 ) ∗ fp o w e r d i s t r i b u t i o n 1 4 = power dens i ty ( r e l a p c e l l 1 4 ) ∗ fp o w e r d i s t r i b u t i o n 1 5 = power dens i ty ( r e l a p c e l l 1 5 ) ∗ fp o w e r d i s t r i b u t i o n 1 6 = power dens i ty ( r e l a p c e l l 1 6 ) ∗ f

Page 140: milonga

milonga v0.1

p o w e r d i s t r i b u t i o n 1 7 = power dens i ty ( r e l a p c e l l 1 7 ) ∗ fp o w e r d i s t r i b u t i o n 1 8 = power dens i ty ( r e l a p c e l l 1 8 ) ∗ fp o w e r d i s t r i b u t i o n 1 9 = power dens i ty ( r e l a p c e l l 1 9 ) ∗ fp o w e r d i s t r i b u t i o n 2 0 = power dens i ty ( r e l a p c e l l 2 0 ) ∗ f

# wri t e the dimensional power in to shared memoryEXPORT SHM_OBJECT to ta l power to ta l power# wri t e the nondimensional p owe r d i s t r i b u t i on in to shared memory# and t e l l RELAP we are done with our par t f o r t h i s s t epEXPORT SHM_OBJECT p o w e r d i s t r i b u t i o n p o w e r d i s t r i b u t i o n SEMAPHORE_READY ←↩

r e l a p g o

PRINT HEADER TEXT ”\# informat ion wr i t t en and i n i t i a l semaphore s e t ”

# pr in t some informat ion to the screenPRINT 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 ins tantaneous d i s t r i b u t i o n s to a f i l eFILE d i s t d i s t . dat STEPPRINT_FUNCTION FILE d i s t power dens i ty xenon Tcool Tfue l dcoo l SigmaA 1 ←↩

nuSigmaF 2 f l u x 1 f l u x 2

# be po l i t e , and say goodbye to the user when f i n i s h e dPRINT FOOTER TEXT ”\# coupled c a l c u l a t i o n f i n i s h e d , have a n i c e day ! ”

## mater ia l d e f i n i t i o n s# f u e l XS are wr i t t en as a c en t r a l va lue p lu s d e r i v a t i v e s t imes# increments with r e spec t to the c en t r a l va lue sMATERIAL f u e l {

D 1 D1(b( x ) )D 2 D2(b( x ) )SigmaA 1 ” abs1 (b( x ) ) + dabs1dXe (b( x ) ) ∗xenon ( x ) + dabs1dTfuel (b( x ) ) ∗( Tfue l ←↩

( x )−Tfuel0 ) + dabs1dTcool (b( x ) ) ∗( Tcool ( x )−Tcool0 ) + dabs1ddcool (b( x ) ) ∗( ←↩dcoo l ( x )−dcoo l0 ) ”

SigmaA 2 ” abs2 (b( x ) ) + dabs2dXe (b( x ) ) ∗xenon ( x ) + dabs2dTfuel (b( x ) ) ∗( Tfue l ←↩( x )−Tfuel0 ) + dabs2dTcool (b( x ) ) ∗( Tcool ( x )−Tcool0 ) + dabs2ddcool (b( x ) ) ∗( ←↩dcoo l ( x )−dcoo l0 ) ”

SigmaS 1 . 2 ” sca12 (b( x ) ) + dsca12dXe (b( x ) ) ∗xenon ( x ) + dsca12dTfuel (b( x ) ) ∗( ←↩Tfue l ( x )−Tfuel0 ) + dsca12dTcool (b( x ) ) ∗( Tcool ( x )−Tcool0 ) + dsca12ddcool (b ←↩( x ) ) ∗( dcoo l ( x )−dcoo l0 ) ”

SigmaS 2 . 1 ” sca21 (b( x ) ) + dsca21dXe (b( x ) ) ∗xenon ( x ) + dsca21dTfuel (b( x ) ) ∗( ←↩Tfue l ( x )−Tfuel0 ) + dsca21dTcool (b( x ) ) ∗( Tcool ( x )−Tcool0 ) + dsca21ddcool (b ←↩( x ) ) ∗( dcoo l ( x )−dcoo l0 ) ”

nuSigmaF 1 ” nuf1 (b( x ) ) + dnuf1dXe (b( x ) ) ∗xenon ( x ) + dnuf1dTfuel (b( x ) ) ∗( Tfue l ←↩( x )−Tfuel0 ) + dnuf1dTcool (b( x ) ) ∗( Tcool ( x )−Tcool0 ) + dnuf1ddcool (b( x ) ) ∗( ←↩dcoo l ( x )−dcoo l0 ) ”

nuSigmaF 2 ” nuf2 (b( x ) ) + dnuf2dXe (b( x ) ) ∗xenon ( x ) + dnuf2dTfuel (b( x ) ) ∗( Tfue l ←↩( x )−Tfuel0 ) + dnuf2dTcool (b( x ) ) ∗( Tcool ( x )−Tcool0 ) + dnuf2ddcool (b( x ) ) ∗( ←↩dcoo l ( x )−dcoo l0 ) ”

ESigmaF 1 ” 1 .6 e−13∗(Ef1 (b( x ) ) + dEf1dXe (b( x ) ) ∗xenon ( x ) + dEf1dTfuel (b( x ) ) ←↩∗( Tfue l ( x )−Tfuel0 ) + dEf1dTcool (b( x ) ) ∗( Tcool ( x )−Tcool0 ) + dEf1ddcool (b( x ←↩) ) ∗( dcoo l ( x )−dcoo l0 ) ) ”

ESigmaF 2 ” 1 .6 e−13∗(Ef2 (b( x ) ) + dEf2dXe (b( x ) ) ∗xenon ( x ) + dEf2dTfuel (b( x ) ) ←↩∗( Tfue l ( x )−Tfuel0 ) + dEf2dTcool (b( x ) ) ∗( Tcool ( x )−Tcool0 ) + dEf2ddcool (b( x ←↩) ) ∗( dcoo l ( x )−dcoo l0 ) ) ”

}

MATERIAL r e f l bo t t om {D 1 1 .35D 2 9 .294 e−01SigmaA 1 7 .828 e−05SigmaA 2 1 .463 e−02SigmaS 1 . 2 4 .368 e−05SigmaS 2 . 1 6 .507 e−04

}

Page 141: milonga

milonga v0.1

MATERIAL r e f l t o p {D 1 1 .35D 2 9 .583 e−01SigmaA 1 1 .510 e−04SigmaA 2 1 .234 e−02SigmaS 1 . 2 6 .891 e−05SigmaS 2 . 1 1 .059 e−03

}

$ cat channel.cplRELAP_TIME_STATUS relap_status

RELAP_EXPORT {SHARE_NAME coolant_temperatureSCALAR tempf 87 3:22SKIP_STEP 100}

RELAP_EXPORT {SHARE_NAME coolant_densitySCALAR rho 87 3:22SKIP_STEP 100}

RELAP_EXPORT {SHARE_NAME fuel_temperatureSCALAR htvatp 1875 1:20SEMAPHORE_READY relap_readySKIP_STEP 100}

RELAP_IMPORT {SHARE_NAME total_powerSEMAPHORE_WAIT relap_goSCALAR cnvarn 100 0SKIP_STEP 100}

RELAP_IMPORT {SHARE_NAME power_distributionSCALAR cnvsan 201 1SCALAR cnvsan 202 1SCALAR cnvsan 203 1SCALAR cnvsan 204 1SCALAR cnvsan 205 1SCALAR cnvsan 206 1SCALAR cnvsan 207 1SCALAR cnvsan 208 1SCALAR cnvsan 209 1SCALAR cnvsan 210 1SCALAR cnvsan 211 1SCALAR cnvsan 212 1SCALAR cnvsan 213 1SCALAR cnvsan 214 1SCALAR cnvsan 215 1SCALAR cnvsan 216 1SCALAR cnvsan 217 1SCALAR cnvsan 218 1SCALAR cnvsan 219 1SCALAR cnvsan 220 1SKIP_STEP 100}

RELAP_IMPORT {SHARE_NAME relap_done

Page 142: milonga

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 externosrelap5cpl: [email protected]: ultima modificacion 2011-05-02 08:40:14relap5cpl: 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 watergenerated 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 ProgramCopyright (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 Reason0.0 0.0000 1.00E-04 0.0 03301 12.14 0.0000 0.00 03301 ←↩

12.14 0.00 g 0.00 a 0Transient terminated by end of time step cards.At time 100.019 seconds; Step 3852done!## information written and initial semaphore set1.000000e+00 0.000000e+00 1.063907e+00 5.510000e+022.000000e+00 1.397503e+00 8.848904e-01 5.614382e+023.000000e+00 4.080064e+00 8.939054e-01 5.699261e+024.000000e+00 6.763396e+00 8.909174e-01 5.748820e+025.000000e+00 9.425237e+00 8.899390e-01 5.775089e+026.000000e+00 1.207100e+01 8.891607e-01 5.792419e+027.000000e+00 1.470793e+01 8.887985e-01 5.801273e+028.000000e+00 1.733898e+01 8.884757e-01 5.807304e+029.000000e+00 1.996726e+01 8.883491e-01 5.810124e+021.000000e+01 2.259325e+01 8.882032e-01 5.812667e+021.100000e+01 2.521825e+01 8.881619e-01 5.813650e+021.200000e+01 2.784223e+01 8.880915e-01 5.814805e+021.300000e+01 3.046586e+01 8.880812e-01 5.815115e+021.400000e+01 3.308902e+01 8.880452e-01 5.815673e+021.500000e+01 3.571208e+01 8.880456e-01 5.815744e+021.600000e+01 3.833490e+01 8.880262e-01 5.816030e+021.700000e+01 4.095771e+01 8.880296e-01 5.816019e+021.800000e+01 4.358040e+01 8.880186e-01 5.816174e+021.900000e+01 4.620310e+01 8.880222e-01 5.816143e+022.000000e+01 4.882572e+01 8.880157e-01 5.816231e+022.100000e+01 5.144837e+01 8.880187e-01 5.816200e+022.200000e+01 5.407098e+01 8.880147e-01 5.816253e+022.300000e+01 5.669360e+01 8.880170e-01 5.816227e+022.400000e+01 5.931620e+01 8.880145e-01 5.816260e+022.500000e+01 6.193881e+01 8.880161e-01 5.816241e+022.600000e+01 6.456141e+01 8.880145e-01 5.816261e+022.700000e+01 6.718402e+01 8.880156e-01 5.816248e+022.800000e+01 6.980661e+01 8.880146e-01 5.816261e+022.900000e+01 7.242922e+01 8.880154e-01 5.816251e+023.000000e+01 7.505181e+01 8.880147e-01 5.816260e+02

Page 143: milonga

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

therm

al n

u-fi

ssio

n X

S [

1/c

m]

axial coordinate [cm]

step 1step 2step 5step 40

3.100000e+01 7.767441e+01 8.880152e-01 5.816254e+023.200000e+01 8.029701e+01 8.880147e-01 5.816259e+023.300000e+01 8.291961e+01 8.880151e-01 5.816255e+023.400000e+01 8.554221e+01 8.880148e-01 5.816259e+023.500000e+01 8.816481e+01 8.880150e-01 5.816256e+023.600000e+01 9.078741e+01 8.880148e-01 5.816258e+023.700000e+01 9.341001e+01 8.880150e-01 5.816256e+023.800000e+01 9.603261e+01 8.880149e-01 5.816258e+023.900000e+01 9.865521e+01 8.880150e-01 5.816256e+024.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

flux [

cm^

-2 s

^-1

]

axial coordinate [cm]

fast step 1thermal step 1fast step 2thermal step 2fast step 2thermal step 2fast step 40thermal 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

xenon c

once

ntr

ati

on [

cm^

-3]

axial coordinate [cm]

step 1step 2step 5step 40

Page 144: milonga

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

fuel te

mp

era

ture

[K

]

axial coordinate [cm]

step 1step 2step 5step 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

fast

ab

sorp

tion X

S [

1/c

m]

axial coordinate [cm]

step 1step 2step 5step 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

therm

al nu-fi

ssio

n X

S [

1/c

m]

axial coordinate [cm]

step 1step 2step 5step 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

pow

er

densi

ty [

w/c

m^

3]

axial coordinate [cm]

step 1step 2step 5step 40

Page 145: milonga

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

coola

nt

tem

pera

ture

[K

]

axial coordinate [cm]

step 1step 2step 5step 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

fuel te

mp

era

ture

[K

]

axial coordinate [cm]

step 1step 2step 5step 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

coola

nt

densi

ty [

K]

axial coordinate [cm]

step 1step 2step 5step 40

Page 146: milonga

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 Diffusion Computations, pages 753–911. Springer,2010.

[5] Computational Benchmark Problem Comitee for the Mathematics and Computation Divisionof the American Nuclear Society. Argonne Code Center: Benchmark problem book. TechnicalReport ANL-7416 Supplement 2, Argonne National Laboratory, June 1977.

[6] Imelda Ariani and Doddy Kastanya. Evaluation of the IAEA 3-D PWR benchmark problemusing NESTLE code.

[7] Russel Mosteller. Static benchmarking of the NESTLE advanced nodal code. Proceedings ofthe Joint International Conference on Mathematical Methods and Supercomputing for NuclearApplications, 2:1596–1605, 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 rodand fuel assembly motion using moving meshes. Annals of Nuclear Energy, 35, 2008.

[11] Information Systems Laboratories Inc. RELAP5/MOD3.3 Code Manual Volume 1–Code Struc-ture, System Models and Solution Methods. Technical Report NUREG/CR-5535/Rev 1, NuclearSafety Analysis Division, 2001.

[12] Douglas A. Barber and Thomans J. Downar. Software requirements specification for the PARCS-specific 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 termofluidodinamicas acopladas con codigos de calculo externos. Technical Report10105-G-IT-001, TECNA S.A., 2009.

[14] G. Theler. Simulacion de experimentos de estabilidad en flujo de dos fases acoplando RELAPa un codigo externo de control inteligente basado en logica difusa. Mecanica Computacional,XXVIII:3169–3183, 2009.

[15] O. Mazzantini, M. Schivo, J. Di Cesare, R. Garbero, M. Rivero, and G. Theler. A coupledcalculation suite for Atucha II operational transient analysis. Science and Technology of NuclearInstallations, 2011.

Page 147: milonga

Chapter V

Installation and execution

Part of the inhumanity of the computer is that, once it iscompetently 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 tocompile and install milonga and its required libraries from scratch. This is the reason why it comesat 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 yourparticular 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 accordingto 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 mathematicaloperations in order to obtain some results. One question arises about the type of computers the codeshould 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 familyof processors and operating systems or to provide means to conditionally include or remove piecesof source code in order to be compiled with different tools. Nowadays, desktop—and even laptop—Personal Computers are commonly used as engineering platforms. Even though there is a wide varietyof models, compatibility and portability between architectures is far more easy than twenty or thirtyyears 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 free—reason that should be enough to choose it as adevelopment platform—the GNU operating system with the Linux kernel1 has reached a higher levelof maturity and efficiency running over a wide variety of modern computers than any other operatingsystem.

Although portability per-se is not into milonga’s design basis, it is expected on the one hand to beable to run the code in a reasonable spectrum of digital computers and on the other hand to be ableto scale up with both software and hardware developments during a reasonable time frame, as statedin section 1.2. Thus, even though GNU/Linux is selected as the development platform, the code isexpected to run into other operating systems and architectures of interest.

Feedback about installation and executing issues—either positive or negative—is welcome.

1Strictly speaking, the official Linux kernel release contains some portions of code that are not free in the GNUsense. However, it is possible to obtain 100% free versions of the kernel to build free GNU/Linux distributions such asDebian.

Page 148: milonga

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 file 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 file as the first argument

$ ./milonga test.mil1.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 GSLas static libraries, but some other common libraries such as libglibc, librt and libgfortran aredynamically linked. Any modern distribution of GNU/Linux should be able to resolve them. Ifnot, please install the associated package.

• Windows binaries were compiled using Cygwin. They include PETSc, SLEPc statically linkedin the executable. All the other needed libraries are likend dynamically, but the DLLs aredistributed inside the package under the terms of the GPLv3+.

• The exact versions of libraries and compilers used to generate each executable are stated in eachtarball. Again, it is recommended to compile the source code using the actual tools installed inthe target machine.

• In all the binary versions, PETSc was compiled without MPI support. Therefore, the binarymay be directly executed by invoking the filename from the shell. No MPI wrapper is needed.

• The execution of milonga in Windows-based architectures is highly discouraged! The binary andits 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 notfree 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 thissection can be applied to other UNIX variants and even Cygwin distributions where milonga is knownto compile and run, although no comprehensive testing was made on these platforms.

Page 149: milonga

milonga v0.1

The list of commands provided in the following sections should do the trick in a reasonable workingGNU/Linux box, i.e. bash, ability to compile programs and internet access are assumed. If nointernet connection is available (for example because your company keeps blocking what they thinkare “security risks” sites or, even worse, do not allow to connect your GNU/Linux box to the corporateWindows network because of security issues (sic), of course the downloading stage can be replaced bya bare copy of the tarballs from a flash 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, itis always handy to have a Fortran compiler ready to go, as you never know when you may run acrossa T-Rex—as one that ruled the continent in page 4—with some (of course non-standard) F77 codefor you to run.

Probably some tuning might needed to cope with different software versions. The script-kiddieapproach should be avoided as this installation procedure may help to get an image of how milongadepends 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 requiredlibraries can be easily installed using the distribution’s package manager. Example commands aregiven for apt-get in Debian-based distributions, but equivalent commands should also be available inother 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 files usingHTTP:

# apt-get install gcc gfortran make binutils python tar wget

Then, install the GNU Scientific Libraries (needed by the wasora framework) and LAPACK (neededby 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 workwith milonga, so a manual installation is needed. In any case, compiling both PETSc and SLEPcgives a lot of flexibility in terms of configuration 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

Page 150: milonga

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:

$ milongamilonga 0.1free 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, thensome changes care has to be taken. First, probably you will not be abe to install GSL libaries assystem-wide accesible, so you will have to compile them in you home directory. Lucklily, PETSc isable to automatically download and LAPACK withouth further user interventino. Finally, you willhave 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

Page 151: milonga

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 copymilonga 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$ milongamilonga 0.1free 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 requiredlibraries is recommended. Users familiar with GSL, PETSc and SLEPc may want to re-use theirinstallations or to tune configuration options.

5.3.1 Obtaining the package

Milonga should be available to download from the author’s 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 official source of distribution. Not only should this site containthe 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 most—if not all—of the mathematical and numerical operations involved in solving the neutrondiffusion equation. In particular, matrix handling is done by PETSc and the eigenvalue problem issolved by SLEPc. General mathematical functions are provided by GSL and CUBATURE is used formultidimensional adaptive integration.

GSL

The GNU Scientific Library is a free libary that provides a great deal of routines for scientific andengineering computation. At least version 1.14 is needed. It can be obtained from

Page 152: milonga

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 installedwhere milonga can find them. In most GNU/Linux distributions, there are packages that provide theneeded functionality. In Debian-based distributions, installing package libgsl0-dev is enough tobe able to compile milonga.

# apt-get install libgsl0-dev

If there is no available package, GSL should be manually installed from its source code followingthe standard installation instructions. To install headers system-wide and make them automaticallyavailable to milonga, you have to be sure to execute make install as root after the compilation:

$ ./configure[...]$ make[...]$ suPassword:# make install# exit$

If you do not have root access, either tell GSL’s configure script to install the includes in a directorywhere you have write permissions and add it to the INCLUDE environment variable or keep the treewhere the GSL source was uncompressed and configure milonga with the appropriate flags to tell thecompiler where the headers are (see section 5.3.3). Or, easier, call your system administrator andkindly 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 scientific applications modeled by partial differential equations. It employs theMPI standard for parallelism.

Milonga uses it as an efficient handler of large sparse matrices. Current version of milonga doesnot use any of the parallelization mechanisms provided. At least version 3.1 is needed. Even thoughmost GNU/Linux distributions do provide a PETSc package, the author was not able to successfullycompile milonga with them. The PETSc source package distribution has to be downloaded, configuredand installed manually in order to milonga to work.

PETSc’s webpage is located at

http://www.mcs.anl.gov/petsc/petsc-as/

Detailed installation instructions can be found in the package documentation [2]. A configura-tion script (written in Python, so a interpreter has to be installed) detects available libraries andreads commandline options to generate appropriate makefiles. Linear algebra libraries and headersLAPACK or BLAS have to be installed (provided by package liblapack-dev, libblas-dev orlibatlas-dev), although the script can automatically download a free version of BLAS+LAPACK.It can also detect and use Intel’s Math Kernel Libraries.

It is possible to have a number of PETSc libraries using different configuration options (usingLAPACK or ATLAS, with debug symbols or optimized, with single or double precision, etc) a targetname can be provided. If no name is provided, default is linux-gnu-c-debug.

As milonga 0.1 does not take advantage of PETSc’s parallelization mechanisms, it is best to avoidmessing up with MPI, at least for a first installation.

Page 153: milonga

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 -gFortran Compiler: gfortran -g

Linkers:Static linker: /usr/bin/ar crDynamic linker: /usr/bin/ar

X11:Includes:Library: -lX11

BLAS/LAPACK: -llapack -lblasPETSc:

PETSC_ARCH: linux-gnu-c-debugPETSC_DIR: /home/jeremy/libs/petsc-3.1-p8Clanguage: CScalar type: realPrecision: doubleMemory alignment: 16shared libraries: disableddynamic libraries: disabled

xxx=========================================================================xxxConfigure 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/multiphysicsCompleted 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 testRunning test examples to verify correct installationC/C++ example src/snes/examples/tutorials/ex19 run successfully with 1 MPI processFortran example src/snes/examples/tutorials/ex5f run successfully with 1 MPI ←↩

processCompleted 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 defaultstatic PETSc configuration. If no Fortran compiler is available, --download-c-blas-lapackshould be given to instruct the script to download, compile and use a BLAS+LAPACK versionconverted from Fortran to C using f2c.

To compile SLEPc and milonga, two environment variables have to be set. The first one isPETSC DIR and should contain the directory where PETSc was uncompressed. It can be easilyset by executing

Page 154: milonga

milonga v0.1

$ export PETSC_DIR=$PWD$

from the PETSc directory. The other one is called PETSC ARCH and is the selected target. InGNU/Linux, default is linux-gnu-c-debug as reported by the configure 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,configure 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 multigroupsteady-state neutron diffusion 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. SLEPc’swebpage 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 configuration script written in Python. Luckily, it reads the configuration options passed toPETSc so normally no further arguments are needed. However, in order to be able to read PETSc’sconfiguration, both variables PETSC DIR and PETSC ARCH have to be defined to reflect the instal-lation directory and the target architecture. For example, if PETSc was configured with the defaultarchitecture and the steps in the previous section were followed, the execution of SLEPC’s configureshould be simple

Page 155: milonga

milonga v0.1

$ ./configureChecking environment...Checking PETSc installation...Checking LAPACK library...

================================================================================SLEPc Configuration================================================================================

SLEPc source directory:/home/jeremy/libs/slepc-3.1-p6SLEPc install directory:/home/jeremy/libs/slepc-3.1-p6/linux-gnu-c-debugPETSc directory:/home/jeremy/libs/petsc-3.1-p8Architecture "linux-gnu-c-debug" with double precision real numbers$

Before compiling SLEPc, the SLEPC DIR variable has to be set to reflect SLEPc’s directory. It canbe easily filled with the current directory by using the PWD variable. A make command will compilethe library.

$ export SLEPC_DIR=$PWD$ make==========================================On Fri Jul 15 19:48:34 ART 2011 on tomMachine 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-p6Using PETSc directory: /home/jeremy/libs/petsc-3.1-p8Using PETSc arch: linux-gnu-c-debug-----------------------------------------SLEPC_VERSION_RELEASE 1[...]libfast in: /home/jeremy/libs/slepc-3.1-p6/include/privatelibfast in: /home/jeremy/libs/slepc-3.1-p6/docs/usr/bin/ranlib /home/jeremy/libs/slepc-3.1-p6/linux-gnu-c-debug/lib/*.aCompleted building SLEPc libraries=========================================making shared libraries in /home/jeremy/libs/slepc-3.1-p6/linux-gnu-c-debug/libbuilding libslepc.so=========================================Now to check if the libraries are working do: make test=========================================$ make testRunning test examples to verify correct installationC/C++ example src/examples/ex1 run successfully with 1 MPI processFortran example src/examples/ex1f run successfully with 1 MPI processCompleted 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/

Page 156: milonga

milonga v0.1

It is used by milonga to compute cell average cross sections and to compute the surface integralsof the diffusion coefficients. As cubature is a small routine, it is incorporated into milonga as anothersource file 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 andSLEPc environment variables are set to their proper values, then the standard ./configure andmake steps should do the trick:

$ ./configurechecking for a BSD-compatible install... /usr/bin/install -cchecking whether build environment is sane... yeschecking for a thread-safe mkdir -p... /bin/mkdir -pchecking for gawk... gawkchecking whether make sets $(MAKE)... yeschecking for PETSC_DIR environment variable... /home/jeremy/libs/petsc-3.1-p8checking for PETSC_ARCH environment variable... linux-gnu-c-debugchecking for SLEPC_DIR environment variable... /home/jeremy/libs/slepc-3.1-p6checking for gcc... gcc[...]checking for strdup... yeschecking for strstr... yesconfigure: creating ./config.statusconfig.status: creating Makefileconfig.status: creating src/config.hconfig.status: src/config.h is unchangedconfig.status: executing depfiles commands$ makegcc -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.Pogcc -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, configuration script will com-plain. However, if they are set but their content is not correct, configure will run but make willfail.

If GSL was installed either from the distribution’s packages or compiled from the source andthen installed as root, the header should be globally available and milonga’s configure should

Page 157: milonga

milonga v0.1

be able to find them. If, however, they are installed somewhere else—probably because no rootaccess is available—then you have to tell milonga where they are. For example, if you uncompressedthe source distribution into directory /libs/gsl-1.15 and performed the ./configure andmake commmands there—without the make install step—then you have to pass to milonga’sconfiguration 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 command—and you have superuser access ofcourse—you 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 compilation—or by directly downloading a binary distribution—you will end up withan executable called milonga. Scientific codes linked against PETSc usually make use its parallelizationcapabilities and, as such, they have to be run using an MPI wrapper application. However, currentversion of milonga does not support parallelization, and thus it can be executed as any other regularprogram.

Milonga needs as its first argument the path of the input file containing the problem it has tosolve. If milonga is system-wide available, you can go to the directory where the input is and just callmilonga followed by the input name

$ cd examples$ milonga test.mil1.092211e+00$

If milonga is not installed system-wide, either you will have to copy the executable where the inputis, provide the full path to the executable or provide the full path to the input. Keep in mind thatusing the last choice that files 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 theexamples subdirectory of milonga’s distribution:

$ cd examples$ cd 01-analytical$ ./runx01-bare_slabmilonga comparisson.milanalytical keff = 1.09220381numerical keff = 1.09221091

difference = 7.101524e-06milonga flux.mil5.000000e-01 2.466006e-02 2.467300e-021.500000e+00 7.398017e-02 7.399464e-02

Page 158: milonga

milonga v0.1

2.500000e+00 1.232273e-01 1.232433e-01[...]06-two-zone_slabmilonga twozone.mil## copy and paste the following lines into gnuplot to obtain## the continuous flux distribution as a function of xnumerical_keff = 1.14799085analytical_keff = 1.14779361phi1(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 files are used to instruct a digital computer to perform a certain task. As discussed in the designbasis in chapter 1, they should in some sense resemble the approach taken by high-level source codecompilers. This way, milonga’s input files should be friendly human-readable chunks of text insteadof a bunch of numbers representing perforated cards.

As with source code, to render input files even more human-friendly, it is very handy to have asystem of syntax highlight when working with milonga’s input files. The distribution includes a syntaxfile definition for the text editor kate.

Figure 5.1: Syntax highlight in editor kate for milonga input files.

To have kate understand milonga’s input file, copy milonga.xml (located in subdirectory doc)to katepart’s 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$

Page 159: milonga

milonga v0.1

This way, any file with extension mil opened in kate or in any other editor using kate’s framework(such as kwrite) will be highlighted as shown in figure 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 usersmanual. 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.

Page 160: milonga

Keywords, variables and functions index

ALLOW NEGATIVE FLUX, 52

bc, 49BE QUIET, 56BOUNDARY CONDITIONS, 45build time, 48

cD, 49cESigmaF, 49chi, 43cnuSigmaF, 49CONDITION, 50CONTINUE, 56cSigmaA, 49cSigmaT, 49

D g, 49D EPSILON, 52D g, 45D MEAN, 52DEBUG, 55DIFFERENCES, 52DIMENSIONS, 42

EIGENVALUE INVERSE K, 53EIGENVALUE K, 53epsilon, 53ESigmaF g, 49ESigmaF g, 45

FILE, 49, 50flux g, 48

gamma I, 51gamma Xe, 51GRAD D LOCAL, 52GRAD D NEIGHBORS, 52GROUPS, 42

INCLUDE, 42INCREMENTAL, 44INFORM, 56INNER RADIUS, 44

keff, 47

keff error, 48

lambda I, 51lambda Xe, 51

MATERIAL, 44, 45MATRICES ASCII, 55MATRICES BINARY, 55MAX, 50MAX DAUGHTERS, 54METHOD, 53MIN, 50MIRROR, 45

NO NEGATIVE FLUX, 52NONE, 53nu, 51NULL, 45nuSigmaF g, 49nuSigmaF g, 45

ON ERROR, 57ON GSL ERROR, 57ON NAN, 56OUTER RADIUS, 44

PARAMETRIC, 53PARAMETRIC LOG, 54power, 51power density, 51PRINT, 50PRINT FUNCTION, 50PROBLEM, 42

QUIT, 56

SCHEME, 52SigmaA g, 49SigmaA g, 45sigmaAXe, 51SigmaS g, 45SigmaT g, 49SigmaT g, 45SLEPC, 53solve time, 48

155

Page 161: milonga

milonga v0.1

SOLVER, 53static iterations, 52static step, 52STEP, 50

TEXT, 50TOLERANCE, 53

VOLUMES, 52

x bare length, 42x cells, 43X CENTER, 44X MAX, 44, 45X MIN, 44, 45xenon, 51XS CENTER, 52XS MEAN, 52xs mean tolerance, 53

y bare length, 42y cells, 43Y CENTER, 44Y MAX, 44, 45Y MIN, 44, 45

z bare length, 42Z MAX, 44, 45Z MIN, 44, 45ZONE, 44

Page 162: milonga

TECNA S.A.http://www.tecna.com

Instituto Balseirohttp://www.ib.edu.ar

http://ib.cnea.gov.ar/˜thelerg/wasora/milonga