diff --git a/examples/python/pincell/build-xml.py b/examples/python/pincell/build-xml.py new file mode 100644 index 000000000..6916bef9c --- /dev/null +++ b/examples/python/pincell/build-xml.py @@ -0,0 +1,214 @@ +import openmc + + +############################################################################### +# Simulation Input File Parameters +############################################################################### + +# OpenMC simulation parameters +batches = 100 +inactive = 10 +particles = 1000 + + +############################################################################### +# Exporting to OpenMC materials.xml File +############################################################################### + +# Instantiate some Nuclides +h1 = openmc.Nuclide('H-1') +h2 = openmc.Nuclide('H-2') +he4 = openmc.Nuclide('He-4') +b10 = openmc.Nuclide('B-10') +b11 = openmc.Nuclide('B-11') +o16 = openmc.Nuclide('O-16') +o17 = openmc.Nuclide('O-17') +cr50 = openmc.Nuclide('Cr-50') +cr52 = openmc.Nuclide('Cr-52') +cr53 = openmc.Nuclide('Cr-53') +cr54 = openmc.Nuclide('Cr-54') +fe54 = openmc.Nuclide('Fe-54') +fe56 = openmc.Nuclide('Fe-56') +fe57 = openmc.Nuclide('Fe-57') +fe58 = openmc.Nuclide('Fe-58') +zr90 = openmc.Nuclide('Zr-90') +zr91 = openmc.Nuclide('Zr-91') +zr92 = openmc.Nuclide('Zr-92') +zr94 = openmc.Nuclide('Zr-94') +zr96 = openmc.Nuclide('Zr-96') +sn112 = openmc.Nuclide('Sn-112') +sn114 = openmc.Nuclide('Sn-114') +sn115 = openmc.Nuclide('Sn-115') +sn116 = openmc.Nuclide('Sn-116') +sn117 = openmc.Nuclide('Sn-117') +sn118 = openmc.Nuclide('Sn-118') +sn119 = openmc.Nuclide('Sn-119') +sn120 = openmc.Nuclide('Sn-120') +sn122 = openmc.Nuclide('Sn-122') +sn124 = openmc.Nuclide('Sn-124') +u234 = openmc.Nuclide('U-234') +u235 = openmc.Nuclide('U-235') +u238 = openmc.Nuclide('U-238') + +# Instantiate some Materials and register the appropriate Nuclides +uo2 = openmc.Material(material_id=1, name='UO2 fuel at 2.4% wt enrichment') +uo2.setDensity('g/cm3', 10.29769) +uo2.addNuclide(u234, 4.4843e-6) +uo2.addNuclide(u235, 5.5815e-4) +uo2.addNuclide(u238, 2.2408e-2) +uo2.addNuclide(o16, 4.5829e-2) +uo2.addNuclide(o17, 1.1164e-4) + +helium = openmc.Material(material_id=2, name='Helium for gap') +helium.setDensity('g/cm3', 0.001598) +helium.addNuclide(he4, 2.4044e-4) + +zircaloy = openmc.Material(material_id=3, name='Zircaloy 4') +zircaloy.setDensity('g/cm3', 6.55) +zircaloy.addNuclide(o16, 3.0743e-4) +zircaloy.addNuclide(o17, 7.4887e-7) +zircaloy.addNuclide(cr50, 3.2962e-6) +zircaloy.addNuclide(cr52, 6.3564e-5) +zircaloy.addNuclide(cr53, 7.2076e-6) +zircaloy.addNuclide(cr54, 1.7941e-6) +zircaloy.addNuclide(fe54, 8.6699e-6) +zircaloy.addNuclide(fe56, 1.3610e-4) +zircaloy.addNuclide(fe57, 3.1431e-6) +zircaloy.addNuclide(fe58, 4.1829e-7) +zircaloy.addNuclide(zr90, 2.1827e-2) +zircaloy.addNuclide(zr91, 4.7600e-3) +zircaloy.addNuclide(zr92, 7.2758e-3) +zircaloy.addNuclide(zr94, 7.3734e-3) +zircaloy.addNuclide(zr96, 1.1879e-3) +zircaloy.addNuclide(sn112, 4.6735e-6) +zircaloy.addNuclide(sn114, 3.1799e-6) +zircaloy.addNuclide(sn115, 1.6381e-6) +zircaloy.addNuclide(sn116, 7.0055e-5) +zircaloy.addNuclide(sn117, 3.7003e-5) +zircaloy.addNuclide(sn118, 1.1669e-4) +zircaloy.addNuclide(sn119, 4.1387e-5) +zircaloy.addNuclide(sn120, 1.5697e-4) +zircaloy.addNuclide(sn122, 2.2308e-5) +zircaloy.addNuclide(sn124, 2.7897e-5) + +borated_water = openmc.Material(material_id=4, name='Borated water at 975 ppm') +borated_water.setDensity('g/cm3', 0.740582) +borated_water.addNuclide(b10, 8.0042e-6) +borated_water.addNuclide(b11, 3.2218e-5) +borated_water.addNuclide(h1, 4.9457e-2) +borated_water.addNuclide(h2, 7.4196e-6) +borated_water.addNuclide(o16, 2.4672e-2) +borated_water.addNuclide(o17, 6.0099e-5) +borated_water.addSAlphaBeta('HH2O', '71t') + +# Instantiate a MaterialsFile, register all Materials, and export to XML +materials_file = openmc.MaterialsFile() +materials_file.setDefaultXS('71c') +materials_file.addMaterials([uo2, helium, zircaloy, borated_water]) +materials_file.exportToXML() + + +############################################################################### +# 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') + +left.setBoundaryType('reflective') +right.setBoundaryType('reflective') +top.setBoundaryType('reflective') +bottom.setBoundaryType('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') + +# Register Surfaces with Cells +fuel.addSurface(fuel_or, halfspace=-1) +gap.addSurface(fuel_or, halfspace=+1) +gap.addSurface(clad_ir, halfspace=-1) +clad.addSurface(clad_ir, halfspace=+1) +clad.addSurface(clad_or, halfspace=-1) +water.addSurface(clad_or, halfspace=+1) +water.addSurface(left, halfspace=+1) +water.addSurface(right, halfspace=-1) +water.addSurface(bottom, halfspace=+1) +water.addSurface(top, halfspace=-1) + +# Register Materials with Cells +fuel.setFill(uo2) +gap.setFill(helium) +clad.setFill(zircaloy) +water.setFill(borated_water) + +# Instantiate Universe +root = openmc.Universe(universe_id=0, name='root universe') + +# Register Cells with Universe +root.addCells([fuel, gap, clad, water]) + +# Instantiate a Geometry and register the root Universe +geometry = openmc.Geometry() +geometry.setRootUniverse(root) + +# Instantiate a GeometryFile, register Geometry, and export to XML +geometry_file = openmc.GeometryFile() +geometry_file.setGeometry(geometry) +geometry_file.exportToXML() + + +############################################################################### +# Exporting to OpenMC settings.xml File +############################################################################### + +# Instantiate a SettingsFile, set all runtime parameters, and export to XML +settings_file = openmc.SettingsFile() +settings_file.setBatches(batches) +settings_file.setInactive(inactive) +settings_file.setParticles(particles) +settings_file.setSourceSpace('box', [-0.62992, -0.62992, -1, \ + 0.62992, 0.62992, 1]) +settings_file.setEntropyLowerLeft([-0.39218, -0.39218, -1.e50]) +settings_file.setEntropyUpperRight([0.39218, 0.39218, 1.e50]) +settings_file.setEntropyDimension([10, 10, 1]) +settings_file.exportToXML() + + +############################################################################### +# Exporting to OpenMC tallies.xml File +############################################################################### + +# Instantiate a tally mesh +mesh = openmc.Mesh(mesh_id=1) +mesh.setType('rectangular') +mesh.setDimension([100, 100, 1]) +mesh.setLowerLeft([-0.62992, -0.62992, -1.e50]) +mesh.setUpperRight([0.62992, 0.62992, 1.e50]) + +# Instantiate some tally Filters +energy_filter = openmc.Filter(type='energy', bins=[0., 4.e-6, 20.]) +mesh_filter = openmc.Filter() +mesh_filter.setMesh(mesh) + +# Instantiate the Tally +tally = openmc.Tally(tally_id=1) +tally.addFilter(energy_filter) +tally.addFilter(mesh_filter) +tally.addScore('flux') +tally.addScore('fission') +tally.addScore('nu-fission') + +# Instantiate a TalliesFile, register all Tallies, and export to XML +tallies_file = openmc.TalliesFile() +tallies_file.addMesh(mesh) +tallies_file.addTally(tally) +tallies_file.exportToXML() diff --git a/examples/python/pincell/geometry.xml b/examples/python/pincell/geometry.xml deleted file mode 100644 index 53cb2f15d..000000000 --- a/examples/python/pincell/geometry.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/python/pincell/materials.xml b/examples/python/pincell/materials.xml deleted file mode 100644 index 427fc175d..000000000 --- a/examples/python/pincell/materials.xml +++ /dev/null @@ -1,70 +0,0 @@ - - - - - 71c - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/python/pincell/settings.xml b/examples/python/pincell/settings.xml deleted file mode 100644 index 443af9cde..000000000 --- a/examples/python/pincell/settings.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - 100 - 10 - 1000 - - - - - - - -0.62992 -0.62992 -1. - 0.62992 0.62992 1. - - - - - - - -0.39218 -0.39218 -1.e50 - 0.39218 0.39218 1.e50 - 10 10 1 - - - \ No newline at end of file diff --git a/examples/python/pincell/tallies.xml b/examples/python/pincell/tallies.xml deleted file mode 100644 index bbfd58836..000000000 --- a/examples/python/pincell/tallies.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - 100 100 1 - -0.62992 -0.62992 -1.e50 - 0.62992 0.62992 1.e50 - - - - - - flux fission nu-fission - - - \ No newline at end of file