Skip to content

Commit

Permalink
combined tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shimwell committed Mar 18, 2024
1 parent 06d29a7 commit a3c4701
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 630 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci_with_install.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

# This CI does includes particle transport tests as openmc is installed

name: CI with install

on:
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/ci_with_pip_install.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

# This CI does not currently include particle transport tests as openmc is not installed

name: CI with pip install

on:
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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```
Expand Down Expand Up @@ -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```
Expand Down
137 changes: 0 additions & 137 deletions tests/test_h5m_in_simulation.py

This file was deleted.

78 changes: 72 additions & 6 deletions tests/test_h5m_in_transport.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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)]
Expand All @@ -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)]
Expand All @@ -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),
)
47 changes: 0 additions & 47 deletions tests/test_model_creation_for_transport.py

This file was deleted.

Loading

0 comments on commit a3c4701

Please sign in to comment.