Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding projection plot #4

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions examples/example_plot_projected_position_from_initial_source.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import openmc_source_plotter as osp
import openmc
import numpy as np

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


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

# plots the particle energy distribution
plot = osp.plot_position_projected_from_initial_source(
input_filename=initial_source_filename, axis="XY"
)

plot.show()
1 change: 1 addition & 0 deletions openmc_source_plotter/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from .core import plot_direction_from_initial_source
from .core import plot_position_from_initial_source
from .core import plot_position_projected_from_initial_source
from .core import plot_energy_from_initial_source
from .core import get_particle_data
from .core import create_initial_particles
37 changes: 37 additions & 0 deletions openmc_source_plotter/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,43 @@ def plot_energy_from_initial_source(
return fig


def plot_projected_position_from_initial_source(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def plot_projected_position_from_initial_source(
def plot_position_with_geometry_from_initial_source(

input_filename="initial_source.h5", axis="XY"
):
Comment on lines +132 to +133
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
input_filename="initial_source.h5", axis="XY"
):
input_filename="initial_source.h5",
h5m_filename="dagmc.h5m",
axis="XY"
):

"""makes a plot of the initial creation locations of the particle source"""

data = get_particle_data(input_filename)

text = ["Energy = " + str(i) + " eV" for i in data["e_values"]]

fig = go.Figure()

if axis == "XY":
x = data["x_values"]
y = data["y_values"]
if axis == "XZ":
x = data["x_values"]
y = data["z_values"]

fig.add_trace(
go.Scatter(
x=x,
y=y,
hovertext=text,
text=text,
mode="markers",
marker={
"size": 2,
"color": data["e_values"],
},
)
)

fig.update_layout(title="Particle production coordinates - coloured by energy")

return fig


def plot_position_from_initial_source(input_filename="initial_source.h5"):
"""makes a plot of the initial creation locations of the particle source"""

Expand Down