# deplete.ReactionRates command

**URL:** https://openmc.discourse.group/t/deplete-reactionrates-command/1404
**Category:** User Support
**Created:** [August 31, 2021, 3:19pm UTC](https://openmc.discourse.group/t/deplete-reactionrates-command/1404 "2021-08-31T15:19:39Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![brianliu329](https://avatars.discourse-cdn.com/v4/letter/b/a4c791/32.png) [@brianliu329](https://openmc.discourse.group/u/brianliu329)
#### Post date: [August 31, 2021, 3:19pm UTC](https://openmc.discourse.group/t/deplete-reactionrates-command/1404/1 "2021-08-31T15:19:39Z")

</div>

Hi,

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

 ![image](https://global.discourse-cdn.com/free1/uploads/openmc/original/2X/9/95cf114757be4ecf758615d9982b1f8fbd5e1722.png)

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.

---

<div class="post-metadata">

### Author: ![andrewjohnson](https://avatars.discourse-cdn.com/v4/letter/a/f14d63/32.png) [@andrewjohnson](https://openmc.discourse.group/u/andrewjohnson)
#### Post date: [September 1, 2021, 4:01am UTC](https://openmc.discourse.group/t/deplete-reactionrates-command/1404/2 "2021-09-01T04:01:48Z")

</div>

@brianliu329,

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

```python
funcion(a, b=5, c)

```

is not allowed but something like

```python
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](https://docs.openmc.org/en/stable/pythonapi/generated/openmc.deplete.ReactionRates.html) might not be what you want. If you’re trying to process a depletion file, the [ResultsList](https://docs.openmc.org/en/stable/pythonapi/generated/openmc.deplete.ResultsList.html) class might be better suited.

The [pincell depletion example](https://docs.openmc.org/en/stable/examples/pincell_depletion.html) has a much better explanation on how to extract reaction rates using the `ResultList` class.

Cheers,  
Andrew

---

<div class="post-metadata">

### Author: ![brianliu329](https://avatars.discourse-cdn.com/v4/letter/b/a4c791/32.png) [@brianliu329](https://openmc.discourse.group/u/brianliu329)
#### Post date: [September 5, 2021, 1:39pm UTC](https://openmc.discourse.group/t/deplete-reactionrates-command/1404/3 "2021-09-05T13:39:01Z")

</div>

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:

 ![image](https://global.discourse-cdn.com/free1/uploads/openmc/original/2X/4/427440cbe541dfcc1ac02f9f9aa9ae9b0d28c3ca.png)  
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.

---

<div class="post-metadata">

### Author: ![paulromano](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/paulromano/32/486_2.png) [@paulromano](https://openmc.discourse.group/u/paulromano)
#### Post date: [September 7, 2021, 11:51am UTC](https://openmc.discourse.group/t/deplete-reactionrates-command/1404/4 "2021-09-07T11:51:19Z")

</div>

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:

```auto
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

```

---

<div class="post-metadata">

### Author: ![brianliu329](https://avatars.discourse-cdn.com/v4/letter/b/a4c791/32.png) [@brianliu329](https://openmc.discourse.group/u/brianliu329)
#### Post date: [September 7, 2021, 1:20pm UTC](https://openmc.discourse.group/t/deplete-reactionrates-command/1404/5 "2021-09-07T13:20:48Z")

</div>

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 openmc.data.Reaction as follow:

 ![image](https://global.discourse-cdn.com/free1/uploads/openmc/original/2X/1/1385ba3365e2d7e700c997c78420fb4f917bb1a7.png)  
which did not work.

Sorry if these are stupid questions.

---

<div class="post-metadata">

### Author: ![paulromano](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/paulromano/32/486_2.png) [@paulromano](https://openmc.discourse.group/u/paulromano)
#### Post date: [September 7, 2021, 4:18pm UTC](https://openmc.discourse.group/t/deplete-reactionrates-command/1404/6 "2021-09-07T16:18:28Z")

</div>

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

---

<div class="post-metadata">

### Author: ![brianliu329](https://avatars.discourse-cdn.com/v4/letter/b/a4c791/32.png) [@brianliu329](https://openmc.discourse.group/u/brianliu329)
#### Post date: [September 7, 2021, 8:50pm UTC](https://openmc.discourse.group/t/deplete-reactionrates-command/1404/7 "2021-09-07T20:50:14Z")

</div>

Hi,

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

 ![image](https://global.discourse-cdn.com/free1/uploads/openmc/original/2X/0/06d0790c5e587434fa43f2810c4643e4b15919d9.png)

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:  
 ![image](https://global.discourse-cdn.com/free1/uploads/openmc/original/2X/6/62f1f9f236789777ba7cf28f9ef42196d71aa012.png)

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

---

<div class="post-metadata">

### Author: ![paulromano](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/paulromano/32/486_2.png) [@paulromano](https://openmc.discourse.group/u/paulromano)
#### Post date: [September 8, 2021, 3:39am UTC](https://openmc.discourse.group/t/deplete-reactionrates-command/1404/8 "2021-09-08T03:39:34Z")

</div>

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:

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

```

---

<div class="post-metadata">

### Author: ![brianliu329](https://avatars.discourse-cdn.com/v4/letter/b/a4c791/32.png) [@brianliu329](https://openmc.discourse.group/u/brianliu329)
#### Post date: [September 8, 2021, 5:49pm UTC](https://openmc.discourse.group/t/deplete-reactionrates-command/1404/9 "2021-09-08T17:49:47Z")

</div>

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