fusion-energy / openmc_source_plotter

A Python package for extracting and plotting the locations, directions, energy distributions of OpenMC source particles
MIT License
10 stars 3 forks source link

Allowing movement of initial source.h5 #6

Closed shimwell closed 2 years ago

shimwell commented 2 years ago

allows initial_source filename to be specified and also allows multiple energy plots to be added to the same graph using the

example usage of these two features together

import openmc_source_plotter as osp
import openmc_plasma_source as ops
import numpy as np

source_files = []
for temp in [500, 1000]:

    # sets the energy distribution to a Muir distribution neutrons for DT fusion neutrons
    my_source = ops.FusionPointSource(
        temperature=temp,
        fuel="DD",  # can be changed from DD to DT to get neutrons of different energy
    )

    source_filename = f"{temp}.h5"

    # makes an initial_source.h5 file with details of the particles
    osp.create_initial_particles(
        source=my_source,
        number_of_particles=100000,
        output_source_filename=source_filename,
        openmc_exec="/home/jshim/miniconda3/envs/openmc_0_11_0/bin/openmc",
    )

    source_files.append(source_filename)

# plots the particle energy distribution
plot = osp.plot_energy_from_initial_sources(
    energy_bins=np.linspace(0, 15e6, 10000),
    input_filenames=source_files
)

plot.show()
shimwell commented 2 years ago

CI is passing locally