From 6bfc929e4ab1ac857d4e405fd851acc8a30fa7d6 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 18 Mar 2024 02:16:43 +0000 Subject: [PATCH 01/21] more packages in the pip installer --- .github/workflows/ci_with_benchmarks.yml | 4 +--- .github/workflows/ci_with_install.yml | 2 +- .github/workflows/ci_with_pip_install.yml | 22 +++++++++++++++++----- README.md | 5 +++++ pyproject.toml | 2 ++ 5 files changed, 26 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci_with_benchmarks.yml b/.github/workflows/ci_with_benchmarks.yml index 0970370..6a42c02 100644 --- a/.github/workflows/ci_with_benchmarks.yml +++ b/.github/workflows/ci_with_benchmarks.yml @@ -37,11 +37,9 @@ jobs: sudo apt-get upgrade -y sudo apt-get install -y libgl1-mesa-glx libgl1-mesa-dev libglu1-mesa-dev freeglut3-dev libosmesa6 libosmesa6-dev libgles2-mesa-dev libarchive-dev libpangocairo-1.0-0 mamba activate - mamba install -y -c conda-forge "openmc=0.14.0=dagmc*nompi*" moab>=5.3.0 gmsh python-gmsh + mamba install -y -c conda-forge "openmc=0.14.0=dagmc*nompi*" moab>=5.3.0 python -m pip install --upgrade pip python -m pip install . - python -m pip install cadquery-ocp==7.7.2 - python -m pip install cadquery==2.4.0 python -m pip install openmc_data_downloader openmc_data_downloader -l ENDFB-7.1-NNDC -i Fe56 Be9 git clone --single-branch -b main --depth 1 https://github.com/fusion-energy/model_benchmark_zoo.git diff --git a/.github/workflows/ci_with_install.yml b/.github/workflows/ci_with_install.yml index 71579ab..119e44c 100644 --- a/.github/workflows/ci_with_install.yml +++ b/.github/workflows/ci_with_install.yml @@ -37,7 +37,7 @@ jobs: mamba activate mamba create -y --name cad_to_dagmc python=3.10 mamba activate cad_to_dagmc - mamba install -y -c conda-forge moab>=5.3.0 gmsh python-gmsh ocp=7.7.2.0 cadquery=2.4.0 + mamba install -y -c conda-forge moab>=5.3.0 python -m pip install --upgrade pip python -m pip install . python -c "import cad_to_dagmc" diff --git a/.github/workflows/ci_with_pip_install.yml b/.github/workflows/ci_with_pip_install.yml index 932617a..b47fefd 100644 --- a/.github/workflows/ci_with_pip_install.yml +++ b/.github/workflows/ci_with_pip_install.yml @@ -32,16 +32,28 @@ jobs: apt-get update -y apt-get upgrade -y apt-get install -y libgl1-mesa-glx libgl1-mesa-dev libglu1-mesa-dev freeglut3-dev libosmesa6 libosmesa6-dev libgles2-mesa-dev libarchive-dev libpangocairo-1.0-0 libxcursor-dev libxft2 libxinerama-dev + apt-get install -y make cmake apt install python3 apt install python3-pip - python -m pip install --upgrade pip - python -m pip install gmsh - python -m pip install cadquery-ocp==7.7.2 - python -m pip install cadquery==2.4.0 + python -m pip install --upgrade pip + mkdir -MOAB + cd /MOAB + git clone --single-branch -b 5.3.0 --depth 1 https://bitbucket.org/fathomteam/moab/ + mkdir build + cd build + cmake .. -DENABLE_PYMOAB=ON -DENABLE_HDF5=ON + make + make install + cd pymoab + bash install.sh + cd ../.. python -m pip install . python -c "import cad_to_dagmc" python -m pip install .[tests] - pytest tests -v + 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 cd examples python create_stp_files_for_examples.py python cadquery_assembly.py diff --git a/README.md b/README.md index 3d0ef5d..0f97516 100644 --- a/README.md +++ b/README.md @@ -127,6 +127,11 @@ Then you can install the cad_to_dagmc package with ```pip``` pip install cad_to_dagmc ``` +# Known incompatibilities + +The package requires newer versions of Linux. For example the package does not work on Ubuntu 18.04 or older. + +The package requires newer versions of pip. It is recommended to ensure that your version of pip is up to date. This can be done with ```python -m pip install --upgrade pip``` # Usage - with OpenMC diff --git a/pyproject.toml b/pyproject.toml index b91b060..9e6efbe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,6 +20,8 @@ classifiers = [ dependencies = [ "trimesh", "networkx", + "cadquery-ocp>=7.7.2" + "cadquery>=2.4.0" ] dynamic = ["version"] From 3c5d44cc9aee64660bc2a58fbf91180476373721 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 18 Mar 2024 02:18:20 +0000 Subject: [PATCH 02/21] added missing comma --- pyproject.toml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 9e6efbe..c2345ec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,8 +20,9 @@ classifiers = [ dependencies = [ "trimesh", "networkx", - "cadquery-ocp>=7.7.2" - "cadquery>=2.4.0" + "gmsh", + "cadquery-ocp>=7.7.2", + "cadquery>=2.4.0", ] dynamic = ["version"] From 597981c15326e946a688f0cd7cd991f605fc6345 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 18 Mar 2024 02:21:46 +0000 Subject: [PATCH 03/21] remove extra - --- .github/workflows/ci_with_pip_install.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_with_pip_install.yml b/.github/workflows/ci_with_pip_install.yml index b47fefd..153af53 100644 --- a/.github/workflows/ci_with_pip_install.yml +++ b/.github/workflows/ci_with_pip_install.yml @@ -36,7 +36,7 @@ jobs: apt install python3 apt install python3-pip python -m pip install --upgrade pip - mkdir -MOAB + mkdir MOAB cd /MOAB git clone --single-branch -b 5.3.0 --depth 1 https://bitbucket.org/fathomteam/moab/ mkdir build From 5de08f7248b5882e8e6cb75298a35e6aa2c4110f Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 18 Mar 2024 02:32:14 +0000 Subject: [PATCH 04/21] gmsh back in conda --- .github/workflows/ci_with_benchmarks.yml | 2 +- .github/workflows/ci_with_install.yml | 2 +- pyproject.toml | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci_with_benchmarks.yml b/.github/workflows/ci_with_benchmarks.yml index 6a42c02..b82c303 100644 --- a/.github/workflows/ci_with_benchmarks.yml +++ b/.github/workflows/ci_with_benchmarks.yml @@ -37,7 +37,7 @@ jobs: sudo apt-get upgrade -y sudo apt-get install -y libgl1-mesa-glx libgl1-mesa-dev libglu1-mesa-dev freeglut3-dev libosmesa6 libosmesa6-dev libgles2-mesa-dev libarchive-dev libpangocairo-1.0-0 mamba activate - mamba install -y -c conda-forge "openmc=0.14.0=dagmc*nompi*" moab>=5.3.0 + mamba install -y -c conda-forge "openmc=0.14.0=dagmc*nompi*" moab>=5.3.0 gmsh python-gmsh python -m pip install --upgrade pip python -m pip install . python -m pip install openmc_data_downloader diff --git a/.github/workflows/ci_with_install.yml b/.github/workflows/ci_with_install.yml index 119e44c..6fb283b 100644 --- a/.github/workflows/ci_with_install.yml +++ b/.github/workflows/ci_with_install.yml @@ -37,7 +37,7 @@ jobs: mamba activate mamba create -y --name cad_to_dagmc python=3.10 mamba activate cad_to_dagmc - mamba install -y -c conda-forge moab>=5.3.0 + mamba install -y -c conda-forge moab>=5.3.0 gmsh python-gmsh python -m pip install --upgrade pip python -m pip install . python -c "import cad_to_dagmc" diff --git a/pyproject.toml b/pyproject.toml index c2345ec..4542820 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,7 +20,6 @@ classifiers = [ dependencies = [ "trimesh", "networkx", - "gmsh", "cadquery-ocp>=7.7.2", "cadquery>=2.4.0", ] From 0c01656ae9875e85db5959246e3f4e682321a98e Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 18 Mar 2024 02:38:23 +0000 Subject: [PATCH 05/21] removed / --- .github/workflows/ci_with_pip_install.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_with_pip_install.yml b/.github/workflows/ci_with_pip_install.yml index 153af53..b361eac 100644 --- a/.github/workflows/ci_with_pip_install.yml +++ b/.github/workflows/ci_with_pip_install.yml @@ -37,7 +37,7 @@ jobs: apt install python3-pip python -m pip install --upgrade pip mkdir MOAB - cd /MOAB + cd MOAB git clone --single-branch -b 5.3.0 --depth 1 https://bitbucket.org/fathomteam/moab/ mkdir build cd build From 57621ccfb6144be01d7e69a578a5e8016b9869e2 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 18 Mar 2024 11:17:23 +0000 Subject: [PATCH 06/21] fixing cmake cmd --- .github/workflows/ci_with_pip_install.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_with_pip_install.yml b/.github/workflows/ci_with_pip_install.yml index b361eac..de7647a 100644 --- a/.github/workflows/ci_with_pip_install.yml +++ b/.github/workflows/ci_with_pip_install.yml @@ -41,7 +41,7 @@ jobs: git clone --single-branch -b 5.3.0 --depth 1 https://bitbucket.org/fathomteam/moab/ mkdir build cd build - cmake .. -DENABLE_PYMOAB=ON -DENABLE_HDF5=ON + cmake ../moab -DENABLE_PYMOAB=ON -DENABLE_HDF5=ON make make install cd pymoab From 9e930cbbbde6d4d46d6a97867ed67605253f805d Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 18 Mar 2024 11:19:44 +0000 Subject: [PATCH 07/21] blas of --- .github/workflows/ci_with_pip_install.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_with_pip_install.yml b/.github/workflows/ci_with_pip_install.yml index de7647a..f7e597a 100644 --- a/.github/workflows/ci_with_pip_install.yml +++ b/.github/workflows/ci_with_pip_install.yml @@ -41,7 +41,7 @@ jobs: git clone --single-branch -b 5.3.0 --depth 1 https://bitbucket.org/fathomteam/moab/ mkdir build cd build - cmake ../moab -DENABLE_PYMOAB=ON -DENABLE_HDF5=ON + cmake ../moab -DENABLE_PYMOAB=ON -DENABLE_HDF5=ON -DENABLE_BLASLAPACK=OFF make make install cd pymoab From 540beff9b959bc8bf14e62e17afe5c6c6026098c Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 18 Mar 2024 11:32:31 +0000 Subject: [PATCH 08/21] adding sudo for pymoab --- .github/workflows/ci_with_pip_install.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_with_pip_install.yml b/.github/workflows/ci_with_pip_install.yml index f7e597a..0bee4d0 100644 --- a/.github/workflows/ci_with_pip_install.yml +++ b/.github/workflows/ci_with_pip_install.yml @@ -45,7 +45,7 @@ jobs: make make install cd pymoab - bash install.sh + sudo bash install.sh cd ../.. python -m pip install . python -c "import cad_to_dagmc" From f81a8ef81193af7772544ad8134a892df6226dc6 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 18 Mar 2024 11:38:01 +0000 Subject: [PATCH 09/21] moab 5.5.1 --- .github/workflows/ci_with_pip_install.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci_with_pip_install.yml b/.github/workflows/ci_with_pip_install.yml index 0bee4d0..f0d3093 100644 --- a/.github/workflows/ci_with_pip_install.yml +++ b/.github/workflows/ci_with_pip_install.yml @@ -38,15 +38,14 @@ jobs: python -m pip install --upgrade pip mkdir MOAB cd MOAB - git clone --single-branch -b 5.3.0 --depth 1 https://bitbucket.org/fathomteam/moab/ + git clone --single-branch -b 5.5.1 --depth 1 https://bitbucket.org/fathomteam/moab/ mkdir build cd build - cmake ../moab -DENABLE_PYMOAB=ON -DENABLE_HDF5=ON -DENABLE_BLASLAPACK=OFF - make + apt-get install -y libeigen3-dev + cmake ../moab -DENABLE_PYMOAB=ON -DENABLE_HDF5=ON -DENABLE_BLASLAPACK=OFF -DENABLE_FORTRAN=OFF + make -j2 make install - cd pymoab - sudo bash install.sh - cd ../.. + cd .. python -m pip install . python -c "import cad_to_dagmc" python -m pip install .[tests] From 1df72998596ba82c09b2d4a9d75543fbe1b043a9 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 18 Mar 2024 11:50:41 +0000 Subject: [PATCH 10/21] [skip-ci] improved install instructions --- README.md | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 0f97516..35ebf4f 100644 --- a/README.md +++ b/README.md @@ -30,11 +30,9 @@ Also checkout these other software projects that also create DAGMC geometry [CAD # Installation options -- Install using Mamba and minimal pip -- Install using Conda and minimal pip +- Install using Mamba and pip +- Install using Conda and pip - Install using pip and source compilations -- Install using Conda and maximum pip TODO -- Install using Mamba and maximum pip TODO ## Install using Mamba and pip @@ -59,7 +57,7 @@ mamba activate new_env Install the dependencies ```bash -mamba install -y -c conda-forge gmsh python-gmsh moab>=5.3.0 ocp>=7.7.2.0 cadquery>=2.4.0 +mamba install -y -c conda-forge moab>=5.3.0 gmsh python-gmsh ``` Then you can install the cad_to_dagmc package with ```pip``` @@ -100,7 +98,7 @@ conda activate new_env Install the dependencies ```bash -conda install -y -c conda-forge gmsh python-gmsh moab>=5.3.0 ocp>=7.7.2.0 cadquery>=2.4.0 +conda install -y -c conda-forge moab>=5.3.0 gmsh python-gmsh ``` Then you can install the cad_to_dagmc package with ```pip``` @@ -110,16 +108,11 @@ pip install cad_to_dagmc ## Install using pip and source compilations -It is possible to avoid the use of conda and installing using pip and compiling from source. +It should possible to avoid the use of conda and installing using pip and compiling from source. First compile MOAB (and install Pymoab) from source -Then install cadquery and ocp using pip - -```bash -pip install cadquery-ocp==7.7.2 -pip install cadquery==2.4.0 -``` +Then install gmsh from source (installing from pip appears to cause conflicts with the open cascade used in ocp and cadquery) Then you can install the cad_to_dagmc package with ```pip``` @@ -133,6 +126,8 @@ The package requires newer versions of Linux. For example the package does not w The package requires newer versions of pip. It is recommended to ensure that your version of pip is up to date. This can be done with ```python -m pip install --upgrade pip``` +Installing one of the package dependancies (gmsh) with pip appears to result in occational errors when passing cad objects between cadquery / ocp and gmsh. The conda install gmsh appears to work fine. + # Usage - with OpenMC You may also want to install OpenMC with DAGMC to make use of the h5m geometry files produced in simulations. However you could also use other supported particle transport codes such as MCNP, FLUKA and others supported by [DAGMC](https://svalinn.github.io/DAGMC/). From 0b7c9324caff8341a2de2b4a2dcaa54932124d7d Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 18 Mar 2024 12:10:47 +0000 Subject: [PATCH 11/21] [skip-ci] improved install instructions --- README.md | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 35ebf4f..a49a33a 100644 --- a/README.md +++ b/README.md @@ -65,17 +65,6 @@ Then you can install the cad_to_dagmc package with ```pip``` pip install cad_to_dagmc ``` -You may also want to install OpenMC with DAGMC to make use of the h5m geometry files produced in simulations. However you could also use other supported particle transport codes such as MCNP, FLUKA and others [link to DAGMC documentation](https://svalinn.github.io/DAGMC/). - -To install OpenMC You can run ```mamba install -c conda-forge openmc``` however this more specific command makes sure the latest version of OpenMC which contains DAGMC is chosen by conda / mamba -```bash -mamba install -c conda-forge -y "openmc=0.14.0=dagmc*nompi*" -``` - -It might not be possible to install OpenMC and cad-to-dagmc in the same conda/mamba python environment so you may have to create a new conda/mamba environment and install OpenMC there. - -Another option would be to [install OpenMC from source](https://docs.openmc.org/en/stable/quickinstall.html) which would also need compiling with MOAB and DAGMC options. - ## Install using Conda and pip @@ -120,6 +109,19 @@ Then you can install the cad_to_dagmc package with ```pip``` pip install cad_to_dagmc ``` +## Install transport code (e.g OpenMC) + +You may also want to install OpenMC with DAGMC to make use of the h5m geometry files produced in simulations. However you could also use other supported particle transport codes such as MCNP, FLUKA and others [link to DAGMC documentation](https://svalinn.github.io/DAGMC/). + +To install OpenMC you can run ```mamba install -c conda-forge openmc``` however this more specific command makes sure the latest version of OpenMC which contains DAGMC is chosen by conda / mamba +```bash +mamba install -c conda-forge -y "openmc=0.14.0=dagmc*nompi*" +``` + +It might not be possible to install OpenMC and cad-to-dagmc in the same conda/mamba python environment so you may have to create a new conda/mamba environment and install OpenMC there. + +Another option would be to [install OpenMC from source](https://docs.openmc.org/en/stable/quickinstall.html) which would also need compiling with MOAB and DAGMC options. + # Known incompatibilities The package requires newer versions of Linux. For example the package does not work on Ubuntu 18.04 or older. From 4c1f21c2831a4643f076e09a6022568cbddcec45 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 18 Mar 2024 12:12:42 +0000 Subject: [PATCH 12/21] openmc in same env --- .github/workflows/ci_with_install.yml | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci_with_install.yml b/.github/workflows/ci_with_install.yml index 6fb283b..a4364f2 100644 --- a/.github/workflows/ci_with_install.yml +++ b/.github/workflows/ci_with_install.yml @@ -37,15 +37,12 @@ jobs: mamba activate mamba create -y --name cad_to_dagmc python=3.10 mamba activate cad_to_dagmc - mamba install -y -c conda-forge moab>=5.3.0 gmsh python-gmsh + mamba install -y -c conda-forge "openmc=0.14.0=dagmc*nompi*" gmsh python-gmsh python -m pip install --upgrade pip 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 python examples/surface_mesh/create_stp_files_for_examples.py python examples/surface_mesh/cadquery_assembly.py python examples/surface_mesh/cadquery_compound.py @@ -58,13 +55,4 @@ jobs: python examples/surface_mesh/single_cadquery_object.py python examples/surface_mesh/single_stp_file.py python examples/unstrucutred_volume_mesh/curved_cadquery_object_to_dagmc_volume_mesh.py - pytest -v tests/test_model_creation_for_transport.py - mamba activate base - mamba create -y --name openmc python=3.10 - mamba activate openmc - mamba install -y -c conda-forge "openmc=0.14.0=dagmc*nompi*" - python -m pip install pytest - python -m pip install vtk - pytest -v tests/test_h5m_in_simulation.py - pytest -v tests/test_h5m_in_transport.py python examples/unstrucutred_volume_mesh/simulate_unstrucutred_volume_mesh_with_openmc.py From a41e8db83e9d5643c3ae832de14c92a1aba6662c Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 18 Mar 2024 12:50:18 +0000 Subject: [PATCH 13/21] building geometry in test env --- tests/test_h5m_in_transport.py | 56 ++++++++++++++++------------------ 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/tests/test_h5m_in_transport.py b/tests/test_h5m_in_transport.py index 0edfffb..228cfb6 100644 --- a/tests/test_h5m_in_transport.py +++ b/tests/test_h5m_in_transport.py @@ -1,5 +1,6 @@ import openmc - +from cad_to_Dagmc import CadToDagmc +import cadquery as cq """ Tests that check that: @@ -117,21 +118,20 @@ def transport_particles_on_h5m_geometry( def test_transport_result_h5m_with_2_sep_volumes(): - # h5m_filename = "test_two_sep_volumes.h5m" + 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) + 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]] - # ) - h5m_filename = "test_two_sep_volumes.h5m" + 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]] + ) transport_particles_on_h5m_geometry( h5m_filename=h5m_filename, @@ -141,17 +141,15 @@ def test_transport_result_h5m_with_2_sep_volumes(): def test_transport_result_h5m_with_1_volumes(): - # h5m_filename = "one_cylinder.h5m" + 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) + 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]]) - - h5m_filename = "one_cylinder.h5m" + my_model = CadToDagmc() + my_model.add_cadquery_object(workplane1) + my_model.export_dagmc_h5m_file(filename=h5m_filename, material_tags=[material_tags[0]]) transport_particles_on_h5m_geometry( h5m_filename=h5m_filename, @@ -161,22 +159,22 @@ def test_transport_result_h5m_with_1_volumes(): def test_transport_result_h5m_with_2_joined_volumes(): - # h5m_filename = "two_connected_cylinders.h5m" + 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) + 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]] - # ) + 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]] + ) transport_particles_on_h5m_geometry( - h5m_filename="two_connected_cylinders.h5m", + h5m_filename=h5m_filename, material_tags=material_tags, nuclides=["H1"] * len(material_tags), ) From 06d29a75fc60c1493f756e0f14b57d7913e84a9f Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 18 Mar 2024 13:01:09 +0000 Subject: [PATCH 14/21] corrected typo --- tests/test_h5m_in_transport.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_h5m_in_transport.py b/tests/test_h5m_in_transport.py index 228cfb6..88d3d36 100644 --- a/tests/test_h5m_in_transport.py +++ b/tests/test_h5m_in_transport.py @@ -1,5 +1,5 @@ import openmc -from cad_to_Dagmc import CadToDagmc +from cad_to_dagmc import CadToDagmc import cadquery as cq """ From a3c4701e6926ae3119c4d6d13e614763daa8ade6 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 18 Mar 2024 13:33:01 +0000 Subject: [PATCH 15/21] 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", -# } From 281f08c3c63a86b7f94cb6c317299a9f5f0833f4 Mon Sep 17 00:00:00 2001 From: shimwell Date: Mon, 18 Mar 2024 13:33:23 +0000 Subject: [PATCH 16/21] [skip ci] Apply formatting changes --- tests/test_h5m_in_transport.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/test_h5m_in_transport.py b/tests/test_h5m_in_transport.py index 6bb26fc..95f2be9 100644 --- a/tests/test_h5m_in_transport.py +++ b/tests/test_h5m_in_transport.py @@ -122,6 +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" @@ -145,6 +146,7 @@ def test_transport_result_h5m_with_2_sep_volumes(): nuclides=["H1"] * len(material_tags), ) + @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" @@ -163,6 +165,7 @@ def test_transport_result_h5m_with_1_curved_volumes(): nuclides=["H1"] * len(material_tags), ) + @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" @@ -207,6 +210,7 @@ def test_h5m_with_single_volume_list(): nuclides=["H1"], ) + @pytest.mark.skipif(openmc is None, reason="openmc tests only required for CI") def test_h5m_with_multi_volume_not_touching(): @@ -216,7 +220,10 @@ def test_h5m_with_multi_volume_not_touching(): 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"]) + 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(): From 8e36b32bf6352e01e6916475258a115f02831249 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 18 Mar 2024 13:40:09 +0000 Subject: [PATCH 17/21] removed h2 --- tests/test_h5m_in_transport.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_h5m_in_transport.py b/tests/test_h5m_in_transport.py index 6bb26fc..7c22dfd 100644 --- a/tests/test_h5m_in_transport.py +++ b/tests/test_h5m_in_transport.py @@ -59,7 +59,6 @@ def transport_particles_on_h5m_geometry( - """ ) From 9386863760887ddc4b2dd9e00aac93907819ca7b Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 18 Mar 2024 14:00:22 +0000 Subject: [PATCH 18/21] added 2n mat tag --- README.md | 4 +++- tests/test_h5m_in_transport.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 92c00cd..34b84b4 100644 --- a/README.md +++ b/README.md @@ -109,7 +109,7 @@ Then you can install the cad_to_dagmc package with ```pip``` pip install cad_to_dagmc ``` -## Install transport code (e.g OpenMC) +## Install with transport code (e.g OpenMC) You may also want to install OpenMC with DAGMC to make use of the h5m geometry files produced in simulations. However you could also use other supported particle transport codes such as MCNP, FLUKA and others [link to DAGMC documentation](https://svalinn.github.io/DAGMC/). @@ -122,6 +122,8 @@ It might not be possible to install OpenMC and cad-to-dagmc in the same conda/ma Another option would be to [install OpenMC from source](https://docs.openmc.org/en/stable/quickinstall.html) which would also need compiling with MOAB and DAGMC options. + + # Known incompatibilities The package requires newer versions of Linux. For example the package does not work on Ubuntu 18.04 or older. diff --git a/tests/test_h5m_in_transport.py b/tests/test_h5m_in_transport.py index 9ab942f..56a1587 100644 --- a/tests/test_h5m_in_transport.py +++ b/tests/test_h5m_in_transport.py @@ -220,7 +220,7 @@ def test_h5m_with_multi_volume_not_touching(): 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"] + h5m_filename="tests/two_disconnected_cubes.h5m", material_tags=["mat1", "mat2"], nuclides=["H1", "H1"], ) From 280fe90eb94bf5d16718f3edaf94a73dce92ed88 Mon Sep 17 00:00:00 2001 From: shimwell Date: Mon, 18 Mar 2024 14:00:43 +0000 Subject: [PATCH 19/21] [skip ci] Apply formatting changes --- tests/test_h5m_in_transport.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_h5m_in_transport.py b/tests/test_h5m_in_transport.py index 56a1587..e464089 100644 --- a/tests/test_h5m_in_transport.py +++ b/tests/test_h5m_in_transport.py @@ -220,7 +220,9 @@ def test_h5m_with_multi_volume_not_touching(): 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"], nuclides=["H1", "H1"], + h5m_filename="tests/two_disconnected_cubes.h5m", + material_tags=["mat1", "mat2"], + nuclides=["H1", "H1"], ) From d67845c7d4191443d284fea8b6f0f9fea71a012f Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 18 Mar 2024 14:09:57 +0000 Subject: [PATCH 20/21] changed to mat tags --- tests/test_h5m_in_transport.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_h5m_in_transport.py b/tests/test_h5m_in_transport.py index 56a1587..49a66c8 100644 --- a/tests/test_h5m_in_transport.py +++ b/tests/test_h5m_in_transport.py @@ -248,5 +248,5 @@ def test_h5m_with_multi_volume_touching(): transport_particles_on_h5m_geometry( h5m_filename=h5m_file, material_tags=mat_tags, - nuclides=["H1"] * len(material_tags), + nuclides=["H1"] * len(mat_tags), ) From 45336073cde5d9f631b7cbf39c5f6dc46e3b717b Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 18 Mar 2024 14:17:19 +0000 Subject: [PATCH 21/21] added cd .. --- .github/workflows/ci_with_pip_install.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_with_pip_install.yml b/.github/workflows/ci_with_pip_install.yml index 607306d..d111180 100644 --- a/.github/workflows/ci_with_pip_install.yml +++ b/.github/workflows/ci_with_pip_install.yml @@ -47,7 +47,7 @@ jobs: cmake ../moab -DENABLE_PYMOAB=ON -DENABLE_HDF5=ON -DENABLE_BLASLAPACK=OFF -DENABLE_FORTRAN=OFF make -j2 make install - cd .. + cd ../.. python -m pip install . python -c "import cad_to_dagmc" python -m pip install .[tests]