Skip to content

Instantly share code, notes, and snippets.

@shimwell
Created March 28, 2023 10:35
Show Gist options
  • Select an option

  • Save shimwell/b49e78e380df1ee943a2fd978d47eba8 to your computer and use it in GitHub Desktop.

Select an option

Save shimwell/b49e78e380df1ee943a2fd978d47eba8 to your computer and use it in GitHub Desktop.
Plot neutron reaction threshold energy for an isotopes. Setup to show different reactions resulting from DD (~2.5MeV) and DT (~14.1MeV) neutron sources.
import matplotlib.pyplot as plt
import openmc
from matplotlib.lines import Line2D
def plot_thresholds(nuclide="Fe56"):
plt.clf()
threshold_below_14 = 0
threshold_below_2 = 0
x = {}
fe = openmc.data.IncidentNeutron.from_hdf5(
# this dir would need changing to read the local nuclear data
f"/home/jshimwell/ENDF-B-VIII.0-NNDC/h5_files/neutron/{nuclide}.h5"
)
for key, value in fe.reactions.items():
reaction = fe[key]
xs = reaction.xs["294K"]
threshold = xs.x[0]
name = reaction.__str__().split()[-1][:-1]
if name not in ["heating", "damage-energy", "heating-local"]:
# print(threshold/1e6, name)
x[name] = threshold
if threshold < 14.1e6:
threshold_below_14 = threshold_below_14 + 1
color = "blue"
plt.plot(xs.x / 1e6, xs.y, label=name, color=color, linewidth=0.5)
if threshold < 2.5e6:
threshold_below_2 = threshold_below_2 + 1
color = "red"
plt.plot(xs.x / 1e6, xs.y, label=name, color=color, linewidth=0.5)
print(key, name, threshold / 1e6)
custom_lines = [
Line2D([0], [0], color="red", lw=4),
Line2D([0], [0], color="blue", lw=4),
]
plt.legend(
custom_lines,
["Reaction threshold < 2.5MeV", "Reaction threshold > 2.5 MeV and < 14 MeV"],
)
plt.title(
f"Neutron reaction cross sections for {nuclide} colored by threshold energy.\n {threshold_below_2} reactions below 2.5MeV {threshold_below_14} reactions below 14.1MeV"
)
plt.yscale("log")
plt.xlabel("Energy [MeV]")
plt.ylabel("Cross sections [barns]")
plt.xlim((0, 15))
plt.ylim((1e-16, 1e10))
plt.savefig(f"threshold_{nuclide}.png", dpi=200)
# all the reactiosn sorted by energy
all = dict(sorted(x.items(), key=lambda item: item[1]))
plot_thresholds(nuclide="Al27")
plot_thresholds(nuclide="Fe56")
@shimwell

Copy link
Copy Markdown
Author

Example plots show there are many more reactions from DT neutron sources compared to DD neutron sources

threshold_Fe56
threshold_Al27

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment