Neutron flux distribution

Hello, I am trying to plot the neutron flux distribution per energy unit using the TRIGA reactor model provided by OpenMC. I am new to OpenMC and keep getting a problem where the flux_mean value always doubles itself based on the energies value, which eventually makes the plot impossible. Here is my tally configuration

tallies = openmc.Tallies()
energies = np.logspace(-3,7,50)
e_filter = openmc.EnergyFilter(energies)

tally = openmc.Tally(name='energy')
tally.filters = [e_filter]
tally.scores = ['flux', 'fission']
tallies.append(tally)
tallies.export_to_xml()

flux_mean

sp = openmc.StatePoint('statepoint.100.h5')
flux = sp.get_tally(scores=['flux'])
flux_mean = flux.mean.ravel()

And the plot

plt.figure()
plt.plot(energies[:-1], flux_mean/np.diff(energies))
plt.grid()
plt.show()

Please help me. I’m stuck on this problem for over a week.
Thank you. Also sorry for my very bad english (i’m using google translate)

The problem is that your flux variable really refers to the full tally (with both flux and fission scores), so what you are getting in flux.mean is both the flux and fission rate. Instead, what you need is something like:

tally = sp.get_tally(name='energy')
flux_mean = tally.get_values(scores=['flux']).ravel()
2 Likes

Thank you very much sir! I ended up using get_slice(scores=["flux"]) syntax and the code worked perfectly. Is this work different or the same as what you mentioned above?