openmc icon indicating copy to clipboard operation
openmc copied to clipboard

Production of multigroup cross sections with NJOY

Open shimwell opened this issue 10 months ago • 13 comments

Description

Following up with a slack conversation with @bohmt @MicahGale and @lewisgross1296

Currently the njoy.py file is able to create cards for ACER, PURR, GASPR, HEATR, HEATR_LOCAL, BROADR, RECONR and is useful for processing nuclear data. We also have lots of nice inbuilt energy group structures and NJOY input file writting and output file reading.

I was wondering if we could add GROUPR to the supported NJOY cards and another method called something like a classmethod MGXS.from_njoy()?

This would give use the ability to generate multigroup cross sections directly from ENDF data (without particle transport).

I have tried to match the existing openmc NJOY templates by using njoy inp examples from IAEA and groupr examples from T2 and page 230 of the njoy manual but I don't really know NJOY well enough to understand all the numbers.

_TEMPLATE_GROUPR = """
groupr / %%%%%%%%%%%%%%%% Multigroup data %%%%%%%%%%%%%%%%
{nendf} {npendf} 0 {ndir} /
{mat} 1 1 11 6 1 1 1/  <---- arbitrary structure for ign, arbitrary structure for igg, 11 for iwt number, 6 for mfd number, not sure about the last 3 numbers
'{library} GROUPR for {zsymam} processed by NJOY'/
{temperature}
1.E+10
 {num_energy_bins}
{energy_bins}
 {num_energy_bins}
{energy_bins}
3/
6/
16/
0/
0/
"""

Tagging @gonuke who is also interested in have a method of making multigroup cross sections

Alternatives

Run NJOY outside of openmc and get the GROUPR cross sections

Compatibility

This would add a method without disturbing existing code

shimwell avatar Apr 11 '24 17:04 shimwell

I thought one had to do it through transport, else you are missing the various group weighting factors from where the flux is in a given group and for self shielding?

makeclean avatar Apr 11 '24 18:04 makeclean

Typically, you need some multi-group neutron spectrum, yes. I guess if you use a "typical" spectrum, you don't need to run transport, but that probably would not be recommended unless you were confident in the flux. But if you just want quick and dirty MGXS, you could use equal group weighting or some contrived flux weighting.

lewisgross1296 avatar Apr 11 '24 19:04 lewisgross1296

NJOY does offer a couple of models to estimate self shielding (Bondarenko model and the flux calculator). I guess they are not as good as transporting but perhaps better than nothing.

shimwell avatar Apr 11 '24 19:04 shimwell

Yes with GROUPR inputs ( I refuse to say card) you use a fine-group structure. I would say anything less than 50 groups with GROUPR is getting risky.

So the one thing is I have actually written a script to do exactly this before with openmc. The hardest part is that it produces a group-wise ENDF GENDF (little sad they did create a GANDALF backronym). It uses a few more advanced features of ENDF-6 that breaks the ENDF reader in Openmc. I think this should be done but with a lot of infrastructure rework for reading ENDFs to make it more robust.

On Transport for multigroup cross sections

This is just me rambling, for better documentation see GROUPR in the NJOY manual.

So with multigroup cross sections you assume that the flux can be represented by something like

$$\sigma = \frac{\sum_{n=1}^N \phi_n \sigma_n}{\sum_{n=1}^N \phi_n}$$

Where $$\phi_n$$ is the flux , and $$\sigma_n$$ is the multi-group cross-section. This essentially assumes that the flux can be represented as:

$$\phi = \sum_{n=1}^N a_n \psi_n$$

Where $a_n$ is the group flux multiplier and $$\psi_n$$ is the "shape". So this assumes that inside of the energy group the flux shape is constant and is just varied by a multiplier. This is only valid for very fine groups.

In GROUPR you typically do a combo of a maxwell-boltzmann flux, a $$\frac{1}{E}$$, and a watts fission spectrum in thermal, epithermal, fast spectra. So this typical fast spectrum isn't valid for use in fusion, which is the biggest danger I see.

MicahGale avatar Apr 11 '24 20:04 MicahGale

I had a go at getting NJOY to run GROUPR but couldn't quite get it working.


 njoy 2016.74  12Jan24                                       04/11/24 23:05:58
 *****************************************************************************

 reconr...                                                                0.0s

 ---message from rdf2bw---calculation of angular distribution not installed.

 ---message from emerge---nonpositive elastic cross sections found.

 broadr...                                                                2.1s

 heatr...                                                                 3.9s

 heatr...                                                                 7.3s

 gaspr...                                                                26.7s

 purr...                                                                 27.5s

 mat = 2631                                                              27.5s

 ---message from purr---mat 2631 has no unresolved parameters
                          copy as is to nout

 groupr...                                                               27.7s

 ***error in groupr***unable to find mat=2631 t=  2.9360E+02
 
STOP 77
Traceback (most recent call last):
  File "/home/j/group_data_with_njoy/openmc_script.py", line 15, in <module>
    make_ace(
  File "/home/j/openmc/openmc/data/njoy.py", line 422, in make_ace
    run(commands, tapein, tapeout, **kwargs)
  File "/home/j/openmc/openmc/data/njoy.py", line 227, in run
    raise CalledProcessError(njoy.returncode, njoy_exec,
subprocess.CalledProcessError: Command 'njoy' returned non-zero exit status 77.

I'm building on this branch and running this test script

import openmc
from openmc.data.njoy import make_ace

kwargs = {
    "output_dir": ".",
    "acer": "./acer",
    "pendf": "./pendf",
    "heatr": "./heatr",
    "broadr": "./broadr",
    "gaspr": "./gaspr",
    "purr": "./purr",
    "groupr": "./groupr",
    "evaluation": None,
}
make_ace(
    filename="n-026_Fe_056.endf",
    temperatures=[293.6],
    stdout=True,
    **kwargs
)

shimwell avatar Apr 11 '24 22:04 shimwell

I'll crack open the NJOY manual again and take a look at your template. This error is weird, because the mat number should be the same throughout the whole run.

MicahGale avatar Apr 11 '24 22:04 MicahGale

It uses a few more advanced features of ENDF-6 that breaks the ENDF reader in Openmc

@MicahGale can you elaborate on this?

paulromano avatar Apr 12 '24 17:04 paulromano

@paulromano, it's been awhile and misremembered. I didn't have to change anything with endf.py base implementation; I just had to create a new class to handle the peculiarities of reading a GENDF.

Rereading the code though; there are so many magic numbers with ENDF files. I personally don't think there is much value in OpenMC creating a much more extensive ENDF parser. I think if we really want to go down this road for GROUPR I think we should use ENDFtk instead of implementing a GENDF reader. If we did this, I think the path forward would be:

  1. Make PRs to ACEtk and ENDFtk to make it build wheels, be pip installable and deployed to pypi.
  2. Add these libraries as optional(?) python dependencies
  3. Deprecate openmc.data.endf, and switch the machinery to ENDFtk

MicahGale avatar Apr 12 '24 19:04 MicahGale

But the more I think about this: is there enough use of openmc multi-group data to justify this being placed in openmc? I feel like multi-group is pretty rare and really should be left to the user to do.

MicahGale avatar Apr 12 '24 19:04 MicahGale

But the more I think about this: is there enough use of openmc multi-group data to justify this being placed in openmc? I feel like multi-group is pretty rare and really should be left to the user to do.

With OpenMC moving ever more into the fixed source fusion space, there is a need for generating weight windows. The FW-CADIS with random ray project is likely to be a fast way to do this, but requires some sort of MGXS data as input. One way we are thinking of doing this is to create a workflow where it generates very coarsely resolved XS data with a CE MC solve up-front as input to the random ray solver. It would be great though to have an option via NJOY or otherwise to generate MGXS data quickly using various assumptions on the flux spectrum. Recent work:

Raffuzzi, V., Cosgrove, P., Shriwise, P. C., & Tramm, J. R. (2024). Application of the Random Ray Method to Global Variance Reduction in Radiation Shielding Problems. International Conference on Physics of Reactors (PHYSOR 2024).

showed that NJOY XS data was good enough to get good weight windows for a shielding use case. Anyway, as I expect users in the future doing more fixed source work will find the upcoming variance reduction tools critical, I think it adds to the justification for adding this sort of capability to OpenMC.

jtramm avatar May 08 '24 18:05 jtramm

Raffuzzi, V., Cosgrove, P., Shriwise, P. C., & Tramm, J. R. (2024). Application of the Random Ray Method to Global Variance Reduction in Radiation Shielding Problems. International Conference on Physics of Reactors (PHYSOR 2024).

About two weeks? Impressive speed.

So re: Fission neutron spectrum. There are some fusion peak options for GROUPR. I think further investigation is needed to ensure that the slowing down is handled properly by those spectra for a fusion application though.

MicahGale avatar May 08 '24 19:05 MicahGale

If the MGXS are just being used for WW generation, then it probably requires less rigorous investigation, compared to MGXS used for transport, for example.

But I agree getting the fusion spectrum right is important for generating quality MGXS. Better MGXS will lead to better WWs, but any WWs (generated in a logical way for the problem) is better than none for fixed source fusion transport.

lewisgross1296 avatar May 08 '24 23:05 lewisgross1296

True, but never underestimate the ability of users to ignore caveats and run with data they really shouldn't be using.

MicahGale avatar May 21 '24 19:05 MicahGale