This repository has been archived by the owner on Aug 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from fusion-energy/develop
Major refactoring to use OpenMC classes
- Loading branch information
Showing
26 changed files
with
2,400 additions
and
2,385 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# A minimal example that obtains TBR on the blanket and fast neutron flux on all | ||
# cells in the DAGMC geometry. | ||
# Particular emphasis is placed on explaining the openmc-dagmc-wrapper | ||
# extentions of openmc base classes. | ||
|
||
import tarfile | ||
import urllib.request | ||
|
||
import openmc | ||
import openmc_dagmc_wrapper as odw | ||
from openmc_plasma_source import FusionRingSource | ||
|
||
# downloads a dagmc file for use in the example | ||
url = "https://github.com/fusion-energy/neutronics_workflow/archive/refs/tags/v0.0.2.tar.gz" | ||
urllib.request.urlretrieve(url, "v0.0.2.tar.gz") | ||
tar = tarfile.open("v0.0.2.tar.gz", "r:gz") | ||
tar.extractall(".") | ||
tar.close() | ||
h5m_filename = "neutronics_workflow-0.0.2/example_02_multi_volume_cell_tally/stage_2_output/dagmc.h5m" | ||
|
||
|
||
# creates a geometry object from a DAGMC geometry. | ||
# In this case the geometry doen't have a graveyard cell. | ||
# So a set of 6 CSG surfaces are automatically made and added to the geometry | ||
geometry = odw.Geometry(h5m_filename=h5m_filename) | ||
|
||
# Creates the materials to use in the problem using by linking the material | ||
# tags in the DAGMC h5m file with material definitions in the | ||
# neutronics-material-maker. One could also use openmc.Material or nmm.Material | ||
# objects instead of the strings used here | ||
materials = odw.Materials( | ||
h5m_filename=h5m_filename, | ||
correspondence_dict={ | ||
"blanket_mat": "Li4SiO4", | ||
"blanket_rear_wall_mat": "Be", | ||
"center_column_shield_mat": "Be", | ||
"divertor_mat": "Be", | ||
"firstwall_mat": "Be", | ||
"inboard_tf_coils_mat": "Be", | ||
"pf_coil_case_mat": "Be", | ||
"pf_coil_mat": "Be", | ||
"tf_coil_mat": "Be", | ||
}, | ||
) | ||
|
||
# A cell tally allows a set of standard tally types (made from filters and | ||
# scores) to be applied to a DAGMC material or a volume | ||
# This cell tally applies a TBR tally to the volume(s) labeled with the | ||
# blanket_mat tag in the DAGMC geometry | ||
tally1 = odw.CellTally( | ||
tally_type="TBR", | ||
target="blanket_mat", | ||
materials=materials) | ||
|
||
# This cell tally obtains the neutron fast flux on all volumes in the problem | ||
tally2 = odw.CellTallies( | ||
tally_types=["neutron_fast_flux"], | ||
targets="all_volumes", | ||
h5m_filename=h5m_filename) | ||
|
||
# no modifications are made to the default openmc.Tallies | ||
tallies = openmc.Tallies([tally1] + tally2.tallies) | ||
|
||
# Creates and openmc settings object with the run mode set to 'fixed source' | ||
# and the number of inactivate particles set to zero. Setting these to values | ||
# by default means less code is needed by the user and less chance of simulating | ||
# batches that don't contribute to the tallies | ||
settings = odw.FusionSettings() | ||
settings.batches = 1 | ||
settings.particles = 100 | ||
# assigns a ring source of DT energy neutrons to the source using the | ||
# openmc_plasma_source package | ||
settings.source = FusionRingSource(fuel="DT", radius=350) | ||
|
||
|
||
# no modifications are made to the default openmc.Model object | ||
my_model = openmc.Model( | ||
materials=materials, geometry=geometry, settings=settings, tallies=tallies | ||
) | ||
statepoint_file = my_model.run() | ||
|
||
# processes the output h5 file. the process_results function contains logic on | ||
# how to process each tally with respect to the tally multipliers and units | ||
# involved. The fusion power input allows tallies to be scaled from the units | ||
# of per source neutron to units such as Watts (for heating), Sv per second | ||
# (for dose) and other convenient units. | ||
odw.process_results(statepoint_file, fusion_power=1e9) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# A minimal example that obtains TBR on the blanket and fast neutron flux on all | ||
# cells in the DAGMC geometry. | ||
# Particular emphasis is placed on explaining the openmc-dagmc-wrapper | ||
# extentions of openmc base classes. | ||
|
||
import tarfile | ||
import urllib.request | ||
|
||
import openmc | ||
import openmc_dagmc_wrapper as odw | ||
from openmc_plasma_source import FusionRingSource | ||
|
||
|
||
# downloads a dagmc file for use in the example | ||
# url = "https://github.com/fusion-energy/neutronics_workflow/archive/refs/tags/v0.0.2.tar.gz" | ||
# urllib.request.urlretrieve(url, "v0.0.2.tar.gz") | ||
# tar = tarfile.open("v0.0.2.tar.gz", "r:gz") | ||
# tar.extractall(".") | ||
# tar.close() | ||
h5m_filename = "neutronics_workflow-0.0.2/example_02_multi_volume_cell_tally/stage_2_output/dagmc.h5m" | ||
h5m_filename = "neutronics_workflow-0.0.2/example_02_multi_volume_cell_tally/stage_2_output/dagmc_no_grave_yard.h5m" | ||
|
||
|
||
# creates a geometry object from a DAGMC geometry. | ||
# In this case the geometry doen't have a graveyard cell. | ||
# So a set of 6 CSG surfaces are automatically made and added to the geometry | ||
geometry = odw.Geometry(h5m_filename=h5m_filename) | ||
|
||
# Creates the materials to use in the problem using by linking the material | ||
# tags in the DAGMC h5m file with material definitions in the | ||
# neutronics-material-maker. One could also use openmc.Material or nmm.Material | ||
# objects instead of the strings used here | ||
materials = odw.Materials( | ||
h5m_filename=h5m_filename, | ||
correspondence_dict={ | ||
"blanket_mat": "Li4SiO4", | ||
"blanket_rear_wall_mat": "Be", | ||
"center_column_shield_mat": "Be", | ||
"divertor_mat": "Be", | ||
"firstwall_mat": "Be", | ||
"inboard_tf_coils_mat": "Be", | ||
"pf_coil_case_mat": "Be", | ||
"pf_coil_mat": "Be", | ||
"tf_coil_mat": "Be", | ||
}, | ||
) | ||
|
||
# A MeshTally2D tally allows a set of standard tally types (made from filters | ||
# and scores) to be applied to the DAGMC geometry. By default the mesh will be | ||
# applied across the entire geomtry with and the size of the geometry is | ||
# automatically found. | ||
|
||
tally1 = odw.MeshTally2D( | ||
tally_type="photon_effective_dose", plane="xy", bounding_box=h5m_filename | ||
) | ||
tally2 = odw.MeshTally2D( | ||
tally_type="neutron_effective_dose", plane="xy", bounding_box=h5m_filename | ||
) | ||
|
||
# no modifications are made to the default openmc.Tallies | ||
tallies = openmc.Tallies([tally1, tally2]) | ||
|
||
# Creates and openmc settings object with the run mode set to 'fixed source' | ||
# and the number of inactivate particles set to zero. Setting these to values | ||
# by default means less code is needed by the user and less chance of simulating | ||
# batches that don't contribute to the tallies | ||
settings = odw.FusionSettings() | ||
settings.batches = 2 | ||
settings.particles = 100 | ||
settings.photon_transport = True | ||
# assigns a ring source of DT energy neutrons to the source using the | ||
# openmc_plasma_source package | ||
settings.source = FusionRingSource(fuel="DT", radius=350) | ||
|
||
# no modifications are made to the default openmc.Model object | ||
my_model = openmc.Model( | ||
materials=materials, geometry=geometry, settings=settings, tallies=tallies | ||
) | ||
statepoint_file = my_model.run() | ||
|
||
# processes the output h5 file. The process_results function contains logic on | ||
# how to process each tally with respect to the tally multipliers and units | ||
# involved. The fusion power input allows tallies to be scaled from the units | ||
# of per source neutron to units such as Watts (for heating), Sv per second | ||
# (for dose) and other convenient units. | ||
odw.process_results(statepoint_file, fusion_power=1e9) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# A minimal example that obtains TBR on the blanket and fast neutron flux on all | ||
# cells in the DAGMC geometry. | ||
# Particular emphasis is placed on explaining the openmc-dagmc-wrapper | ||
# extentions of openmc base classes. | ||
|
||
import tarfile | ||
import urllib.request | ||
|
||
import openmc | ||
import openmc_dagmc_wrapper as odw | ||
from openmc_plasma_source import FusionRingSource | ||
|
||
# downloads a dagmc file for use in the example | ||
# url = "https://github.com/fusion-energy/neutronics_workflow/archive/refs/tags/v0.0.2.tar.gz" | ||
# urllib.request.urlretrieve(url, "v0.0.2.tar.gz") | ||
# tar = tarfile.open("v0.0.2.tar.gz", "r:gz") | ||
# tar.extractall(".") | ||
# tar.close() | ||
h5m_filename = "neutronics_workflow-0.0.2/example_02_multi_volume_cell_tally/stage_2_output/dagmc.h5m" | ||
|
||
|
||
# creates a geometry object from a DAGMC geometry. | ||
# In this case the geometry doen't have a graveyard cell. | ||
# So a set of 6 CSG surfaces are automatically made and added to the geometry | ||
geometry = odw.Geometry(h5m_filename=h5m_filename) | ||
|
||
# Creates the materials to use in the problem using by linking the material | ||
# tags in the DAGMC h5m file with material definitions in the | ||
# neutronics-material-maker. One could also use openmc.Material or nmm.Material | ||
# objects instead of the strings used here | ||
materials = odw.Materials( | ||
h5m_filename=h5m_filename, | ||
correspondence_dict={ | ||
"blanket_mat": "Li4SiO4", | ||
"blanket_rear_wall_mat": "Be", | ||
"center_column_shield_mat": "Be", | ||
"divertor_mat": "Be", | ||
"firstwall_mat": "Be", | ||
"inboard_tf_coils_mat": "Be", | ||
"pf_coil_case_mat": "Be", | ||
"pf_coil_mat": "Be", | ||
"tf_coil_mat": "Be", | ||
}, | ||
) | ||
|
||
# A MeshTally3D tally allows a set of standard tally types (made from filters | ||
# and scores) to be applied to the DAGMC geometry. By default the mesh will be | ||
# applied across the entire geomtry with and the size of the geometry is | ||
# automatically found. | ||
tally1 = odw.MeshTally3D( | ||
tally_type="neutron_effective_dose", | ||
bounding_box=h5m_filename) | ||
|
||
# no modifications are made to the default openmc.Tallies | ||
tallies = openmc.Tallies([tally1]) | ||
|
||
# Creates and openmc settings object with the run mode set to 'fixed source' | ||
# and the number of inactivate particles set to zero. Setting these to values | ||
# by default means less code is needed by the user and less chance of simulating | ||
# batches that don't contribute to the tallies | ||
settings = odw.FusionSettings() | ||
settings.batches = 1 | ||
settings.particles = 100 | ||
# assigns a ring source of DT energy neutrons to the source using the | ||
# openmc_plasma_source package | ||
settings.source = FusionRingSource(fuel="DT", radius=350) | ||
|
||
# no modifications are made to the default openmc.Model object | ||
my_model = openmc.Model( | ||
materials=materials, geometry=geometry, settings=settings, tallies=tallies | ||
) | ||
statepoint_file = my_model.run() | ||
|
||
# processes the output h5 file. The process_results function contains logic on | ||
# how to process each tally with respect to the tally multipliers and units | ||
# involved. The fusion power input allows tallies to be scaled from the units | ||
# of per source neutron to units such as Watts (for heating), Sv per second | ||
# (for dose) and other convenient units. | ||
odw.process_results(statepoint_file, fusion_power=1e9) |
Oops, something went wrong.