Skip to content

Commit

Permalink
Merge pull request #9 from fusion-energy/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
shimwell authored Oct 23, 2021
2 parents fa285a2 + 85ed5ab commit ce08928
Show file tree
Hide file tree
Showing 14 changed files with 438 additions and 146 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci_with_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ jobs:
run: |
python setup.py install
- name: install openmc
run: |
conda install -c conda-forge openmc
- name: install packages for tests
run: |
pip install -r requirements-test.txt
Expand Down
66 changes: 64 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,64 @@
# dose_map_plotter
A Python package for plotting neutronics dose maps
[![N|Python](https://www.python.org/static/community_logos/python-powered-w-100x40.png)](https://www.python.org)

[![CI with install](https://github.com/fusion-energy/regular_mesh_plotter/actions/workflows/ci_with_install.yml/badge.svg?branch=develop)](https://github.com/fusion-energy/regular_mesh_plotter/actions/workflows/ci_with_install.yml)

[![PyPI](https://img.shields.io/pypi/v/regular-mesh-plotter?color=brightgreen&label=pypi&logo=grebrightgreenen&logoColor=green)](https://pypi.org/project/regular-mesh-plotter/)

[![codecov](https://codecov.io/gh/fusion-energy/regular_mesh_plotter/branch/main/graph/badge.svg)](https://codecov.io/gh/fusion-energy/regular_mesh_plotter)

## A minimal Python package that plots 2D mesh tally results with the underlying DAGMC geometry

# Installation

```bash
pip install regular_mesh_plotter
```

Mesh results in the form of Numpy arrays or OpenMC.tally objects can be plotted
with a single API call.

A Matplotlib.pyplot object is returned by all functions so one can make changes
to the legend, axis, colour map etc. However some key options are accessable
in the function call directly.

There are additional options that allow

- rotation of the mesh tally results
- rotation of the DAGMC geometry slice
- saving the plot as an image file
- specifying contour lines TODO
- changing axis and colour bar labels
- changing colour scale applied
- truncation of values
- The plane_normal of the DAGMC geometry

The resulting plots can be used to show dose maps, activation, reaction rate
and other mesh tally results.


Example 1 shows a Numpy array plotted
```python
TODO
```

Example 2 shows a Numpy array plotted with an underlying DAGMC geometry
```python
TODO
```

Example 3 shows a OpenMC tally plotted with an underlying DAGMC geometry
```python
TODO
```

Example 4 shows how to rotate the underlying DAGMC geometry and mesh tally.
This is sometimes necessary as the slice and mesh can get out of alignment
when changing the
```python
TODO
```

# Related packages

If you want to plot the DAGMC geometry without a mesh tally then take a look at
the [dagmc_geometry_slice_plotter](https://github.com/fusion-energy/dagmc_geometry_slice_plotter) package
77 changes: 77 additions & 0 deletions examples/examples_from_readme.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# this examples requires additional python packages

from dagmc_geometry_slice_plotter import plot_slice_of_dagmc_geometry
from stl_to_h5m import stl_to_h5m

import paramak

my_reactor = paramak.SubmersionTokamak(
inner_bore_radial_thickness=30,
inboard_tf_leg_radial_thickness=30,
center_column_shield_radial_thickness=30,
divertor_radial_thickness=80,
inner_plasma_gap_radial_thickness=50,
plasma_radial_thickness=200,
outer_plasma_gap_radial_thickness=50,
firstwall_radial_thickness=30,
blanket_rear_wall_radial_thickness=30,
number_of_tf_coils=16,
rotation_angle=360,
support_radial_thickness=90,
inboard_blanket_radial_thickness=30,
outboard_blanket_radial_thickness=30,
elongation=2.00,
triangularity=0.50,
pf_coil_case_thicknesses=[10, 10, 10, 10],
pf_coil_radial_thicknesses=[20, 50, 50, 20],
pf_coil_vertical_thicknesses=[20, 50, 50, 20],
pf_coil_radial_position=[500, 550, 550, 500],
pf_coil_vertical_position=[270, 100, -100, -270],
rear_blanket_to_tf_gap=50,
outboard_tf_coil_radial_thickness=30,
outboard_tf_coil_poloidal_thickness=30,
)


stl_filenames = my_reactor.export_stl()


stl_to_h5m(
files_with_tags=[
(stl_filename, name)
for name, stl_filename in zip(my_reactor.name, stl_filenames)
],
h5m_filename="dagmc.h5m",
)


plot = plot_slice_of_dagmc_geometry(
dagmc_file_or_trimesh_object="dagmc.h5m",
plane_normal=[0, 0, 1],
output_filename="my_plot1.png",
)


plot = plot_slice_of_dagmc_geometry(
dagmc_file_or_trimesh_object="dagmc.h5m",
plane_origin=[0, 0, 300],
plane_normal=[0, 0, 1],
output_filename="my_plot2.png",
)


plot = plot_slice_of_dagmc_geometry(
dagmc_file_or_trimesh_object="dagmc.h5m",
plane_normal=[0, 1, 0],
rotate_plot=45,
output_filename="my_plot3.png",
)

plot.savefig("big.png", dpi=600)

plot_slice_of_dagmc_geometry(
dagmc_file_or_trimesh_object="dagmc.h5m",
plane_normal=[1, 0, 0],
rotate_plot=270,
output_filename="my_plot4.png",
)
17 changes: 17 additions & 0 deletions examples/plot_mesh_with_geometry_slice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

from regular_mesh_plotter import plot_regular_mesh_tally_with_geometry
import openmc

# loads in the statepoint file containing tallies
statepoint = openmc.StatePoint(filepath="statepoint.3.h5")

# gets one tally from the available tallies
my_tally = statepoint.get_tally(name="neutron_effective_dose_on_2D_mesh_xy")

# creates the matplotlib mesh plot with geometry
plot = plot_regular_mesh_tally_with_geometry(
tally=my_tally,
mesh_file_or_trimesh_object="dagmc.h5m",
)

plot.show()
7 changes: 0 additions & 7 deletions examples/plot_mesh_with_slice.py

This file was deleted.

7 changes: 5 additions & 2 deletions regular_mesh_plotter/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@

from .core import plot_mesh
from .core import plot_regular_mesh_values
from .core import plot_regular_mesh_values_with_geometry
from .core import plot_regular_mesh_tally
from .core import plot_regular_mesh_tally_with_geometry
from .core import get_tally_extent
from .core import plot_stl_slice

Loading

0 comments on commit ce08928

Please sign in to comment.