deplete.ReactionRates command


I want to run the openmc.deplete.ReactionRates, but I get a syntax error as follow:

As I am still new to openmc and there is no example on the official website, what is the correct way to execute the reaction rate command? Thanks.


The issue is firstly related to how you are calling the function. In python, keyword arguments must after positional arguments . So something like

funcion(a, b=5, c)

is not allowed but something like

function(a, 5, c)

might be.

It looks like you are passing reactions= as the second argument to the ReactionRates object, and a string results_filename as the final argument.

Are you trying to pull reaction rates from a result file generated from a depletion run? The ReactionRates class might not be what you want. If you’re trying to process a depletion file, the ResultsList class might be better suited.

The pincell depletion example has a much better explanation on how to extract reaction rates using the ResultList class.


Hi Andrew,

Thanks for the reply. I followed the pincell depletion example to extract reaction rates from the ResultList. As I am simulating the transmutation of aluminium alloy, I guess I need to change the reaction rate to something else instead of having fission and I get the following error:

May I ask what the third argument (rx) should be in my case?

In addition, since the material I am dealing with is an alloy, how do I add mutiple isotopes into the reaction rates? Thanks.

The third argument needs to be the name of a reaction that is tracked during depletion, e.g. (n,gamma), (n,2n), or fission. If you want to add up the reaction rates for all nuclides in a material, you’ll have to write a loop to add it up, something like:

nuclides = list(results[0].nuc_to_ind.keys())
reaction_rate = np.zeros(len(results))
for nuc in nuclides:
    time, rr = results.get_reaction_rate("1", nuc, "fission")
    reaction_rate += rr

Thanks Paul. May I ask how you define the “reactions” in the second line? I tried to put reactions = (n,total) and obviously it would not do anything. I then also tried to do as follow:

which did not work.

Sorry if these are stupid questions.

My fault – that should have been results, not reactions. I’ve fixed it above. Sorry for the confusion!


Thanks for the response. I now get an error and I am not sure what the reason is.

I did not have a material identifier so I guess openmc automatically assigns it as 1. The nuclides here, I guess it is referring to the nuclides in my small chain:

Do you know why I am only getting an ‘Al26’ error? Is it something possibly to do with my chain file?

Yes, I believe this is because some nuclides in the chain (such as Al26) don’t have associated neutron cross sections (and hence no reaction rate is tallied). Instead of using results[0].nuc_to_ind, if you use results[0].rates[0].index_nuc, it should limit it to only nuclides with neutron data:

nuclides = list(results[0].rates[0].index_nuc.keys())

It is good now. Thanks for all the helps Paul.