Skip to content

Commit

Permalink
Merge pull request #6 from fusion-energy/allowing_movement_of_initial…
Browse files Browse the repository at this point in the history
…_source.h5

Allowing movement of initial source.h5
  • Loading branch information
shimwell authored Jan 26, 2022
2 parents caf9e50 + b4f7f1e commit 616e4be
Show file tree
Hide file tree
Showing 12 changed files with 390 additions and 210 deletions.
30 changes: 17 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ A Python package for plotting the locations, directions or energy distributions
pip install openmc_source_plotter
```

temporary fix
For fixed source sources it is currently necessary to use openmc version 0.11
and also to point the ```openmc_exec``` path to the openmc executable
This can be installed with:
```bash
conda install -c conda-forge openmc=0.11
```


# Features

The package provides functions to:
Expand All @@ -33,15 +42,12 @@ 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 = osp.plot_source_energy(
source=my_source,
number_of_particles=2000,
energy_bins=np.linspace(0, 20e6, 100),
openmc_exec="/home/jshim/miniconda3/envs/openmc_0_11_0/bin/openmc",
)

plot.show()
Expand All @@ -59,15 +65,13 @@ 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(
# plots the particle energy distribution
plot = osp.plot_source_direction(
source=my_source,
number_of_particles=100,
openmc_exec="/home/jshim/miniconda3/envs/openmc_0_11_0/bin/openmc",
)

# 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)
Expand Down
21 changes: 0 additions & 21 deletions examples/example_plot_direction_from_initial_source.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import openmc_source_plotter as osp
from openmc_plasma_source import TokamakSource
import openmc

my_source = TokamakSource(
elongation=1.557,
Expand All @@ -21,14 +20,12 @@
ion_temperature_beta=6,
).make_openmc_sources()

# makes an initial_source.h5 file with details of the particles
initial_source_filename = osp.create_initial_particles(

# plots the particle energy distribution
plot = osp.plot_source_position(
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_from_initial_source(input_filename=initial_source_filename)

plot.show()
17 changes: 17 additions & 0 deletions examples/example_plot_source_direction.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
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()

# plots the particle energy distribution
plot = osp.plot_source_direction(
source=my_source,
number_of_particles=100,
openmc_exec="/home/jshim/miniconda3/envs/openmc_0_11_0/bin/openmc",
)

plot.show()
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,15 @@
# 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 energy distribution to a Muir distribution 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
initial_source_filename = osp.create_initial_particles(
# plots the particle energy distribution
plot = osp.plot_source_energy(
source=my_source,
number_of_particles=10000,
energy_bins=np.linspace(0, 20e6, 100),
openmc_exec="/home/jshim/miniconda3/envs/openmc_0_11_0/bin/openmc",
)

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

plot.show()
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import openmc_source_plotter as osp
import openmc
import numpy as np

# initialises a new source object
my_source = openmc.Source()
Expand All @@ -19,15 +18,9 @@
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_from_initial_source(input_filename=initial_source_filename)
plot = osp.plot_source_position(
source=my_source, openmc_exec="/home/jshim/miniconda3/envs/openmc_0_11_0/bin/openmc"
)

plot.show()
24 changes: 24 additions & 0 deletions examples/example_plot_two_source_energies.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import openmc_source_plotter as osp
import openmc
import numpy as np

# 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
plot = osp.plot_source_energy(
source=[my_dt_source, my_dd_source],
number_of_particles=10000,
energy_bins=np.linspace(0, 20e6, 100),
openmc_exec="/home/jshim/miniconda3/envs/openmc_0_11_0/bin/openmc",
)

plot.show()
10 changes: 5 additions & 5 deletions openmc_source_plotter/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .core import plot_direction_from_initial_source
from .core import plot_position_from_initial_source
from .core import plot_energy_from_initial_source
from .core import get_particle_data
from .core import create_initial_particles
from .utils import get_particle_data
from .utils import create_initial_particles
from .core import plot_source_direction
from .core import plot_source_energy
from .core import plot_source_position
Loading

0 comments on commit 616e4be

Please sign in to comment.