Skip to content

Commit

Permalink
Merge pull request #2 from fusion-energy/develop
Browse files Browse the repository at this point in the history
Adding CI tests
  • Loading branch information
shimwell authored Nov 30, 2021
2 parents 1489179 + ea6ed38 commit caf9e50
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 0 deletions.
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,56 @@ The package provides functions to:

# Example plots

Plot of energy distribution of the source

```python
import openmc_source_plotter as osp
import openmc
import numpy as np

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

# makes an initial_source.h5 file with details of the particles
osp.create_initial_particles(
source=my_source,
number_of_particles=10000,
)

# plots the particle energy distribution
plot = osp.plot_energy_from_initial_source(
energy_bins=np.linspace(0, 20e6, 100)
)

plot.show()
```
![openmc particle source energy plot](https://user-images.githubusercontent.com/8583900/143615694-a3578115-f8a2-4971-bf26-458177b4f113.png)


```python
import openmc_source_plotter as osp
import openmc

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

# sets the direction to isotropic
my_source.angle = openmc.stats.Isotropic()

# makes an initial_source.h5 file with details of the particles
initial_source_filename = osp.create_initial_particles(
source=my_source,
number_of_particles=100,
)

# plots the particle energy distribution
plot = osp.plot_direction_from_initial_source(input_filename=initial_source_filename)

plot.show()
```
![openmc particle source direction plot](https://user-images.githubusercontent.com/8583900/143615706-3b3a8467-0233-42d6-a66c-d536c80a01d8.png)

# Usage
Expand Down
43 changes: 43 additions & 0 deletions tests/test_get_particle_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import openmc_source_plotter as osp
import openmc
import unittest


class TestReactor(unittest.TestCase):
def setUp(self):

# initialises a new source object
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))

# sets the direction to isotropic
my_source.angle = openmc.stats.Isotropic()

# sets the energy distribution to 100% 14MeV neutrons
my_source.energy = openmc.stats.Discrete([14e6], [1])

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

def test_keys(self):

key_values = [
"x_values",
"y_values",
"z_values",
"x_dir",
"y_dir",
"z_dir",
"e_values",
]

data = osp.get_particle_data(self.initial_source_filename)
for key in key_values:
assert key in data.keys()

0 comments on commit caf9e50

Please sign in to comment.