gavin@ridleygav.in:~/projects$ cat horker.html
22.213 · reactor physics III · MITHorker++
I wrote Horker++ (high order reactor kinetics and evaluation of reactivity) for MIT's reactor physics III class, naming the code after the majestic three-tusked walrus-like creature from the Elder Scrolls series. The code is posted here. In that class, we studied time-dependent problems in reactor physics. In particular, the focus is on so-called spatial kinetics. The legendary Alan Henry conceived of a model of nuclear reactor dynamics called "point kinetics" back in the early days of nuclear engineering. This model basically assumes that the power level can change in time, but the shape of the power distribution does not.
Certain time-dependent problems in nuclear reactors require consideration of the change in the power level as a function of time, though. A key example of this is exhibited by the LRA benchmark, described here, where LRA stands for a long German acronym. One of the coolest things about this class was that it was taught by Kord Smith, who arguably provided one of the first well-resolved calculations of the LRA benchmark in his 1979 master's thesis.
In this problem, you calculate the response of a boiling water reactor core's response to an accidental removal of a control blade assembly. The reactor becomes prompt supercritical causing the power to rise in an entirely wild and out-of-control fashion, increasing orders of magnitude before the nuclear chain reaction is halted by the negative feedback of Doppler broadening. Because many others have run this calculation using the same parameters, you can compare the reuslts of your code to others. My code pretty much nails this benchmark.
So, what are some details on the code? I was tired of how every nuclear engineer on the face of the Earth is using either OpenFOAM or MOOSE to solve finite element problems for them. Maybe this is great if you're looking to minimize coding effort and don't want to optimize the internals of your code much, but I wanted the utmost in speed and in addition wanted to get a better mastery of the finite element method. Actually, it's not that hard to just assemble a finite element mesh yourself (for this geometry) and the related matrices you need to solve the finite element problem. The one thing I didn't write myself for this project was a linear algebra solver. I guess my bad case of NIH syndrome has to stop somewhere.
So, there are a few key things about the code I wrote that are unique:
- Generates meshes at run-time based on textual input files
- Fixing finite element order at run-time allows compiler to unroll loops over local mass/stiffness matrices
- Only dependency is Eigen, a truly excellent C++ library for linear algebra
- Comes with a python script that generates arbitrary order tensor-product finite elements
- VTK output for beautiful Paraview visualizations
- Finite element formulation allows handling of mesh deformation in transients
The last point is pretty cool, because most of the diffusion-based reactor kinetics codes out there use these things called transverse-integrated nodal methods (icky!) that only work on a perfectly coordinate-aligned Cartesian mesh (and sometimes in hexagonal geometry). From what I have read, PARCS can handle geometry deformation approximately using some modifications to the leakage operator. It sounds like it works pretty well if the deformations are small, which they always are in reactors.
The input files to the code were inspired by Serpent, which uses an input syntax which is beautiful by its simplicity and flexibility. For example, here is the input file to run the LRA benchmark transient in the 2D configuration. I'll describe the syntax after the input file.
set title "LRA Benchmark Steady State" set mode transient set eig_tol 1e-10 set dt 1e-3 set tfinal 3.0 set linsolve_tol 1e-6 set refine 2 set P0 1e-6 % W/cm^3 set T0 300 % K set rhocp 0.83655 % J/(cm^3 K) set write_vtk_interval 10 % --- Fuel assembly types --- assem 1 d 1.255 0.211 sig_a 0.008252 0.1003 nu_sig_f 0.004602 0.1091 sig_s 0 0 0.02533 0 chi 1 0 chi_d 1 0 betas 0.0054 0.001087 lambdas 0.0654 1.35 velocities 3e7 3e5 gam 3.034e-3 0 end assem 2 d 1.268 0.1902 sig_a 0.007181 0.07047 nu_sig_f 0.004609 0.08675 sig_s 0 0 0.02767 0 chi 1 0 chi_d 1 0 betas 0.0054 0.001087 lambdas 0.0654 1.35 velocities 3e7 3e5 gam 3.034e-3 0 end assem 3 d 1.259 0.2091 sig_a 0.008002 0.08344 nu_sig_f 0.004663 0.1021 sig_s 0 0 0.02617 0 chi 1 0 chi_d 1 0 betas 0.0054 0.001087 lambdas 0.0654 1.35 velocities 3e7 3e5 gam 3.034e-3 0 end assem 4 d 1.259 0.2091 sig_a 0.008002 0.073324 nu_sig_f 0.004663 0.1021 sig_s 0 0 0.02617 0 chi 1 0 chi_d 1 0 betas 0.0054 0.001087 lambdas 0.0654 1.35 velocities 3e7 3e5 gam 3.034e-3 0 end assem 5 d 1.257 0.1592 sig_a 0.0006034 0.01911 nu_sig_f 0 0 sig_s 0 0 0.04754 0 chi 1 0 chi_d 1 0 betas 0.0054 0.001087 lambdas 0.0654 1.35 velocities 3e7 3e5 gam 3.034e-3 0 end assem 6 d 1.259 0.2091 sig_a 0.008002 0.08344 nu_sig_f 0.004663 0.1021 sig_s 0 0 0.02617 0 chi 1 0 chi_d 1 0 betas 0.0054 0.001087 lambdas 0.0654 1.35 velocities 3e7 3e5 gam 3.034e-3 0 end % Set LRA material perturbations % Perturb material 6's sigma_a XS in group 1, 2 separate times matpert 6 sig_a 1 2 0 2 1 0.8787632 set axial_buckling 1e-4 set assembly_size 15.0 corelayout 13 13 v v v v v v v v v v v v v r 5 5 5 5 5 5 5 5 5 5 5 v r 5 5 5 5 5 5 5 5 5 5 5 v r 3 3 3 3 3 3 3 5 5 5 5 v r 3 3 3 3 3 3 3 4 5 5 5 v r 2 1 1 1 1 2 2 6 6 5 5 v r 2 1 1 1 1 2 2 6 6 5 5 v r 1 1 1 1 1 1 1 3 3 5 5 v r 1 1 1 1 1 1 1 3 3 5 5 v r 1 1 1 1 1 1 1 3 3 5 5 v r 1 1 1 1 1 1 1 3 3 5 5 v r 2 1 1 1 1 2 2 3 3 5 5 v v r r r r r r r r r r r v
At the beginning, there are a few lines that set general settings for the calculation. For instance, we set the time step to be one millisecond, converge the reactor eigenvalue to within 1e-10, solve three seconds of transient, subdivide each fuel assembly into four mesh squares, set a initial power density of a microwatt per cubic centimeter, set the fuel to room temperature at first, and output a VTK file every ten time steps.
After that, we define each of the different fuel assemblies in the problem, which you can find in the link I posted above to Sutton and Aviles' paper. The last few lines define the layout of the core. To place an assembly somewhere, you just put that number in the text. Reflecting boundaries are defined by an "r" character, and vacuum boundaries by the character "v". So, you can build some interesting geometries using this.
For example, I set up an SMR core calculation using this geometry. "5" is plain water, and "2" and "1" are alternating higher and lower enriched assemblies.
v v v v v v v v v v v v 5 5 5 5 5 5 5 5 5 v v 5 5 5 1 1 1 5 5 5 v v 5 5 1 2 2 2 1 5 5 v v 5 1 2 2 2 2 2 1 5 v v 5 1 2 1 2 1 2 1 5 v v 5 1 2 2 2 2 2 1 5 v v 5 5 1 2 2 2 1 5 5 v v 5 5 5 1 1 1 5 5 5 v v 5 5 5 5 5 5 5 5 5 v v v v v v v v v v v v
And if we plot the resulting thermal flux, it looks like this:
Nice! You can see how the fourth order finite elements model the sharp flux gradients pretty well. I put two low enriched assemblies in the middle to give that interesting pattern. To show a similar visualization, I plotted the thermal flux peaking factor over the course of the LRA benchmark. You can clearly see how dropping the control blade causes the power shape to strongly shift to the upper right region where the control blade was dropped from.
Lastly, I'll give my slides for the presentation here. I had originally developed this code in order to test a generalized version of what we call the "frequency transform" in reactor physics that I called "algebraic frequency transform", although I was unable to find any success with it. Also, you can see the exact equations I used here to formulate the problem. The model is based on neutron diffusion, not transport.