Skip to main content

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 to example script.

openmc particle source energy plot

Plot of energy distribution of two sources

🔗Link to example script.

openmc particle source energy plot

Plot direction of particles

🔗Link to example script.

openmc particle source direction plot

Plot position of particles

🔗Link to example script.

openmc particle source position plot

Plot labeled gamma lines from material

🔗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

Tokamak sources can also be plotted using the openmc-plasma-source package

openmc_source_plotter_openmc-plasma-source_tokamak

Metadata

Release files for openmc-source-plotter 0.7.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for openmc-source-plotter 0.7.2
File Size Uploaded
openmc_source_plotter-0.7.2.tar.gz 38.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for openmc-source-plotter 0.7.2
File Interpreter ABI Platform
openmc_source_plotter-0.7.2-py3-none-any.whl Python 3 none any Details

Total release size: 47.0 kB

Release files / openmc_source_plotter-0.7.2.tar.gz

Download URL openmc_source_plotter-0.7.2.tar.gz
Size 38.2 kB
Tags Source
SHA-256 checksum
How to use checksums
1889ae006bf7e034a9b0cad2292ecb92122ab8d612fbbe6d3f356b6a2ca91f3b
BLAKE2b-256 checksum
How to use checksums
297ffdd4ce50502f5410b210de7a97ddcf29f49221c007c927504b4da59dbe22
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release files / openmc_source_plotter-0.7.2-py3-none-any.whl

Download URL openmc_source_plotter-0.7.2-py3-none-any.whl
Size 8.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
177036a018d790ff4eaca2eb650973dbeab5252692195d2041f8c551bbdf7a8d
BLAKE2b-256 checksum
How to use checksums
638c8be84668ca843e75e3cdbaeb040ff76481dac94c904fda6fc71510fd2c2d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release history Release notifications | RSS feed

This release

0.7.2 This release

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.8

2 release files

0.6.7

2 release files

0.6.6

2 release files

0.6.5

2 release files

0.6.4

2 release files

0.6.3

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.1.0

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page