From 7343b21bcbfe8bd9131344c6f3474b23947df28d Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Thu, 28 Oct 2021 14:23:37 +0100 Subject: [PATCH 01/28] added error message when cross_section.xml can not be found --- openmc_dagmc_wrapper/Tally.py | 2 +- openmc_dagmc_wrapper/utils.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/openmc_dagmc_wrapper/Tally.py b/openmc_dagmc_wrapper/Tally.py index ed11173..85cc8ce 100644 --- a/openmc_dagmc_wrapper/Tally.py +++ b/openmc_dagmc_wrapper/Tally.py @@ -74,7 +74,7 @@ def set_score(self): ] if self.tally_type == "TBR": - self.scores = ["(n,Xt)"] # where X is a wild card + self.scores = ["(n,Xt)"] # todo see if H3-production can replace this elif self.tally_type in flux_scores: self.scores = ["flux"] else: diff --git a/openmc_dagmc_wrapper/utils.py b/openmc_dagmc_wrapper/utils.py index 968796a..da7c4cc 100644 --- a/openmc_dagmc_wrapper/utils.py +++ b/openmc_dagmc_wrapper/utils.py @@ -44,6 +44,12 @@ def get_an_isotope_present_in_cross_sections_xml(): variable""" cross_sections_xml = os.getenv('OPENMC_CROSS_SECTIONS') + if cross_sections_xml is None: + msg = ('set your OPENMC_CROSS_SECTIONS environmental variable before ' + 'running this script. This can be done automatically using the ' + 'openmc-data-downloader package or manually with an "export ' + 'OPENMC_CROSS_SECTIONS path to cross_sections.xml"') + raise ValueError(msg) import xml.etree.ElementTree as ET tree = ET.parse(cross_sections_xml) root = tree.getroot() From e800883a4248df2fde85939006fa3e530d49ecf2 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Tue, 23 Nov 2021 17:52:52 +0000 Subject: [PATCH 02/28] removed mesh ids setting --- openmc_dagmc_wrapper/Tally.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/openmc_dagmc_wrapper/Tally.py b/openmc_dagmc_wrapper/Tally.py index 9364ada..a771221 100644 --- a/openmc_dagmc_wrapper/Tally.py +++ b/openmc_dagmc_wrapper/Tally.py @@ -349,21 +349,18 @@ def create_mesh(self, bounding_box): self.mesh_resolution[0], 1, ] - mesh.id = 2 elif self.plane == "xz": mesh.dimension = [ self.mesh_resolution[1], 1, self.mesh_resolution[0], ] - mesh.id = 3 elif self.plane == "yz": mesh.dimension = [ 1, self.mesh_resolution[1], self.mesh_resolution[0], ] - mesh.id = 4 # mesh corners self.set_bounding_box(bounding_box) From e097a0386a7bf20a83162d377ace1478a4030817 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Tue, 23 Nov 2021 18:06:13 +0000 Subject: [PATCH 03/28] added method of finding bounding box --- openmc_dagmc_wrapper/Geometry.py | 74 +++++++++++++------------------- 1 file changed, 31 insertions(+), 43 deletions(-) diff --git a/openmc_dagmc_wrapper/Geometry.py b/openmc_dagmc_wrapper/Geometry.py index bf48245..8672f8c 100644 --- a/openmc_dagmc_wrapper/Geometry.py +++ b/openmc_dagmc_wrapper/Geometry.py @@ -5,6 +5,7 @@ from numpy import cos, sin from .utils import find_bounding_box +import trimesh class Geometry(openmc.Geometry): @@ -90,8 +91,7 @@ def make_root(self): vac_surf = self.create_sphere_of_vacuum_surface() region = -vac_surf & -reflective_1 & +reflective_2 - containing_cell = openmc.Cell( - cell_id=9999, region=region, fill=dag_univ) + containing_cell = openmc.Cell(cell_id=9999, region=region, fill=dag_univ) root = [containing_cell] @@ -102,7 +102,7 @@ def create_sphere_of_vacuum_surface(self): be used as an alternative to the traditionally DAGMC graveyard cell""" if self.graveyard_box is None: - self.graveyard_box = find_bounding_box(self.h5m_filename) + self.graveyard_box = self.corners() bbox = [[*self.graveyard_box[0]], [*self.graveyard_box[1]]] largest_radius = 3 * max(max(bbox[0]), max(bbox[1])) @@ -113,43 +113,31 @@ def create_sphere_of_vacuum_surface(self): return sphere_surface - def create_cube_of_vacuum_surfaces(self): - """Creates six vacuum surfaces that surround the geometry and can be - used as an alternative to the traditionally DAGMC graveyard cell""" - - if self.graveyard_box is None: - self.graveyard_box = find_bounding_box(self.h5m_filename) - bbox = [[*self.graveyard_box[0]], [*self.graveyard_box[1]]] - # add reflective surfaces - # fix the x and y minimums to zero to get the universe boundary co - bbox[0][0] = 0.0 - bbox[0][1] = 0.0 - - lower_x = openmc.XPlane( - bbox[0][0], - surface_id=9999, - boundary_type="vacuum") - upper_x = openmc.XPlane( - bbox[1][0], - surface_id=9998, - boundary_type="vacuum") - - lower_y = openmc.YPlane( - bbox[0][1], - surface_id=9997, - boundary_type="vacuum") - upper_y = openmc.YPlane( - bbox[1][1], - surface_id=9996, - boundary_type="vacuum") - - lower_z = openmc.ZPlane( - bbox[0][2], - surface_id=9995, - boundary_type="vacuum") - upper_z = openmc.ZPlane( - bbox[1][2], - surface_id=9994, - boundary_type="vacuum") - - return [lower_x, upper_x, lower_y, upper_y, lower_z, upper_z] + def corners(self, expand=None): + """Finds the bounding box of the geometry h5m file + Args: + expand: increase (+ve) number or decrease the offset from the + bounding box + + Returns: + vertices of lower left corner and upper right corner + """ + mesh_object = trimesh.load_mesh(self.h5m_filename, process=False) + verts = mesh_object.bounding_box.vertices + for vert in verts: + if ( + vert[0] < mesh_object.centroid[0] + and vert[1] < mesh_object.centroid[1] + and vert[2] < mesh_object.centroid[2] + ): + llc = (vert[0], vert[1], vert[2]) + if ( + vert[0] > mesh_object.centroid[0] + and vert[1] > mesh_object.centroid[1] + and vert[2] > mesh_object.centroid[2] + ): + urc = (vert[0], vert[1], vert[2]) + if expand: + llc = (llc[0] - expand[0], llc[1] - expand[1], llc[2] - expand[2]) + urc = (urc[0] + expand[0], urc[1] + expand[1], urc[2] + expand[2]) + return llc, urc From 5c02a7895879c23ce1b2f7fb6b8d4e4d88a65045 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Tue, 23 Nov 2021 18:26:13 +0000 Subject: [PATCH 04/28] removing bounding box from h5m file option --- openmc_dagmc_wrapper/Tally.py | 21 ++------------ openmc_dagmc_wrapper/__init__.py | 2 +- openmc_dagmc_wrapper/utils.py | 50 -------------------------------- 3 files changed, 4 insertions(+), 69 deletions(-) diff --git a/openmc_dagmc_wrapper/Tally.py b/openmc_dagmc_wrapper/Tally.py index a771221..de8bf71 100644 --- a/openmc_dagmc_wrapper/Tally.py +++ b/openmc_dagmc_wrapper/Tally.py @@ -7,8 +7,6 @@ from openmc_dagmc_wrapper import Materials -from .utils import find_bounding_box - class Tally(openmc.Tally): """ @@ -266,10 +264,7 @@ def __init__( def add_mesh_filter(self, bounding_box): - if isinstance(bounding_box, str): - self.bounding_box = find_bounding_box(h5m_filename=bounding_box) - else: - self.bounding_box = bounding_box + self.bounding_box = bounding_box mesh = openmc.RegularMesh(name="3d_mesh") mesh.dimension = self.mesh_resolution @@ -322,15 +317,14 @@ def __init__( self, tally_type: str, plane: str, - bounding_box: Union[str, List[Tuple[float]]], + bounding_box: List[Tuple[float]], mesh_resolution: Tuple[float, float] = (400, 400), ): self.tally_type = tally_type self.plane = plane self.mesh_resolution = mesh_resolution - self.bbox_from_h5 = None - self.bounding_box = None + self.bounding_box = bounding_box self.create_mesh(bounding_box) @@ -410,15 +404,6 @@ def create_mesh(self, bounding_box): self.mesh = mesh - def set_bounding_box(self, bounding_box): - - if isinstance(bounding_box, str): - self.bbox_from_h5 = True - self.bounding_box = find_bounding_box(h5m_filename=bounding_box) - else: - self.bbox_from_h5 = False - self.bounding_box = bounding_box - class MeshTallies2D: """[summary] diff --git a/openmc_dagmc_wrapper/__init__.py b/openmc_dagmc_wrapper/__init__.py index e7e9385..e9021b9 100644 --- a/openmc_dagmc_wrapper/__init__.py +++ b/openmc_dagmc_wrapper/__init__.py @@ -1,4 +1,4 @@ -from .utils import create_material, find_bounding_box +from .utils import create_material from .Geometry import Geometry from .Materials import Materials diff --git a/openmc_dagmc_wrapper/utils.py b/openmc_dagmc_wrapper/utils.py index 76c5d1d..dcaeca4 100644 --- a/openmc_dagmc_wrapper/utils.py +++ b/openmc_dagmc_wrapper/utils.py @@ -104,53 +104,3 @@ def diff_between_angles(angle_a: float, angle_b: float) -> float: if delta_mod > 180: delta_mod -= 360 return delta_mod - - -def find_bounding_box(h5m_filename: str) -> List[Tuple[float, float, float]]: - """Computes the bounding box of the DAGMC geometry - - Args: - h5m_filename: the filename of the DAGMC h5m file - - Returns: - x,y,z coordinates for the upper left and lower right corner - """ - if not Path(h5m_filename).is_file: - msg = f"h5m file with filename {h5m_filename} not found" - raise FileNotFoundError(msg) - dag_univ = openmc.DAGMCUniverse(h5m_filename, auto_geom_ids=False) - - geometry = openmc.Geometry(root=dag_univ) - geometry.root_universe = dag_univ - geometry.export_to_xml() - - silently_remove_file("materials.xml") - materials = create_placeholder_openmc_materials(h5m_filename) - materials.export_to_xml() - - openmc.Plots().export_to_xml() - - # a minimal settings .xml to allow openmc to init - settings = openmc.Settings() - settings.verbosity = 1 - settings.batches = 1 - settings.particles = 1 - settings.export_to_xml() - - # The -p runs in plotting mode which avoids the check that OpenMC does - # when looking for boundary surfaces and therefore avoids this error - # ERROR: No boundary conditions were applied to any surfaces! - openmc.lib.init(["-p"]) - - bbox = openmc.lib.global_bounding_box() - openmc.lib.finalize() - - silently_remove_file("settings.xml") - silently_remove_file("plots.xml") - silently_remove_file("geometry.xml") - silently_remove_file("materials.xml") - - return ( - (bbox[0][0], bbox[0][1], bbox[0][2]), - (bbox[1][0], bbox[1][1], bbox[1][2]), - ) From 0a2508b047902e93c6ef2ac3d89b63c48c459e17 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 23 Nov 2021 21:40:14 +0000 Subject: [PATCH 05/28] makin use of dagmc_bounding_box --- openmc_dagmc_wrapper/Geometry.py | 35 +++----------------------------- openmc_dagmc_wrapper/Tally.py | 6 ++---- setup.py | 1 + 3 files changed, 6 insertions(+), 36 deletions(-) diff --git a/openmc_dagmc_wrapper/Geometry.py b/openmc_dagmc_wrapper/Geometry.py index 8672f8c..9cac6ba 100644 --- a/openmc_dagmc_wrapper/Geometry.py +++ b/openmc_dagmc_wrapper/Geometry.py @@ -2,11 +2,9 @@ import dagmc_h5m_file_inspector as di import openmc +from dagmc_bounding_box import DagmcBoundingBox from numpy import cos, sin -from .utils import find_bounding_box -import trimesh - class Geometry(openmc.Geometry): """A openmc.Geometry object with a DAGMC Universe. If the model @@ -35,6 +33,8 @@ def __init__( self.h5m_filename = h5m_filename self.reflective_angles = reflective_angles self.graveyard_box = graveyard_box + self.bounding_box = DagmcBoundingBox(self.h5m_filename).corners + super().__init__(root=self.make_root()) def make_root(self): @@ -112,32 +112,3 @@ def create_sphere_of_vacuum_surface(self): ) return sphere_surface - - def corners(self, expand=None): - """Finds the bounding box of the geometry h5m file - Args: - expand: increase (+ve) number or decrease the offset from the - bounding box - - Returns: - vertices of lower left corner and upper right corner - """ - mesh_object = trimesh.load_mesh(self.h5m_filename, process=False) - verts = mesh_object.bounding_box.vertices - for vert in verts: - if ( - vert[0] < mesh_object.centroid[0] - and vert[1] < mesh_object.centroid[1] - and vert[2] < mesh_object.centroid[2] - ): - llc = (vert[0], vert[1], vert[2]) - if ( - vert[0] > mesh_object.centroid[0] - and vert[1] > mesh_object.centroid[1] - and vert[2] > mesh_object.centroid[2] - ): - urc = (vert[0], vert[1], vert[2]) - if expand: - llc = (llc[0] - expand[0], llc[1] - expand[1], llc[2] - expand[2]) - urc = (urc[0] + expand[0], urc[1] + expand[1], urc[2] + expand[2]) - return llc, urc diff --git a/openmc_dagmc_wrapper/Tally.py b/openmc_dagmc_wrapper/Tally.py index de8bf71..d37411c 100644 --- a/openmc_dagmc_wrapper/Tally.py +++ b/openmc_dagmc_wrapper/Tally.py @@ -251,7 +251,7 @@ class MeshTally3D(Tally): def __init__( self, tally_type: str, - bounding_box: Union[str, List[Tuple[float]]], + bounding_box: List[Tuple[float]], mesh_resolution=(100, 100, 100), **kwargs ): @@ -287,7 +287,7 @@ class MeshTallies3D: def __init__( self, tally_types: str, - bounding_box: Union[str, List[Tuple[float]]], + bounding_box: List[Tuple[float]], meshes_resolution: Tuple[float] = (100, 100, 100), ): self.tallies = [] @@ -324,8 +324,6 @@ def __init__( self.plane = plane self.mesh_resolution = mesh_resolution - self.bounding_box = bounding_box - self.create_mesh(bounding_box) super().__init__(tally_type) diff --git a/setup.py b/setup.py index 8eefd51..dd0b4ba 100644 --- a/setup.py +++ b/setup.py @@ -27,6 +27,7 @@ "plotly", "defusedxml", "dagmc_h5m_file_inspector", + "dagmc_bounding_box", ], # openmc, dagmc, moab are also needed and embree and double down are also # optionally needed but not avaible on PyPi From b57bcb01a386536803542c6350172e05f6c8bd84 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 23 Nov 2021 21:53:25 +0000 Subject: [PATCH 06/28] added plane_slice_location arg --- openmc_dagmc_wrapper/Geometry.py | 2 - openmc_dagmc_wrapper/Tally.py | 84 ++++++++++++++------------------ setup.py | 1 - 3 files changed, 36 insertions(+), 51 deletions(-) diff --git a/openmc_dagmc_wrapper/Geometry.py b/openmc_dagmc_wrapper/Geometry.py index 9cac6ba..b9daf7f 100644 --- a/openmc_dagmc_wrapper/Geometry.py +++ b/openmc_dagmc_wrapper/Geometry.py @@ -2,7 +2,6 @@ import dagmc_h5m_file_inspector as di import openmc -from dagmc_bounding_box import DagmcBoundingBox from numpy import cos, sin @@ -33,7 +32,6 @@ def __init__( self.h5m_filename = h5m_filename self.reflective_angles = reflective_angles self.graveyard_box = graveyard_box - self.bounding_box = DagmcBoundingBox(self.h5m_filename).corners super().__init__(root=self.make_root()) diff --git a/openmc_dagmc_wrapper/Tally.py b/openmc_dagmc_wrapper/Tally.py index d37411c..b4f361a 100644 --- a/openmc_dagmc_wrapper/Tally.py +++ b/openmc_dagmc_wrapper/Tally.py @@ -257,6 +257,7 @@ def __init__( ): self.tally_type = tally_type self.mesh_resolution = mesh_resolution + self.bounding_box = bounding_box super().__init__(tally_type, **kwargs) self.add_mesh_filter(bounding_box) @@ -264,8 +265,6 @@ def __init__( def add_mesh_filter(self, bounding_box): - self.bounding_box = bounding_box - mesh = openmc.RegularMesh(name="3d_mesh") mesh.dimension = self.mesh_resolution mesh.lower_left = self.bounding_box[0] @@ -318,11 +317,14 @@ def __init__( tally_type: str, plane: str, bounding_box: List[Tuple[float]], + plane_slice_location: Tuple[float, float] = (1,-1), mesh_resolution: Tuple[float, float] = (400, 400), ): self.tally_type = tally_type self.plane = plane self.mesh_resolution = mesh_resolution + self.bounding_box = bounding_box + self.plane_slice_location = plane_slice_location self.create_mesh(bounding_box) @@ -341,64 +343,50 @@ def create_mesh(self, bounding_box): self.mesh_resolution[0], 1, ] + mesh.lower_left = [ + self.bounding_box[0][0], + self.bounding_box[0][1], + self.plane_slice_location[1], + ] + mesh.upper_right = [ + self.bounding_box[1][0], + self.bounding_box[1][1], + self.plane_slice_location[0], + ] + elif self.plane == "xz": mesh.dimension = [ self.mesh_resolution[1], 1, self.mesh_resolution[0], ] + mesh.lower_left = [ + self.bounding_box[0][0], + self.plane_slice_location[1], + self.bounding_box[0][2], + ] + mesh.upper_right = [ + self.bounding_box[1][0], + self.plane_slice_location[0], + self.bounding_box[1][2], + ] + elif self.plane == "yz": mesh.dimension = [ 1, self.mesh_resolution[1], self.mesh_resolution[0], ] - - # mesh corners - self.set_bounding_box(bounding_box) - - if self.bbox_from_h5: - if self.plane == "xy": - mesh.lower_left = [ - self.bounding_box[0][0], - self.bounding_box[0][1], - -1, - ] - - mesh.upper_right = [ - self.bounding_box[1][0], - self.bounding_box[1][1], - 1, - ] - elif self.plane == "xz": - mesh.lower_left = [ - self.bounding_box[0][0], - -1, - self.bounding_box[0][2], - ] - - mesh.upper_right = [ - self.bounding_box[1][0], - 1, - self.bounding_box[1][2], - ] - elif self.plane == "yz": - mesh.lower_left = [ - -1, - self.bounding_box[0][1], - self.bounding_box[0][2], - ] - - mesh.upper_right = [ - 1, - self.bounding_box[1][1], - self.bounding_box[1][2], - ] - - else: - print(self.bounding_box) - mesh.lower_left = self.bounding_box[0] - mesh.upper_right = self.bounding_box[1] + mesh.lower_left = [ + self.plane_slice_location[1], + self.bounding_box[0][1], + self.bounding_box[0][2], + ] + mesh.upper_right = [ + self.plane_slice_location[0], + self.bounding_box[1][1], + self.bounding_box[1][2], + ] self.mesh = mesh diff --git a/setup.py b/setup.py index dd0b4ba..8eefd51 100644 --- a/setup.py +++ b/setup.py @@ -27,7 +27,6 @@ "plotly", "defusedxml", "dagmc_h5m_file_inspector", - "dagmc_bounding_box", ], # openmc, dagmc, moab are also needed and embree and double down are also # optionally needed but not avaible on PyPi From b9310ffbe907c16c6cce2173ab83acd8cdb18552 Mon Sep 17 00:00:00 2001 From: autopep8 Date: Tue, 23 Nov 2021 21:55:00 +0000 Subject: [PATCH 07/28] Automated autopep8 fixes --- openmc_dagmc_wrapper/Geometry.py | 3 ++- openmc_dagmc_wrapper/Tally.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/openmc_dagmc_wrapper/Geometry.py b/openmc_dagmc_wrapper/Geometry.py index 9cac6ba..d33d7b0 100644 --- a/openmc_dagmc_wrapper/Geometry.py +++ b/openmc_dagmc_wrapper/Geometry.py @@ -91,7 +91,8 @@ def make_root(self): vac_surf = self.create_sphere_of_vacuum_surface() region = -vac_surf & -reflective_1 & +reflective_2 - containing_cell = openmc.Cell(cell_id=9999, region=region, fill=dag_univ) + containing_cell = openmc.Cell( + cell_id=9999, region=region, fill=dag_univ) root = [containing_cell] diff --git a/openmc_dagmc_wrapper/Tally.py b/openmc_dagmc_wrapper/Tally.py index d37411c..718d5a2 100644 --- a/openmc_dagmc_wrapper/Tally.py +++ b/openmc_dagmc_wrapper/Tally.py @@ -72,7 +72,8 @@ def set_score(self): ] if self.tally_type == "TBR": - self.scores = ["(n,Xt)"] # todo see if H3-production can replace this + # todo see if H3-production can replace this + self.scores = ["(n,Xt)"] elif self.tally_type in flux_scores: self.scores = ["flux"] else: From 3ce340f8d032fa63f7e83bb2795aa326462428d8 Mon Sep 17 00:00:00 2001 From: autopep8 Date: Tue, 23 Nov 2021 21:56:14 +0000 Subject: [PATCH 08/28] Automated autopep8 fixes --- openmc_dagmc_wrapper/Tally.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openmc_dagmc_wrapper/Tally.py b/openmc_dagmc_wrapper/Tally.py index b9adc5f..a75980c 100644 --- a/openmc_dagmc_wrapper/Tally.py +++ b/openmc_dagmc_wrapper/Tally.py @@ -318,7 +318,7 @@ def __init__( tally_type: str, plane: str, bounding_box: List[Tuple[float]], - plane_slice_location: Tuple[float, float] = (1,-1), + plane_slice_location: Tuple[float, float] = (1, -1), mesh_resolution: Tuple[float, float] = (400, 400), ): self.tally_type = tally_type From 31e17ba90b75049adf0ec08107886623a8001985 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Wed, 24 Nov 2021 17:37:38 +0000 Subject: [PATCH 09/28] removed tests that are now in dagmc-bounding-box package --- tests/test_neutronics_utils.py | 32 +------------------------------- 1 file changed, 1 insertion(+), 31 deletions(-) diff --git a/tests/test_neutronics_utils.py b/tests/test_neutronics_utils.py index ce41eb7..5413f24 100644 --- a/tests/test_neutronics_utils.py +++ b/tests/test_neutronics_utils.py @@ -6,7 +6,7 @@ import openmc import openmc_dagmc_wrapper -from openmc_dagmc_wrapper import create_material, find_bounding_box +from openmc_dagmc_wrapper import create_material import neutronics_material_maker as nmm import pytest @@ -72,36 +72,6 @@ def incorrect_type(): self.assertRaises(TypeError, incorrect_type) - def test_bounding_box_size(self): - - bounding_box = find_bounding_box(self.h5m_filename_bigger) - - print(bounding_box) - assert len(bounding_box) == 2 - assert len(bounding_box[0]) == 3 - assert len(bounding_box[1]) == 3 - assert bounding_box[0][0] == pytest.approx(-10005, abs=0.1) - assert bounding_box[0][1] == pytest.approx(-10005, abs=0.1) - assert bounding_box[0][2] == pytest.approx(-10005, abs=0.1) - assert bounding_box[1][0] == pytest.approx(10005, abs=0.1) - assert bounding_box[1][1] == pytest.approx(10005, abs=0.1) - assert bounding_box[1][2] == pytest.approx(10005, abs=0.1) - - def test_bounding_box_size_2(self): - - bounding_box = find_bounding_box(self.h5m_filename_smaller) - - print(bounding_box) - assert len(bounding_box) == 2 - assert len(bounding_box[0]) == 3 - assert len(bounding_box[1]) == 3 - assert bounding_box[0][0] == pytest.approx(-10005, abs=0.1) - assert bounding_box[0][1] == pytest.approx(-10005, abs=0.1) - assert bounding_box[0][2] == pytest.approx(-10005, abs=0.1) - assert bounding_box[1][0] == pytest.approx(10005, abs=0.1) - assert bounding_box[1][1] == pytest.approx(10005, abs=0.1) - assert bounding_box[1][2] == pytest.approx(10005, abs=0.1) - # def test_create_initial_source_file(self): # """Creates an initial_source.h5 from a point source""" From 756c73c6906d30422cf03a9dfd3ccc88ff0848d3 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Wed, 24 Nov 2021 17:45:35 +0000 Subject: [PATCH 10/28] adding method of finding bounding box --- openmc_dagmc_wrapper/Geometry.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openmc_dagmc_wrapper/Geometry.py b/openmc_dagmc_wrapper/Geometry.py index fa1186b..cdd738c 100644 --- a/openmc_dagmc_wrapper/Geometry.py +++ b/openmc_dagmc_wrapper/Geometry.py @@ -36,6 +36,7 @@ def __init__( super().__init__(root=self.make_root()) def make_root(self): + # this is the underlying geometry container that is filled with the # faceted DAGMC CAD model dag_univ = openmc.DAGMCUniverse(self.h5m_filename) @@ -101,7 +102,8 @@ def create_sphere_of_vacuum_surface(self): be used as an alternative to the traditionally DAGMC graveyard cell""" if self.graveyard_box is None: - self.graveyard_box = self.corners() + from dagmc_bounding_box import DagmcBoundingBox + self.graveyard_box = DagmcBoundingBox(self.h5m_filename).corners() bbox = [[*self.graveyard_box[0]], [*self.graveyard_box[1]]] largest_radius = 3 * max(max(bbox[0]), max(bbox[1])) From d8a05cab91cddf49d3ac178b8344def397d2f4a7 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 24 Nov 2021 20:17:24 +0000 Subject: [PATCH 11/28] updated bounding_box arg to avoid use of h5m file --- requirements-test.txt | 1 + tests/test_system/test_system_single_volume.py | 15 ++++++++++----- tests/test_tallies/test_mesh_tally_2d.py | 8 ++++---- tests/test_tallies/test_mesh_tally_3d.py | 7 +++++-- 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/requirements-test.txt b/requirements-test.txt index 21976d9..f898533 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -6,3 +6,4 @@ nbformat nbconvert requests openmc-plasma-source +dagmc_bounding_box diff --git a/tests/test_system/test_system_single_volume.py b/tests/test_system/test_system_single_volume.py index a633cc8..f6c738b 100644 --- a/tests/test_system/test_system_single_volume.py +++ b/tests/test_system/test_system_single_volume.py @@ -7,6 +7,7 @@ import neutronics_material_maker as nmm import openmc import openmc_dagmc_wrapper as odw +from dagmc_bounding_box import DagmcBoundingBox class TestShape(unittest.TestCase): @@ -227,10 +228,11 @@ def test_neutronics_component_2d_mesh_simulation(self): materials = odw.Materials( h5m_filename=self.h5m_filename_smaller, correspondence_dict={"mat1": "Be"}) + my_tallies = odw.MeshTallies2D( tally_types=["heating"], planes=["xy", "xz", "yz"], - bounding_box=self.h5m_filename_smaller) + bounding_box=DagmcBoundingBox(self.h5m_filename_smaller).corners()) my_model = openmc.model.Model( geometry=geometry, @@ -261,7 +263,7 @@ def test_neutronics_component_3d_mesh_simulation(self): my_tallies = odw.MeshTallies3D( tally_types=["heating", "(n,Xt)"], - bounding_box=self.h5m_filename_smaller) + bounding_box=DagmcBoundingBox(self.h5m_filename_smaller).corners()) my_model = openmc.model.Model( geometry=geometry, @@ -273,7 +275,7 @@ def test_neutronics_component_3d_mesh_simulation(self): h5m_filename = my_model.run() results = openmc.StatePoint(h5m_filename) - assert len(results.meshes) == 1 + assert len(results.meshes) == 2 # ideally these tallies would share the same mesh and there would be 1 mesh assert len(results.tallies.items()) == 2 assert Path(h5m_filename).exists() is True @@ -291,12 +293,15 @@ def test_neutronics_component_3d_and_2d_mesh_simulation(self): correspondence_dict={"mat1": "Be"}) my_3d_tally = odw.MeshTally3D( - tally_type="heating", bounding_box=self.h5m_filename_smaller) + tally_type="heating", + bounding_box=DagmcBoundingBox(self.h5m_filename_smaller).corners() + ) my_2d_tallies = odw.MeshTallies2D( planes=["xz", "xy", "yz"], tally_types=["heating"], - bounding_box=self.h5m_filename_smaller) + bounding_box=DagmcBoundingBox(self.h5m_filename_smaller).corners() + ) my_model = openmc.model.Model( geometry=geometry, diff --git a/tests/test_tallies/test_mesh_tally_2d.py b/tests/test_tallies/test_mesh_tally_2d.py index e6e12d2..3dd3a3d 100644 --- a/tests/test_tallies/test_mesh_tally_2d.py +++ b/tests/test_tallies/test_mesh_tally_2d.py @@ -6,7 +6,7 @@ import openmc import openmc_dagmc_wrapper as odw from openmc_plasma_source import FusionRingSource - +from dagmc_bounding_box import DagmcBoundingBox class TestMeshTally2D(unittest.TestCase): """Tests the MeshTally2D class functionality""" @@ -58,19 +58,19 @@ def test_shape_of_resulting_png(self): tally1 = odw.MeshTally2D( tally_type="neutron_flux", plane="xy", - bounding_box=self.h5m_filename_smaller, + bounding_box=DagmcBoundingBox(self.h5m_filename_smaller).corners(), mesh_resolution=(10, 200), ) tally2 = odw.MeshTally2D( tally_type="neutron_flux", plane="xz", - bounding_box=self.h5m_filename_smaller, + bounding_box=DagmcBoundingBox(self.h5m_filename_smaller).corners(), mesh_resolution=(20, 100), ) tally3 = odw.MeshTally2D( tally_type="neutron_flux", plane="yz", - bounding_box=self.h5m_filename_smaller, + bounding_box=DagmcBoundingBox(self.h5m_filename_smaller).corners(), mesh_resolution=(30, 500), ) diff --git a/tests/test_tallies/test_mesh_tally_3d.py b/tests/test_tallies/test_mesh_tally_3d.py index f3e6b0f..e41dca2 100644 --- a/tests/test_tallies/test_mesh_tally_3d.py +++ b/tests/test_tallies/test_mesh_tally_3d.py @@ -5,6 +5,7 @@ import openmc import openmc_dagmc_wrapper as odw +from dagmc_bounding_box import DagmcBoundingBox class TestMeshTally3D(unittest.TestCase): @@ -45,15 +46,17 @@ def incorrect_mesh_tally_3d_type(): def test_meshfilter_from_h5m_file(self): # build - bbox = odw.find_bounding_box(self.h5m_filename_smaller) expected_mesh = openmc.RegularMesh(mesh_id=99, name="3d_mesh_expected") + bbox = DagmcBoundingBox(self.h5m_filename_smaller).corners() expected_mesh.lower_left = bbox[0] expected_mesh.upper_right = bbox[1] expected_mesh.dimension = (100, 100, 100) # run my_tally = odw.MeshTally3D( - "heating", bounding_box=self.h5m_filename_smaller) + "heating", + bounding_box=DagmcBoundingBox(self.h5m_filename_smaller).corners() + ) produced_filter = my_tally.filters[-1] produced_mesh = produced_filter.mesh # test From cb6162512fbb55987e4035ae6791f74002d63547 Mon Sep 17 00:00:00 2001 From: autopep8 Date: Wed, 24 Nov 2021 20:17:51 +0000 Subject: [PATCH 12/28] Automated autopep8 fixes --- tests/test_system/test_system_single_volume.py | 4 +++- tests/test_tallies/test_mesh_tally_2d.py | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/test_system/test_system_single_volume.py b/tests/test_system/test_system_single_volume.py index f6c738b..c5d8633 100644 --- a/tests/test_system/test_system_single_volume.py +++ b/tests/test_system/test_system_single_volume.py @@ -275,7 +275,9 @@ def test_neutronics_component_3d_mesh_simulation(self): h5m_filename = my_model.run() results = openmc.StatePoint(h5m_filename) - assert len(results.meshes) == 2 # ideally these tallies would share the same mesh and there would be 1 mesh + # ideally these tallies would share the same mesh and there would be 1 + # mesh + assert len(results.meshes) == 2 assert len(results.tallies.items()) == 2 assert Path(h5m_filename).exists() is True diff --git a/tests/test_tallies/test_mesh_tally_2d.py b/tests/test_tallies/test_mesh_tally_2d.py index 3dd3a3d..a9454ad 100644 --- a/tests/test_tallies/test_mesh_tally_2d.py +++ b/tests/test_tallies/test_mesh_tally_2d.py @@ -8,6 +8,7 @@ from openmc_plasma_source import FusionRingSource from dagmc_bounding_box import DagmcBoundingBox + class TestMeshTally2D(unittest.TestCase): """Tests the MeshTally2D class functionality""" From 2f07399b8083388c08a17f5e04dcf50d87edfa27 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 24 Nov 2021 20:27:14 +0000 Subject: [PATCH 13/28] added pip install requirments-text.txt --- .circleci/config.yml | 5 +++++ .github/workflows/ci_with_install.yml | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index a26b529..9bba8b2 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -15,6 +15,11 @@ jobs: command: | python setup.py install + - run: + name: install packages required for testing + command: | + pip install -r requirements-test.txt + - run: name: run test_neutronics_utils command: diff --git a/.github/workflows/ci_with_install.yml b/.github/workflows/ci_with_install.yml index c91cda8..7d670cd 100644 --- a/.github/workflows/ci_with_install.yml +++ b/.github/workflows/ci_with_install.yml @@ -23,6 +23,10 @@ jobs: run: | python setup.py install + - name: install packages required for testing + run: | + pip install -r requirements-test.txt + - name: run tests run: | pytest tests/test_neutronics_utils.py -v --cov=openmc_dagmc_wrapper --cov-append --cov-report term --cov-report xml From e5541fef519863f574b71cb1eac50bfa662e61e4 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 24 Nov 2021 20:27:41 +0000 Subject: [PATCH 14/28] updated dagmc, double down openmc to specific versions / commits --- Dockerfile | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0f4c377..8855bfb 100755 --- a/Dockerfile +++ b/Dockerfile @@ -109,7 +109,7 @@ RUN pip install --upgrade numpy cython && \ # Clone and install Double-Down -RUN git clone --shallow-submodules --single-branch --branch main --depth 1 https://github.com/pshriwise/double-down.git && \ +RUN git clone --shallow-submodules --single-branch --branch v1.0.0 --depth 1 https://github.com/pshriwise/double-down.git && \ cd double-down && \ mkdir build && \ cd build && \ @@ -125,7 +125,11 @@ RUN mkdir DAGMC && \ cd DAGMC && \ # change to version 3.2.1 when released # git clone --single-branch --branch 3.2.1 --depth 1 https://github.com/svalinn/DAGMC.git && \ - git clone --shallow-submodules --single-branch --branch develop --depth 1 https://github.com/svalinn/DAGMC.git && \ + git clone --single-branch --branch develop https://github.com/svalinn/DAGMC.git && \ + cd DAGMC && \ + # this commit is from this PR https://github.com/svalinn/DAGMC/pull/786 + git checkout fbd0cdbad100a0fd8d80de42321e69d09fdd67f4 && \ + cd .. && \ mkdir build && \ cd build && \ cmake ../DAGMC -DBUILD_TALLY=ON \ @@ -140,7 +144,11 @@ RUN mkdir DAGMC && \ # Clone and install OpenMC with DAGMC # TODO clone a specific release when the next release containing (PR 1825) is avaialble. -RUN git clone --shallow-submodules --recurse-submodules --single-branch --branch develop --depth 1 https://github.com/openmc-dev/openmc.git /opt/openmc && \ +RUN cd /opt && \ + git clone --single-branch --branch develop https://github.com/openmc-dev/openmc.git && \ + cd openmc && \ + # this commit is from this PR https://github.com/openmc-dev/openmc/pull/1900 + git checkout 0157dc219ff8dca814859b3140c6cef1e78cdee1 && \ cd /opt/openmc && \ mkdir build && \ cd build && \ From 31f2c289aa633f7f66d68a6ef35fd233f6722d58 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 24 Nov 2021 20:47:49 +0000 Subject: [PATCH 15/28] update examples to use dagmc-bounding-box --- examples/regular_2d_mesh_tally_example.py | 11 ++++++++--- examples/regular_3d_mesh_tally_example.py | 8 +++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/examples/regular_2d_mesh_tally_example.py b/examples/regular_2d_mesh_tally_example.py index 4626cd3..57ee8f3 100644 --- a/examples/regular_2d_mesh_tally_example.py +++ b/examples/regular_2d_mesh_tally_example.py @@ -9,7 +9,7 @@ import openmc import openmc_dagmc_wrapper as odw from openmc_plasma_source import FusionRingSource - +from dagmc_bounding_box import DagmcBoundingBox # downloads a dagmc file for use in the example # url = "https://github.com/fusion-energy/neutronics_workflow/archive/refs/tags/v0.0.2.tar.gz" @@ -45,16 +45,21 @@ }, ) +# makes use of the dagmc-bound-box package to get the corners of the bounding +# box. This will be used to set the bounding box for the tally +my_bounding_box = DagmcBoundingBox(h5m_filename).corners() + + # A MeshTally2D tally allows a set of standard tally types (made from filters # and scores) to be applied to the DAGMC geometry. By default the mesh will be # applied across the entire geomtry with and the size of the geometry is # automatically found. tally1 = odw.MeshTally2D( - tally_type="photon_effective_dose", plane="xy", bounding_box=h5m_filename + tally_type="photon_effective_dose", plane="xy", bounding_box=my_bounding_box ) tally2 = odw.MeshTally2D( - tally_type="neutron_effective_dose", plane="xy", bounding_box=h5m_filename + tally_type="neutron_effective_dose", plane="xy", bounding_box=my_bounding_box ) # no modifications are made to the default openmc.Tallies diff --git a/examples/regular_3d_mesh_tally_example.py b/examples/regular_3d_mesh_tally_example.py index d5dc0cb..711b102 100644 --- a/examples/regular_3d_mesh_tally_example.py +++ b/examples/regular_3d_mesh_tally_example.py @@ -9,6 +9,7 @@ import openmc import openmc_dagmc_wrapper as odw from openmc_plasma_source import FusionRingSource +from dagmc_bounding_box import DagmcBoundingBox # downloads a dagmc file for use in the example # url = "https://github.com/fusion-energy/neutronics_workflow/archive/refs/tags/v0.0.2.tar.gz" @@ -43,13 +44,18 @@ }, ) +# makes use of the dagmc-bound-box package to get the corners of the bounding +# box. This will be used to set the bounding box for the tally +my_bounding_box = DagmcBoundingBox(h5m_filename).corners() + # A MeshTally3D tally allows a set of standard tally types (made from filters # and scores) to be applied to the DAGMC geometry. By default the mesh will be # applied across the entire geomtry with and the size of the geometry is # automatically found. tally1 = odw.MeshTally3D( tally_type="neutron_effective_dose", - bounding_box=h5m_filename) + bounding_box=my_bounding_box +) # no modifications are made to the default openmc.Tallies tallies = openmc.Tallies([tally1]) From 3f943461e9c2688f4aa4d6d493df8698d0cdadec Mon Sep 17 00:00:00 2001 From: autopep8 Date: Wed, 24 Nov 2021 20:48:16 +0000 Subject: [PATCH 16/28] Automated autopep8 fixes --- examples/regular_2d_mesh_tally_example.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/regular_2d_mesh_tally_example.py b/examples/regular_2d_mesh_tally_example.py index 57ee8f3..8bd37da 100644 --- a/examples/regular_2d_mesh_tally_example.py +++ b/examples/regular_2d_mesh_tally_example.py @@ -56,11 +56,13 @@ # automatically found. tally1 = odw.MeshTally2D( - tally_type="photon_effective_dose", plane="xy", bounding_box=my_bounding_box -) + tally_type="photon_effective_dose", + plane="xy", + bounding_box=my_bounding_box) tally2 = odw.MeshTally2D( - tally_type="neutron_effective_dose", plane="xy", bounding_box=my_bounding_box -) + tally_type="neutron_effective_dose", + plane="xy", + bounding_box=my_bounding_box) # no modifications are made to the default openmc.Tallies tallies = openmc.Tallies([tally1, tally2]) From b5623976bd344a47a6e94bc4511bbab529b31e16 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 24 Nov 2021 21:13:19 +0000 Subject: [PATCH 17/28] added test for graveyard free simulation --- requirements-test.txt | 1 + .../test_system/test_system_single_volume.py | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/requirements-test.txt b/requirements-test.txt index f898533..2ef0094 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -7,3 +7,4 @@ nbconvert requests openmc-plasma-source dagmc_bounding_box +remove_dagmc_tags diff --git a/tests/test_system/test_system_single_volume.py b/tests/test_system/test_system_single_volume.py index c5d8633..d24dedf 100644 --- a/tests/test_system/test_system_single_volume.py +++ b/tests/test_system/test_system_single_volume.py @@ -8,6 +8,7 @@ import openmc import openmc_dagmc_wrapper as odw from dagmc_bounding_box import DagmcBoundingBox +from remove_dagmc_tags import remove_tags class TestShape(unittest.TestCase): @@ -80,6 +81,35 @@ def test_simulation_with_previous_h5m_file(self): assert Path(statepoint_file).exists() + def test_simulation_with_previous_h5m_file_with_graveyard_removed(self): + """This performs a simulation using previously created h5m file. The + graveyard is removed from the geometry""" + + os.system("rm statepoint.*.h5") + os.system("rm summary.h5") + + remove_tags( + input=self.h5m_filename_smaller, + output='no_graveyard_dagmc_file.h5m', + tags=['mat:graveyard', 'graveyard'] + ) + + geometry = odw.Geometry(h5m_filename='no_graveyard_dagmc_file.h5m') + materials = odw.Materials( + h5m_filename='no_graveyard_dagmc_file.h5m', + correspondence_dict={"mat1": "WC"}) + + my_model = openmc.model.Model( + geometry=geometry, + materials=materials, + tallies=[], + settings=self.settings + ) + + statepoint_file = my_model.run() + + assert Path(statepoint_file).exists() + def test_neutronics_component_simulation_with_openmc_mat(self): """Makes a neutronics model and simulates with a cell tally""" From af9567040451d1843d1d072e025d87f77d384cc7 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 24 Nov 2021 21:57:48 +0000 Subject: [PATCH 18/28] added extra unit tests for filters --- examples/regular_2d_mesh_tally_example.py | 1 - openmc_dagmc_wrapper/Tally.py | 9 ++--- tests/test_tallies/test_cell_tallies.py | 43 ++++++++++++++++++++++- 3 files changed, 47 insertions(+), 6 deletions(-) diff --git a/examples/regular_2d_mesh_tally_example.py b/examples/regular_2d_mesh_tally_example.py index 8bd37da..ae7ff91 100644 --- a/examples/regular_2d_mesh_tally_example.py +++ b/examples/regular_2d_mesh_tally_example.py @@ -18,7 +18,6 @@ # tar.extractall(".") # tar.close() h5m_filename = "neutronics_workflow-0.0.2/example_02_multi_volume_cell_tally/stage_2_output/dagmc.h5m" -h5m_filename = "neutronics_workflow-0.0.2/example_02_multi_volume_cell_tally/stage_2_output/dagmc_no_grave_yard.h5m" # creates a geometry object from a DAGMC geometry. diff --git a/openmc_dagmc_wrapper/Tally.py b/openmc_dagmc_wrapper/Tally.py index a75980c..270ab6d 100644 --- a/openmc_dagmc_wrapper/Tally.py +++ b/openmc_dagmc_wrapper/Tally.py @@ -1,4 +1,4 @@ -from typing import List, Tuple, Union +from typing import Iterable, List, Tuple, Union import dagmc_h5m_file_inspector as di import openmc @@ -72,7 +72,7 @@ def set_score(self): ] if self.tally_type == "TBR": - # todo see if H3-production can replace this + # H3-production could replace this self.scores = ["(n,Xt)"] elif self.tally_type in flux_scores: self.scores = ["flux"] @@ -167,10 +167,11 @@ class CellTallies: def __init__( self, - tally_types, - targets=[None], + tally_types: Iterable, + targets: Iterable=[None], materials=None, h5m_filename=None): + self.tallies = [] self.tally_types = tally_types self.targets = targets diff --git a/tests/test_tallies/test_cell_tallies.py b/tests/test_tallies/test_cell_tallies.py index 36f4346..c4206a1 100644 --- a/tests/test_tallies/test_cell_tallies.py +++ b/tests/test_tallies/test_cell_tallies.py @@ -1,5 +1,7 @@ +import tarfile import unittest - +import urllib.request +from pathlib import Path import openmc import openmc_dagmc_wrapper as odw @@ -8,6 +10,19 @@ class TestCellTallies(unittest.TestCase): """Tests the CellTallies class functionality""" + def setUp(self): + + if not Path("tests/v0.0.2.tar.gz").is_file(): + url = "https://github.com/fusion-energy/neutronics_workflow/archive/refs/tags/v0.0.2.tar.gz" + urllib.request.urlretrieve(url, "tests/v0.0.2.tar.gz") + + tar = tarfile.open("tests/v0.0.2.tar.gz", "r:gz") + tar.extractall("tests") + tar.close() + + self.h5m_filename_smaller = "tests/neutronics_workflow-0.0.2/example_01_single_volume_cell_tally/stage_2_output/dagmc.h5m" + self.h5m_filename_bigger = "tests/neutronics_workflow-0.0.2/example_02_multi_volume_cell_tally/stage_2_output/dagmc.h5m" + def test_name(self): my_tally = odw.CellTally("heating", target=1) @@ -15,3 +30,29 @@ def test_name(self): my_tally = odw.CellTally("heating", target="coucou", materials=[]) assert my_tally.name == "coucou_heating" + + def test_cell_filter(self): + my_tally = odw.CellTally("heating", target=4) + + assert len(my_tally.filters[0].bins) == 1 + assert my_tally.filters[0].bins[0] == 4 + + my_tally = odw.CellTally("neutron_flux", target=2) + + assert len(my_tally.filters[0].bins) == 1 + assert my_tally.filters[0].bins[0] == 'neutron' + + my_tally = odw.CellTally("photon_flux", target=2) + + assert len(my_tally.filters[0].bins) == 1 + assert my_tally.filters[0].bins[0] == 'photon' + + my_tally = odw.CellTally("neutron_heating", target=2) + + assert len(my_tally.filters[0].bins) == 1 + assert my_tally.filters[0].bins[0] == 'neutron' + + my_tally = odw.CellTally("photon_heating", target=2) + + assert len(my_tally.filters[0].bins) == 1 + assert my_tally.filters[0].bins[0] == 'photon' From 1c30eaa6d0190289364f24a8e589a1f401191e25 Mon Sep 17 00:00:00 2001 From: autopep8 Date: Wed, 24 Nov 2021 21:58:15 +0000 Subject: [PATCH 19/28] Automated autopep8 fixes --- openmc_dagmc_wrapper/Tally.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openmc_dagmc_wrapper/Tally.py b/openmc_dagmc_wrapper/Tally.py index 270ab6d..c1b2858 100644 --- a/openmc_dagmc_wrapper/Tally.py +++ b/openmc_dagmc_wrapper/Tally.py @@ -168,7 +168,7 @@ class CellTallies: def __init__( self, tally_types: Iterable, - targets: Iterable=[None], + targets: Iterable = [None], materials=None, h5m_filename=None): From 48230c04da2819f3315723c2a6fc76a9b4419c4f Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 24 Nov 2021 22:04:10 +0000 Subject: [PATCH 20/28] added tests for angle finder --- openmc_dagmc_wrapper/__init__.py | 2 +- tests/test_neutronics_utils.py | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/openmc_dagmc_wrapper/__init__.py b/openmc_dagmc_wrapper/__init__.py index e9021b9..e4db8a4 100644 --- a/openmc_dagmc_wrapper/__init__.py +++ b/openmc_dagmc_wrapper/__init__.py @@ -1,4 +1,4 @@ -from .utils import create_material +from .utils import create_material, diff_between_angles from .Geometry import Geometry from .Materials import Materials diff --git a/tests/test_neutronics_utils.py b/tests/test_neutronics_utils.py index 5413f24..2046154 100644 --- a/tests/test_neutronics_utils.py +++ b/tests/test_neutronics_utils.py @@ -5,8 +5,7 @@ from pathlib import Path import openmc -import openmc_dagmc_wrapper -from openmc_dagmc_wrapper import create_material +import openmc_dagmc_wrapper as odw import neutronics_material_maker as nmm import pytest @@ -28,6 +27,13 @@ def setUp(self): self.h5m_filename_smaller = "tests/neutronics_workflow-0.0.2/example_01_single_volume_cell_tally/stage_2_output/dagmc.h5m" self.h5m_filename_bigger = "tests/neutronics_workflow-0.0.2/example_02_multi_volume_cell_tally/stage_2_output/dagmc.h5m" + def test_diff_between_angles_returns_correct_answer(self): + + assert odw.diff_between_angles(0,90) == 90 + assert odw.diff_between_angles(0,180) == 180 + assert odw.diff_between_angles(90,90) == 0 + assert odw.diff_between_angles(180,90) == -90 + def test_create_material_from_string(self): mats = ["Be", "tungsten", "eurofer", "copper"] @@ -40,7 +46,7 @@ def test_create_material_from_string(self): expected_mat.name = tag_mat # run - produced_mat = create_material(tag_mat, mat) + produced_mat = odw.create_material(tag_mat, mat) # test assert produced_mat.density == expected_mat.density @@ -59,7 +65,7 @@ def test_create_material_as_openmc_materials(self): expected_mat.name = tag_mat # run - produced_mat = create_material(tag_mat, expected_mat) + produced_mat = odw.create_material(tag_mat, expected_mat) # test assert produced_mat.density == expected_mat.density @@ -68,7 +74,7 @@ def test_create_material_as_openmc_materials(self): def test_create_material_wrong_type(self): def incorrect_type(): - create_material("mat1", [1, 2, 3]) + odw.create_material("mat1", [1, 2, 3]) self.assertRaises(TypeError, incorrect_type) From 3d0dbc6569c6861b42327409e741e95714b1a327 Mon Sep 17 00:00:00 2001 From: autopep8 Date: Wed, 24 Nov 2021 22:08:02 +0000 Subject: [PATCH 21/28] Automated autopep8 fixes --- tests/test_neutronics_utils.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_neutronics_utils.py b/tests/test_neutronics_utils.py index 2046154..61ed947 100644 --- a/tests/test_neutronics_utils.py +++ b/tests/test_neutronics_utils.py @@ -29,10 +29,10 @@ def setUp(self): def test_diff_between_angles_returns_correct_answer(self): - assert odw.diff_between_angles(0,90) == 90 - assert odw.diff_between_angles(0,180) == 180 - assert odw.diff_between_angles(90,90) == 0 - assert odw.diff_between_angles(180,90) == -90 + assert odw.diff_between_angles(0, 90) == 90 + assert odw.diff_between_angles(0, 180) == 180 + assert odw.diff_between_angles(90, 90) == 0 + assert odw.diff_between_angles(180, 90) == -90 def test_create_material_from_string(self): mats = ["Be", "tungsten", "eurofer", "copper"] From 2244f2c1288e1a2af1960ae3237397b01d726687 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 24 Nov 2021 22:32:49 +0000 Subject: [PATCH 22/28] pep8 formatting --- docs/source/conf.py | 29 ++-- examples/cell_tally_example.py | 10 +- examples/regular_2d_mesh_tally_example.py | 10 +- examples/regular_3d_mesh_tally_example.py | 3 +- openmc_dagmc_wrapper/Geometry.py | 4 +- openmc_dagmc_wrapper/Tally.py | 26 ++-- openmc_dagmc_wrapper/__init__.py | 2 +- openmc_dagmc_wrapper/utils.py | 18 ++- tests/notebook_testing.py | 5 +- tests/test_materials.py | 10 +- tests/test_neutronics_utils.py | 22 +++ tests/test_settings.py | 1 - tests/test_system/test_system_multi_volume.py | 7 +- .../test_system/test_system_single_volume.py | 142 +++++++++--------- tests/test_tallies/test_cell_tallies.py | 8 +- tests/test_tallies/test_mesh_tally_2d.py | 10 +- tests/test_tallies/test_mesh_tally_3d.py | 6 +- 17 files changed, 157 insertions(+), 156 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index ccefadd..da0cd46 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -35,7 +35,7 @@ # If your documentation needs a minimal Sphinx version, state it here. # -needs_sphinx = '3.5.4' +needs_sphinx = "3.5.4" # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom @@ -136,11 +136,13 @@ # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - (master_doc, - "OpenMC-DAGMC-Wrapper.tex", - "OpenMC-DAGMC-Wrapper Documentation", - "OpenMC-DAGMC-Wrapper contributors", - "manual"), + ( + master_doc, + "OpenMC-DAGMC-Wrapper.tex", + "OpenMC-DAGMC-Wrapper Documentation", + "OpenMC-DAGMC-Wrapper contributors", + "manual", + ), ] @@ -149,11 +151,14 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - (master_doc, - "OpenMC-DAGMC-Wrapper", - "OpenMC-DAGMC-Wrapper Documentation", - [author], - 1)] + ( + master_doc, + "OpenMC-DAGMC-Wrapper", + "OpenMC-DAGMC-Wrapper Documentation", + [author], + 1, + ) +] # -- Options for Texinfo output ---------------------------------------------- @@ -194,4 +199,4 @@ # -- Extension configuration ------------------------------------------------- -html_favicon = 'favicon.ico' +html_favicon = "favicon.ico" diff --git a/examples/cell_tally_example.py b/examples/cell_tally_example.py index 47708f9..a747f12 100644 --- a/examples/cell_tally_example.py +++ b/examples/cell_tally_example.py @@ -47,16 +47,12 @@ # scores) to be applied to a DAGMC material or a volume # This cell tally applies a TBR tally to the volume(s) labeled with the # blanket_mat tag in the DAGMC geometry -tally1 = odw.CellTally( - tally_type="TBR", - target="blanket_mat", - materials=materials) +tally1 = odw.CellTally(tally_type="TBR", target="blanket_mat", materials=materials) # This cell tally obtains the neutron fast flux on all volumes in the problem tally2 = odw.CellTallies( - tally_types=["neutron_fast_flux"], - targets="all_volumes", - h5m_filename=h5m_filename) + tally_types=["neutron_fast_flux"], targets="all_volumes", h5m_filename=h5m_filename +) # no modifications are made to the default openmc.Tallies tallies = openmc.Tallies([tally1] + tally2.tallies) diff --git a/examples/regular_2d_mesh_tally_example.py b/examples/regular_2d_mesh_tally_example.py index ae7ff91..4b0d850 100644 --- a/examples/regular_2d_mesh_tally_example.py +++ b/examples/regular_2d_mesh_tally_example.py @@ -55,13 +55,11 @@ # automatically found. tally1 = odw.MeshTally2D( - tally_type="photon_effective_dose", - plane="xy", - bounding_box=my_bounding_box) + tally_type="photon_effective_dose", plane="xy", bounding_box=my_bounding_box +) tally2 = odw.MeshTally2D( - tally_type="neutron_effective_dose", - plane="xy", - bounding_box=my_bounding_box) + tally_type="neutron_effective_dose", plane="xy", bounding_box=my_bounding_box +) # no modifications are made to the default openmc.Tallies tallies = openmc.Tallies([tally1, tally2]) diff --git a/examples/regular_3d_mesh_tally_example.py b/examples/regular_3d_mesh_tally_example.py index 711b102..58c60c0 100644 --- a/examples/regular_3d_mesh_tally_example.py +++ b/examples/regular_3d_mesh_tally_example.py @@ -53,8 +53,7 @@ # applied across the entire geomtry with and the size of the geometry is # automatically found. tally1 = odw.MeshTally3D( - tally_type="neutron_effective_dose", - bounding_box=my_bounding_box + tally_type="neutron_effective_dose", bounding_box=my_bounding_box ) # no modifications are made to the default openmc.Tallies diff --git a/openmc_dagmc_wrapper/Geometry.py b/openmc_dagmc_wrapper/Geometry.py index cdd738c..b9a511a 100644 --- a/openmc_dagmc_wrapper/Geometry.py +++ b/openmc_dagmc_wrapper/Geometry.py @@ -90,8 +90,7 @@ def make_root(self): vac_surf = self.create_sphere_of_vacuum_surface() region = -vac_surf & -reflective_1 & +reflective_2 - containing_cell = openmc.Cell( - cell_id=9999, region=region, fill=dag_univ) + containing_cell = openmc.Cell(cell_id=9999, region=region, fill=dag_univ) root = [containing_cell] @@ -103,6 +102,7 @@ def create_sphere_of_vacuum_surface(self): if self.graveyard_box is None: from dagmc_bounding_box import DagmcBoundingBox + self.graveyard_box = DagmcBoundingBox(self.h5m_filename).corners() bbox = [[*self.graveyard_box[0]], [*self.graveyard_box[1]]] diff --git a/openmc_dagmc_wrapper/Tally.py b/openmc_dagmc_wrapper/Tally.py index c1b2858..cb04903 100644 --- a/openmc_dagmc_wrapper/Tally.py +++ b/openmc_dagmc_wrapper/Tally.py @@ -166,11 +166,12 @@ class CellTallies: """ def __init__( - self, - tally_types: Iterable, - targets: Iterable = [None], - materials=None, - h5m_filename=None): + self, + tally_types: Iterable, + targets: Iterable = [None], + materials=None, + h5m_filename=None, + ): self.tallies = [] self.tally_types = tally_types @@ -188,10 +189,8 @@ def __init__( for score in self.tally_types: for target in all_targets: self.tallies.append( - CellTally( - tally_type=score, - target=target, - materials=materials)) + CellTally(tally_type=score, target=target, materials=materials) + ) class TetMeshTally(Tally): @@ -243,10 +242,7 @@ def __init__(self, tally_types, filenames): self.tally_types = tally_types for score in self.tally_types: for filename in filenames: - self.tallies.append( - TetMeshTally( - tally_type=score, - filename=filename)) + self.tallies.append(TetMeshTally(tally_type=score, filename=filename)) class MeshTally3D(Tally): @@ -470,9 +466,7 @@ def compute_filters(tally_type): energy_function_filter_n = openmc.EnergyFunctionFilter( energy_bins_n, dose_coeffs_n ) - additional_filters = [ - neutron_particle_filter, - energy_function_filter_n] + additional_filters = [neutron_particle_filter, energy_function_filter_n] elif tally_type == "photon_effective_dose": energy_function_filter_p = openmc.EnergyFunctionFilter( energy_bins_p, dose_coeffs_p diff --git a/openmc_dagmc_wrapper/__init__.py b/openmc_dagmc_wrapper/__init__.py index e4db8a4..69a1d53 100644 --- a/openmc_dagmc_wrapper/__init__.py +++ b/openmc_dagmc_wrapper/__init__.py @@ -10,6 +10,6 @@ MeshTally3D, MeshTallies3D, TetMeshTally, - TetMeshTallies + TetMeshTallies, ) from .Settings import FusionSettings diff --git a/openmc_dagmc_wrapper/utils.py b/openmc_dagmc_wrapper/utils.py index dcaeca4..0b47745 100644 --- a/openmc_dagmc_wrapper/utils.py +++ b/openmc_dagmc_wrapper/utils.py @@ -20,7 +20,8 @@ def create_material(material_tag: str, material_entry): if isinstance(material_entry, str): openmc_material = nmm.Material.from_library( - name=material_entry, material_id=None).openmc_material + name=material_entry, material_id=None + ).openmc_material elif isinstance(material_entry, openmc.Material): # sets the material name in the event that it had not been set openmc_material = material_entry @@ -43,18 +44,21 @@ def get_an_isotope_present_in_cross_sections_xml(): """Opens the xml file found with the OPENMC_CROSS_SECTIONS environmental variable""" - cross_sections_xml = os.getenv('OPENMC_CROSS_SECTIONS') + cross_sections_xml = os.getenv("OPENMC_CROSS_SECTIONS") if cross_sections_xml is None: - msg = ('set your OPENMC_CROSS_SECTIONS environmental variable before ' - 'running this script. This can be done automatically using the ' - 'openmc-data-downloader package or manually with an "export ' - 'OPENMC_CROSS_SECTIONS path to cross_sections.xml"') + msg = ( + "set your OPENMC_CROSS_SECTIONS environmental variable before " + "running this script. This can be done automatically using the " + 'openmc-data-downloader package or manually with an "export ' + 'OPENMC_CROSS_SECTIONS path to cross_sections.xml"' + ) raise ValueError(msg) import xml.etree.ElementTree as ET + tree = ET.parse(cross_sections_xml) root = tree.getroot() for child in root[:1]: - available_isotope = child.attrib['materials'] + available_isotope = child.attrib["materials"] return available_isotope diff --git a/tests/notebook_testing.py b/tests/notebook_testing.py index c3f96c1..ae4b7df 100644 --- a/tests/notebook_testing.py +++ b/tests/notebook_testing.py @@ -21,10 +21,7 @@ def notebook_run(path): ep = ExecutePreprocessor(kernel_name=kernel_name, timeout=800) try: - ep.preprocess( - note_book, { - "metadata": { - "path": this_file_directory}}) + ep.preprocess(note_book, {"metadata": {"path": this_file_directory}}) except CellExecutionError as e: if "SKIP" in e.traceback: diff --git a/tests/test_materials.py b/tests/test_materials.py index 3888203..2476e95 100644 --- a/tests/test_materials.py +++ b/tests/test_materials.py @@ -1,4 +1,3 @@ - import tarfile import unittest import urllib.request @@ -39,15 +38,14 @@ def setUp(self): def test_resulting_attributes_with_single_material_and_string(self): my_material = odw.Materials( - correspondence_dict={'mat1': 'Be'}, - h5m_filename=self.h5m_filename_smaller + correspondence_dict={"mat1": "Be"}, h5m_filename=self.h5m_filename_smaller ) assert isinstance(my_material, openmc.Materials) assert len(my_material) == 1 - assert my_material[0].nuclides[0][0] == 'Be9' - assert my_material[0].nuclides[0][1] == 1. - assert my_material[0].name == 'mat1' + assert my_material[0].nuclides[0][0] == "Be9" + assert my_material[0].nuclides[0][1] == 1.0 + assert my_material[0].name == "mat1" def test_incorrect_materials(self): """Set a material as a string which should raise an error""" diff --git a/tests/test_neutronics_utils.py b/tests/test_neutronics_utils.py index 61ed947..e7c562a 100644 --- a/tests/test_neutronics_utils.py +++ b/tests/test_neutronics_utils.py @@ -27,12 +27,34 @@ def setUp(self): self.h5m_filename_smaller = "tests/neutronics_workflow-0.0.2/example_01_single_volume_cell_tally/stage_2_output/dagmc.h5m" self.h5m_filename_bigger = "tests/neutronics_workflow-0.0.2/example_02_multi_volume_cell_tally/stage_2_output/dagmc.h5m" + def test_get_an_isotope_present_in_cross_sections_xml(self): + """Checks that an isotope string is returned from the + cross_sections.xml file""" + + isotope = odw.utils.get_an_isotope_present_in_cross_sections_xml() + assert isinstance(isotope, str) + assert len(isotope) in [1, 2] + + def test_get_an_isotope_present_in_cross_sections_xml_error_handeling(self): + """Checks that an error message is raised if the OPENMC_CROSS_SECTIONS + variable does not exist""" + + def no_env_var(): + del os.environ["OPENMC_CROSS_SECTIONS"] + odw.utils.get_an_isotope_present_in_cross_sections_xml() + + self.assertRaises(ValueError, no_env_var) + # os.environ["OPENMC_CROSS_SECTIONS"] = "1" + def test_diff_between_angles_returns_correct_answer(self): + """Checks the angle difference works with a few known examples""" assert odw.diff_between_angles(0, 90) == 90 assert odw.diff_between_angles(0, 180) == 180 assert odw.diff_between_angles(90, 90) == 0 assert odw.diff_between_angles(180, 90) == -90 + assert odw.diff_between_angles(360, 0) == 0 + assert odw.diff_between_angles(0, 360) == 0 def test_create_material_from_string(self): mats = ["Be", "tungsten", "eurofer", "copper"] diff --git a/tests/test_settings.py b/tests/test_settings.py index 7752009..46ab115 100644 --- a/tests/test_settings.py +++ b/tests/test_settings.py @@ -1,4 +1,3 @@ - import unittest import openmc_dagmc_wrapper as odw diff --git a/tests/test_system/test_system_multi_volume.py b/tests/test_system/test_system_multi_volume.py index 856318a..5175005 100644 --- a/tests/test_system/test_system_multi_volume.py +++ b/tests/test_system/test_system_multi_volume.py @@ -57,18 +57,19 @@ def setUp(self): def test_cell_tally_simulation(self): - os.system('rm statepoint*.h5') + os.system("rm statepoint*.h5") geometry = odw.Geometry(h5m_filename=self.h5m_filename_bigger) materials = odw.Materials( h5m_filename=self.h5m_filename_bigger, - correspondence_dict=self.material_description_bigger) + correspondence_dict=self.material_description_bigger, + ) my_tally = odw.CellTally("TBR") my_model = openmc.model.Model( geometry=geometry, materials=materials, tallies=[my_tally], - settings=self.settings + settings=self.settings, ) statepoint_file = my_model.run() diff --git a/tests/test_system/test_system_single_volume.py b/tests/test_system/test_system_single_volume.py index d24dedf..8d37562 100644 --- a/tests/test_system/test_system_single_volume.py +++ b/tests/test_system/test_system_single_volume.py @@ -67,14 +67,11 @@ def test_simulation_with_previous_h5m_file(self): geometry = odw.Geometry(h5m_filename=self.h5m_filename_smaller) materials = odw.Materials( - h5m_filename=self.h5m_filename_smaller, - correspondence_dict={"mat1": "WC"}) + h5m_filename=self.h5m_filename_smaller, correspondence_dict={"mat1": "WC"} + ) my_model = openmc.model.Model( - geometry=geometry, - materials=materials, - tallies=[], - settings=self.settings + geometry=geometry, materials=materials, tallies=[], settings=self.settings ) statepoint_file = my_model.run() @@ -90,20 +87,18 @@ def test_simulation_with_previous_h5m_file_with_graveyard_removed(self): remove_tags( input=self.h5m_filename_smaller, - output='no_graveyard_dagmc_file.h5m', - tags=['mat:graveyard', 'graveyard'] + output="no_graveyard_dagmc_file.h5m", + tags=["mat:graveyard", "graveyard"], ) - geometry = odw.Geometry(h5m_filename='no_graveyard_dagmc_file.h5m') + geometry = odw.Geometry(h5m_filename="no_graveyard_dagmc_file.h5m") materials = odw.Materials( - h5m_filename='no_graveyard_dagmc_file.h5m', - correspondence_dict={"mat1": "WC"}) + h5m_filename="no_graveyard_dagmc_file.h5m", + correspondence_dict={"mat1": "WC"}, + ) my_model = openmc.model.Model( - geometry=geometry, - materials=materials, - tallies=[], - settings=self.settings + geometry=geometry, materials=materials, tallies=[], settings=self.settings ) statepoint_file = my_model.run() @@ -123,7 +118,8 @@ def test_neutronics_component_simulation_with_openmc_mat(self): geometry = odw.Geometry(h5m_filename=self.h5m_filename_smaller) materials = odw.Materials( h5m_filename=self.h5m_filename_smaller, - correspondence_dict={"mat1": test_mat}) + correspondence_dict={"mat1": test_mat}, + ) my_tally = odw.CellTally("heating", target="mat1", materials=materials) self.settings.batches = 2 @@ -131,7 +127,7 @@ def test_neutronics_component_simulation_with_openmc_mat(self): geometry=geometry, materials=materials, tallies=[my_tally], - settings=self.settings + settings=self.settings, ) h5m_filename = my_model.run() self.settings.batches = 10 @@ -151,7 +147,8 @@ def test_neutronics_component_simulation_with_nmm(self): geometry = odw.Geometry(h5m_filename=self.h5m_filename_smaller) materials = odw.Materials( h5m_filename=self.h5m_filename_smaller, - correspondence_dict={"mat1": test_mat}) + correspondence_dict={"mat1": test_mat}, + ) my_tally = odw.CellTally("heating", target=1) @@ -159,7 +156,7 @@ def test_neutronics_component_simulation_with_nmm(self): geometry=geometry, materials=materials, tallies=[my_tally], - settings=self.settings + settings=self.settings, ) h5m_filename = my_model.run() @@ -170,6 +167,7 @@ def test_neutronics_component_simulation_with_nmm(self): def test_incorrect_cell_tallies(self): """Set a cell tally that is not accepted which should raise an error""" + def incorrect_cell_tallies(): odw.CellTally("coucou") @@ -178,6 +176,7 @@ def incorrect_cell_tallies(): def test_incorrect_cell_tally_type(self): """Set a cell tally that is the wrong type which should raise an error""" + def incorrect_cell_tally_type(): odw.CellTally(1) @@ -195,21 +194,17 @@ def test_neutronics_component_cell_simulation_heating(self): geometry = odw.Geometry(h5m_filename=self.h5m_filename_smaller) materials = odw.Materials( - h5m_filename=self.h5m_filename_smaller, - correspondence_dict={"mat1": mat}) + h5m_filename=self.h5m_filename_smaller, correspondence_dict={"mat1": mat} + ) my_tallies = odw.CellTallies( - tally_types=[ - "heating", - "flux", - "TBR", - "neutron_spectra", - "photon_spectra"]) + tally_types=["heating", "flux", "TBR", "neutron_spectra", "photon_spectra"] + ) my_model = openmc.model.Model( geometry=geometry, materials=materials, tallies=my_tallies.tallies, - settings=self.settings + settings=self.settings, ) # performs an openmc simulation on the model h5m_filename = my_model.run() @@ -231,16 +226,15 @@ def test_neutronics_spectra(self): geometry = odw.Geometry(h5m_filename=self.h5m_filename_smaller) materials = odw.Materials( - h5m_filename=self.h5m_filename_smaller, - correspondence_dict={"mat1": mat}) - my_tallies = odw.CellTallies( - tally_types=["neutron_spectra", "photon_spectra"]) + h5m_filename=self.h5m_filename_smaller, correspondence_dict={"mat1": mat} + ) + my_tallies = odw.CellTallies(tally_types=["neutron_spectra", "photon_spectra"]) my_model = openmc.model.Model( geometry=geometry, materials=materials, tallies=my_tallies.tallies, - settings=self.settings + settings=self.settings, ) # performs an openmc simulation on the model @@ -256,19 +250,20 @@ def test_neutronics_component_2d_mesh_simulation(self): geometry = odw.Geometry(h5m_filename=self.h5m_filename_smaller) materials = odw.Materials( - h5m_filename=self.h5m_filename_smaller, - correspondence_dict={"mat1": "Be"}) + h5m_filename=self.h5m_filename_smaller, correspondence_dict={"mat1": "Be"} + ) my_tallies = odw.MeshTallies2D( tally_types=["heating"], planes=["xy", "xz", "yz"], - bounding_box=DagmcBoundingBox(self.h5m_filename_smaller).corners()) + bounding_box=DagmcBoundingBox(self.h5m_filename_smaller).corners(), + ) my_model = openmc.model.Model( geometry=geometry, materials=materials, tallies=my_tallies.tallies, - settings=self.settings + settings=self.settings, ) # performs an openmc simulation on the model h5m_filename = my_model.run() @@ -288,18 +283,19 @@ def test_neutronics_component_3d_mesh_simulation(self): geometry = odw.Geometry(h5m_filename=self.h5m_filename_smaller) materials = odw.Materials( - h5m_filename=self.h5m_filename_smaller, - correspondence_dict={"mat1": "Be"}) + h5m_filename=self.h5m_filename_smaller, correspondence_dict={"mat1": "Be"} + ) my_tallies = odw.MeshTallies3D( tally_types=["heating", "(n,Xt)"], - bounding_box=DagmcBoundingBox(self.h5m_filename_smaller).corners()) + bounding_box=DagmcBoundingBox(self.h5m_filename_smaller).corners(), + ) my_model = openmc.model.Model( geometry=geometry, materials=materials, tallies=my_tallies.tallies, - settings=self.settings + settings=self.settings, ) # performs an openmc simulation on the model h5m_filename = my_model.run() @@ -321,25 +317,25 @@ def test_neutronics_component_3d_and_2d_mesh_simulation(self): geometry = odw.Geometry(h5m_filename=self.h5m_filename_smaller) materials = odw.Materials( - h5m_filename=self.h5m_filename_smaller, - correspondence_dict={"mat1": "Be"}) + h5m_filename=self.h5m_filename_smaller, correspondence_dict={"mat1": "Be"} + ) my_3d_tally = odw.MeshTally3D( tally_type="heating", - bounding_box=DagmcBoundingBox(self.h5m_filename_smaller).corners() + bounding_box=DagmcBoundingBox(self.h5m_filename_smaller).corners(), ) my_2d_tallies = odw.MeshTallies2D( planes=["xz", "xy", "yz"], tally_types=["heating"], - bounding_box=DagmcBoundingBox(self.h5m_filename_smaller).corners() + bounding_box=DagmcBoundingBox(self.h5m_filename_smaller).corners(), ) my_model = openmc.model.Model( geometry=geometry, materials=materials, tallies=[my_3d_tally] + my_2d_tallies.tallies, - settings=self.settings + settings=self.settings, ) # performs an openmc simulation on the model h5m_filename = my_model.run() @@ -348,8 +344,7 @@ def test_neutronics_component_3d_and_2d_mesh_simulation(self): assert len(results.meshes) == 4 # one 3D and three 2D assert len(results.tallies.items()) == 4 # one 3D and three 2D - def test_neutronics_component_3d_and_2d_mesh_simulation_with_corner_points( - self): + def test_neutronics_component_3d_and_2d_mesh_simulation_with_corner_points(self): """Makes a neutronics model and simulates with a 3D and 2D mesh tally and checks that the vtk and png files are produced. This checks the mesh ID values don't overlap""" @@ -359,8 +354,8 @@ def test_neutronics_component_3d_and_2d_mesh_simulation_with_corner_points( geometry = odw.Geometry(h5m_filename=self.h5m_filename_smaller) materials = odw.Materials( - h5m_filename=self.h5m_filename_smaller, - correspondence_dict={"mat1": "Be"}) + h5m_filename=self.h5m_filename_smaller, correspondence_dict={"mat1": "Be"} + ) my_3d_tally = odw.MeshTally3D( tally_type="heating", @@ -370,7 +365,7 @@ def test_neutronics_component_3d_and_2d_mesh_simulation_with_corner_points( my_2d_tallies = odw.MeshTallies2D( planes=["xz", "xy", "yz"], tally_types=["heating"], - bounding_box=[(5, 5, 5), (15, 15, 15)] + bounding_box=[(5, 5, 5), (15, 15, 15)], ) assert my_3d_tally.bounding_box == [(0, 0, 0), (10, 10, 10)] @@ -381,7 +376,7 @@ def test_neutronics_component_3d_and_2d_mesh_simulation_with_corner_points( geometry=geometry, materials=materials, tallies=[my_3d_tally] + my_2d_tallies.tallies, - settings=self.settings + settings=self.settings, ) # performs an openmc simulation on the model @@ -400,17 +395,16 @@ def test_reactor_from_shapes_cell_tallies(self): geometry = odw.Geometry(h5m_filename=self.h5m_filename_smaller) materials = odw.Materials( - h5m_filename=self.h5m_filename_smaller, - correspondence_dict={"mat1": "Be"}) + h5m_filename=self.h5m_filename_smaller, correspondence_dict={"mat1": "Be"} + ) - my_tallies = odw.CellTallies( - tally_types=["TBR", "heating", "flux"]) + my_tallies = odw.CellTallies(tally_types=["TBR", "heating", "flux"]) my_model = openmc.model.Model( geometry=geometry, materials=materials, tallies=my_tallies.tallies, - settings=self.settings + settings=self.settings, ) # performs an openmc simulation on the model @@ -427,17 +421,18 @@ def test_cell_tallies_simulation_fast_flux(self): geometry = odw.Geometry(h5m_filename=self.h5m_filename_smaller) materials = odw.Materials( - h5m_filename=self.h5m_filename_smaller, - correspondence_dict={"mat1": "Be"}) + h5m_filename=self.h5m_filename_smaller, correspondence_dict={"mat1": "Be"} + ) my_tallies = odw.CellTallies( - tally_types=["photon_fast_flux", "neutron_fast_flux", "flux"]) + tally_types=["photon_fast_flux", "neutron_fast_flux", "flux"] + ) my_model = openmc.model.Model( geometry=geometry, materials=materials, tallies=my_tallies.tallies, - settings=self.settings + settings=self.settings, ) # performs an openmc simulation on the model @@ -454,17 +449,18 @@ def test_cell_tallies_simulation_effective_dose(self): geometry = odw.Geometry(h5m_filename=self.h5m_filename_smaller) materials = odw.Materials( - h5m_filename=self.h5m_filename_smaller, - correspondence_dict={"mat1": "Be"}) + h5m_filename=self.h5m_filename_smaller, correspondence_dict={"mat1": "Be"} + ) my_tallies = odw.CellTallies( - tally_types=["photon_effective_dose", "neutron_effective_dose"]) + tally_types=["photon_effective_dose", "neutron_effective_dose"] + ) my_model = openmc.model.Model( geometry=geometry, materials=materials, tallies=my_tallies.tallies, - settings=self.settings + settings=self.settings, ) # performs an openmc simulation on the model @@ -493,9 +489,9 @@ def test_cell_tallies_simulation_effective_dose(self): # ) # # performs an openmc simulation on the model - # statepoint_file = my_model.run() + # statepoint_file = my_model.run() - # assert Path(statepoint_file).exists() + # assert Path(statepoint_file).exists() def test_simulations_with_missing_h5m_files(self): """Creates NeutronicsModel objects and tries to perform simulation @@ -506,7 +502,8 @@ def test_missing_h5m_file_error_handling(): should fail with a FileNotFoundError""" import shutil - shutil.copy(self.h5m_filename_smaller, '.') + + shutil.copy(self.h5m_filename_smaller, ".") # creates xml files so that the code passes the xml file check os.system("touch geometry.xml") @@ -515,14 +512,9 @@ def test_missing_h5m_file_error_handling(): os.system("touch tallies.xml") os.system("rm dagmc.h5m") - odw.Materials( - h5m_filename="dagmc.h5m", - correspondence_dict={"mat1": "Be"} - ) + odw.Materials(h5m_filename="dagmc.h5m", correspondence_dict={"mat1": "Be"}) - self.assertRaises( - FileNotFoundError, - test_missing_h5m_file_error_handling) + self.assertRaises(FileNotFoundError, test_missing_h5m_file_error_handling) if __name__ == "__main__": diff --git a/tests/test_tallies/test_cell_tallies.py b/tests/test_tallies/test_cell_tallies.py index c4206a1..6639b05 100644 --- a/tests/test_tallies/test_cell_tallies.py +++ b/tests/test_tallies/test_cell_tallies.py @@ -40,19 +40,19 @@ def test_cell_filter(self): my_tally = odw.CellTally("neutron_flux", target=2) assert len(my_tally.filters[0].bins) == 1 - assert my_tally.filters[0].bins[0] == 'neutron' + assert my_tally.filters[0].bins[0] == "neutron" my_tally = odw.CellTally("photon_flux", target=2) assert len(my_tally.filters[0].bins) == 1 - assert my_tally.filters[0].bins[0] == 'photon' + assert my_tally.filters[0].bins[0] == "photon" my_tally = odw.CellTally("neutron_heating", target=2) assert len(my_tally.filters[0].bins) == 1 - assert my_tally.filters[0].bins[0] == 'neutron' + assert my_tally.filters[0].bins[0] == "neutron" my_tally = odw.CellTally("photon_heating", target=2) assert len(my_tally.filters[0].bins) == 1 - assert my_tally.filters[0].bins[0] == 'photon' + assert my_tally.filters[0].bins[0] == "photon" diff --git a/tests/test_tallies/test_mesh_tally_2d.py b/tests/test_tallies/test_mesh_tally_2d.py index a9454ad..6f01c50 100644 --- a/tests/test_tallies/test_mesh_tally_2d.py +++ b/tests/test_tallies/test_mesh_tally_2d.py @@ -31,8 +31,8 @@ def test_incorrect_mesh_tally_2d(self): def incorrect_mesh_tally_2d(): odw.MeshTally2D( - "coucou", bounding_box=[ - (10, 10, 10), (-10, -10, -10)], plane="xy") + "coucou", bounding_box=[(10, 10, 10), (-10, -10, -10)], plane="xy" + ) self.assertRaises(ValueError, incorrect_mesh_tally_2d) @@ -84,10 +84,8 @@ def test_shape_of_resulting_png(self): settings.source = FusionRingSource(fuel="DT", radius=1) my_model = openmc.Model( - materials=materials, - geometry=geometry, - settings=settings, - tallies=tallies) + materials=materials, geometry=geometry, settings=settings, tallies=tallies + ) statepoint_file = my_model.run() assert Path(statepoint_file).exists() diff --git a/tests/test_tallies/test_mesh_tally_3d.py b/tests/test_tallies/test_mesh_tally_3d.py index e41dca2..45043a3 100644 --- a/tests/test_tallies/test_mesh_tally_3d.py +++ b/tests/test_tallies/test_mesh_tally_3d.py @@ -29,9 +29,7 @@ def test_incorrect_mesh_tally_3d(self): error""" def incorrect_mesh_tally_3d(): - odw.MeshTally3D( - "coucou", bounding_box=[ - (10, 10, 10), (-10, -10, -10)]) + odw.MeshTally3D("coucou", bounding_box=[(10, 10, 10), (-10, -10, -10)]) self.assertRaises(ValueError, incorrect_mesh_tally_3d) @@ -55,7 +53,7 @@ def test_meshfilter_from_h5m_file(self): # run my_tally = odw.MeshTally3D( "heating", - bounding_box=DagmcBoundingBox(self.h5m_filename_smaller).corners() + bounding_box=DagmcBoundingBox(self.h5m_filename_smaller).corners(), ) produced_filter = my_tally.filters[-1] produced_mesh = produced_filter.mesh From ebd8351e2303a81399f51c56f8fec768e066c67b Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 24 Nov 2021 22:35:19 +0000 Subject: [PATCH 23/28] resetting OPENMC_CROSS_SECTIONS --- tests/test_neutronics_utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_neutronics_utils.py b/tests/test_neutronics_utils.py index e7c562a..3f208f9 100644 --- a/tests/test_neutronics_utils.py +++ b/tests/test_neutronics_utils.py @@ -43,8 +43,10 @@ def no_env_var(): del os.environ["OPENMC_CROSS_SECTIONS"] odw.utils.get_an_isotope_present_in_cross_sections_xml() + cross_sections_xml = os.getenv("OPENMC_CROSS_SECTIONS") self.assertRaises(ValueError, no_env_var) - # os.environ["OPENMC_CROSS_SECTIONS"] = "1" + # sets the variable again so that other tests don't fail + os.environ["OPENMC_CROSS_SECTIONS"] = cross_sections_xml def test_diff_between_angles_returns_correct_answer(self): """Checks the angle difference works with a few known examples""" From f0737025ee1d65cb4b895e3907bb4b5f4b543243 Mon Sep 17 00:00:00 2001 From: autopep8 Date: Wed, 24 Nov 2021 22:35:46 +0000 Subject: [PATCH 24/28] Automated autopep8 fixes --- examples/cell_tally_example.py | 10 ++- examples/regular_2d_mesh_tally_example.py | 10 ++- openmc_dagmc_wrapper/Geometry.py | 3 +- openmc_dagmc_wrapper/Tally.py | 15 +++- tests/notebook_testing.py | 5 +- tests/test_materials.py | 5 +- tests/test_neutronics_utils.py | 3 +- .../test_system/test_system_single_volume.py | 87 ++++++++++++------- tests/test_tallies/test_mesh_tally_2d.py | 10 ++- tests/test_tallies/test_mesh_tally_3d.py | 4 +- 10 files changed, 101 insertions(+), 51 deletions(-) diff --git a/examples/cell_tally_example.py b/examples/cell_tally_example.py index a747f12..47708f9 100644 --- a/examples/cell_tally_example.py +++ b/examples/cell_tally_example.py @@ -47,12 +47,16 @@ # scores) to be applied to a DAGMC material or a volume # This cell tally applies a TBR tally to the volume(s) labeled with the # blanket_mat tag in the DAGMC geometry -tally1 = odw.CellTally(tally_type="TBR", target="blanket_mat", materials=materials) +tally1 = odw.CellTally( + tally_type="TBR", + target="blanket_mat", + materials=materials) # This cell tally obtains the neutron fast flux on all volumes in the problem tally2 = odw.CellTallies( - tally_types=["neutron_fast_flux"], targets="all_volumes", h5m_filename=h5m_filename -) + tally_types=["neutron_fast_flux"], + targets="all_volumes", + h5m_filename=h5m_filename) # no modifications are made to the default openmc.Tallies tallies = openmc.Tallies([tally1] + tally2.tallies) diff --git a/examples/regular_2d_mesh_tally_example.py b/examples/regular_2d_mesh_tally_example.py index 4b0d850..ae7ff91 100644 --- a/examples/regular_2d_mesh_tally_example.py +++ b/examples/regular_2d_mesh_tally_example.py @@ -55,11 +55,13 @@ # automatically found. tally1 = odw.MeshTally2D( - tally_type="photon_effective_dose", plane="xy", bounding_box=my_bounding_box -) + tally_type="photon_effective_dose", + plane="xy", + bounding_box=my_bounding_box) tally2 = odw.MeshTally2D( - tally_type="neutron_effective_dose", plane="xy", bounding_box=my_bounding_box -) + tally_type="neutron_effective_dose", + plane="xy", + bounding_box=my_bounding_box) # no modifications are made to the default openmc.Tallies tallies = openmc.Tallies([tally1, tally2]) diff --git a/openmc_dagmc_wrapper/Geometry.py b/openmc_dagmc_wrapper/Geometry.py index b9a511a..2d5a547 100644 --- a/openmc_dagmc_wrapper/Geometry.py +++ b/openmc_dagmc_wrapper/Geometry.py @@ -90,7 +90,8 @@ def make_root(self): vac_surf = self.create_sphere_of_vacuum_surface() region = -vac_surf & -reflective_1 & +reflective_2 - containing_cell = openmc.Cell(cell_id=9999, region=region, fill=dag_univ) + containing_cell = openmc.Cell( + cell_id=9999, region=region, fill=dag_univ) root = [containing_cell] diff --git a/openmc_dagmc_wrapper/Tally.py b/openmc_dagmc_wrapper/Tally.py index cb04903..befc3ee 100644 --- a/openmc_dagmc_wrapper/Tally.py +++ b/openmc_dagmc_wrapper/Tally.py @@ -189,8 +189,10 @@ def __init__( for score in self.tally_types: for target in all_targets: self.tallies.append( - CellTally(tally_type=score, target=target, materials=materials) - ) + CellTally( + tally_type=score, + target=target, + materials=materials)) class TetMeshTally(Tally): @@ -242,7 +244,10 @@ def __init__(self, tally_types, filenames): self.tally_types = tally_types for score in self.tally_types: for filename in filenames: - self.tallies.append(TetMeshTally(tally_type=score, filename=filename)) + self.tallies.append( + TetMeshTally( + tally_type=score, + filename=filename)) class MeshTally3D(Tally): @@ -466,7 +471,9 @@ def compute_filters(tally_type): energy_function_filter_n = openmc.EnergyFunctionFilter( energy_bins_n, dose_coeffs_n ) - additional_filters = [neutron_particle_filter, energy_function_filter_n] + additional_filters = [ + neutron_particle_filter, + energy_function_filter_n] elif tally_type == "photon_effective_dose": energy_function_filter_p = openmc.EnergyFunctionFilter( energy_bins_p, dose_coeffs_p diff --git a/tests/notebook_testing.py b/tests/notebook_testing.py index ae4b7df..c3f96c1 100644 --- a/tests/notebook_testing.py +++ b/tests/notebook_testing.py @@ -21,7 +21,10 @@ def notebook_run(path): ep = ExecutePreprocessor(kernel_name=kernel_name, timeout=800) try: - ep.preprocess(note_book, {"metadata": {"path": this_file_directory}}) + ep.preprocess( + note_book, { + "metadata": { + "path": this_file_directory}}) except CellExecutionError as e: if "SKIP" in e.traceback: diff --git a/tests/test_materials.py b/tests/test_materials.py index 2476e95..a55f673 100644 --- a/tests/test_materials.py +++ b/tests/test_materials.py @@ -38,8 +38,9 @@ def setUp(self): def test_resulting_attributes_with_single_material_and_string(self): my_material = odw.Materials( - correspondence_dict={"mat1": "Be"}, h5m_filename=self.h5m_filename_smaller - ) + correspondence_dict={ + "mat1": "Be"}, + h5m_filename=self.h5m_filename_smaller) assert isinstance(my_material, openmc.Materials) assert len(my_material) == 1 diff --git a/tests/test_neutronics_utils.py b/tests/test_neutronics_utils.py index 3f208f9..c8a6484 100644 --- a/tests/test_neutronics_utils.py +++ b/tests/test_neutronics_utils.py @@ -35,7 +35,8 @@ def test_get_an_isotope_present_in_cross_sections_xml(self): assert isinstance(isotope, str) assert len(isotope) in [1, 2] - def test_get_an_isotope_present_in_cross_sections_xml_error_handeling(self): + def test_get_an_isotope_present_in_cross_sections_xml_error_handeling( + self): """Checks that an error message is raised if the OPENMC_CROSS_SECTIONS variable does not exist""" diff --git a/tests/test_system/test_system_single_volume.py b/tests/test_system/test_system_single_volume.py index 8d37562..9fa1925 100644 --- a/tests/test_system/test_system_single_volume.py +++ b/tests/test_system/test_system_single_volume.py @@ -67,12 +67,15 @@ def test_simulation_with_previous_h5m_file(self): geometry = odw.Geometry(h5m_filename=self.h5m_filename_smaller) materials = odw.Materials( - h5m_filename=self.h5m_filename_smaller, correspondence_dict={"mat1": "WC"} - ) + h5m_filename=self.h5m_filename_smaller, + correspondence_dict={ + "mat1": "WC"}) my_model = openmc.model.Model( - geometry=geometry, materials=materials, tallies=[], settings=self.settings - ) + geometry=geometry, + materials=materials, + tallies=[], + settings=self.settings) statepoint_file = my_model.run() @@ -98,8 +101,10 @@ def test_simulation_with_previous_h5m_file_with_graveyard_removed(self): ) my_model = openmc.model.Model( - geometry=geometry, materials=materials, tallies=[], settings=self.settings - ) + geometry=geometry, + materials=materials, + tallies=[], + settings=self.settings) statepoint_file = my_model.run() @@ -194,11 +199,16 @@ def test_neutronics_component_cell_simulation_heating(self): geometry = odw.Geometry(h5m_filename=self.h5m_filename_smaller) materials = odw.Materials( - h5m_filename=self.h5m_filename_smaller, correspondence_dict={"mat1": mat} - ) + h5m_filename=self.h5m_filename_smaller, + correspondence_dict={ + "mat1": mat}) my_tallies = odw.CellTallies( - tally_types=["heating", "flux", "TBR", "neutron_spectra", "photon_spectra"] - ) + tally_types=[ + "heating", + "flux", + "TBR", + "neutron_spectra", + "photon_spectra"]) my_model = openmc.model.Model( geometry=geometry, @@ -226,9 +236,13 @@ def test_neutronics_spectra(self): geometry = odw.Geometry(h5m_filename=self.h5m_filename_smaller) materials = odw.Materials( - h5m_filename=self.h5m_filename_smaller, correspondence_dict={"mat1": mat} - ) - my_tallies = odw.CellTallies(tally_types=["neutron_spectra", "photon_spectra"]) + h5m_filename=self.h5m_filename_smaller, + correspondence_dict={ + "mat1": mat}) + my_tallies = odw.CellTallies( + tally_types=[ + "neutron_spectra", + "photon_spectra"]) my_model = openmc.model.Model( geometry=geometry, @@ -250,8 +264,9 @@ def test_neutronics_component_2d_mesh_simulation(self): geometry = odw.Geometry(h5m_filename=self.h5m_filename_smaller) materials = odw.Materials( - h5m_filename=self.h5m_filename_smaller, correspondence_dict={"mat1": "Be"} - ) + h5m_filename=self.h5m_filename_smaller, + correspondence_dict={ + "mat1": "Be"}) my_tallies = odw.MeshTallies2D( tally_types=["heating"], @@ -283,8 +298,9 @@ def test_neutronics_component_3d_mesh_simulation(self): geometry = odw.Geometry(h5m_filename=self.h5m_filename_smaller) materials = odw.Materials( - h5m_filename=self.h5m_filename_smaller, correspondence_dict={"mat1": "Be"} - ) + h5m_filename=self.h5m_filename_smaller, + correspondence_dict={ + "mat1": "Be"}) my_tallies = odw.MeshTallies3D( tally_types=["heating", "(n,Xt)"], @@ -317,8 +333,9 @@ def test_neutronics_component_3d_and_2d_mesh_simulation(self): geometry = odw.Geometry(h5m_filename=self.h5m_filename_smaller) materials = odw.Materials( - h5m_filename=self.h5m_filename_smaller, correspondence_dict={"mat1": "Be"} - ) + h5m_filename=self.h5m_filename_smaller, + correspondence_dict={ + "mat1": "Be"}) my_3d_tally = odw.MeshTally3D( tally_type="heating", @@ -344,7 +361,8 @@ def test_neutronics_component_3d_and_2d_mesh_simulation(self): assert len(results.meshes) == 4 # one 3D and three 2D assert len(results.tallies.items()) == 4 # one 3D and three 2D - def test_neutronics_component_3d_and_2d_mesh_simulation_with_corner_points(self): + def test_neutronics_component_3d_and_2d_mesh_simulation_with_corner_points( + self): """Makes a neutronics model and simulates with a 3D and 2D mesh tally and checks that the vtk and png files are produced. This checks the mesh ID values don't overlap""" @@ -354,8 +372,9 @@ def test_neutronics_component_3d_and_2d_mesh_simulation_with_corner_points(self) geometry = odw.Geometry(h5m_filename=self.h5m_filename_smaller) materials = odw.Materials( - h5m_filename=self.h5m_filename_smaller, correspondence_dict={"mat1": "Be"} - ) + h5m_filename=self.h5m_filename_smaller, + correspondence_dict={ + "mat1": "Be"}) my_3d_tally = odw.MeshTally3D( tally_type="heating", @@ -395,8 +414,9 @@ def test_reactor_from_shapes_cell_tallies(self): geometry = odw.Geometry(h5m_filename=self.h5m_filename_smaller) materials = odw.Materials( - h5m_filename=self.h5m_filename_smaller, correspondence_dict={"mat1": "Be"} - ) + h5m_filename=self.h5m_filename_smaller, + correspondence_dict={ + "mat1": "Be"}) my_tallies = odw.CellTallies(tally_types=["TBR", "heating", "flux"]) @@ -421,8 +441,9 @@ def test_cell_tallies_simulation_fast_flux(self): geometry = odw.Geometry(h5m_filename=self.h5m_filename_smaller) materials = odw.Materials( - h5m_filename=self.h5m_filename_smaller, correspondence_dict={"mat1": "Be"} - ) + h5m_filename=self.h5m_filename_smaller, + correspondence_dict={ + "mat1": "Be"}) my_tallies = odw.CellTallies( tally_types=["photon_fast_flux", "neutron_fast_flux", "flux"] @@ -449,8 +470,9 @@ def test_cell_tallies_simulation_effective_dose(self): geometry = odw.Geometry(h5m_filename=self.h5m_filename_smaller) materials = odw.Materials( - h5m_filename=self.h5m_filename_smaller, correspondence_dict={"mat1": "Be"} - ) + h5m_filename=self.h5m_filename_smaller, + correspondence_dict={ + "mat1": "Be"}) my_tallies = odw.CellTallies( tally_types=["photon_effective_dose", "neutron_effective_dose"] @@ -512,9 +534,14 @@ def test_missing_h5m_file_error_handling(): os.system("touch tallies.xml") os.system("rm dagmc.h5m") - odw.Materials(h5m_filename="dagmc.h5m", correspondence_dict={"mat1": "Be"}) + odw.Materials( + h5m_filename="dagmc.h5m", + correspondence_dict={ + "mat1": "Be"}) - self.assertRaises(FileNotFoundError, test_missing_h5m_file_error_handling) + self.assertRaises( + FileNotFoundError, + test_missing_h5m_file_error_handling) if __name__ == "__main__": diff --git a/tests/test_tallies/test_mesh_tally_2d.py b/tests/test_tallies/test_mesh_tally_2d.py index 6f01c50..a9454ad 100644 --- a/tests/test_tallies/test_mesh_tally_2d.py +++ b/tests/test_tallies/test_mesh_tally_2d.py @@ -31,8 +31,8 @@ def test_incorrect_mesh_tally_2d(self): def incorrect_mesh_tally_2d(): odw.MeshTally2D( - "coucou", bounding_box=[(10, 10, 10), (-10, -10, -10)], plane="xy" - ) + "coucou", bounding_box=[ + (10, 10, 10), (-10, -10, -10)], plane="xy") self.assertRaises(ValueError, incorrect_mesh_tally_2d) @@ -84,8 +84,10 @@ def test_shape_of_resulting_png(self): settings.source = FusionRingSource(fuel="DT", radius=1) my_model = openmc.Model( - materials=materials, geometry=geometry, settings=settings, tallies=tallies - ) + materials=materials, + geometry=geometry, + settings=settings, + tallies=tallies) statepoint_file = my_model.run() assert Path(statepoint_file).exists() diff --git a/tests/test_tallies/test_mesh_tally_3d.py b/tests/test_tallies/test_mesh_tally_3d.py index 45043a3..72773b2 100644 --- a/tests/test_tallies/test_mesh_tally_3d.py +++ b/tests/test_tallies/test_mesh_tally_3d.py @@ -29,7 +29,9 @@ def test_incorrect_mesh_tally_3d(self): error""" def incorrect_mesh_tally_3d(): - odw.MeshTally3D("coucou", bounding_box=[(10, 10, 10), (-10, -10, -10)]) + odw.MeshTally3D( + "coucou", bounding_box=[ + (10, 10, 10), (-10, -10, -10)]) self.assertRaises(ValueError, incorrect_mesh_tally_3d) From 2e8e3425607c2514fa001d6dcfb460419297cf70 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 24 Nov 2021 22:39:36 +0000 Subject: [PATCH 25/28] allowing longer isotope names --- tests/test_neutronics_utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_neutronics_utils.py b/tests/test_neutronics_utils.py index 3f208f9..7a5b435 100644 --- a/tests/test_neutronics_utils.py +++ b/tests/test_neutronics_utils.py @@ -33,7 +33,8 @@ def test_get_an_isotope_present_in_cross_sections_xml(self): isotope = odw.utils.get_an_isotope_present_in_cross_sections_xml() assert isinstance(isotope, str) - assert len(isotope) in [1, 2] + # could be an isotope such as Ag107 or H3 or and element such as H + assert len(isotope) in [1, 2, 3, 4, 5] def test_get_an_isotope_present_in_cross_sections_xml_error_handeling(self): """Checks that an error message is raised if the OPENMC_CROSS_SECTIONS From 25e18185fb6e414e5214325032205edcba63aa04 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 24 Nov 2021 23:09:02 +0000 Subject: [PATCH 26/28] added all classes to the docs --- docs/source/cell_tallies.rst | 7 +++ docs/source/cell_tally.rst | 7 +++ .../source/example_neutronics_simulations.rst | 51 ------------------- docs/source/index.rst | 10 +++- docs/source/mesh_tallies_2d.rst | 7 +++ docs/source/mesh_tallies_3d.rst | 7 +++ docs/source/mesh_tally_2d.rst | 7 +++ docs/source/mesh_tally_3d.rst | 7 +++ docs/source/neutronics_model.rst | 7 --- docs/source/tet_mesh_tallies.rst | 7 +++ docs/source/tet_mesh_tally.rst | 7 +++ openmc_dagmc_wrapper/Tally.py | 6 +-- 12 files changed, 67 insertions(+), 63 deletions(-) create mode 100644 docs/source/cell_tallies.rst create mode 100644 docs/source/cell_tally.rst delete mode 100644 docs/source/example_neutronics_simulations.rst create mode 100644 docs/source/mesh_tallies_2d.rst create mode 100644 docs/source/mesh_tallies_3d.rst create mode 100644 docs/source/mesh_tally_2d.rst create mode 100644 docs/source/mesh_tally_3d.rst delete mode 100644 docs/source/neutronics_model.rst create mode 100644 docs/source/tet_mesh_tallies.rst create mode 100644 docs/source/tet_mesh_tally.rst diff --git a/docs/source/cell_tallies.rst b/docs/source/cell_tallies.rst new file mode 100644 index 0000000..eec7e1f --- /dev/null +++ b/docs/source/cell_tallies.rst @@ -0,0 +1,7 @@ + +CellTallies() +^^^^^^^^^^^^^ + +.. automodule:: openmc_dagmc_wrapper.CellTallies + :members: + :show-inheritance: diff --git a/docs/source/cell_tally.rst b/docs/source/cell_tally.rst new file mode 100644 index 0000000..c8cee8d --- /dev/null +++ b/docs/source/cell_tally.rst @@ -0,0 +1,7 @@ + +CellTally() +^^^^^^^^^^^ + +.. automodule:: openmc_dagmc_wrapper.CellTally + :members: + :show-inheritance: diff --git a/docs/source/example_neutronics_simulations.rst b/docs/source/example_neutronics_simulations.rst deleted file mode 100644 index 392fba2..0000000 --- a/docs/source/example_neutronics_simulations.rst +++ /dev/null @@ -1,51 +0,0 @@ -Examples - Neutronics Simulations -================================= - -These are minimal examples of neutronics simulations that demonstrate the core -functionality of the neutronics features. - - -ball_reactor.ipynb -^^^^^^^^^^^^^^^^^^ - -`Link to notebook `__ - - -ball_reactor_minimal.ipynb -^^^^^^^^^^^^^^^^^^^^^^^^^^ - -`Link to notebook `__ - - -ball_reactor_source_plot.ipynb -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -`Link to notebook `__ - - -center_column_study_reactor.ipynb -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -`Link to notebook `__ - - -center_column_study_reactor_minimal.ipynb -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -`Link to notebook `__ - - -OpenMC logo simulation -^^^^^^^^^^^^^^^^^^^^^^ - -`Link to notebook `__ - -.. raw:: html - - - - -text_example.ipynb -^^^^^^^^^^^^^^^^^^ - -`Link to notebook `__ diff --git a/docs/source/index.rst b/docs/source/index.rst index 6e8c583..cfa9b2a 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -8,8 +8,14 @@ standard neutronics simulations and post using OpenMC and DAGMC. :maxdepth: 1 install - example_neutronics_simulations - neutronics_model + cell_tally + cell_tallies + mesh_tally_2d + mesh_tallies_2d + mesh_tally_3d + mesh_tallies_3d + tet_mesh_tally + tet_mesh_tallies tests History diff --git a/docs/source/mesh_tallies_2d.rst b/docs/source/mesh_tallies_2d.rst new file mode 100644 index 0000000..a44c2b1 --- /dev/null +++ b/docs/source/mesh_tallies_2d.rst @@ -0,0 +1,7 @@ + +MeshTallies2D() +^^^^^^^^^^^^^^^ + +.. automodule:: openmc_dagmc_wrapper.MeshTallies2D + :members: + :show-inheritance: diff --git a/docs/source/mesh_tallies_3d.rst b/docs/source/mesh_tallies_3d.rst new file mode 100644 index 0000000..39fed8b --- /dev/null +++ b/docs/source/mesh_tallies_3d.rst @@ -0,0 +1,7 @@ + +MeshTallies3D() +^^^^^^^^^^^^^^^ + +.. automodule:: openmc_dagmc_wrapper.MeshTallies3D + :members: + :show-inheritance: diff --git a/docs/source/mesh_tally_2d.rst b/docs/source/mesh_tally_2d.rst new file mode 100644 index 0000000..4aae03c --- /dev/null +++ b/docs/source/mesh_tally_2d.rst @@ -0,0 +1,7 @@ + +MeshTally2D() +^^^^^^^^^^^^^ + +.. automodule:: openmc_dagmc_wrapper.MeshTally2D + :members: + :show-inheritance: diff --git a/docs/source/mesh_tally_3d.rst b/docs/source/mesh_tally_3d.rst new file mode 100644 index 0000000..9f54b21 --- /dev/null +++ b/docs/source/mesh_tally_3d.rst @@ -0,0 +1,7 @@ + +MeshTally3D() +^^^^^^^^^^^^^ + +.. automodule:: openmc_dagmc_wrapper.MeshTally3D + :members: + :show-inheritance: diff --git a/docs/source/neutronics_model.rst b/docs/source/neutronics_model.rst deleted file mode 100644 index 66e9084..0000000 --- a/docs/source/neutronics_model.rst +++ /dev/null @@ -1,7 +0,0 @@ - -NeutronicsModel() -^^^^^^^^^^^^^^^^^ - -.. automodule:: openmc_dagmc_wrapper.neutronics_model - :members: - :show-inheritance: diff --git a/docs/source/tet_mesh_tallies.rst b/docs/source/tet_mesh_tallies.rst new file mode 100644 index 0000000..00e343e --- /dev/null +++ b/docs/source/tet_mesh_tallies.rst @@ -0,0 +1,7 @@ + +TetMeshTallies() +^^^^^^^^^^^^^^^^ + +.. automodule:: openmc_dagmc_wrapper.TetMeshTallies + :members: + :show-inheritance: diff --git a/docs/source/tet_mesh_tally.rst b/docs/source/tet_mesh_tally.rst new file mode 100644 index 0000000..c34333e --- /dev/null +++ b/docs/source/tet_mesh_tally.rst @@ -0,0 +1,7 @@ + +TetMeshTally() +^^^^^^^^^^^^^^ + +.. automodule:: openmc_dagmc_wrapper.TetMeshTally + :members: + :show-inheritance: diff --git a/openmc_dagmc_wrapper/Tally.py b/openmc_dagmc_wrapper/Tally.py index befc3ee..988ac9e 100644 --- a/openmc_dagmc_wrapper/Tally.py +++ b/openmc_dagmc_wrapper/Tally.py @@ -277,13 +277,13 @@ def add_mesh_filter(self, bounding_box): class MeshTallies3D: - """[summary] + """Creates several MeshTally3D, one for each tally_type provided. The + tallies share the same mesh. Args: tally_types (list): [description] - meshes_resolutions (list): [description] - meshes_corners (list, optional): [description]. Defaults to None. bounding_box ([type], optional): [description]. Defaults to None. + meshes_resolutions (list): [description] """ def __init__( From de7168659a007b68796f4a336e30de666634f0d6 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 24 Nov 2021 23:35:22 +0000 Subject: [PATCH 27/28] indented index and combined tallies --- docs/source/cell_tallies.rst | 7 --- docs/source/cell_tally.rst | 7 --- docs/source/fusion_settings.rst | 7 +++ docs/source/geometry.rst | 7 +++ docs/source/index.rst | 77 ++++++++------------------------ docs/source/install.rst | 30 ++++++++----- docs/source/license.rst | 7 +++ docs/source/materials.rst | 7 +++ docs/source/mesh_tallies_2d.rst | 7 --- docs/source/mesh_tallies_3d.rst | 7 --- docs/source/mesh_tally_2d.rst | 7 --- docs/source/mesh_tally_3d.rst | 7 --- docs/source/tally.rst | 49 ++++++++++++++++++++ docs/source/tet_mesh_tallies.rst | 7 --- docs/source/tet_mesh_tally.rst | 7 --- 15 files changed, 116 insertions(+), 124 deletions(-) delete mode 100644 docs/source/cell_tallies.rst delete mode 100644 docs/source/cell_tally.rst create mode 100644 docs/source/fusion_settings.rst create mode 100644 docs/source/geometry.rst create mode 100644 docs/source/license.rst create mode 100644 docs/source/materials.rst delete mode 100644 docs/source/mesh_tallies_2d.rst delete mode 100644 docs/source/mesh_tallies_3d.rst delete mode 100644 docs/source/mesh_tally_2d.rst delete mode 100644 docs/source/mesh_tally_3d.rst create mode 100644 docs/source/tally.rst delete mode 100644 docs/source/tet_mesh_tallies.rst delete mode 100644 docs/source/tet_mesh_tally.rst diff --git a/docs/source/cell_tallies.rst b/docs/source/cell_tallies.rst deleted file mode 100644 index eec7e1f..0000000 --- a/docs/source/cell_tallies.rst +++ /dev/null @@ -1,7 +0,0 @@ - -CellTallies() -^^^^^^^^^^^^^ - -.. automodule:: openmc_dagmc_wrapper.CellTallies - :members: - :show-inheritance: diff --git a/docs/source/cell_tally.rst b/docs/source/cell_tally.rst deleted file mode 100644 index c8cee8d..0000000 --- a/docs/source/cell_tally.rst +++ /dev/null @@ -1,7 +0,0 @@ - -CellTally() -^^^^^^^^^^^ - -.. automodule:: openmc_dagmc_wrapper.CellTally - :members: - :show-inheritance: diff --git a/docs/source/fusion_settings.rst b/docs/source/fusion_settings.rst new file mode 100644 index 0000000..67f07ab --- /dev/null +++ b/docs/source/fusion_settings.rst @@ -0,0 +1,7 @@ + +FusionSettings() +---------------- + +.. automodule:: openmc_dagmc_wrapper.FusionSettings + :members: + :show-inheritance: diff --git a/docs/source/geometry.rst b/docs/source/geometry.rst new file mode 100644 index 0000000..6f5eb8c --- /dev/null +++ b/docs/source/geometry.rst @@ -0,0 +1,7 @@ + +Geometry() +---------- + +.. automodule:: openmc_dagmc_wrapper.Geometry + :members: + :show-inheritance: diff --git a/docs/source/index.rst b/docs/source/index.rst index cfa9b2a..289e529 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -1,66 +1,27 @@ openmc-dagmc-wrapper ==================== -The openmc-dagmc-wrapper python package allows convenient access to a series of -standard neutronics simulations and post using OpenMC and DAGMC. - -.. toctree:: - :maxdepth: 1 - - install - cell_tally - cell_tallies - mesh_tally_2d - mesh_tallies_2d - mesh_tally_3d - mesh_tallies_3d - tet_mesh_tally - tet_mesh_tallies - tests - -History -------- - -The package was originally conceived by Jonathan Shimwell to help automate -neutronics simulations of fusion reactors in a reproducible manner. - -The source code is distributed with a permissive open-source -license (MIT) and is available from the GitHub repository -`https://github.com/fusion-energy/openmc-dagmc-wrapper `_ +The openmc-dagmc-wrapper python package extends OpenMC base classes and adds +convenience features aimed as easing the use of OpenMC with DAGMC for +fixed-source simulations. +The openmc-dagmc-wrapper is built around the assumption that a DAGMC geometry +in the form of a h5m is used as the simulation geometry. This allows several +aspects of openmc simulations to be simplified. -Features --------- +Further simplifications are access by using additional packages from the +`fusion-neutronics-workflow `_ -In general the openmc-dagmc-wrapper takes a DAGMC geometry in the form of a h5m -file and helps adding tallies, materials and a source term to be easily added to -create a complete neutronics model. The package will also post processes the -results of the neutronics simulation to allow easy access to the outputs. -The simulated results are extracted from the statepoint.h5 file that -OpenMC produces and converted to vtk, png and JSON files depending on the tally. +If you are looking for an easy neutronics interface for performing simulations +of fusion reactors this package was built for you. -To create a model it is also necessary to define the source and the materials -used. - -The Paramak accepts native OpenMC materials and also Neutronics Material Maker -materials. Further details on the Neutronics Material Maker is avaialbe via online -`documentation `_ -and the `source code repository `_ -. - -The `OpenMC workshop `_ -also has some tasks that make use of this package. The workshop also -demonstrates methods of creating the CAD geometry and h5m files from CAD -geometry. - -The `OpenMC workflow `_ -demonstrates the use of this package along side others in a complete neutronics -tool chain. - -`CAD-to-h5m `_ makes use of the -`Cubit API `_ to convert CAD -files (stp or sat format) into `DAGMC `_ -compatible h5m files for use in DAGMC enabled neutronics codes. +.. toctree:: + :maxdepth: 2 -For magnetic confinement fusion simulations you might want to use the parametric-plasma-source -`Git repository `_ + install + geometry + materials + fusion_settings + tally + tests + license \ No newline at end of file diff --git a/docs/source/install.rst b/docs/source/install.rst index 11c5162..4baa727 100644 --- a/docs/source/install.rst +++ b/docs/source/install.rst @@ -2,13 +2,29 @@ Installation ============ - -Install -------- - To use the OpenMC-DAGMC-Wrapper package you will need the Python, MOAB, DAGMC and OpenMC installed. + +To complete the software stack OpenMC, DAGMC and MOAB will also need installing. +We don't have simple instructions for these packages yet but one option is to +duplicate the stages in the `Dockerfile https://github.com/fusion-energy/neutronics_workflow/blob/main/Dockerfile>`_ +or to make use of the `install scripts `_ (preferable to avoid hdf5 conflicts) @@ -38,12 +54,6 @@ Then install the OpenMC-DAGMC-Wrapper package using Pip. pip install openmc-dagmc-wrapper -To complete the software stack OpenMC, DAGMC and MOAB will also need installing. -We don't have simple instructions for these packages yet but one option is to -duplicate the stages in the `Dockerfile https://github.com/fusion-energy/neutronics_workflow/blob/main/Dockerfile>`_ -or to make use of the `install scripts `_ diff --git a/docs/source/materials.rst b/docs/source/materials.rst new file mode 100644 index 0000000..8f6bb3a --- /dev/null +++ b/docs/source/materials.rst @@ -0,0 +1,7 @@ + +Materials() +----------- + +.. automodule:: openmc_dagmc_wrapper.Materials + :members: + :show-inheritance: diff --git a/docs/source/mesh_tallies_2d.rst b/docs/source/mesh_tallies_2d.rst deleted file mode 100644 index a44c2b1..0000000 --- a/docs/source/mesh_tallies_2d.rst +++ /dev/null @@ -1,7 +0,0 @@ - -MeshTallies2D() -^^^^^^^^^^^^^^^ - -.. automodule:: openmc_dagmc_wrapper.MeshTallies2D - :members: - :show-inheritance: diff --git a/docs/source/mesh_tallies_3d.rst b/docs/source/mesh_tallies_3d.rst deleted file mode 100644 index 39fed8b..0000000 --- a/docs/source/mesh_tallies_3d.rst +++ /dev/null @@ -1,7 +0,0 @@ - -MeshTallies3D() -^^^^^^^^^^^^^^^ - -.. automodule:: openmc_dagmc_wrapper.MeshTallies3D - :members: - :show-inheritance: diff --git a/docs/source/mesh_tally_2d.rst b/docs/source/mesh_tally_2d.rst deleted file mode 100644 index 4aae03c..0000000 --- a/docs/source/mesh_tally_2d.rst +++ /dev/null @@ -1,7 +0,0 @@ - -MeshTally2D() -^^^^^^^^^^^^^ - -.. automodule:: openmc_dagmc_wrapper.MeshTally2D - :members: - :show-inheritance: diff --git a/docs/source/mesh_tally_3d.rst b/docs/source/mesh_tally_3d.rst deleted file mode 100644 index 9f54b21..0000000 --- a/docs/source/mesh_tally_3d.rst +++ /dev/null @@ -1,7 +0,0 @@ - -MeshTally3D() -^^^^^^^^^^^^^ - -.. automodule:: openmc_dagmc_wrapper.MeshTally3D - :members: - :show-inheritance: diff --git a/docs/source/tally.rst b/docs/source/tally.rst new file mode 100644 index 0000000..e889785 --- /dev/null +++ b/docs/source/tally.rst @@ -0,0 +1,49 @@ + +tally +===== + + +MeshTally2D() +------------- + +.. automodule:: openmc_dagmc_wrapper.MeshTally2D + :members: + :show-inheritance: + +MeshTallies2D() +--------------- + +.. automodule:: openmc_dagmc_wrapper.MeshTallies2D + :members: + :show-inheritance: + +MeshTally3D() +------------- + +.. automodule:: openmc_dagmc_wrapper.MeshTally3D + :members: + :show-inheritance: + +MeshTallies3D() +--------------- + +.. automodule:: openmc_dagmc_wrapper.MeshTallies3D + :members: + :show-inheritance: + +TetMeshTally() +-------------- + +.. automodule:: openmc_dagmc_wrapper.TetMeshTally + :members: + :show-inheritance: + + +TetMeshTallies() +---------------- + +.. automodule:: openmc_dagmc_wrapper.TetMeshTallies + :members: + :show-inheritance: + + diff --git a/docs/source/tet_mesh_tallies.rst b/docs/source/tet_mesh_tallies.rst deleted file mode 100644 index 00e343e..0000000 --- a/docs/source/tet_mesh_tallies.rst +++ /dev/null @@ -1,7 +0,0 @@ - -TetMeshTallies() -^^^^^^^^^^^^^^^^ - -.. automodule:: openmc_dagmc_wrapper.TetMeshTallies - :members: - :show-inheritance: diff --git a/docs/source/tet_mesh_tally.rst b/docs/source/tet_mesh_tally.rst deleted file mode 100644 index c34333e..0000000 --- a/docs/source/tet_mesh_tally.rst +++ /dev/null @@ -1,7 +0,0 @@ - -TetMeshTally() -^^^^^^^^^^^^^^ - -.. automodule:: openmc_dagmc_wrapper.TetMeshTally - :members: - :show-inheritance: From aeb5f1d5431774e7cfb75498a18379073e6ff069 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 24 Nov 2021 23:48:55 +0000 Subject: [PATCH 28/28] unified the intro text for the package on github and readthedocs --- README.md | 47 +++++++++++++++++---------------------- docs/source/index.rst | 7 +++++- docs/source/materials.rst | 3 +++ docs/source/tally.rst | 21 +++++++++++++++++ 4 files changed, 50 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 57ebcdb..83584d7 100644 --- a/README.md +++ b/README.md @@ -20,33 +20,26 @@ # OpenMC DAGMC Wrapper -The openmc-dagmc-wrapper python package allows convenient access to a series of standard neutronics simulations and post using OpenMC and DAGMC. - -The intended use case is to take DAGMC compatible h5m files generated by -[cad_to_h5m](https://github.com/fusion-energy/cad_to_h5m) with CAD file inputs -from the [Paramak](https://github.com/fusion-energy/paramak) as demonstrated in -the [neutronics_workflow](https://github.com/fusion-energy/neutronics_workflow). However the package can also be used with h5m files generated in other ways. - -Standard simulations tallies are facilitated: -- Volume / cell tallies -- Regular 2D mesh tallies -- Regular 3D mesh tallies -- Unstructured mesh tally (on road map) - -Neutronics responses can be obtained: -- Tritium Breeding Ratio (TBR) -- Heating (photon and neutron) -- Effective dose (photon and neutron) -- Any supported reaction from the [standard OpenMC reactions](https://docs.openmc.org/en/latest/usersguide/tallies.html#scores) - -A standard collection of materials are available by making use of the -[neutronics_material_maker](https://github.com/fusion-energy/neutronics_material_maker) package. - -OpenMC sources definitions are used for the particle sources. - -Post processing of the OpenMC output files are also carried out to automatically -provide: JSON text files, PNG images, VTK files for convenient access to the -results. + +The openmc-dagmc-wrapper python package extends OpenMC base classes and adds +convenience features aimed as easing the use of OpenMC with DAGMC for +fixed-source simulations. + +The openmc-dagmc-wrapper is built around the assumption that a DAGMC geometry +in the form of a h5m is used as the simulation geometry. This allows several +aspects of openmc simulations to be simplified and automated. + +Additional convenience is available when making tallies as standard tally types +are added which automated the application of openmc.Filters and openmc.scores +for standard tallies such as neutron spectra, effective dose, heating, TBR and +others. + +Further simplifications are access by using additional packages from the +[fusion-neutronics-workflow](https://github.com/fusion-energy/fusion_neutronics_workflow) + +If you are looking for an easy neutronics interface for performing simulations +of fusion reactors this package was built for you. + :point_right: [Documentation](https://openmc-dagmc-wrapper.readthedocs.io) diff --git a/docs/source/index.rst b/docs/source/index.rst index 289e529..f9ca494 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -7,7 +7,12 @@ fixed-source simulations. The openmc-dagmc-wrapper is built around the assumption that a DAGMC geometry in the form of a h5m is used as the simulation geometry. This allows several -aspects of openmc simulations to be simplified. +aspects of openmc simulations to be simplified and automated. + +Additional convenience is available when making tallies as standard tally types +are added which automated the application of openmc.Filters and openmc.scores +for standard tallies such as neutron spectra, effective dose, heating, TBR and +others. Further simplifications are access by using additional packages from the `fusion-neutronics-workflow `_ diff --git a/docs/source/materials.rst b/docs/source/materials.rst index 8f6bb3a..60fd312 100644 --- a/docs/source/materials.rst +++ b/docs/source/materials.rst @@ -1,4 +1,7 @@ +A standard collection of materials are available by making use of the +[neutronics_material_maker](https://github.com/fusion-energy/neutronics_material_maker) package. + Materials() ----------- diff --git a/docs/source/tally.rst b/docs/source/tally.rst index e889785..4709f45 100644 --- a/docs/source/tally.rst +++ b/docs/source/tally.rst @@ -2,6 +2,27 @@ tally ===== +Standard simulations tallies are facilitated: +- Volume / cell tallies +- Regular 2D mesh tallies +- Regular 3D mesh tallies +- Unstructured mesh tally + +Neutronics responses can be obtained: +- Tritium Breeding Ratio (TBR) +- Heating (photon and neutron) +- Effective dose (photon and neutron) +- Spectrum (photon and neutron) +- Damage per Atom (DPA) +- Any supported reaction from the [standard OpenMC reactions](https://docs.openmc.org/en/latest/usersguide/tallies.html#scores) + +Additionally the ability to target the tally to material tags or volume ids +that exist in the DAGMC h5m file offer easy access to tallies. + +Bounding boxes for the tallies can be automatically found and extended using +the `dagmc-bounding-box `_ +package. + MeshTally2D() -------------