Skip to main content

A Python package for extracting and plotting the locations, directions, energy distributions of OpenMC source particles.

Project description

CI with install

Upload Python Package

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 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

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.

openmc particle source energy plot

Plot of energy distribution of two sources

:link:Link to example script.

openmc particle source energy plot

Plot direction of particles

:link:Link to example script.

openmc particle source direction plot

Plot position of particles

:link:Link to example script.

openmc particle source position plot

Plot labeled gamma lines from material

:link:Link to example script.

gamma spec with labels

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
from openmc_source_plotter import sample_initial_particles

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 = sample_initial_particles(this=model, 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

openmc_source_plotter_openmc-plasma-source_tokamak

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

openmc_source_plotter-0.7.1.tar.gz (38.3 kB view details)

Uploaded Source

Built Distribution

openmc_source_plotter-0.7.1-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file openmc_source_plotter-0.7.1.tar.gz.

File metadata

  • Download URL: openmc_source_plotter-0.7.1.tar.gz
  • Upload date:
  • Size: 38.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for openmc_source_plotter-0.7.1.tar.gz
Algorithm Hash digest
SHA256 3328e447943f0b5353bf732df43ce72fddbe1dd62cc77f26c5c9024ed69c8a4d
MD5 8ea8a7b8384343caf2f2dabb4b05595c
BLAKE2b-256 44a31ddd44ea7720a14fbeb6b467885dee890ef5cf6e7061b8f51f46067b3f47

See more details on using hashes here.

File details

Details for the file openmc_source_plotter-0.7.1-py3-none-any.whl.

File metadata

File hashes

Hashes for openmc_source_plotter-0.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bcdb5b3b1bb0f8d18797a0ee7a15f91e302e46a15f7c327f6fcea9a741ce98b9
MD5 9b2b7f3852a0120b9ee97142c104e76a
BLAKE2b-256 034fa98767c90e9307b69a584685ce507860ede7ec181fd8656fea478d5b02c7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page