Skip to content
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

High Temperature key error in from_njoy() #2317

Closed
teutebergt opened this issue Dec 5, 2022 · 1 comment · Fixed by #2320
Closed

High Temperature key error in from_njoy() #2317

teutebergt opened this issue Dec 5, 2022 · 1 comment · Fixed by #2320

Comments

@teutebergt
Copy link

When using openmc.data.IncidentNeutron.from_njoy(), for high temperatures a python KeyError may arise.

For what I can say the problem arises from the following sequence of actions performed by this routine (in file neutron.py):

  • Input temperature is taken in Kelvin.

  • Temperature is converted to MeV and written to an .ace file by njoy, rounded to something like 6 digits.

  • Data from the .ace file is read in by OpenMC and temperature is converted from MeV to K and rounded to an int - for temperatures above approx. 1e5 K this is not the same as the temperature int from the input.
    data = cls.from_ace(lib.tables[0])
    data.add_temperature_from_ace(table)
    This temperature is stored in data.temperatures.

  • A key for the data table is created using the "new" temperature after reading and rounding - but at a later point OpenMC tries to access the data table with a key from an evaluation object which seems to hold the "old" temperature from the input (or maybe it has been converted back and forth with higher precision, so rounding does not have an impact for the numbers I tested)
    temp = "{}K".format(round(ev.target["temperature"]))
    kerma = data.reactions[301].xs[temp]

  • Consequently, a python KeyError arises.

As a workaround, one can use openmc.data.njoy.make_ace and subsequently openmc.data.IncidentNeutron.from_ace (in this case, the data table is created and accessed with the same key from the .ace file).

Nevertheless, I suppose that the observed behaviour is not intended, so you might want to have a look at that.

@paulromano
Copy link
Contributor

Thanks for reporting this @teutebergt! Should be an easy fix; I'll try to get a PR submitted shortly. However, do note that NJOY itself also has some issues with high temperatures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants