Skip to content

source plotter does not support stats.univariate.mixture #41

@rlbarker

Description

@rlbarker

I’ve been using openmc_source_plotter.plot_gamma_emission and found a small bug. It seems that if material.get_decay_photon_energy() (line 50) returns an openmc.stats.univariate.mixture object then the function fails because openmc.stats.univariate.mixture does not have a .p attribute. However, if it returns am openmc.stats.univariate.discrete object, the plotter works fine (as the example does).
I have attached a minimum working example of this code which returns the error:

plt = plot_gamma_emission(material=my_material, label_top=3)
  File "/home/rbarker/miniforge3/envs/openmc_dev/lib/python3.9/site-packages/openmc_source_plotter/material.py", line 51, in plot_gamma_emission
    for p in energy_dis.p:
AttributeError: 'Mixture' object has no attribute 'p'

I have also attached the materials.xml file needed to run this code.

Minimum working example:

import openmc
from openmc_source_plotter import plot_gamma_emission

# This example is modified from https://github.com/fusion-energy/openmc_source_plotter/blob/main/examples/example_gamma_spec_plot.py

# this path will need changing to point to your chain file
openmc.config["chain_file"] = "/home/rbarker/chain.xml"

my_materials = openmc.Materials.from_xml()
my_material = my_materials.pop()

print(my_material.get_decay_photon_energy(clip_tolerance=0.0))

# adds labels to the most active 3 gamma energies
plt = plot_gamma_emission(material=my_material, label_top=3)
plt.xscale("log")
plt.savefig("gamma_spec.png")

materials.xml needed to run this file:

<materials>
<material id="26" volume="0.5078834276747504">
<density units="g/cm3" value="7.3100000000000005"/>
<nuclide ao="9.870374962755434e-116" name="Ag116"/>
<nuclide ao="2.687060094666136e-137" name="Ag117"/>
<nuclide ao="6.186243801149529e-159" name="Ag118"/>
<nuclide ao="0.001641354995525772" name="In113"/>
<nuclide ao="1.3848004856324852e-23" name="In114"/>
<nuclide ao="2.021398689349616e-23" name="In114_m1"/>
<nuclide ao="0.03669910273691459" name="In115"/>
<nuclide ao="7.61819302603757e-43" name="In115_m1"/>
<nuclide ao="5.027376610212269e-22" name="In116"/>
<nuclide ao="3.0847422082568705e-52" name="In117"/>
<nuclide ao="6.3004012242905105e-52" name="In117_m1"/>
</material>
</materials>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions