From a3c4701e6926ae3119c4d6d13e614763daa8ade6 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 18 Mar 2024 13:33:01 +0000 Subject: [PATCH] combined tests --- .github/workflows/ci_with_install.yml | 2 + .github/workflows/ci_with_pip_install.yml | 7 +- README.md | 4 +- tests/test_h5m_in_simulation.py | 137 ------- tests/test_h5m_in_transport.py | 78 +++- tests/test_model_creation_for_transport.py | 47 --- tests/test_package.py | 434 --------------------- 7 files changed, 79 insertions(+), 630 deletions(-) delete mode 100644 tests/test_h5m_in_simulation.py delete mode 100644 tests/test_model_creation_for_transport.py delete mode 100644 tests/test_package.py diff --git a/.github/workflows/ci_with_install.yml b/.github/workflows/ci_with_install.yml index a4364f2..2e87231 100644 --- a/.github/workflows/ci_with_install.yml +++ b/.github/workflows/ci_with_install.yml @@ -1,4 +1,6 @@ +# This CI does includes particle transport tests as openmc is installed + name: CI with install on: diff --git a/.github/workflows/ci_with_pip_install.yml b/.github/workflows/ci_with_pip_install.yml index f0d3093..607306d 100644 --- a/.github/workflows/ci_with_pip_install.yml +++ b/.github/workflows/ci_with_pip_install.yml @@ -1,4 +1,6 @@ +# This CI does not currently include particle transport tests as openmc is not installed + name: CI with pip install on: @@ -49,10 +51,7 @@ jobs: python -m pip install . python -c "import cad_to_dagmc" python -m pip install .[tests] - pytest -v tests/test_file_creation.py - pytest -v tests/test_loading_from_file_vs_shape_object.py - pytest -v tests/test_python_api.py - pytest -v tests/test_version.py + pytest -v tests cd examples python create_stp_files_for_examples.py python cadquery_assembly.py diff --git a/README.md b/README.md index a49a33a..92c00cd 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ mamba activate new_env Install the dependencies ```bash -mamba install -y -c conda-forge moab>=5.3.0 gmsh python-gmsh +mamba install -y -c conda-forge "moab>=5.3.0" gmsh python-gmsh ``` Then you can install the cad_to_dagmc package with ```pip``` @@ -87,7 +87,7 @@ conda activate new_env Install the dependencies ```bash -conda install -y -c conda-forge moab>=5.3.0 gmsh python-gmsh +conda install -y -c conda-forge "moab>=5.3.0" gmsh python-gmsh ``` Then you can install the cad_to_dagmc package with ```pip``` diff --git a/tests/test_h5m_in_simulation.py b/tests/test_h5m_in_simulation.py deleted file mode 100644 index ba22786..0000000 --- a/tests/test_h5m_in_simulation.py +++ /dev/null @@ -1,137 +0,0 @@ -import openmc - -""" - - h5m files can be used a transport geometry in DAGMC with OpenMC -""" - - -def transport_particles_on_h5m_geometry( - h5m_filename: str, - material_tags, -): - """A function for testing the geometry file with particle transport in DAGMC OpenMC""" - - with open("cross_sections.xml", "w") as file: - file.write( - """ - - - - - - """ - ) - - openmc.config["cross_sections"] = "cross_sections.xml" - - materials = openmc.Materials() - for material_tag in material_tags: - # simplified material definitions have been used to keen this example minimal - mat_dag_material_tag = openmc.Material(name=material_tag) - mat_dag_material_tag.add_nuclide("H1", 1, "ao") - mat_dag_material_tag.set_density("g/cm3", 0.01) - - materials.append(mat_dag_material_tag) - - # makes use of the dagmc geometry - dag_univ = openmc.DAGMCUniverse(h5m_filename) - - # creates an edge of universe boundary surface - vac_surf = openmc.Sphere(r=10000, surface_id=9999, boundary_type="vacuum") - - # specifies the region as below the universe boundary - region = -vac_surf - - # creates a cell from the region and fills the cell with the dagmc geometry - containing_cell = openmc.Cell(cell_id=9999, region=region, fill=dag_univ) - - geometry = openmc.Geometry(root=[containing_cell]) - - # initialises a new source object - my_source = openmc.IndependentSource() - # sets the location of the source to x=0.1 y=0.1 z=0.1 which is not on a vertex - my_source.space = openmc.stats.Point((0.1, 0.1, 0.1)) - # sets the direction to isotropic - my_source.angle = openmc.stats.Isotropic() - # sets the energy distribution to 100% 14MeV neutrons - my_source.energy = openmc.stats.Discrete([14e6], [1]) - - # specifies the simulation computational intensity - settings = openmc.Settings() - settings.batches = 10 - settings.particles = 10000 - settings.inactive = 0 - settings.run_mode = "fixed source" - settings.source = my_source - settings.photon_transport = False - - # adds a tally to record the heat deposited in entire geometry - cell_tally = openmc.Tally(name="heating") - cell_tally.scores = ["heating"] - - # creates a mesh that covers the geometry - mesh = openmc.RegularMesh() - mesh.dimension = [100, 100, 100] - mesh.lower_left = [ - -10, - -10, - -10, - ] # x,y,z coordinates start at 0 as this is a sector model - mesh.upper_right = [10, 10, 10] - - # makes a mesh tally using the previously created mesh and records heating on the mesh - mesh_tally = openmc.Tally(name="heating_on_mesh") - mesh_filter = openmc.MeshFilter(mesh) - mesh_tally.filters = [mesh_filter] - mesh_tally.scores = ["heating"] - - # groups the two tallies - tallies = openmc.Tallies([cell_tally, mesh_tally]) - - # builds the openmc model - my_model = openmc.Model( - materials=materials, geometry=geometry, settings=settings, tallies=tallies - ) - - # starts the simulation - my_model.run() - - -def test_h5m_with_single_volume_list(): - """The simplest geometry, a single 4 sided shape with lists instead of np arrays""" - - h5m_files = [ - # "tests/extrude_rectangle.h5m", - "tests/single_cube.h5m", - # "tests/single_volume_thin.h5m", - ] - - for h5m_file in h5m_files: - transport_particles_on_h5m_geometry( - h5m_filename=h5m_file, - material_tags=["mat1"], - ) - - -def test_h5m_with_multi_volume_not_touching(): - material_tags = [ - ["mat1", "mat2"], - ] - h5m_files = [ - "tests/two_disconnected_cubes.h5m", - ] - for mat_tags, h5m_file in zip(material_tags, h5m_files): - transport_particles_on_h5m_geometry(h5m_filename=h5m_file, material_tags=mat_tags) - - -def test_h5m_with_multi_volume_touching(): - material_tags = [ - ["mat1", "mat2", "mat3", "mat4", "mat5", "mat6"], - ["mat1", "mat2"], - ] - h5m_files = [ - "tests/multi_volume_cylinders.h5m", - "tests/two_connected_cubes.h5m", - ] - for mat_tags, h5m_file in zip(material_tags, h5m_files): - transport_particles_on_h5m_geometry(h5m_filename=h5m_file, material_tags=mat_tags) diff --git a/tests/test_h5m_in_transport.py b/tests/test_h5m_in_transport.py index 88d3d36..6bb26fc 100644 --- a/tests/test_h5m_in_transport.py +++ b/tests/test_h5m_in_transport.py @@ -1,4 +1,10 @@ -import openmc +import pytest + +try: + import openmc +except ImportError: + openmc = None + from cad_to_dagmc import CadToDagmc import cadquery as cq @@ -116,7 +122,7 @@ def transport_particles_on_h5m_geometry( return my_flux_cell_tally.mean.flatten()[0] - +@pytest.mark.skipif(openmc is None, reason="openmc tests only required for CI") def test_transport_result_h5m_with_2_sep_volumes(): h5m_filename = "test_two_sep_volumes.h5m" volumes = 2 @@ -139,8 +145,8 @@ def test_transport_result_h5m_with_2_sep_volumes(): nuclides=["H1"] * len(material_tags), ) - -def test_transport_result_h5m_with_1_volumes(): +@pytest.mark.skipif(openmc is None, reason="openmc tests only required for CI") +def test_transport_result_h5m_with_1_curved_volumes(): h5m_filename = "one_cylinder.h5m" volumes = 1 material_tags = [f"material_{n}" for n in range(1, volumes + 1)] @@ -157,8 +163,8 @@ def test_transport_result_h5m_with_1_volumes(): nuclides=["H1"] * len(material_tags), ) - -def test_transport_result_h5m_with_2_joined_volumes(): +@pytest.mark.skipif(openmc is None, reason="openmc tests only required for CI") +def test_transport_result_h5m_with_2_joined_curved_volumes(): h5m_filename = "two_connected_cylinders.h5m" volumes = 2 material_tags = [f"material_{n}" for n in range(1, volumes + 1)] @@ -178,3 +184,63 @@ def test_transport_result_h5m_with_2_joined_volumes(): material_tags=material_tags, nuclides=["H1"] * len(material_tags), ) + + +@pytest.mark.skipif(openmc is None, reason="openmc tests only required for CI") +def test_h5m_with_single_volume_list(): + """The simplest geometry, a single 4 sided shape with lists instead of np arrays""" + + h5m_file = "tests/single_cube.h5m" + + my_model = CadToDagmc() + my_model.add_stp_file(filename="tests/single_cube.stp") + my_model.export_dagmc_h5m_file(filename=h5m_file, material_tags=["mat1"]) + + h5m_files = [ + "tests/single_cube.h5m", + ] + + for h5m_file in h5m_files: + transport_particles_on_h5m_geometry( + h5m_filename=h5m_file, + material_tags=["mat1"], + nuclides=["H1"], + ) + +@pytest.mark.skipif(openmc is None, reason="openmc tests only required for CI") +def test_h5m_with_multi_volume_not_touching(): + + h5m_file = "tests/two_disconnected_cubes.h5m" + + my_model = CadToDagmc() + my_model.add_stp_file(filename="tests/two_disconnected_cubes.stp") + my_model.export_dagmc_h5m_file(filename=h5m_file, material_tags=["mat1", "mat2"]) + + transport_particles_on_h5m_geometry(h5m_filename="tests/two_disconnected_cubes.h5m", material_tags=["mat1", "mat2"]) + +@pytest.mark.skipif(openmc is None, reason="openmc tests only required for CI") +def test_h5m_with_multi_volume_touching(): + stp_files = [ + "tests/multi_volume_cylinders.stp", + "tests/two_connected_cubes.stp", + ] + material_tags = [ + ["mat1", "mat2", "mat3", "mat4", "mat5", "mat6"], + ["mat1", "mat2"], + ] + h5m_files = [ + "tests/multi_volume_cylinders.h5m", + "tests/two_connected_cubes.h5m", + ] + for stp_file, mat_tags, h5m_file in zip(stp_files, material_tags, h5m_files): + + my_model = CadToDagmc() + my_model.add_stp_file(stp_file) + + my_model.export_dagmc_h5m_file(filename=h5m_file, material_tags=mat_tags) + + transport_particles_on_h5m_geometry( + h5m_filename=h5m_file, + material_tags=mat_tags, + nuclides=["H1"] * len(material_tags), + ) diff --git a/tests/test_model_creation_for_transport.py b/tests/test_model_creation_for_transport.py deleted file mode 100644 index ab3fe47..0000000 --- a/tests/test_model_creation_for_transport.py +++ /dev/null @@ -1,47 +0,0 @@ -from cad_to_dagmc import CadToDagmc -import cadquery as cq - - -def test_transport_result_h5m_with_2_sep_volumes(): - h5m_filename = "test_two_sep_volumes.h5m" - volumes = 2 - material_tags = [f"material_{n}" for n in range(1, volumes + 1)] - - workplane1 = cq.Workplane("XY").cylinder(height=10, radius=4) - workplane2 = cq.Workplane("XY").moveTo(0, 15).cylinder(height=10, radius=5) - # cq.Assembly().add(workplane1).add(workplane2) - - my_model = CadToDagmc() - my_model.add_cadquery_object(workplane1) - my_model.add_cadquery_object(workplane2) - my_model.export_dagmc_h5m_file( - filename=h5m_filename, material_tags=[material_tags[0], material_tags[1]] - ) - - -def test_transport_result_h5m_with_1_volumes(): - h5m_filename = "one_cylinder.h5m" - volumes = 1 - material_tags = [f"material_{n}" for n in range(1, volumes + 1)] - - workplane1 = cq.Workplane("XY").cylinder(height=10, radius=4) - - my_model = CadToDagmc() - my_model.add_cadquery_object(workplane1) - my_model.export_dagmc_h5m_file(filename=h5m_filename, material_tags=[material_tags[0]]) - - -def test_transport_result_h5m_with_2_joined_volumes(): - h5m_filename = "two_connected_cylinders.h5m" - volumes = 2 - material_tags = [f"material_{n}" for n in range(1, volumes + 1)] - - workplane1 = cq.Workplane("XY").cylinder(height=10, radius=4) - workplane2 = cq.Workplane("XY").cylinder(height=10, radius=5).cut(workplane1) - - my_model = CadToDagmc() - my_model.add_cadquery_object(workplane1) - my_model.add_cadquery_object(workplane2) - my_model.export_dagmc_h5m_file( - filename=h5m_filename, material_tags=[material_tags[0], material_tags[1]] - ) diff --git a/tests/test_package.py b/tests/test_package.py deleted file mode 100644 index 691d294..0000000 --- a/tests/test_package.py +++ /dev/null @@ -1,434 +0,0 @@ -from pathlib import Path - -import numpy as np -import openmc -import pymoab as mb -from pymoab import core, types - - -""" -Tests that check that: - - h5m files are created - - h5m files contain the correct number of volumes - - h5m files contain the correct material tags - - h5m files can be used a transport geometry in DAGMC with OpenMC -""" - - -def get_volumes_and_materials_from_h5m(filename: str) -> dict: - """Reads in a DAGMC h5m file and uses PyMoab to find the volume ids with - their associated material tags. - - Arguments: - filename: the filename of the DAGMC h5m file - - Returns: - A dictionary of volume ids and material tags - """ - - mbcore = core.Core() - mbcore.load_file(filename) - category_tag = mbcore.tag_get_handle(mb.types.CATEGORY_TAG_NAME) - group_category = ["Group"] - group_ents = mbcore.get_entities_by_type_and_tag( - 0, mb.types.MBENTITYSET, category_tag, group_category - ) - name_tag = mbcore.tag_get_handle(mb.types.NAME_TAG_NAME) - id_tag = mbcore.tag_get_handle(mb.types.GLOBAL_ID_TAG_NAME) - vol_mat = {} - for group_ent in group_ents: - group_name = mbcore.tag_get_data(name_tag, group_ent)[0][0] - # confirm that this is a material! - if group_name.startswith("mat:"): - vols = mbcore.get_entities_by_type(group_ent, mb.types.MBENTITYSET) - for vol in vols: - id = mbcore.tag_get_data(id_tag, vol)[0][0].item() - vol_mat[id] = group_name - print("vol_mat", vol_mat) - return vol_mat - - -def transport_particles_on_h5m_geometry(h5m_filename, material_tags, cross_sections_xml=None): - """A function for testing the geometry file with particle transport in DAGMC OpenMC""" - - materials = openmc.Materials() - for material_tag in material_tags: - # simplified material definitions have been used to keen this example minimal - mat_dag_material_tag = openmc.Material(name=material_tag) - mat_dag_material_tag.add_nuclide("H1", 1, "ao") - mat_dag_material_tag.set_density("g/cm3", 0.01) - - materials.append(mat_dag_material_tag) - - if cross_sections_xml: - materials.cross_sections = cross_sections_xml - # downloads the nuclear data and sets the openmc_cross_sections environmental variable - - if cross_sections_xml: - openmc.config["cross_sections"] = cross_sections_xml - - else: - with open("cross_sections.xml", "w") as file: - file.write( - """ - - - - - - """ - ) - - openmc.config["cross_sections"] = "cross_sections.xml" - - # makes use of the dagmc geometry - dag_univ = openmc.DAGMCUniverse(h5m_filename) - - # creates an edge of universe boundary surface - vac_surf = openmc.Sphere(r=10000, surface_id=9999, boundary_type="vacuum") - - # specifies the region as below the universe boundary - region = -vac_surf - - # creates a cell from the region and fills the cell with the dagmc geometry - containing_cell = openmc.Cell(cell_id=9999, region=region, fill=dag_univ) - - geometry = openmc.Geometry(root=[containing_cell]) - - # initialises a new source object - my_source = openmc.IndependentSource() - # sets the location of the source to x=0.1 y=0.1 z=0.1 which is not on a vertex - my_source.space = openmc.stats.Point((0.1, 0.1, 0.1)) - # sets the direction to isotropic - my_source.angle = openmc.stats.Isotropic() - # sets the energy distribution to 100% 14MeV neutrons - my_source.energy = openmc.stats.Discrete([14e6], [1]) - - # specifies the simulation computational intensity - settings = openmc.Settings() - settings.batches = 10 - settings.particles = 10000 - settings.inactive = 0 - settings.run_mode = "fixed source" - settings.source = my_source - - # adds a tally to record the heat deposited in entire geometry - cell_tally = openmc.Tally(name="heating") - cell_tally.scores = ["heating"] - - # creates a mesh that covers the geometry - mesh = openmc.RegularMesh() - mesh.dimension = [100, 100, 100] - mesh.lower_left = [ - -10, - -10, - -10, - ] # x,y,z coordinates start at 0 as this is a sector model - mesh.upper_right = [10, 10, 10] - - # makes a mesh tally using the previously created mesh and records heating on the mesh - mesh_tally = openmc.Tally(name="heating_on_mesh") - mesh_filter = openmc.MeshFilter(mesh) - mesh_tally.filters = [mesh_filter] - mesh_tally.scores = ["heating"] - - # groups the two tallies - tallies = openmc.Tallies([cell_tally, mesh_tally]) - - # builds the openmc model - my_model = openmc.Model( - materials=materials, geometry=geometry, settings=settings, tallies=tallies - ) - - # starts the simulation - my_model.run() - - -# triangle normal need fixing -# def test_h5m_production_with_single_volume_list(): -# """The simplest geometry, a single 4 sided shape with lists instead of np arrays""" - -# test_h5m_filename = "single_tet.h5m" - -# # a list of xyz coordinates -# vertices = [ -# [0.0, 0.0, 0.0], -# [1.0, 0.0, 0.0], -# [0.0, 1.0, 0.0], -# [0.0, 0.0, 1.0], -# ] - -# # the index of the coordinate that make up the corner of a tet, normals need fixing -# triangles = { -# 1: { -# 1: [[0, 1, 2]], -# 2: [[3, 1, 2]], -# 3: [[0, 2, 3]], -# 4: [[0, 1, 3]], -# }, -# } - -# vertices_to_h5m( -# vertices=vertices, -# triangles_by_solid_by_face=triangles, -# material_tags=["mat1"], -# h5m_filename=test_h5m_filename, -# ) - -# transport_particles_on_h5m_geometry( -# h5m_filename=test_h5m_filename, -# material_tags=["mat1"], -# ) - -# assert Path(test_h5m_filename).is_file() -# assert get_volumes_and_materials_from_h5m(test_h5m_filename) == {1: "mat:mat1"} - - -# def test_h5m_production_with_single_volume_numpy(): -# """The simplest geometry, a single 4 sided shape""" - -# test_h5m_filename = "single_tet.h5m" - -# # a list of xyz coordinates -# vertices = np.array( -# [ -# [0.0, 0.0, 0.0], -# [1.0, 0.0, 0.0], -# [0.0, 1.0, 0.0], -# [0.0, 0.0, 1.0], -# ], -# dtype="float64", -# ) - -# # the index of the coordinate that make up the corner of a tet, normals need fixing -# triangles = [np.array( -# [0, 1, 2], -# [3, 1, 2], -# [0, 2, 3], -# [0, 1, 3]])] - -# vertices_to_h5m( -# vertices=vertices, -# triangles=triangles, -# material_tags=["mat1"], -# h5m_filename=test_h5m_filename, -# ) - -# transport_particles_on_h5m_geometry( -# h5m_filename=test_h5m_filename, -# material_tags=["mat1"], -# ) - -# assert Path(test_h5m_filename).is_file() -# assert get_volumes_and_materials_from_h5m(test_h5m_filename) == {1: "mat:mat1"} - - -# def test_h5m_production_with_two_touching_edges_numpy(): -# """Two 4 sided shapes that share and edge""" - -# test_h5m_filename = "double_tet.h5m" - -# # a list of xyz coordinates -# vertices = np.array( -# [ -# [0.0, 0.0, 0.0], -# [1.0, 0.0, 0.0], -# [0.0, 1.0, 0.0], -# [0.0, 0.0, 1.0], -# [1.0, 1.0, 1.0], -# [1.0, 1.0, 0.0], -# ], -# dtype="float64", -# ) - -# # the index of the coordinate that make up the corner of a tet, normals need fixing -# triangles = [ -# np.array([[0, 1, 2], [3, 1, 2], [0, 2, 3], [0, 1, 3]]), -# np.array([[4, 5, 1], [4, 5, 2], [4, 1, 2], [5, 1, 2]]), -# ] - -# vertices_to_h5m( -# vertices=vertices, -# triangles=triangles, -# material_tags=["mat1", "mat2"], -# h5m_filename=test_h5m_filename, -# ) - -# transport_particles_on_h5m_geometry( -# h5m_filename=test_h5m_filename, -# material_tags=["mat1", "mat2"], -# ) - -# assert Path(test_h5m_filename).is_file() -# assert get_volumes_and_materials_from_h5m(test_h5m_filename) == { -# 1: "mat:mat1", -# 2: "mat:mat2", -# } - - -# def test_h5m_production_with_two_touching_edges_lists(): -# """Two 4 sided shapes that share and edge""" - -# test_h5m_filename = "double_tet.h5m" - -# # a list of xyz coordinates -# vertices = [ -# [0.0, 0.0, 0.0], -# [1.0, 0.0, 0.0], -# [0.0, 1.0, 0.0], -# [0.0, 0.0, 1.0], -# [1.0, 1.0, 1.0], -# [1.0, 1.0, 0.0], -# ] - -# # the index of the coordinate that make up the corner of a tet, normals need fixing -# triangles = [ -# [[0, 1, 2], [3, 1, 2], [0, 2, 3], [0, 1, 3]], -# [[4, 5, 1], [4, 5, 2], [4, 1, 2], [5, 1, 2]], -# ] - -# vertices_to_h5m( -# vertices=vertices, -# triangles=triangles, -# material_tags=["mat1", "mat2"], -# h5m_filename=test_h5m_filename, -# ) - -# transport_particles_on_h5m_geometry( -# h5m_filename=test_h5m_filename, -# material_tags=["mat1", "mat2"], -# ) - -# assert Path(test_h5m_filename).is_file() -# assert get_volumes_and_materials_from_h5m(test_h5m_filename) == { -# 1: "mat:mat1", -# 2: "mat:mat2", -# } - - -# def test_h5m_production_with_two_touching_vertex_numpy(): -# """Two 4 sided shapes that share an single vertex""" - -# test_h5m_filename = "touching_vertex_tets.h5m" - -# vertices = np.array( -# [ -# [0, 0, 0], -# [1, 0, 0], -# [0, 1, 0], -# [0, 0, 1], -# [-1, 0, 0], -# [0, -1, 0], -# [0, 0, -1], -# ], -# dtype="float64", -# ) - -# # the index of the coordinate that make up the corner of a tet, normals need fixing -# triangles = [ -# np.array([[0, 4, 5], [6, 4, 5], [0, 5, 6], [0, 4, 6]]), -# np.array([[0, 1, 2], [3, 1, 2], [0, 2, 3], [0, 1, 3]]), -# ] - -# vertices_to_h5m( -# vertices=vertices, -# triangles=triangles, -# material_tags=["mat1", "mat2"], -# h5m_filename=test_h5m_filename, -# ) - -# transport_particles_on_h5m_geometry( -# h5m_filename=test_h5m_filename, -# material_tags=["mat1", "mat2"], -# ) - -# assert Path(test_h5m_filename).is_file() -# assert get_volumes_and_materials_from_h5m(test_h5m_filename) == { -# 1: "mat:mat1", -# 2: "mat:mat2", -# } - - -# def test_h5m_production_with_two_touching_vertex_list(): -# """Two 4 sided shapes that share an single vertex""" - -# test_h5m_filename = "touching_vertex_tets.h5m" - -# vertices = [ -# [0.0, 0.0, 0.0], -# [1.0, 0.0, 0.0], -# [0.0, 1.0, 0.0], -# [0.0, 0.0, 1.0], -# [-1.0, 0.0, 0.0], -# [0.0, -1.0, 0.0], -# [0.0, 0.0, -1.0], -# ] - -# # the index of the coordinate that make up the corner of a tet, normals need fixing -# triangles = [ -# [[0, 4, 5], [6, 4, 5], [0, 5, 6], [0, 4, 6]], -# [[0, 1, 2], [3, 1, 2], [0, 2, 3], [0, 1, 3]], -# ] - -# vertices_to_h5m( -# vertices=vertices, -# triangles=triangles, -# material_tags=["mat1", "mat2"], -# h5m_filename=test_h5m_filename, -# ) - -# transport_particles_on_h5m_geometry( -# h5m_filename=test_h5m_filename, -# material_tags=["mat1", "mat2"], -# ) - -# assert Path(test_h5m_filename).is_file() -# assert get_volumes_and_materials_from_h5m(test_h5m_filename) == { -# 1: "mat:mat1", -# 2: "mat:mat2", -# } - - -# def test_h5m_production_with_two_touching_face_numpy(): -# """Two 4 sided shapes that share a face""" - -# test_h5m_filename = "double_tet_touching_face.h5m" - -# # a list of xyz coordinates -# vertices = np.array( -# [ -# [0.0, 0.0, 0.0], -# [1.0, 0.0, 0.0], -# [0.0, 1.0, 0.0], -# [0.0, 0.0, 1.0], -# [1.0, 0.0, 1.0], -# [0.0, 1.0, 1.0], -# # [1.0, 1.0, 1.0], -# # [1.0, 1.0, 0.0], -# ], -# dtype="float64", -# ) - -# # the index of the coordinate that make up the corner of a tet, normals need fixing -# triangles = [ -# np.array([[0, 1, 2], [3, 1, 2], [0, 2, 3], [0, 1, 3]]), -# np.array([[1, 2, 3], [1, 3, 4], [3, 5, 2], [1, 2, 4], [2, 4, 5], [3, 5, 4]]), -# ] - -# vertices_to_h5m( -# vertices=vertices, -# triangles=triangles, -# material_tags=["mat1", "mat2"], -# h5m_filename=test_h5m_filename, -# ) - -# transport_particles_on_h5m_geometry( -# h5m_filename=test_h5m_filename, -# material_tags=["mat1", "mat2"], -# ) - -# assert Path(test_h5m_filename).is_file() -# assert get_volumes_and_materials_from_h5m(test_h5m_filename) == { -# 1: "mat:mat1", -# 2: "mat:mat2", -# }