From 31662711baf8a9a3aeec2776bac77e20ff4c8d64 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Tue, 2 Nov 2021 17:12:37 +0000 Subject: [PATCH 1/9] added specific version of h5py --- .github/workflows/ci_with_install.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci_with_install.yml b/.github/workflows/ci_with_install.yml index 374a9a5..b535c2b 100644 --- a/.github/workflows/ci_with_install.yml +++ b/.github/workflows/ci_with_install.yml @@ -27,6 +27,7 @@ jobs: - name: install package run: | + conda install -c conda-forge h5py==3.2 conda install -c conda-forge openmc python setup.py install From 4fec92d2de60892e22db8c07cb673375e35f9dc5 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Tue, 2 Nov 2021 17:16:52 +0000 Subject: [PATCH 2/9] h5py version 3.2.1 --- .github/workflows/ci_with_install.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_with_install.yml b/.github/workflows/ci_with_install.yml index b535c2b..815acd8 100644 --- a/.github/workflows/ci_with_install.yml +++ b/.github/workflows/ci_with_install.yml @@ -27,7 +27,7 @@ jobs: - name: install package run: | - conda install -c conda-forge h5py==3.2 + conda install -c conda-forge h5py=3.2.1 conda install -c conda-forge openmc python setup.py install From ef5621f94c6cfbae90f8562c1c1a8d051c13e94d Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Tue, 2 Nov 2021 17:19:59 +0000 Subject: [PATCH 3/9] added pymoab as seperate conda install --- .github/workflows/ci_with_install.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci_with_install.yml b/.github/workflows/ci_with_install.yml index 815acd8..5cdcd07 100644 --- a/.github/workflows/ci_with_install.yml +++ b/.github/workflows/ci_with_install.yml @@ -28,6 +28,7 @@ jobs: - name: install package run: | conda install -c conda-forge h5py=3.2.1 + conda install -c conda-forge moab conda install -c conda-forge openmc python setup.py install From 2a81d50b37d62653fee615a5a689e9f125e24a45 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 2 Nov 2021 20:53:12 +0000 Subject: [PATCH 4/9] added batch and particle control to statepoint simulation --- .github/workflows/ci_with_install.yml | 6 +- openmc_post_processor/utils.py | 5 +- tests/create_statepoint_file_for_testing.py | 14 +- ...e_statepoint_file_for_testing_one_batch.py | 172 ------------------ 4 files changed, 17 insertions(+), 180 deletions(-) delete mode 100644 tests/create_statepoint_file_for_testing_one_batch.py diff --git a/.github/workflows/ci_with_install.yml b/.github/workflows/ci_with_install.yml index 5cdcd07..c65c681 100644 --- a/.github/workflows/ci_with_install.yml +++ b/.github/workflows/ci_with_install.yml @@ -38,13 +38,15 @@ jobs: - name: Run test_utils run: | - python tests/create_statepoint_file_for_testing.py - python tests/create_statepoint_file_for_testing_one_batch.py + python tests/create_statepoint_file_for_testing.py --batches 2 --particles 100 + python tests/create_statepoint_file_for_testing.py --batches 1 --particles 100 pytest tests/ -v --cov=openmc_post_processor --cov-append --cov-report term --cov-report xml - name: Run examples run: | cd examples + cp ../tests/statepoint.2.h5 . + cp ../tests/statepoint.1.h5 . python processing_2d_mesh_effective_dose_tally.py python processing_cell_damage-energy_tally.py python processing_cell_effective_dose_tally.py diff --git a/openmc_post_processor/utils.py b/openmc_post_processor/utils.py index 49bfa6c..acb2427 100644 --- a/openmc_post_processor/utils.py +++ b/openmc_post_processor/utils.py @@ -285,9 +285,8 @@ def process_tally( "EnergyFunctionFilter are not known to OpenMC. Therefore " "the units of this tally can not be found. If you have " "applied dose coefficients to an EnergyFunctionFilter " - "the units of these are known and yo can use the " - "get_tally_units_dose function instead of the " - "get_tally_units" + "the units of these are known and you can use the " + "process_dose_tally function instead of the process_tally" ) raise ValueError(msg) diff --git a/tests/create_statepoint_file_for_testing.py b/tests/create_statepoint_file_for_testing.py index d28b2e2..8fd95d4 100644 --- a/tests/create_statepoint_file_for_testing.py +++ b/tests/create_statepoint_file_for_testing.py @@ -5,7 +5,15 @@ import openmc_dagmc_wrapper as odw import openmc_plasma_source as ops import openmc_data_downloader as odd +import argparse +parser = argparse.ArgumentParser() + +parser.add_argument('-b', '--batches', type=int, default=2, + help='number of batches') +parser.add_argument('-p', '--particles', type=int, default=1000000, + help='number of particles') +args = parser.parse_args() # MATERIALS breeder_material = openmc.Material(1, "PbLi") # Pb84.2Li15.8 @@ -22,7 +30,7 @@ iron = openmc.Material(name="iron") iron.set_density("g/cm3", 7.75) -iron.add_element("Fe", 0.95, percent_type="wo") +iron.add_element("Pb", 0.95, percent_type="wo") materials = openmc.Materials([breeder_material, iron]) @@ -160,8 +168,8 @@ settings = odw.FusionSettings() -settings.batches = 2 -settings.particles = 1000000 +settings.batches = args.batches +settings.particles = args.particles # assigns a ring source of DT energy neutrons to the source using the # openmc_plasma_source package settings.source = ops.FusionPointSource() diff --git a/tests/create_statepoint_file_for_testing_one_batch.py b/tests/create_statepoint_file_for_testing_one_batch.py deleted file mode 100644 index 9b33533..0000000 --- a/tests/create_statepoint_file_for_testing_one_batch.py +++ /dev/null @@ -1,172 +0,0 @@ -# This minimal example makes a 3D volume and exports the shape to a stp file -# A surrounding volume called a graveyard is needed for neutronics simulations - -import openmc -import openmc_dagmc_wrapper as odw -import openmc_plasma_source as ops -import openmc_data_downloader as odd - - -# MATERIALS -breeder_material = openmc.Material(1, "PbLi") # Pb84.2Li15.8 -breeder_material.add_element("Pb", 84.2, percent_type="ao") -breeder_material.add_element( - "Li", - 15.8, - percent_type="ao", - enrichment=50.0, - enrichment_target="Li6", - enrichment_type="ao", -) # 50% enriched -breeder_material.set_density("atom/b-cm", 3.2720171e-2) # around 11 g/cm3 - -iron = openmc.Material(name="iron") -iron.set_density("g/cm3", 7.75) -iron.add_element("Fe", 0.95, percent_type="wo") - -materials = openmc.Materials([breeder_material, iron]) - -odd.just_in_time_library_generator(libraries="TENDL-2019", materials=materials) - -# GEOMETRY - -# surfaces -vessel_inner = openmc.Sphere(r=500) -first_wall_outer_surface = openmc.Sphere(r=510) -breeder_blanket_outer_surface = openmc.Sphere(r=610, boundary_type="vacuum") - - -# cells -inner_vessel_region = -vessel_inner -inner_vessel_cell = openmc.Cell(region=inner_vessel_region) - -first_wall_region = -first_wall_outer_surface & +vessel_inner -first_wall_cell = openmc.Cell(region=first_wall_region) -first_wall_cell.fill = iron - -breeder_blanket_region = +first_wall_outer_surface & -breeder_blanket_outer_surface -breeder_blanket_cell = openmc.Cell(region=breeder_blanket_region) -breeder_blanket_cell.fill = breeder_material - -universe = openmc.Universe( - cells=[inner_vessel_cell, first_wall_cell, breeder_blanket_cell] -) -geometry = openmc.Geometry(universe) - - -tally1 = odw.CellTally( - tally_type="flux", - target=2, -) - -tally2 = odw.CellTally( - tally_type="neutron_spectra", - target=2, -) - -tally3 = odw.CellTally( - tally_type="TBR", - target=2, -) - -tally4 = odw.CellTally( - tally_type="heating", - target=2, -) - -tally5 = odw.CellTally( - tally_type="neutron_effective_dose", - target=2, -) - -tally6 = odw.CellTally( - tally_type="photon_effective_dose", - target=2, -) - -tally7 = odw.CellTally( - tally_type="neutron_fast_flux", - target=2, -) - -tally8 = odw.CellTally( - tally_type="photon_fast_flux", - target=2, -) - -tally9 = odw.CellTally( - tally_type="neutron_spectra", - target=2, -) - -tally10 = odw.CellTally( - tally_type="neutron_spectra", - target=2, -) - -tally11 = odw.CellTally( - tally_type="neutron_spectra", - target=3, -) - -tally12 = odw.CellTally( - tally_type="photon_spectra", - target=2, -) - -tally13 = odw.CellTally( - tally_type="(n,total)", - target=2, -) - -tally14 = odw.CellTally( - tally_type="damage-energy", - target=2, -) - -tally15 = odw.MeshTally2D( - tally_type="neutron_effective_dose", - plane="xy", - mesh_resolution=(10, 5), - bounding_box=[(-100, -100, 0), (100, 100, 1)], -) - -tally16 = odw.MeshTally3D( - mesh_resolution=(100, 100, 100), - bounding_box=[(-100, -100, 0), (100, 100, 1)], - tally_type="neutron_effective_dose", -) - -tallies = openmc.Tallies( - [ - tally1, - tally2, - tally3, - tally4, - tally5, - tally6, - tally7, - tally8, - tally9, - tally10, - tally11, - tally12, - tally13, - tally14, - tally15, - tally16, - ] -) - -settings = odw.FusionSettings() -settings.batches = 1 -settings.particles = 1000000 -# assigns a ring source of DT energy neutrons to the source using the -# openmc_plasma_source package -settings.source = ops.FusionPointSource() - - -my_model = openmc.model.Model( - materials=materials, geometry=geometry, settings=settings, tallies=tallies -) -statepoint_file = my_model.run() From 6ee9eeb22f3ffc0cc8a82d55f1c8addf9427d1f6 Mon Sep 17 00:00:00 2001 From: shimwell Date: Tue, 2 Nov 2021 20:53:41 +0000 Subject: [PATCH 5/9] [skip ci] Apply formatting changes --- tests/create_statepoint_file_for_testing.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/create_statepoint_file_for_testing.py b/tests/create_statepoint_file_for_testing.py index 8fd95d4..664440a 100644 --- a/tests/create_statepoint_file_for_testing.py +++ b/tests/create_statepoint_file_for_testing.py @@ -9,10 +9,10 @@ parser = argparse.ArgumentParser() -parser.add_argument('-b', '--batches', type=int, default=2, - help='number of batches') -parser.add_argument('-p', '--particles', type=int, default=1000000, - help='number of particles') +parser.add_argument("-b", "--batches", type=int, default=2, help="number of batches") +parser.add_argument( + "-p", "--particles", type=int, default=1000000, help="number of particles" +) args = parser.parse_args() # MATERIALS From 471f944364145c0ffd87cdec7781e2fbe27ec966 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 2 Nov 2021 20:59:36 +0000 Subject: [PATCH 6/9] added create statepoint file to example folder --- .github/workflows/ci_with_install.yml | 3 +- .../create_statepoint_file_for_testing.py | 181 ++++++++++++++++++ 2 files changed, 182 insertions(+), 2 deletions(-) create mode 100644 examples/create_statepoint_file_for_testing.py diff --git a/.github/workflows/ci_with_install.yml b/.github/workflows/ci_with_install.yml index c65c681..21ff9e8 100644 --- a/.github/workflows/ci_with_install.yml +++ b/.github/workflows/ci_with_install.yml @@ -45,8 +45,7 @@ jobs: - name: Run examples run: | cd examples - cp ../tests/statepoint.2.h5 . - cp ../tests/statepoint.1.h5 . + python tests/create_statepoint_file_for_testing.py --batches 2 --particles 100 python processing_2d_mesh_effective_dose_tally.py python processing_cell_damage-energy_tally.py python processing_cell_effective_dose_tally.py diff --git a/examples/create_statepoint_file_for_testing.py b/examples/create_statepoint_file_for_testing.py new file mode 100644 index 0000000..8fd95d4 --- /dev/null +++ b/examples/create_statepoint_file_for_testing.py @@ -0,0 +1,181 @@ +# This minimal example makes a 3D volume and exports the shape to a stp file +# A surrounding volume called a graveyard is needed for neutronics simulations + +import openmc +import openmc_dagmc_wrapper as odw +import openmc_plasma_source as ops +import openmc_data_downloader as odd +import argparse + +parser = argparse.ArgumentParser() + +parser.add_argument('-b', '--batches', type=int, default=2, + help='number of batches') +parser.add_argument('-p', '--particles', type=int, default=1000000, + help='number of particles') +args = parser.parse_args() + +# MATERIALS +breeder_material = openmc.Material(1, "PbLi") # Pb84.2Li15.8 +breeder_material.add_element("Pb", 84.2, percent_type="ao") +breeder_material.add_element( + "Li", + 15.8, + percent_type="ao", + enrichment=50.0, + enrichment_target="Li6", + enrichment_type="ao", +) # 50% enriched +breeder_material.set_density("atom/b-cm", 3.2720171e-2) # around 11 g/cm3 + +iron = openmc.Material(name="iron") +iron.set_density("g/cm3", 7.75) +iron.add_element("Pb", 0.95, percent_type="wo") + +materials = openmc.Materials([breeder_material, iron]) + +odd.just_in_time_library_generator(libraries="TENDL-2019", materials=materials) + +# GEOMETRY + +# surfaces +vessel_inner = openmc.Sphere(r=500) +first_wall_outer_surface = openmc.Sphere(r=510) +breeder_blanket_outer_surface = openmc.Sphere(r=610, boundary_type="vacuum") + + +# cells +inner_vessel_region = -vessel_inner +inner_vessel_cell = openmc.Cell(region=inner_vessel_region) + +first_wall_region = -first_wall_outer_surface & +vessel_inner +first_wall_cell = openmc.Cell(region=first_wall_region) +first_wall_cell.fill = iron + +breeder_blanket_region = +first_wall_outer_surface & -breeder_blanket_outer_surface +breeder_blanket_cell = openmc.Cell(region=breeder_blanket_region) +breeder_blanket_cell.fill = breeder_material + +universe = openmc.Universe( + cells=[inner_vessel_cell, first_wall_cell, breeder_blanket_cell] +) +geometry = openmc.Geometry(universe) + + +tally1 = odw.CellTally( + tally_type="flux", + target=2, +) + +tally2 = odw.CellTally( + tally_type="neutron_spectra", + target=2, +) + +tally3 = odw.CellTally( + tally_type="TBR", + target=2, +) + +tally4 = odw.CellTally( + tally_type="heating", + target=2, +) + +tally5 = odw.CellTally( + tally_type="neutron_effective_dose", + target=2, +) + +tally6 = odw.CellTally( + tally_type="photon_effective_dose", + target=2, +) + +tally7 = odw.CellTally( + tally_type="neutron_fast_flux", + target=2, +) + +tally8 = odw.CellTally( + tally_type="photon_fast_flux", + target=2, +) + +tally9 = odw.CellTally( + tally_type="neutron_spectra", + target=2, +) + +tally10 = odw.CellTally( + tally_type="neutron_spectra", + target=2, +) + +tally11 = odw.CellTally( + tally_type="neutron_spectra", + target=3, +) + +tally12 = odw.CellTally( + tally_type="photon_spectra", + target=2, +) + +tally13 = odw.CellTally( + tally_type="(n,total)", + target=2, +) + +tally14 = odw.CellTally( + tally_type="damage-energy", + target=2, +) + +tally15 = odw.MeshTally2D( + tally_type="neutron_effective_dose", + plane="xy", + mesh_resolution=(10, 5), + bounding_box=[(-100, -100, 0), (100, 100, 1)], +) + +tally16 = odw.MeshTally3D( + mesh_resolution=(100, 100, 100), + bounding_box=[(-100, -100, 0), (100, 100, 1)], + tally_type="neutron_effective_dose", +) + +tallies = openmc.Tallies( + [ + tally1, + tally2, + tally3, + tally4, + tally5, + tally6, + tally7, + tally8, + tally9, + tally10, + tally11, + tally12, + tally13, + tally14, + tally15, + tally16, + ] +) + + +settings = odw.FusionSettings() +settings.batches = args.batches +settings.particles = args.particles +# assigns a ring source of DT energy neutrons to the source using the +# openmc_plasma_source package +settings.source = ops.FusionPointSource() + + +my_model = openmc.model.Model( + materials=materials, geometry=geometry, settings=settings, tallies=tallies +) +statepoint_file = my_model.run() From 2ec3064ba9cbbe915e9aa1468c0d0a0795c5cd6d Mon Sep 17 00:00:00 2001 From: shimwell Date: Tue, 2 Nov 2021 21:00:15 +0000 Subject: [PATCH 7/9] [skip ci] Apply formatting changes --- examples/create_statepoint_file_for_testing.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/create_statepoint_file_for_testing.py b/examples/create_statepoint_file_for_testing.py index 8fd95d4..664440a 100644 --- a/examples/create_statepoint_file_for_testing.py +++ b/examples/create_statepoint_file_for_testing.py @@ -9,10 +9,10 @@ parser = argparse.ArgumentParser() -parser.add_argument('-b', '--batches', type=int, default=2, - help='number of batches') -parser.add_argument('-p', '--particles', type=int, default=1000000, - help='number of particles') +parser.add_argument("-b", "--batches", type=int, default=2, help="number of batches") +parser.add_argument( + "-p", "--particles", type=int, default=1000000, help="number of particles" +) args = parser.parse_args() # MATERIALS From f8a6642a564bd4e9c768a47e881a9857eb684380 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 2 Nov 2021 21:03:14 +0000 Subject: [PATCH 8/9] removed dir from python command --- .github/workflows/ci_with_install.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_with_install.yml b/.github/workflows/ci_with_install.yml index 21ff9e8..9f56a05 100644 --- a/.github/workflows/ci_with_install.yml +++ b/.github/workflows/ci_with_install.yml @@ -45,7 +45,7 @@ jobs: - name: Run examples run: | cd examples - python tests/create_statepoint_file_for_testing.py --batches 2 --particles 100 + python create_statepoint_file_for_testing.py --batches 2 --particles 100 python processing_2d_mesh_effective_dose_tally.py python processing_cell_damage-energy_tally.py python processing_cell_effective_dose_tally.py From 9f39c031a4d10329f443d8b7653cb021b254b649 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 2 Nov 2021 21:15:00 +0000 Subject: [PATCH 9/9] added spectrum_plotter --- requirements-test.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements-test.txt b/requirements-test.txt index a771257..4ff88ad 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -2,3 +2,4 @@ openmc_data_downloader openmc_dagmc_wrapper openmc_plasma_source pytest-cov>=2.12.1 +spectrum_plotter