|
| 1 | +# A minimal example that obtains TBR on the blanket and fast neutron flux on all |
| 2 | +# cells in the DAGMC geometry. |
| 3 | +# Particular emphasis is placed on explaining the openmc-dagmc-wrapper |
| 4 | +# extentions of openmc base classes. |
| 5 | + |
| 6 | +import tarfile |
| 7 | +import urllib.request |
| 8 | + |
| 9 | +import openmc |
| 10 | +import openmc_dagmc_wrapper as odw |
| 11 | +from openmc_plasma_source import FusionRingSource |
| 12 | + |
| 13 | + |
| 14 | +# downloads a dagmc file for use in the example |
| 15 | +# url = "https://github.com/fusion-energy/neutronics_workflow/archive/refs/tags/v0.0.2.tar.gz" |
| 16 | +# urllib.request.urlretrieve(url, "v0.0.2.tar.gz") |
| 17 | +# tar = tarfile.open("v0.0.2.tar.gz", "r:gz") |
| 18 | +# tar.extractall(".") |
| 19 | +# tar.close() |
| 20 | +h5m_filename = "neutronics_workflow-0.0.2/example_02_multi_volume_cell_tally/stage_2_output/dagmc.h5m" |
| 21 | +h5m_filename = "neutronics_workflow-0.0.2/example_02_multi_volume_cell_tally/stage_2_output/dagmc_no_grave_yard.h5m" |
| 22 | + |
| 23 | + |
| 24 | +# creates a geometry object from a DAGMC geometry. |
| 25 | +# In this case the geometry doen't have a graveyard cell. |
| 26 | +# So a set of 6 CSG surfaces are automatically made and added to the geometry |
| 27 | +geometry = odw.Geometry(h5m_filename=h5m_filename) |
| 28 | + |
| 29 | +# Creates the materials to use in the problem using by linking the material |
| 30 | +# tags in the DAGMC h5m file with material definitions in the |
| 31 | +# neutronics-material-maker. One could also use openmc.Material or nmm.Material |
| 32 | +# objects instead of the strings used here |
| 33 | +materials = odw.Materials( |
| 34 | + h5m_filename=h5m_filename, |
| 35 | + correspondence_dict={ |
| 36 | + "blanket_mat": "Li4SiO4", |
| 37 | + "blanket_rear_wall_mat": "Be", |
| 38 | + "center_column_shield_mat": "Be", |
| 39 | + "divertor_mat": "Be", |
| 40 | + "firstwall_mat": "Be", |
| 41 | + "inboard_tf_coils_mat": "Be", |
| 42 | + "pf_coil_case_mat": "Be", |
| 43 | + "pf_coil_mat": "Be", |
| 44 | + "tf_coil_mat": "Be", |
| 45 | + }, |
| 46 | +) |
| 47 | + |
| 48 | +# A MeshTally2D tally allows a set of standard tally types (made from filters |
| 49 | +# and scores) to be applied to the DAGMC geometry. By default the mesh will be |
| 50 | +# applied across the entire geomtry with and the size of the geometry is |
| 51 | +# automatically found. |
| 52 | + |
| 53 | +tally1 = odw.MeshTally2D( |
| 54 | + tally_type="photon_effective_dose", plane="xy", bounding_box=h5m_filename |
| 55 | +) |
| 56 | +tally2 = odw.MeshTally2D( |
| 57 | + tally_type="neutron_effective_dose", plane="xy", bounding_box=h5m_filename |
| 58 | +) |
| 59 | + |
| 60 | +# no modifications are made to the default openmc.Tallies |
| 61 | +tallies = openmc.Tallies([tally1, tally2]) |
| 62 | + |
| 63 | +# Creates and openmc settings object with the run mode set to 'fixed source' |
| 64 | +# and the number of inactivate particles set to zero. Setting these to values |
| 65 | +# by default means less code is needed by the user and less chance of simulating |
| 66 | +# batches that don't contribute to the tallies |
| 67 | +settings = odw.FusionSettings() |
| 68 | +settings.batches = 2 |
| 69 | +settings.particles = 100 |
| 70 | +settings.photon_transport = True |
| 71 | +# assigns a ring source of DT energy neutrons to the source using the |
| 72 | +# openmc_plasma_source package |
| 73 | +settings.source = FusionRingSource(fuel="DT", radius=350) |
| 74 | + |
| 75 | +# no modifications are made to the default openmc.Model object |
| 76 | +my_model = openmc.Model( |
| 77 | + materials=materials, geometry=geometry, settings=settings, tallies=tallies |
| 78 | +) |
| 79 | +statepoint_file = my_model.run() |
| 80 | + |
| 81 | +# processes the output h5 file. The process_results function contains logic on |
| 82 | +# how to process each tally with respect to the tally multipliers and units |
| 83 | +# involved. The fusion power input allows tallies to be scaled from the units |
| 84 | +# of per source neutron to units such as Watts (for heating), Sv per second |
| 85 | +# (for dose) and other convenient units. |
| 86 | +odw.process_results(statepoint_file, fusion_power=1e9) |
0 commit comments