Skip to main content

Extract data and create plots of OpenMC particle sources

Project description

CI with install

Upload Python Package

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

import openmc
import openmc_source_plotter  # extends openmc.Source with plotting functions

# initialises a new source object
my_source = openmc.Source()

# 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()

openmc particle source energy plot

Plot of energy distribution of two sources

import openmc
import openmc_source_plotter  # extends openmc.Source with plotting functions

# initialises a new source object
my_dt_source = openmc.Source()

# 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 = openmc.Source()
# 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()

openmc particle source energy plot

Plot direction of particles

import openmc
import openmc_source_plotter  # extends openmc.Source with plotting functions

# initializes a new source object
my_source = openmc.Source()

# 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()

openmc particle source direction plot

Plot position of particles

import openmc
import openmc_source_plotter  # extends openmc.Source with plotting functions

# initialises a new source object
my_source = openmc.Source()

# 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()

openmc particle source position plot

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.6.2.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

openmc_source_plotter-0.6.2-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: openmc_source_plotter-0.6.2.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.0

File hashes

Hashes for openmc_source_plotter-0.6.2.tar.gz
Algorithm Hash digest
SHA256 813ccb2ebcbfc4f0caf8df83381097423622afb21577e031eaece11756267e90
MD5 de6847f7174c6f0ee2b3231e42863fb5
BLAKE2b-256 c7dece4dda2d1b7541433bb70700546d6638c3b227ae06ada2076f91afc30431

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for openmc_source_plotter-0.6.2-py3-none-any.whl
Algorithm Hash digest
SHA256 096b0c9ef8c523c6ef205758e20c0f5b053fc18f540073c32fbd6ba7f204d12e
MD5 fdb2e3443af17485e5fd12ae51b60619
BLAKE2b-256 aba8dec9723fa48b48bdc1827724948fe5e9996020d816b0d287151e87d49e04

See more details on using hashes here.

Supported by

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