You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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.
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.
The text was updated successfully, but these errors were encountered: