44
55import openmc
66
7-
7+ PINCELL_PITCH = 1.26 # cm
88
99def pwr_pin_cell () -> openmc .Model :
1010 """Create a PWR pin-cell model.
@@ -51,7 +51,7 @@ def pwr_pin_cell() -> openmc.Model:
5151 model .materials = (fuel , clad , hot_water )
5252
5353 # Instantiate ZCylinder surfaces
54- pitch = 1.26
54+ pitch = PINCELL_PITCH
5555 fuel_or = openmc .ZCylinder (x0 = 0 , y0 = 0 , r = 0.39218 , name = 'Fuel OR' )
5656 clad_or = openmc .ZCylinder (x0 = 0 , y0 = 0 , r = 0.45720 , name = 'Clad OR' )
5757 left = openmc .XPlane (x0 = - pitch / 2 , name = 'left' , boundary_type = 'reflective' )
@@ -319,14 +319,14 @@ def pwr_core() -> openmc.Model:
319319 l100 = openmc .RectLattice (
320320 name = 'Fuel assembly (lower half)' , lattice_id = 100 )
321321 l100 .lower_left = (- 10.71 , - 10.71 )
322- l100 .pitch = (1.26 , 1.26 )
322+ l100 .pitch = (PINCELL_PITCH , PINCELL_PITCH )
323323 l100 .universes = np .tile (fuel_cold , (17 , 17 ))
324324 l100 .universes [tube_x , tube_y ] = tube_cold
325325
326326 l101 = openmc .RectLattice (
327327 name = 'Fuel assembly (upper half)' , lattice_id = 101 )
328328 l101 .lower_left = (- 10.71 , - 10.71 )
329- l101 .pitch = (1.26 , 1.26 )
329+ l101 .pitch = (PINCELL_PITCH , PINCELL_PITCH )
330330 l101 .universes = np .tile (fuel_hot , (17 , 17 ))
331331 l101 .universes [tube_x , tube_y ] = tube_hot
332332
@@ -350,7 +350,7 @@ def pwr_core() -> openmc.Model:
350350 # Define core lattices
351351 l200 = openmc .RectLattice (name = 'Core lattice (lower half)' , lattice_id = 200 )
352352 l200 .lower_left = (- 224.91 , - 224.91 )
353- l200 .pitch = (21.42 , 21.42 )
353+ l200 .pitch = (17 * PINCELL_PITCH , 17 * PINCELL_PITCH )
354354 l200 .universes = [
355355 [fa_cw ]* 21 ,
356356 [fa_cw ]* 21 ,
@@ -376,7 +376,7 @@ def pwr_core() -> openmc.Model:
376376
377377 l201 = openmc .RectLattice (name = 'Core lattice (lower half)' , lattice_id = 201 )
378378 l201 .lower_left = (- 224.91 , - 224.91 )
379- l201 .pitch = (21.42 , 21.42 )
379+ l201 .pitch = (17 * PINCELL_PITCH , 17 * PINCELL_PITCH )
380380 l201 .universes = [
381381 [fa_hw ]* 21 ,
382382 [fa_hw ]* 21 ,
@@ -488,7 +488,7 @@ def pwr_assembly() -> openmc.Model:
488488 clad_or = openmc .ZCylinder (x0 = 0 , y0 = 0 , r = 0.45720 , name = 'Clad OR' )
489489
490490 # Create boundary planes to surround the geometry
491- pitch = 21.42
491+ pitch = 17 * PINCELL_PITCH
492492 min_x = openmc .XPlane (x0 = - pitch / 2 , boundary_type = 'reflective' )
493493 max_x = openmc .XPlane (x0 = + pitch / 2 , boundary_type = 'reflective' )
494494 min_y = openmc .YPlane (y0 = - pitch / 2 , boundary_type = 'reflective' )
@@ -514,7 +514,7 @@ def pwr_assembly() -> openmc.Model:
514514
515515 # Create fuel assembly Lattice
516516 assembly = openmc .RectLattice (name = 'Fuel Assembly' )
517- assembly .pitch = (pitch / 17 , pitch / 17 )
517+ assembly .pitch = (PINCELL_PITCH , PINCELL_PITCH )
518518 assembly .lower_left = (- pitch / 2 , - pitch / 2 )
519519
520520 # Create array indices for guide tube locations in lattice
@@ -656,24 +656,21 @@ def slab_mg(num_regions=1, mat_names=None, mgxslib_name='2g.h5') -> openmc.Model
656656 return model
657657
658658
659- def random_ray_lattice () -> openmc .Model :
660- """Create a 2x2 PWR pincell asymmetrical lattic eexample.
661-
662- This model is a 2x2 reflective lattice of fuel pins with one of the lattice
663- locations having just moderator instead of a fuel pin. It uses 7 group
664- cross section data.
659+ def _generate_c5g7_materials () -> openmc .Materials :
660+ """Generate materials utilizing multi-group cross sections based on the
661+ the C5G7 Benchmark.
665662
666663 Returns
667664 -------
668- model : openmc.Model
669- A PWR 2x2 lattice model
670-
665+ materials : openmc.Materials
666+ Materials object containing UO2 and water materials.
667+
668+ Data Sources
669+ ------------
670+ All cross section data are from:
671+ Lewis et al., "Benchmark specification for determinisitc 2D/3D MOX fuel
672+ assembly transport calculations without spatial homogenization"
671673 """
672- model = openmc .Model ()
673-
674- ###########################################################################
675- # Create MGXS data for the problem
676-
677674 # Instantiate the energy group data
678675 group_edges = [1e-5 , 0.0635 , 10.0 , 1.0e2 , 1.0e3 , 0.5e6 , 1.0e6 , 20.0e6 ]
679676 groups = openmc .mgxs .EnergyGroups (group_edges )
@@ -704,9 +701,10 @@ def random_ray_lattice() -> openmc.Model:
704701 uo2_xsdata .set_fission ([7.21206e-03 , 8.19301e-04 , 6.45320e-03 ,
705702 1.85648e-02 , 1.78084e-02 , 8.30348e-02 ,
706703 2.16004e-01 ])
707- uo2_xsdata .set_nu_fission ([2.005998e-02 , 2.027303e-03 , 1.570599e-02 ,
708- 4.518301e-02 , 4.334208e-02 , 2.020901e-01 ,
709- 5.257105e-01 ])
704+ nu_fission = np .array ([2.005998e-02 , 2.027303e-03 , 1.570599e-02 ,
705+ 4.518301e-02 , 4.334208e-02 , 2.020901e-01 ,
706+ 5.257105e-01 ])
707+ uo2_xsdata .set_nu_fission (nu_fission )
710708 uo2_xsdata .set_chi ([5.8791e-01 , 4.1176e-01 , 3.3906e-04 , 1.1761e-07 , 0.0000e+00 ,
711709 0.0000e+00 , 0.0000e+00 ])
712710
@@ -752,14 +750,28 @@ def random_ray_lattice() -> openmc.Model:
752750 # Instantiate a Materials collection and export to XML
753751 materials = openmc .Materials ([uo2 , water ])
754752 materials .cross_sections = "mgxs.h5"
753+ return materials
755754
756- ###########################################################################
757- # Define problem geometry
758755
759- ########################################
760- # Define an unbounded pincell universe
756+ def _generate_subdivided_pin_cell (uo2 , water ) -> openmc .Universe :
757+ """Create a radially and azimuthally subdivided pin cell universe. Helper
758+ function for random_ray_pin_cell() and random_ray_lattice()
761759
762- pitch = 1.26
760+ Parameters
761+ ----------
762+ uo2 : openmc.Material
763+ UO2 material
764+ water : openmc.Material
765+ Water material
766+
767+ Returns
768+ -------
769+ pincell : openmc.Universe
770+ Universe containing an unbounded pin cell
771+
772+ """
773+ ########################################
774+ # Define an unbounded pin cell universe
763775
764776 # Create a surface for the fuel outer radius
765777 fuel_or = openmc .ZCylinder (r = 0.54 , name = 'Fuel OR' )
@@ -781,7 +793,7 @@ def random_ray_lattice() -> openmc.Model:
781793 moderator_c = openmc .Cell (
782794 fill = water , region = + outer_ring_b , name = 'moderator outer c' )
783795
784- # Create pincell universe
796+ # Create pin cell universe
785797 pincell_base = openmc .Universe ()
786798
787799 # Register Cells with Universe
@@ -801,19 +813,125 @@ def random_ray_lattice() -> openmc.Model:
801813 for i in range (8 ):
802814 azimuthal_cell = openmc .Cell (name = f'azimuthal_cell_{ i } ' )
803815 azimuthal_cell .fill = pincell_base
804- azimuthal_cell .region = + azimuthal_planes [i ] & - azimuthal_planes [(i + 1 ) % 8 ]
816+ azimuthal_cell .region = + \
817+ azimuthal_planes [i ] & - azimuthal_planes [(i + 1 ) % 8 ]
805818 azimuthal_cells .append (azimuthal_cell )
806819
807820 # Create a geometry with the azimuthal universes
808821 pincell = openmc .Universe (cells = azimuthal_cells , name = 'pincell' )
809822
823+ return pincell
824+
825+
826+ def random_ray_pin_cell () -> openmc .Model :
827+ """Create a PWR pin cell example using C5G7 cross section data.
828+ cross section data.
829+
830+ Returns
831+ -------
832+ model : openmc.Model
833+ A PWR pin cell model
834+
835+ """
836+ model = openmc .Model ()
837+
838+ ###########################################################################
839+ # Create Materials for the problem
840+ materials = _generate_c5g7_materials ()
841+ uo2 = materials [0 ]
842+ water = materials [1 ]
843+
844+ ###########################################################################
845+ # Define problem geometry
846+ pincell = _generate_subdivided_pin_cell (uo2 , water )
847+
848+ ########################################
849+ # Define cell containing lattice and other stuff
850+ pitch = PINCELL_PITCH
851+ box = openmc .model .RectangularPrism (pitch , pitch , boundary_type = 'reflective' )
852+
853+ pincell = openmc .Cell (fill = pincell , region = - box , name = 'pincell' )
854+
855+ # Create a geometry with the top-level cell
856+ geometry = openmc .Geometry ([pincell ])
857+
858+ ###########################################################################
859+ # Define problem settings
860+
861+ # Instantiate a Settings object, set all runtime parameters, and export to XML
862+ settings = openmc .Settings ()
863+ settings .energy_mode = "multi-group"
864+ settings .batches = 400
865+ settings .inactive = 200
866+ settings .particles = 100
867+
868+ # Create an initial uniform spatial source distribution over fissionable zones
869+ lower_left = (- pitch / 2 , - pitch / 2 , - 1 )
870+ upper_right = (pitch / 2 , pitch / 2 , 1 )
871+ uniform_dist = openmc .stats .Box (lower_left , upper_right )
872+ rr_source = openmc .IndependentSource (space = uniform_dist )
873+
874+ settings .random_ray ['distance_active' ] = 100.0
875+ settings .random_ray ['distance_inactive' ] = 20.0
876+ settings .random_ray ['ray_source' ] = rr_source
877+ settings .random_ray ['volume_normalized_flux_tallies' ] = True
878+
879+ ###########################################################################
880+ # Define tallies
881+ # Now use the mesh filter in a tally and indicate what scores are desired
882+ tally = openmc .Tally (name = "Pin tally" )
883+ tally .scores = ['flux' , 'fission' , 'nu-fission' ]
884+ tally .estimator = 'analog'
885+
886+ # Instantiate a Tallies collection and export to XML
887+ tallies = openmc .Tallies ([tally ])
888+
889+ ###########################################################################
890+ # Exporting to OpenMC model
891+ ###########################################################################
892+
893+ model .geometry = geometry
894+ model .materials = materials
895+ model .settings = settings
896+ model .tallies = tallies
897+ return model
898+
899+
900+ def random_ray_lattice () -> openmc .Model :
901+ """Create a 2x2 PWR pin cell asymmetrical lattice example.
902+
903+ This model is a 2x2 reflective lattice of fuel pins with one of the lattice
904+ locations having just moderator instead of a fuel pin. It uses C5G7
905+ cross section data.
906+
907+ Returns
908+ -------
909+ model : openmc.Model
910+ A PWR 2x2 lattice model
911+
912+ """
913+ model = openmc .Model ()
914+
915+ ###########################################################################
916+ # Create Materials for the problem
917+ materials = _generate_c5g7_materials ()
918+ uo2 = materials [0 ]
919+ water = materials [1 ]
920+
921+ ###########################################################################
922+ # Define problem geometry
923+ pincell = _generate_subdivided_pin_cell (uo2 , water )
924+
810925 ########################################
811926 # Define a moderator lattice universe
812927
813- moderator_infinite = openmc .Cell (fill = water , name = 'moderator infinite' )
928+ moderator_infinite = openmc .Cell (name = 'moderator infinite' )
929+ moderator_infinite .fill = water
930+
814931 mu = openmc .Universe ()
815932 mu .add_cells ([moderator_infinite ])
816933
934+ pitch = PINCELL_PITCH
817935 lattice = openmc .RectLattice ()
818936 lattice .lower_left = [- pitch / 2.0 , - pitch / 2.0 ]
819937 lattice .pitch = [pitch / 10.0 , pitch / 10.0 ]
@@ -837,8 +955,7 @@ def random_ray_lattice() -> openmc.Model:
837955
838956 ########################################
839957 # Define cell containing lattice and other stuff
840- box = openmc .model .RectangularPrism (
841- pitch * 2 , pitch * 2 , boundary_type = 'reflective' )
958+ box = openmc .model .RectangularPrism (pitch * 2 , pitch * 2 , boundary_type = 'reflective' )
842959
843960 assembly = openmc .Cell (fill = lattice2x2 , region = - box , name = 'assembly' )
844961
0 commit comments