From 70a8e1aff0c5677a13313bcc2e7c7591a94f8bfc Mon Sep 17 00:00:00 2001 From: nuclearkevin <66632997+nuclearkevin@users.noreply.github.com> Date: Tue, 31 Dec 2024 13:17:23 -0600 Subject: [PATCH 1/2] Update the BEAVRS builder to the OpenMC 0.15.0 Python API. --- models/openmc/beavrs/assemblies.py | 8 ++++---- models/openmc/beavrs/builder.py | 2 +- models/openmc/beavrs/pincells.py | 14 +++++++------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/models/openmc/beavrs/assemblies.py b/models/openmc/beavrs/assemblies.py index 8cb66e7..4c52e2a 100644 --- a/models/openmc/beavrs/assemblies.py +++ b/models/openmc/beavrs/assemblies.py @@ -50,7 +50,7 @@ class Assemblies(object): # Rectangular prism around the edge of the pinlattice self.lattice_surfs = \ - openmc.rectangular_prism(17*c.pinPitch, 17*c.pinPitch) + openmc.model.RectangularPrism(17*c.pinPitch, 17*c.pinPitch) def _add_assembly_surfs(self): @@ -58,7 +58,7 @@ class Assemblies(object): # Rectangular prism around the edge of the pinlattice self.assem_surfs = \ - openmc.rectangular_prism(c.latticePitch, c.latticePitch) + openmc.model.RectangularPrism(c.latticePitch, c.latticePitch) def _add_bpra_layouts(self): @@ -265,14 +265,14 @@ class Assemblies(object): # Wrap the lattice with the grid sleeve universe u_lattice = InfinitePinCell(name='{0} universe'.format(name)) - u_lattice.add_ring(lattice, self.lattice_surfs, box=True) + u_lattice.add_ring(lattice, -self.lattice_surfs, box=True) u_lattice.add_last_ring(self.pins.u_gridsleeve) self.u_fuel[enr][gt_label][center_label] = u_lattice u_lattice.finalize() # Store the lattice without the gridsleeve u_latticePins = InfinitePinCell(name='{0} pins'.format(name)) - u_latticePins.add_ring(lattice, self.lattice_surfs, box=True) + u_latticePins.add_ring(lattice, -self.lattice_surfs, box=True) u_latticePins.add_last_ring(self.mats['Borated Water']) self.u_fuel_no_sleeve[enr][gt_label][center_label] = u_latticePins u_latticePins.finalize() diff --git a/models/openmc/beavrs/builder.py b/models/openmc/beavrs/builder.py index be23b1a..56e9919 100644 --- a/models/openmc/beavrs/builder.py +++ b/models/openmc/beavrs/builder.py @@ -134,7 +134,7 @@ class BEAVRS(object): settings_file.dd_nodemap = self.dd_nodemap settings_file.dd_allow_leakage = self.dd_truncate settings_file.dd_count_interactions = self.dd_interactions - settings_file.source = openmc.Source(space=openmc.stats.Box( + settings_file.source = openmc.IndependentSource(space=openmc.stats.Box( self.settings_sourcebox[:3], self.settings_sourcebox[3:])) output = {'tallies': self.settings_output_tallies, 'summary': self.settings_summary} diff --git a/models/openmc/beavrs/pincells.py b/models/openmc/beavrs/pincells.py index 500db3c..5d758cc 100644 --- a/models/openmc/beavrs/pincells.py +++ b/models/openmc/beavrs/pincells.py @@ -49,13 +49,13 @@ class Pincells(object): # Rectangular prisms for grid spacers grid_surfs_tb = \ - openmc.rectangular_prism(c.rodGridSide_tb, c.rodGridSide_tb) + openmc.model.RectangularPrism(c.rodGridSide_tb, c.rodGridSide_tb) grid_surfs_i = \ - openmc.rectangular_prism(c.rodGridSide_i, c.rodGridSide_i) + openmc.model.RectangularPrism(c.rodGridSide_i, c.rodGridSide_i) # Rectangular prisms for lattice grid sleeves grid_surfs_ass = \ - openmc.rectangular_prism(c.gridstrapSide, c.gridstrapSide) + openmc.model.RectangularPrism(c.gridstrapSide, c.gridstrapSide) # Grids axial surfaces @@ -79,22 +79,22 @@ class Pincells(object): # Grids pincell universes self.u_grid_i = InfinitePinCell(name='Intermediate grid pincell') - self.u_grid_i.add_ring(self.mats['Borated Water'], grid_surfs_i, box=True) + self.u_grid_i.add_ring(self.mats['Borated Water'], -grid_surfs_i, box=True) self.u_grid_i.add_last_ring(self.mats['Zircaloy 4']) self.u_grid_i.finalize() self.u_grid_tb = InfinitePinCell(name='Top/Bottom grid pincell') - self.u_grid_tb.add_ring(self.mats['Borated Water'], grid_surfs_tb, box=True) + self.u_grid_tb.add_ring(self.mats['Borated Water'], -grid_surfs_tb, box=True) self.u_grid_tb.add_last_ring(self.mats['Inconel 718']) self.u_grid_tb.finalize() self.u_grid_sleeve_i = InfinitePinCell(name='Intermediate grid sleeve pincell') - self.u_grid_sleeve_i.add_ring(self.mats['Zircaloy 4'], grid_surfs_ass, box=True) + self.u_grid_sleeve_i.add_ring(self.mats['Zircaloy 4'], -grid_surfs_ass, box=True) self.u_grid_sleeve_i.add_last_ring(self.mats['Borated Water']) self.u_grid_sleeve_i.finalize() self.u_grid_sleeve_tb = InfinitePinCell(name='Top/Bottom grid sleeve pincell') - self.u_grid_sleeve_tb.add_ring( self.mats['Inconel 718'], grid_surfs_ass, box=True) + self.u_grid_sleeve_tb.add_ring( self.mats['Inconel 718'], -grid_surfs_ass, box=True) self.u_grid_sleeve_tb.add_last_ring(self.mats['Borated Water']) self.u_grid_sleeve_tb.finalize() From 76d535306dd42046048d0985417bd886552e3b2d Mon Sep 17 00:00:00 2001 From: nuclearkevin <66632997+nuclearkevin@users.noreply.github.com> Date: Tue, 31 Dec 2024 13:17:58 -0600 Subject: [PATCH 2/2] Add an OpenMC model container to BEAVRS. --- models/openmc/beavrs/builder.py | 38 +++++++++++++++++++++++++++------ models/openmc/make_beavrs.py | 5 +---- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/models/openmc/beavrs/builder.py b/models/openmc/beavrs/builder.py index 56e9919..d328cdb 100644 --- a/models/openmc/beavrs/builder.py +++ b/models/openmc/beavrs/builder.py @@ -106,6 +106,9 @@ class BEAVRS(object): nuclides.append(openmc.Nuclide(nuc)) self.depletion_nuclides = nuclides + # The OpenMC model container to be populated. + self.model = openmc.Model() + def set_boron_ppm(self, ppm): self.mats = openmc_materials(ppm=ppm) @@ -116,12 +119,15 @@ class BEAVRS(object): materials_file = openmc.Materials(self.mats.values()) materials_file.export_to_xml() + def get_openmc_plots(self): + self.plots = Plots(self.mats) + return openmc.Plots(self.plots.plots) + def write_openmc_plots(self): self.plots = Plots(self.mats) - plot_file = openmc.Plots(self.plots.plots) - plot_file.export_to_xml() + self.get_openmc_plots().export_to_xml() - def write_openmc_settings(self): + def get_openmc_settings_file(self): settings_file = openmc.Settings() settings_file.batches = self.settings_batches settings_file.inactive = self.settings_inactive @@ -139,16 +145,36 @@ class BEAVRS(object): output = {'tallies': self.settings_output_tallies, 'summary': self.settings_summary} settings_file.output = output - settings_file.export_to_xml() + return settings_file - def write_openmc_tallies(self): + def write_openmc_settings(self): + self.get_openmc_settings_file().export_to_xml() + + def get_openmc_tallies_file(self): if len(self.tallies) == 0: return tallies_file = openmc.Tallies() for mesh in self.tally_meshes: tallies_file.add_mesh(mesh) for tally in self.tallies: tallies_file.append(tally) - tallies_file.export_to_xml() + return tallies_file + + def write_openmc_tallies(self): + if len(self.tallies) == 0: return + self.get_openmc_tallies_file().export_to_xml() + + def build_openmc_model(self): + self.model = openmc.Model() + self.model.geometry = self.openmc_geometry + self.model.materials = openmc.Materials(self.mats.values()) + self.model.settings = self.get_openmc_settings_file() + if len(self.tallies) != 0: + self.model.tallies = self.get_openmc_tallies_file() + self.model.plots = self.get_openmc_plots() + return self.model + + def write_openmc_model(self): + self.build_openmc_model().export_to_model_xml() def set_params(self, particles=None, batches=None, inactive=None): if particles: self.settings_particles = particles diff --git a/models/openmc/make_beavrs.py b/models/openmc/make_beavrs.py index 2fa5234..d6fc2b6 100755 --- a/models/openmc/make_beavrs.py +++ b/models/openmc/make_beavrs.py @@ -23,8 +23,5 @@ if not len(args) == 0: p.print_help() b = BEAVRS(is_symmetric=options.is_symmetric, is_2d=options.is_2d) -b.write_openmc_geometry() -b.write_openmc_materials() -b.write_openmc_plots() -b.write_openmc_settings() +b.write_openmc_model()