Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converting material gamma emission plotting to function #40

Merged
merged 1 commit into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ pip install openmc_source_plotter

# Features

The package simply extends the default ```openmc.IndependentSourceBase``` and ```openmc.Model``` to provides additional functions that:
The package provides three plotting functions that can plot source data from openmc objects.
- ```plot_source_energy```
- ```plot_source_position```
- ```plot_source_direction```
- ```plot_gamma_emission```

Additionally the package provides a convienient method of sampling particles
- ```sample_initial_particles```

- extract the positions, directions and energy of particles
- visualise a source with respect to:
- direction
- energy
- position

Or just provide the initial particles with ```sample_initial_particles```

# Example plots

Expand Down
3 changes: 3 additions & 0 deletions examples/example_gamma_spec_plot.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import openmc
from openmc_source_plotter import plot_gamma_emission

# you will need to install optional dependancies for this example
# pip install openmc_source_plotter[gammas]

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

Expand Down
15 changes: 6 additions & 9 deletions src/openmc_source_plotter/material.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


def plot_gamma_emission(
self,
material,
label_top: int = None,
):
"""makes a plot of the gamma energy spectra for a material. The
Expand All @@ -26,7 +26,7 @@ def plot_gamma_emission(
possible_energies_to_label = []
import lineid_plot

atoms = self.get_nuclide_atoms()
atoms = material.get_nuclide_atoms()
for nuc, num_atoms in atoms.items():
dists = []
probs = []
Expand All @@ -47,7 +47,7 @@ def plot_gamma_emission(

probs = []
en = []
energy_dis = self.decay_photon_energy
energy_dis = material.get_decay_photon_energy(clip_tolerance=0.0)
for p in energy_dis.p:
probs.append(0)
probs.append(p)
Expand All @@ -60,17 +60,17 @@ def plot_gamma_emission(
# print(probs)
lineid_plot.plot_line_ids(
en,
# self.decay_photon_energy.x,
# material.decay_photon_energy.x,
probs,
# self.decay_photon_energy.p,
# material.decay_photon_energy.p,
energies_to_label,
labels,
)

else:
probs = []
en = []
energy_dis = self.decay_photon_energy
energy_dis = material.get_decay_photon_energy(clip_tolerance=0.0)
for p in energy_dis.p:
probs.append(0)
probs.append(p)
Expand All @@ -87,6 +87,3 @@ def plot_gamma_emission(
plt.xlabel("Energy [eV]")
plt.ylabel("Activity [Bq/s]")
return plt


openmc.Material.plot_gamma_emission = plot_gamma_emission
Loading