Skip to content

Commit

Permalink
Merge pull request #19 from fusion-energy/m_patch
Browse files Browse the repository at this point in the history
added patch to openmc.Source
  • Loading branch information
shimwell authored Aug 31, 2022
2 parents cdd68c4 + 82a8336 commit 52f15d9
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci_with_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
python examples/example_plot_source_position.py
python examples/example_plot_two_source_energies.py
pip install openmc_plasma_source
python examples/example_plot_plasma_source_position.py
# python examples/example_plot_plasma_source_position.py
- name: Run test_utils
run: |
Expand Down
4 changes: 2 additions & 2 deletions examples/example_get_particle_data.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import openmc
import openmc_source_plotter as osp
import openmc_source_plotter # overwrites the openmc.source method

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

# sets the location of the source to x=0 y=0 z=0
my_source.space = openmc.stats.Point((0, 0, 0))
Expand Down
2 changes: 2 additions & 0 deletions examples/example_plot_plasma_source_position.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
shafranov_factor=0.44789,
triangularity=0.270,
ion_temperature_beta=6,
angles=(0, 3.14), # makes a sector of 0 radians to 3.14 radians
sample_size=100, # reduces the number of samples from a default of 1000 to reduce plot time
).make_openmc_sources()


Expand Down
4 changes: 2 additions & 2 deletions examples/example_plot_source_direction.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import openmc_source_plotter as osp
import openmc
import openmc_source_plotter # overwrites the openmc.source method

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

# sets the direction to isotropic
my_source.angle = openmc.stats.Isotropic()
Expand Down
4 changes: 2 additions & 2 deletions examples/example_plot_source_energy.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from openmc_source_plotter import SourceWithPlotting
import openmc
import openmc_source_plotter # overwrites the openmc.source method

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

# sets the energy distribution to a Muir distribution neutrons
my_source.energy = openmc.stats.Muir(e0=14080000.0, m_rat=5.0, kt=20000.0)
Expand Down
4 changes: 2 additions & 2 deletions examples/example_plot_source_position.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from openmc_source_plotter import SourceWithPlotting
import openmc
import openmc_source_plotter # overwrites the openmc.source method

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

# the distribution of radius is just a single value
radius = openmc.stats.Discrete([10], [1])
Expand Down
6 changes: 3 additions & 3 deletions examples/example_plot_two_source_energies.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import openmc_source_plotter as osp
import openmc
import openmc_source_plotter # overwrites the openmc.source method

# initialises a new source object
my_dt_source = osp.SourceWithPlotting()
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 = osp.SourceWithPlotting()
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)

Expand Down
2 changes: 1 addition & 1 deletion openmc_source_plotter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@

__all__ = ["__version__"]

from .core import SourceWithPlotting
from .core import Source
5 changes: 4 additions & 1 deletion openmc_source_plotter/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import plotly.graph_objects


class SourceWithPlotting(openmc.Source):
class Source(openmc.Source):
r"""Inherits and extents the openmc.Source class to add source plotting
methods for energy, direction and position. Source sampling methods are
also provided for convenience. Additional methods are plot_source_energy(),
Expand Down Expand Up @@ -188,3 +188,6 @@ def plot_source_direction(
)

return figure


openmc.Source = Source
4 changes: 2 additions & 2 deletions tests/test_core.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from openmc_source_plotter import SourceWithPlotting
import openmc
import openmc_source_plotter
import numpy as np
import plotly.graph_objects as go
import pytest
Expand All @@ -8,7 +8,7 @@
@pytest.fixture
def test_source():
# initialises a new source object
my_source = SourceWithPlotting()
my_source = openmc.Source()

# sets the location of the source to x=0 y=0 z=0
my_source.space = openmc.stats.Point((0, 0, 0))
Expand Down

0 comments on commit 52f15d9

Please sign in to comment.