Skip to content

Commit

Permalink
Merge pull request #40 from fusion-energy/fix_gamma
Browse files Browse the repository at this point in the history
Converting material gamma emission plotting to function
  • Loading branch information
shimwell authored Mar 8, 2024
2 parents edc5c5f + 68087ab commit df9509a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
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

0 comments on commit df9509a

Please sign in to comment.