From 68087abe94b3e89ede76c3953ddb3a368434bf36 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Fri, 8 Mar 2024 14:40:46 +0000 Subject: [PATCH] gammas source working again; --- README.md | 16 ++++++++-------- examples/example_gamma_spec_plot.py | 3 +++ src/openmc_source_plotter/material.py | 15 ++++++--------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 49d98b9..4fae8fc 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/examples/example_gamma_spec_plot.py b/examples/example_gamma_spec_plot.py index 35177c6..4ecd5ef 100644 --- a/examples/example_gamma_spec_plot.py +++ b/examples/example_gamma_spec_plot.py @@ -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" diff --git a/src/openmc_source_plotter/material.py b/src/openmc_source_plotter/material.py index 58cec3c..ab9df53 100644 --- a/src/openmc_source_plotter/material.py +++ b/src/openmc_source_plotter/material.py @@ -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 @@ -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 = [] @@ -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) @@ -60,9 +60,9 @@ 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, ) @@ -70,7 +70,7 @@ def plot_gamma_emission( 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) @@ -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