From 24f704849419e4544531f3a7d5dcc9c52975bfd7 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Wed, 4 Sep 2019 16:32:50 -0500 Subject: [PATCH] Update pincell python example --- examples/python/pincell/build-xml.py | 99 +++++++++++----------------- openmc/settings.py | 4 -- 2 files changed, 38 insertions(+), 65 deletions(-) diff --git a/examples/python/pincell/build-xml.py b/examples/python/pincell/build-xml.py index 072cc911f0..dc6df91631 100644 --- a/examples/python/pincell/build-xml.py +++ b/examples/python/pincell/build-xml.py @@ -16,23 +16,23 @@ particles = 1000 # Instantiate some Materials and register the appropriate Nuclides -uo2 = openmc.Material(material_id=1, name='UO2 fuel at 2.4% wt enrichment') +uo2 = openmc.Material(name='UO2 fuel at 2.4% wt enrichment') uo2.set_density('g/cm3', 10.29769) uo2.add_element('U', 1., enrichment=2.4) uo2.add_element('O', 2.) -helium = openmc.Material(material_id=2, name='Helium for gap') +helium = openmc.Material(name='Helium for gap') helium.set_density('g/cm3', 0.001598) helium.add_element('He', 2.4044e-4) -zircaloy = openmc.Material(material_id=3, name='Zircaloy 4') +zircaloy = openmc.Material(name='Zircaloy 4') zircaloy.set_density('g/cm3', 6.55) zircaloy.add_element('Sn', 0.014 , 'wo') zircaloy.add_element('Fe', 0.00165, 'wo') zircaloy.add_element('Cr', 0.001 , 'wo') zircaloy.add_element('Zr', 0.98335, 'wo') -borated_water = openmc.Material(material_id=4, name='Borated water') +borated_water = openmc.Material(name='Borated water') borated_water.set_density('g/cm3', 0.740582) borated_water.add_element('B', 4.0e-5) borated_water.add_element('H', 5.0e-2) @@ -40,54 +40,31 @@ borated_water.add_element('O', 2.4e-2) borated_water.add_s_alpha_beta('c_H_in_H2O') # Instantiate a Materials collection and export to XML -materials_file = openmc.Materials([uo2, helium, zircaloy, borated_water]) -materials_file.export_to_xml() +materials = openmc.Materials([uo2, helium, zircaloy, borated_water]) +materials.export_to_xml() ############################################################################### # Exporting to OpenMC geometry.xml file ############################################################################### -# Instantiate ZCylinder surfaces -fuel_or = openmc.ZCylinder(surface_id=1, x0=0, y0=0, r=0.39218, name='Fuel OR') -clad_ir = openmc.ZCylinder(surface_id=2, x0=0, y0=0, r=0.40005, name='Clad IR') -clad_or = openmc.ZCylinder(surface_id=3, x0=0, y0=0, r=0.45720, name='Clad OR') -left = openmc.XPlane(surface_id=4, x0=-0.62992, name='left') -right = openmc.XPlane(surface_id=5, x0=0.62992, name='right') -bottom = openmc.YPlane(surface_id=6, y0=-0.62992, name='bottom') -top = openmc.YPlane(surface_id=7, y0=0.62992, name='top') +# Create cylindrical surfaces +fuel_or = openmc.ZCylinder(r=0.39218, name='Fuel OR') +clad_ir = openmc.ZCylinder(r=0.40005, name='Clad IR') +clad_or = openmc.ZCylinder(r=0.45720, name='Clad OR') -left.boundary_type = 'reflective' -right.boundary_type = 'reflective' -top.boundary_type = 'reflective' -bottom.boundary_type = 'reflective' +# Create a region represented as the inside of a rectangular prism +pitch = 1.25984 +box = openmc.rectangular_prism(pitch, pitch, boundary_type='reflective') -# Instantiate Cells -fuel = openmc.Cell(cell_id=1, name='cell 1') -gap = openmc.Cell(cell_id=2, name='cell 2') -clad = openmc.Cell(cell_id=3, name='cell 3') -water = openmc.Cell(cell_id=4, name='cell 4') +# Create cells, mapping materials to regions +fuel = openmc.Cell(fill=uo2, region=-fuel_or) +gap = openmc.Cell(fill=helium, region=+fuel_or & -clad_ir) +clad = openmc.Cell(fill=zircaloy, region=+clad_ir & -clad_or) +water = openmc.Cell(fill=borated_water, region=+clad_or & box) -# Use surface half-spaces to define regions -fuel.region = -fuel_or -gap.region = +fuel_or & -clad_ir -clad.region = +clad_ir & -clad_or -water.region = +clad_or & +left & -right & +bottom & -top - -# Register Materials with Cells -fuel.fill = uo2 -gap.fill = helium -clad.fill = zircaloy -water.fill = borated_water - -# Instantiate Universe -root = openmc.Universe(universe_id=0, name='root universe') - -# Register Cells with Universe -root.add_cells([fuel, gap, clad, water]) - -# Instantiate a Geometry, register the root Universe, and export to XML -geometry = openmc.Geometry(root) +# Create a geometry and export to XML +geometry = openmc.Geometry([fuel, gap, clad, water]) geometry.export_to_xml() @@ -96,22 +73,22 @@ geometry.export_to_xml() ############################################################################### # Instantiate a Settings object, set all runtime parameters, and export to XML -settings_file = openmc.Settings() -settings_file.batches = batches -settings_file.inactive = inactive -settings_file.particles = particles +settings = openmc.Settings() +settings.batches = batches +settings.inactive = inactive +settings.particles = particles # Create an initial uniform spatial source distribution over fissionable zones -bounds = [-0.62992, -0.62992, -1, 0.62992, 0.62992, 1] +bounds = [-pitch/2, -pitch/2, -1, pitch/2, pitch/2, 1] uniform_dist = openmc.stats.Box(bounds[:3], bounds[3:], only_fissionable=True) -settings_file.source = openmc.source.Source(space=uniform_dist) +settings.source = openmc.source.Source(space=uniform_dist) entropy_mesh = openmc.RegularMesh() -entropy_mesh.lower_left = [-0.39218, -0.39218, -1.e50] -entropy_mesh.upper_right = [0.39218, 0.39218, 1.e50] -entropy_mesh.dimension = [10, 10, 1] -settings_file.entropy_mesh = entropy_mesh -settings_file.export_to_xml() +entropy_mesh.lower_left = (-fuel_or.r, -fuel_or.r) +entropy_mesh.upper_right = (fuel_or.r, fuel_or.r) +entropy_mesh.dimension = (10, 10) +settings.entropy_mesh = entropy_mesh +settings.export_to_xml() ############################################################################### @@ -120,19 +97,19 @@ settings_file.export_to_xml() # Instantiate a tally mesh mesh = openmc.RegularMesh() -mesh.dimension = [100, 100, 1] -mesh.lower_left = [-0.62992, -0.62992, -1.e50] -mesh.upper_right = [0.62992, 0.62992, 1.e50] +mesh.dimension = (100, 100) +mesh.lower_left = (-pitch/2, -pitch/2) +mesh.upper_right = (pitch/2, pitch/2) # Instantiate some tally Filters -energy_filter = openmc.EnergyFilter([0., 4., 20.e6]) +energy_filter = openmc.EnergyFilter((0., 4., 20.e6)) mesh_filter = openmc.MeshFilter(mesh) # Instantiate the Tally -tally = openmc.Tally(tally_id=1, name='tally 1') +tally = openmc.Tally() tally.filters = [energy_filter, mesh_filter] tally.scores = ['flux', 'fission', 'nu-fission'] # Instantiate a Tallies collection and export to XML -tallies_file = openmc.Tallies([tally]) -tallies_file.export_to_xml() +tallies = openmc.Tallies([tally]) +tallies.export_to_xml() diff --git a/openmc/settings.py b/openmc/settings.py index 794c97b618..cddef9255f 100644 --- a/openmc/settings.py +++ b/openmc/settings.py @@ -612,10 +612,6 @@ class Settings(object): @entropy_mesh.setter def entropy_mesh(self, entropy): cv.check_type('entropy mesh', entropy, RegularMesh) - if entropy.dimension: - cv.check_length('entropy mesh dimension', entropy.dimension, 3) - cv.check_length('entropy mesh lower-left corner', entropy.lower_left, 3) - cv.check_length('entropy mesh upper-right corner', entropy.upper_right, 3) self._entropy_mesh = entropy @trigger_active.setter