cant divide the tally value of epithermal to thermal capture reaction

I am trying to calculate the epithermal to thermal capture in U238.In order to find the ratio ,I am trying to divide the (n,gamma) score for U-238 in epithermal range by (n,gamma) reaction for U-238 in thermal range.I have tried this and several other things but no success

tallies_file = openmc.Tallies()
thermal = openmc.Tally(name=‘thermal capture’)
thermal.scores = [’(n,gamma)’]
thermal.nuclides = [‘U238’]
thermal.filters = [openmc.EnergyFilter([0.0, 0.625]),openmc.CellFilter([fuel_cell])]
tallies_file.append(thermal)

epithermal = openmc.Tally(name=‘epithermal capture’)
epithermal.scores = [’(n,gamma)’]
epithermal.nuclides = [‘U238’]
epithermal.filters = [openmc.EnergyFilter([0.625,100.0e3]),openmc.CellFilter([fuel_cell])]
tallies_file.append(epithermal)

sp = openmc.StatePoint(‘statepoint.100.h5’)
ep = sp.get_tally(name=‘epithermal capture’)
th = sp.get_tally(name=‘thermal capture’)
r = ep/th
print®

I get this when i do things like this

ValueError: Unable to get the bin index for Filter since "(0.625, 100000.0)" is not one of the bins

what am I doing wrong?Can you please show how its done?
thanks in advance

Untitled.ipynb (32.5 KB)

You’re close. You just need to get the mean values from the Tally objects rather than trying to do math on the Tally objects themselves:

r = ep.mean / th.mean

Also note that you can compute the same quantity using a single tally with multiple filter bins:

tallies_file = openmc.Tallies()
tally = openmc.Tally(name=‘U238 capture’)
tally.scores = [’(n,gamma)’]
tally.nuclides = [‘U238’]
tally.filters = [openmc.EnergyFilter([0.0, 0.625, 100.0e3]),openmc.CellFilter([fuel_cell])]
tallies_file.append(tally)
tallies_file.export_to_xml()

tally = sp.get_tally(name=‘U238 capture’)
r = tally.mean[1, 0, 0] / tally.mean[0, 0, 0]
print®

Why do I have to write ep.mean and th.mean ,sir? I mean when I am calculating reaction rate of fuel,it should give me an average because i am not doing any mesh or anything.

and you wrote tally.mean[1,0,0] and tally.mean[0,0,0]? Does it mean that the (n,gamma) reactions in the two energy bins are given output as a numpy array with shape (2, 1, 1)?
Thanks in advance,sir

The mean refers to taking an average over all the active batches from the simulation. Similarly, you can get ep.std_dev and th.std_dev (short for standard deviation) which gives estimates of the uncertainty of the tally.

And you’re correct on the numpy array. The mean and std_dev are output in the from of 3D numpy arrays. The first dimension corresponds to filter bins, energy filter bins in this case. If you specify multiple nuclides for a tally then you index their results with the second dimension of the numpy arrays. Multiple scores can be indexed on the third dimension.

Thanks ,sir