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
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()
Usage
See the examples folder for example usage scripts.
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.5.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 96fc23052be1a41a2ad96cc021b9050e75ed3d51398bb53c2295b968d486ef77 |
|
MD5 | 0c6db6531f9a9c1699d02c46b4b33362 |
|
BLAKE2b-256 | 5e361becafdcb20a15da6f339af999dc944a26296cf48785502f7f36519a56f7 |
Close
Hashes for openmc_source_plotter-0.5.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30ecf55a2ad2dc25ea091c47cac3f95a36abc3e5014bc9dcb1344b2c2ea4d514 |
|
MD5 | 49d166b35f0fc241556ee6df44d9444a |
|
BLAKE2b-256 | 4fae2671ea0025e7700528d032eff18d63065a05cff7d9b8b2e1264200b57892 |