Extract data and create plots of OpenMC particle sources
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
from openmc_source_plotter import SourceWithPlotting
import openmc
import numpy as np
# initialises a new source object
my_source = SourceWithPlotting()
# 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
from openmc_source_plotter import SourceWithPlotting
import openmc
import numpy as np
# initialises a new source object
my_dt_source = SourceWithPlotting()
# 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 = SourceWithPlotting()
# 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
from openmc_source_plotter import SourceWithPlotting
import openmc
# initializes a new source object
my_source = SourceWithPlotting()
# 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 position of particles
from openmc_source_plotter import SourceWithPlotting
import openmc
# initialises a new source object
my_source = SourceWithPlotting()
# 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.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d84a9183ec86bd81c8de7238a8218c07cf6401702bff6267ee46d99fd769d373 |
|
MD5 | 731b2657e197f03d2b038f6a19f92824 |
|
BLAKE2b-256 | 8f432767d71e2902c4eea348d4f1522f2459e8a28bdb4df98bf5859b1c52258f |
Close
Hashes for openmc_source_plotter-0.6.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ed4413f199616ad5b58d3612140291258e88f4442eb931b444bc98f727d4726 |
|
MD5 | 7f5074070767831f5c6136db24b98b19 |
|
BLAKE2b-256 | 2b0be71c9de118157e5966865317a4093517b63111272c62b8d6354bf040fe82 |