A Python package for extracting and plotting the locations, directions, energy distributions of OpenMC source particles.
Project description
A Python package for plotting the positions, directions or energy distributions of OpenMC sources.
Installation
pip install openmc_source_plotter
Features
The package simply extends the default openmc.Source
to provides additional functions that:
- extract the positions, directions and energy of particles
- visualise an
osp.SourceWithPlotting
with respect to:- direction
- energy
- position
Example plots
Below are some basic examples, for more examples see the examples folder for example usage scripts.
Plot of energy distribution of the source
import openmc
import openmc_source_plotter # extends openmc.Source with plotting functions
# initialises a new source object
my_source = openmc.Source()
# sets the energy distribution to a Muir distribution neutrons for DT fusion neutrons
my_source.energy = openmc.stats.Muir(e0=14080000.0, m_rat=5.0, kt=20000.0)
# plots the particle energy distribution
plot = my_source.plot_source_energy(n_samples=2000)
plot.show()
Plot of energy distribution of two sources
import openmc
import openmc_source_plotter # extends openmc.Source with plotting functions
# initialises a new source object
my_dt_source = openmc.Source()
# sets the energy distribution to a Muir distribution DT neutrons
my_dt_source.energy = openmc.stats.Muir(e0=14080000.0, m_rat=5.0, kt=20000.0)
# initialises a new source object
my_dd_source = openmc.Source()
# sets the energy distribution to a Muir distribution DD neutrons
my_dd_source.energy = openmc.stats.Muir(e0=2080000.0, m_rat=2.0, kt=20000.0)
# plots the particle energy distribution by building on the first plot
figure1 = my_dd_source.plot_source_energy(n_samples=10000)
figure2 = my_dt_source.plot_source_energy(figure=figure1, n_samples=10000)
figure2.show()
Plot direction of particles
import openmc
import openmc_source_plotter # extends openmc.Source with plotting functions
# initializes a new source object
my_source = openmc.Source()
# sets the direction to isotropic
my_source.angle = openmc.stats.Isotropic()
# plots the particle energy distribution
plot = my_source.plot_source_direction(n_samples=200)
plot.show()
Plot gamma spectrum of particles
import openmc
import openmc_source_plotter # adds plot_gamma_emission plot to materials
openmc.config["chain_file"] = "chain-endf.xml"
my_material = openmc.Material()
my_material.add_nuclide("Xe135", 1e-12)
my_material.add_nuclide("U235", 1)
my_material.add_nuclide("U238", 1)
my_material.add_nuclide("Co60", 1e-9)
my_material.volume = 1 # must be set so number of atoms can be found
# adds labels to the most active 3 gamma energies
plt = my_material.plot_gamma_emission(label_top=3)
plt.xscale("log") # modify axis from default settings
plt.savefig("gamma_spec.png")
Plot position of particles
import openmc
import openmc_source_plotter # extends openmc.Source with plotting functions
# initialises a new source object
my_source = openmc.Source()
# the distribution of radius is just a single value
radius = openmc.stats.Discrete([10], [1])
# the distribution of source z values is just a single value
z_values = openmc.stats.Discrete([0], [1])
# the distribution of source azimuthal angles
# values is a uniform distribution between 0 and 2 Pi
angle = openmc.stats.Uniform(a=0.0, b=2 * 3.14159265359)
# this makes the ring source using the three distributions and a radius
my_source.space = openmc.stats.CylindricalIndependent(
r=radius, phi=angle, z=z_values, origin=(0.0, 0.0, 0.0)
)
# plots the particle energy distribution
plot = my_source.plot_source_position()
plot.show()
Tokamak sources can also be plotted using the openmc-plasma-source package
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for openmc_source_plotter-0.6.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c5cc0064881d06ade30406eec061fa29efb4a32e2c0bb9b99e8b6f4f2e3dc25 |
|
MD5 | 7d4d4b22154017de075459551856884e |
|
BLAKE2b-256 | 96db821c1082547f606faa97808802e1a7e65f36df5c9c65d3963381327a799b |
Close
Hashes for openmc_source_plotter-0.6.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7b50880be08f6e49e55f00d54ef06050f9adb2346a5990a24e97f33fc71d84e6 |
|
MD5 | 2f2439aee6566c8666aa98dc8eb448d4 |
|
BLAKE2b-256 | 72b1d86ab6078023d8e35125a0cf641d9dcc696172eb4bf5084e30aafe842979 |