I’ve noticed the following odd behaviour when plotting energy spectra using defined energy grids (or I am fundamentally misunderstanding this filter). I will demonstrate with the pincell example:
tallies = openmc.Tallies()
#create two sets of energy tallies:
#one set with uniform log energy grids with np.logspace and
#the second set with pre-defined grids
#evenly-spaced grids
num_groups = [75, 150, 300, 600, 1200]
for n in num_groups:
groups = np.logspace(-5, log10(20e6), n)
tally = openmc.Tally(name=str(n))
tally.scores = ['flux']
efil_in = openmc.EnergyFilter(groups)
tally.filters = [efil_in]
tallies.append(tally)
#pre-defined grids
scale_energy_grid = [1.000E-5, 1.000E-4, ... 1.733E+7, 2.000E+7 ] #shortened for easier viewing
grids = ['CASMO-70', 'XMAS-172', 'SCALE-238', 'SHEM-361', 'UKAEA-1102']
for grid in grids:
if grid=='SCALE-238':
groups = scale_energy_grid
else:
groups = openmc.mgxs.GROUP_STRUCTURES[grid]
tally = openmc.Tally(name=grid)
tally.scores = ['flux']
efil_in = openmc.EnergyFilter(groups)
tally.filters = [efil_in]
tallies.append(tally)
tallies.export_to_xml()
openmc.run()
When plotting the results of all these EnergyFilter tallies we see fairly smooth results for the set of tallies using np.logspace, but wildly oscillating spectra from the set which used defined group structures:
Thank you both, you are absolutely correct. The plots shown above were a straight flux plot, and were from a simplified version of the model in which the odd spectra were originally encountered. I revisited the original model after seeing your notes and the energy width calculation was being performed incorrectly. Thank you again for your help.
I am a new user of OpenMC. Very nice job, and thanks to all creators!
I did my first simulations. However, I have some misunderstandings with the interpretation of data. My question was: When using an Energy filter with non-equidistant bin size, what quantity do OpenMC scores, dN or dN/dE? Does the corresponding bin size divide data in each bin, i.e., the distribution is created? Or are data not divided by bin size, i.e., dN is scored?
However, after reading this thread and Jupyter Notebook Viewer
I think that I know the answer - only dN is scored. Please, am I right?
Perhaps related, we do have some methods on the EnergyFilter like .lethargy_bin_width if you want to do some lethargy plotting and need to divide by the bin width. Example here