# Easily generate macroscopic cross section vs. energy from openmc.Material?

**URL:** <https://openmc.discourse.group/t/easily-generate-macroscopic-cross-section-vs-energy-from-openmc-material/300>\
**Category:** User Support\
**Created:** [November 19, 2017, 10:39pm UTC](https://openmc.discourse.group/t/easily-generate-macroscopic-cross-section-vs-energy-from-openmc-material/300 "2017-11-19T22:39:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gridley](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/gridley/32/1064_2.png) [@gridley](https://openmc.discourse.group/u/gridley)\
**Post date:** [November 19, 2017, 10:39pm UTC](https://openmc.discourse.group/t/easily-generate-macroscopic-cross-section-vs-energy-from-openmc-material/300/1 "2017-11-19T22:39:22Z")

</div>

Hi all,

It would be nice to be able to automatically generate data to plot macroscopic cross section of a material vs. energy for some reaction. In particular, I think this would be useful for making a plot of things like nu\*Sigma\_f / Sigma\_a for comparing different fuels in my senior design project. So far, my approach has been making materials, making a dictionary that maps nuclide names to variables containing instances of openmc.data.IncidentNeutron, and finally writing functions that take the dictionaries and materials to compute macroscopic cross section plots.

1. is there an easier way to do this? Maybe like openmc.Material.computeMacroXS(\<MT\_number\>)? I don’t see any in source.

and 2) would it be desirable to have Material methods that associate nuclides in a material to a particular data library? I think this would look something like adding a field to openmc.Nuclide for the .h5 file containing relevant data. Then Material methods could use those libraries for computing macroscopic cross sections of interest.

Thanks,

Gavin Ridley

---

<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:** [November 22, 2017, 4:52am UTC](https://openmc.discourse.group/t/easily-generate-macroscopic-cross-section-vs-energy-from-openmc-material/300/2 "2017-11-22T04:52:41Z")

</div>

Hi Gavin,

To plot macroscopic cross sections of a material, you can try using the [openmc.plot\_xs](http://openmc.readthedocs.io/en/latest/pythonapi/generated/openmc.plot_xs.html#openmc.plot_xs) function. For example:

import matplotlib.pyplot as plt

…  
openmc.plot\_xs(material, [‘nu-fission’], [‘absorption’])  
plt.show()

As for your second question, unfortunately we don’t have a way right now of managing nuclides from multiple libraries at the same time.

Best regards,  
Paul

---

<div class="post-metadata">

**Author:** ![gridley](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/gridley/32/1064_2.png) [@gridley](https://openmc.discourse.group/u/gridley)\
**Post date:** [November 22, 2017, 5:25am UTC](https://openmc.discourse.group/t/easily-generate-macroscopic-cross-section-vs-energy-from-openmc-material/300/3 "2017-11-22T05:25:59Z")

</div>

Hey Paul,

Thanks, this is a really helpful function! I had no clue it could take Materials as well.

Thanks,

Gavin Ridley
