diff --git a/.gitignore b/.gitignore index 72364f9..41b046d 100644 --- a/.gitignore +++ b/.gitignore @@ -87,3 +87,13 @@ ENV/ # Rope project settings .ropeproject + +# PyCharm project settings +.idea + +# OpenMC output files +*.h5 +*.out + +# Temp files +*.xml~ \ No newline at end of file diff --git a/pin-cell/build-xml.py b/pin-cell/build-xml.py new file mode 100644 index 0000000..a9d2509 --- /dev/null +++ b/pin-cell/build-xml.py @@ -0,0 +1,135 @@ +"""This script creates an infinitely long fuel pin cell with reflective +boundary conditions derived from the mit-crpg/PWR_benchmarks repository.""" + +import numpy as np + +import opencg +import openmc +import openmc.opencg_compatible as opencg_compatible +from beavrs.builder import BEAVRS + + +def find_pin(pin_name, wrap_geometry=True): + """Find a fuel pin with some string name in the BEAVRS OpenCG model. + + This method extracts the pin cell and wraps it in an OpenCG Geometry. + The returned geometry has reflective boundary conditions along the x and y + boundaries. The z-axis left unbounded. + + Parameters + ---------- + pin_name : str + The name of the fuel pin universe + wrap_geometry : bool + If false, the pin cell Universe is returned. If true, the pin cell + Universe is wrapped in an OpenCG Geometry and returned (default). + + Returns + ------- + opencg.Universe + The OpenCG Universe or Geometry for this fuel pin or None if not found + + """ + + # Get all OpenCG Universes + all_univ = beavrs.main_universe.get_all_universes() + + # Iterate over all Universes + fuel_pin = None + for univ_id, univ in all_univ.items(): + if univ._name == pin_name: + fuel_pin = univ + + # Wrap pin cell Universe in a Geometry if requested by the user + if wrap_geometry: + + # Make reflective boundaries + pin_pitch = 0.62992 + min_x = opencg.XPlane(x0=-pin_pitch, boundary='reflective') + max_x = opencg.XPlane(x0=pin_pitch, boundary='reflective') + min_y = opencg.YPlane(y0=-pin_pitch, boundary='reflective') + max_y = opencg.YPlane(y0=pin_pitch, boundary='reflective') + + # Create a root Cell + root_cell = opencg.Cell(name='root cell') + root_cell.fill = fuel_pin + + # Add boundaries to the root Cell + root_cell.add_surface(surface=min_x, halfspace=+1) + root_cell.add_surface(surface=max_x, halfspace=-1) + root_cell.add_surface(surface=min_y, halfspace=+1) + root_cell.add_surface(surface=max_y, halfspace=-1) + + # Create a root Universe + root_univ = opencg.Universe(universe_id=0, name='root universe') + root_univ.add_cell(root_cell) + + # Create a Geometry + fuel_pin = opencg.Geometry() + fuel_pin.root_universe = root_univ + + return fuel_pin + + +#### Create OpenMC "materials.xml" and "geometry.xml" files + +# User-specified enrichment of 1.6, 2.4 or 3.1 percent +enrichment = 1.6 + +# Instantiate a BEAVRS object +beavrs = BEAVRS(nndc_xs=True) + +# Write all BEAVRS materials to materials.xml file +beavrs.write_openmc_materials() + +# Extract fuel pin of interest from InferMC's pre-built pin cell Geometries +pin_name = 'Fuel rod active region - {}% enr'.format(enrichment) +pin_geometry = find_pin(pin_name) +openmc_geometry = opencg_compatible.get_openmc_geometry(pin_geometry) +openmc_geometry.export_to_xml() + + +#### Create OpenMC "settings.xml" file + +# Construct uniform initial source distribution over fissionable zones +lower_left = pin_geometry.bounds[:2] + [-10.] +upper_right = pin_geometry.bounds[3:5] + [10.] +source = openmc.source.Source(space=openmc.stats.Box(lower_left, upper_right)) +source.space.only_fissionable = True + +settings_file = openmc.Settings() +settings_file.batches = 100 +settings_file.inactive = 5 +settings_file.particles = 100000 +settings_file.ptables = True +settings_file.output = {'tallies': False} +settings_file.source = source +settings_file.sourcepoint_write = False +settings_file.export_to_xml() + + +#### Create OpenMC MGXS Library and "tallies.xml" file + +# CASMO 70-group structure +groups = openmc.mgxs.EnergyGroups() +groups.group_edges = np.array([ + 0, 0.005, 0.01, 0.015, 0.02, 0.025, 0.03, 0.035, 0.042, 0.05, 0.058, 0.067, + 0.08, 0.1, 0.14, 0.18, 0.22, 0.25, 0.28, 0.3, 0.32, 0.35, 0.4, 0.5, 0.625, + 0.78, 0.85, 0.91, 0.95, 0.972, 0.996, 1.02, 1.045, 1.071, 1.097, 1.123, + 1.15, 1.3, 1.5, 1.855, 2.1, 2.6, 3.3, 4., 9.877, 15.968, 27.7, 48.052, + 75.501, 148.73, 367.26001, 906.90002, 1.4251e3, 2.2395e3, 3.5191e3, 5.53e3, + 9.118e3, 15.03e3, 24.78e3, 40.85e3, 67.34e3, 111.e3, 183e3, 302.5e3, 500e3, + 821e3, 1.353e6, 2.231e6, 3.679e6, 6.0655e6, 2e7]) + +# Initialize a 70-group MGXS Library +mgxs_lib = openmc.mgxs.Library(openmc_geometry, by_nuclide=True) +mgxs_lib.energy_groups = groups +mgxs_lib.mgxs_types = ['total', 'nu-fission', 'nu-scatter matrix', 'chi'] +mgxs_lib.domain_type = 'material' +mgxs_lib.correction = None +mgxs_lib.build_library() + +# Create a "tallies.xml" file for the MGXS Library +tallies_file = openmc.Tallies() +mgxs_lib.add_to_tallies_file(tallies_file, merge=True) +tallies_file.export_to_xml() \ No newline at end of file diff --git a/pin-cell/geometry.xml b/pin-cell/geometry.xml new file mode 100644 index 0000000..72befbf --- /dev/null +++ b/pin-cell/geometry.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/pin-cell/materials.xml b/pin-cell/materials.xml new file mode 100644 index 0000000..f488b12 --- /dev/null +++ b/pin-cell/materials.xml @@ -0,0 +1,250 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pin-cell/settings.xml b/pin-cell/settings.xml new file mode 100644 index 0000000..73e6fa6 --- /dev/null +++ b/pin-cell/settings.xml @@ -0,0 +1,20 @@ + + + + 10000 + 100 + 5 + + + + -0.62992 -0.62992 -10.0 0.62992 0.62992 10.0 + + + + false + + + false + + true + diff --git a/pin-cell/tallies.xml b/pin-cell/tallies.xml new file mode 100644 index 0000000..0a9a4be --- /dev/null +++ b/pin-cell/tallies.xml @@ -0,0 +1,111 @@ + + + + + + total + flux + tracklength + + + + + He3 He4 O16 O17 Cr50 Cr52 Cr53 Cr54 Fe54 Fe56 Fe57 Fe58 Zr90 Zr91 Zr92 Zr94 Zr96 Sn112 Sn114 Sn115 Sn116 Sn117 Sn118 Sn119 Sn120 Sn122 Sn124 + total nu-fission + tracklength + + + + + total + flux + analog + + + + + + He3 He4 O16 O17 Cr50 Cr52 Cr53 Cr54 Fe54 Fe56 Fe57 Fe58 Zr90 Zr91 Zr92 Zr94 Zr96 Sn112 Sn114 Sn115 Sn116 Sn117 Sn118 Sn119 Sn120 Sn122 Sn124 + nu-scatter-P0 + analog + + + + + He3 He4 O16 O17 Cr50 Cr52 Cr53 Cr54 Fe54 Fe56 Fe57 Fe58 Zr90 Zr91 Zr92 Zr94 Zr96 Sn112 Sn114 Sn115 Sn116 Sn117 Sn118 Sn119 Sn120 Sn122 Sn124 + nu-fission + analog + + + + + He3 He4 O16 O17 Cr50 Cr52 Cr53 Cr54 Fe54 Fe56 Fe57 Fe58 Zr90 Zr91 Zr92 Zr94 Zr96 Sn112 Sn114 Sn115 Sn116 Sn117 Sn118 Sn119 Sn120 Sn122 Sn124 + nu-fission + analog + + + + + O16 O17 Cr50 Cr52 Cr53 Cr54 Fe54 Fe56 Fe57 Fe58 Zr90 Zr91 Zr92 Zr94 Zr96 Sn112 Sn114 Sn115 Sn116 Sn117 Sn118 Sn119 Sn120 Sn122 Sn124 + nu-fission + tracklength + + + + + O16 O17 U234 U235 U238 + total nu-fission + tracklength + + + + + + O16 O17 U234 U235 U238 + nu-scatter-P0 + analog + + + + + O16 O17 U234 U235 U238 + nu-fission + analog + + + + + O16 O17 U234 U235 U238 + nu-fission + analog + + + + + B10 B11 H1 H2 O16 O17 + total nu-fission + tracklength + + + + + + B10 B11 H1 H2 O16 O17 + nu-scatter-P0 + analog + + + + + B10 B11 H1 H2 O16 O17 + nu-fission + analog + + + + + B10 B11 H1 H2 O16 O17 + nu-fission + analog + +