New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hotfix generating 0K data from NJOY #905
Conversation
Well, I pushed the changes to make error tolerance a parameter for generating data from njoy. Let me know if there is any problem. @paulromano |
Thanks @liangjg, I'll take a look soon! |
I found another issue on generating 0K data from NJOY: nuc = openmc.data.IncidentNeutron.from_njoy('n-018_Ar_036.endf', temperatures=[0.], stdout=True)
"""
njoy 2016.15 08May17 07/30/17 10:45:53
*****************************************************************************
reconr... 0.0s
broadr... 0.1s
heatr... 0.1s
purr... 0.2s
mat = 1825 0.2s
1 of 22 loops done for all temps & sig0s. 25.6s
2 of 22 loops done for all temps & sig0s. 50.2s
3 of 22 loops done for all temps & sig0s. 74.6s
4 of 22 loops done for all temps & sig0s. 99.0s
5 of 22 loops done for all temps & sig0s. 123.3s
6 of 22 loops done for all temps & sig0s. 147.7s
7 of 22 loops done for all temps & sig0s. 172.1s
8 of 22 loops done for all temps & sig0s. 196.5s
9 of 22 loops done for all temps & sig0s. 220.9s
10 of 22 loops done for all temps & sig0s. 245.4s
11 of 22 loops done for all temps & sig0s. 269.8s
12 of 22 loops done for all temps & sig0s. 294.3s
13 of 22 loops done for all temps & sig0s. 318.7s
14 of 22 loops done for all temps & sig0s. 343.2s
15 of 22 loops done for all temps & sig0s. 367.6s
16 of 22 loops done for all temps & sig0s. 392.1s
17 of 22 loops done for all temps & sig0s. 416.5s
18 of 22 loops done for all temps & sig0s. 441.0s
19 of 22 loops done for all temps & sig0s. 465.4s
20 of 22 loops done for all temps & sig0s. 489.8s
21 of 22 loops done for all temps & sig0s. 514.3s
22 of 22 loops done for all temps & sig0s. 538.8s
acer... 538.8s
At line 852 of file /home/liangjg/codes/NJOY2016/src/endf.f90 (unit = 24, file = 'tape24')
Fortran runtime error: Bad value during floating point read
""" The error appears for nuclides with unresolved resonance range. There are a lot of 'NaN' in the output of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @liangjg. I also had in mind that it would be useful to specify the error tolerance but then forgot to implement that -- glad you did!
openmc/data/neutron.py
Outdated
@@ -824,7 +824,7 @@ def from_endf(cls, ev_or_filename): | |||
return data | |||
|
|||
@classmethod | |||
def from_njoy(cls, filename, temperatures=None, **kwargs): | |||
def from_njoy(cls, filename, temperatures=None, error=0.001, **kwargs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's put this argument on njoy.make_ace
instead of here. It will still be possible for a user to specify it as a keyword argument since **kwargs
gets passed to make_ace
.
openmc/data/thermal.py
Outdated
@@ -588,7 +588,8 @@ def from_ace(cls, ace_or_filename, name=None): | |||
return table | |||
|
|||
@classmethod | |||
def from_njoy(cls, filename, filename_thermal, temperatures=None, **kwargs): | |||
def from_njoy(cls, filename, filename_thermal, temperatures=None, | |||
error=0.001, **kwargs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing here -- move this argument to njoy.make_ace_thermal
and let **kwargs
pass it if needed.
@paulromano The argument openmc.data.IncidentNeutron.from_njoy("n-092-U-235.endf", [0.], heatr=False, purr=False) will skip calling |
openmc/data/njoy.py
Outdated
@@ -50,84 +50,66 @@ | |||
75: ThermalTuple('ouo2', [8016, 8017, 8018], 1), | |||
} | |||
|
|||
|
|||
_PENDF_TEMPLATE = """ | |||
_ACE_TEMPLATE_RECONR = """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might as well rename all these to just _TEMPLATE_*
since they are not specific to ACE now.
openmc/data/njoy.py
Outdated
@@ -147,6 +130,8 @@ def run(commands, tapein, tapeout, stdout=False, njoy_exec='njoy'): | |||
Dictionary mapping tape numbers to paths for any input files | |||
tapeout : dict | |||
Dictionary mapping tape numbers to paths for any output files | |||
print_commands : bool, optional |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be more useful to have the inputs saved to a file. Why don't we have an argument run(..., input_filename=None, ...)
that if it's set to a string will save the inputs to a file with that name. So below, you'd have something like:
if input_filename is not None:
with open(input_filename, 'w') as input:
input.write(commands)
Really nice set of additions @liangjg. These would have been useful to me as I was debugging this module actually! Should be ready to merge after those last two comments of mine are addressed. By the way, if you just need 0 K cross sections, you could do something like: import openmc.data
openmc.data.njoy.make_pendf(endf_filename)
data = openmc.data.IncidentNeutron.from_endf('pendf')
elastic_scatter = data[2].xs['0K'] |
write NJOY input into file rather than printing on screen _ACE_TEMPLATE -> _TEMPLATE
@paulromano Thanks for the suggestion to use |
It is caused by the action to add 0K elastic scattering cross section from PENDF after running njoy, which overwrites the existing '0K' energy grid. This can be fixed by adding a line above the block
err
card in input file. For thetempr
anderrmax
, we may remove them to use the default values in njoy. The same changes can be made onbroadr
. Thethnmax
(upper limit for broadening) 1.0e6 in the template is recommended to be removed too as the default upper limit for broadening has been changed since NJOY2012.75. But I'm not sure why the values likethnmax
anderrmax
are different in sab case so the changes are not made yet. I'll push the new commit after @paulromano gives more suggestions.