mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 14:15:42 -04:00
changing y axis label for heating plots (#2859)
Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
This commit is contained in:
parent
0aad22d541
commit
27bd315f0f
2 changed files with 39 additions and 11 deletions
|
|
@ -73,24 +73,37 @@ def _get_legend_label(this, type):
|
|||
def _get_yaxis_label(reactions, divisor_types):
|
||||
"""Gets a y axis label for the type of data plotted"""
|
||||
|
||||
if all(isinstance(item, str) for item in reactions.keys()):
|
||||
stem = 'Microscopic'
|
||||
if divisor_types:
|
||||
mid, units = 'Data', ''
|
||||
else:
|
||||
mid, units = 'Cross Section', '[b]'
|
||||
heat_values = {"heating", "heating-local", "damage-energy"}
|
||||
|
||||
# if all the types are heating a different stem and unit is needed
|
||||
if all(set(value).issubset(heat_values) for value in reactions.values()):
|
||||
stem = "Heating"
|
||||
elif all(isinstance(item, str) for item in reactions.keys()):
|
||||
for nuc_reactions in reactions.values():
|
||||
for reaction in nuc_reactions:
|
||||
if reaction in heat_values:
|
||||
raise TypeError(
|
||||
"Mixture of heating and Microscopic reactions. "
|
||||
"Invalid type for plotting"
|
||||
)
|
||||
stem = "Microscopic"
|
||||
elif all(isinstance(item, openmc.Material) for item in reactions.keys()):
|
||||
stem = 'Macroscopic'
|
||||
if divisor_types:
|
||||
mid, units = 'Data', ''
|
||||
else:
|
||||
mid, units = 'Cross Section', '[1/cm]'
|
||||
else:
|
||||
msg = "Mixture of openmc.Material and elements/nuclides. Invalid type for plotting"
|
||||
raise TypeError(msg)
|
||||
|
||||
return f'{stem} {mid} {units}'
|
||||
if divisor_types:
|
||||
mid, units = "Data", ""
|
||||
else:
|
||||
mid = "Cross Section"
|
||||
units = {
|
||||
"Macroscopic": "[1/cm]",
|
||||
"Microscopic": "[b]",
|
||||
"Heating": "[eV-barn]",
|
||||
}[stem]
|
||||
|
||||
return f'{stem} {mid} {units}'
|
||||
|
||||
def _get_title(reactions):
|
||||
"""Gets a title for the type of data plotted"""
|
||||
|
|
|
|||
|
|
@ -118,6 +118,21 @@ def test_plot_axes_labels():
|
|||
)
|
||||
assert axis_label == 'Microscopic Cross Section [b]'
|
||||
|
||||
axis_label = openmc.plotter._get_yaxis_label(
|
||||
reactions={
|
||||
"Li": ["heating", "heating-local"],
|
||||
"Li7": ["heating"],
|
||||
"Be": ["damage-energy"],
|
||||
},
|
||||
divisor_types=False,
|
||||
)
|
||||
assert axis_label == "Heating Cross Section [eV-barn]"
|
||||
|
||||
with pytest.raises(TypeError):
|
||||
axis_label = openmc.plotter.plot_xs(
|
||||
reactions={"Li": ["heating", "heating-local"], "Be9": ["(n,2n)"]}
|
||||
)
|
||||
|
||||
# just materials
|
||||
mat1 = openmc.Material()
|
||||
mat1.add_nuclide('Fe56', 1)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue