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
You will need to have OpenMC version 0.14.0 or newer installed first.
pip install openmc_source_plotter
Features
The package simply extends the default openmc.IndependentSourceBase
and openmc.Model
to provides additional functions that:
- 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
Below are some basic examples, for more examples see the examples folder for example usage scripts.
Plot of energy distribution of the source
:link:Link to example script.
Plot of energy distribution of two sources
:link:Link to example script.
Plot direction of particles
:link:Link to example script.
Plot position of particles
:link:Link to example script.
Plot labeled gamma lines from material
:link:Link to example script.
Extract particle objects
A list of openmc.Particle
objects can be obtained using model.sample_initial_particles()
or openmc.SourceBase.sample_initial_particles()
import openmc
import openmc_source_plotter # extents openmc.Model with sample_initial_particles method
settings = openmc.Settings()
settings.particles = 1
settings.batches = 1
my_source = openmc.IndependentSource()
my_source.energy = openmc.stats.muir(e0=14080000.0, m_rat=5.0, kt=20000.0)
settings.source = my_source
materials = openmc.Materials()
sph = openmc.Sphere(r=100, boundary_type="vacuum")
cell = openmc.Cell(region=-sph)
geometry = openmc.Geometry([cell])
model = openmc.Model(geometry, materials, settings)
particles = model.sample_initial_particles(n_samples=10)
print(particles)
>>>[<SourceParticle: neutron at E=1.440285e+07 eV>, <SourceParticle: neutron at E=1.397691e+07 eV>, <SourceParticle: neutron at E=1.393681e+07 eV>, <SourceParticle: neutron at E=1.470896e+07 eV>, <SourceParticle: neutron at E=1.460563e+07 eV>, <SourceParticle: neutron at E=1.420684e+07 eV>, <SourceParticle: neutron at E=1.413932e+07 eV>, <SourceParticle: neutron at E=1.412428e+07 eV>, <SourceParticle: neutron at E=1.464779e+07 eV>, <SourceParticle: neutron at E=1.391648e+07 eV>]
print(particles[0].E)
>>>1.440285e+07
Related packages
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
Hashes for openmc_source_plotter-0.6.8.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ee5e6980f1cdeba53859a78894f69b6d2dae1fe9ca8dd7f2fa1b57f561084d6 |
|
MD5 | 0c3474cc5c25c5f443de2102b8f2cb49 |
|
BLAKE2b-256 | 8da64161df34c0204516abec04d3f026e3eb6017bc1f0043ad065de3f2802f44 |
Hashes for openmc_source_plotter-0.6.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65eaf5aecde3032cc98a34d2f820a186166a92763f718fcfed0ea21454f87b7d |
|
MD5 | 295771e15c9aacab94a99569ea5d1921 |
|
BLAKE2b-256 | 9a3e84e2c333974ab24b72d06e5ff22bf41430e625b78ff16d2d4cd437b8ec9a |