2015-12-02 13:52:32 -06:00
|
|
|
import numpy as np
|
2014-10-13 09:19:55 -04:00
|
|
|
import openmc
|
|
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
|
# Simulation Input File Parameters
|
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
|
|
# OpenMC simulation parameters
|
|
|
|
|
batches = 500
|
|
|
|
|
inactive = 10
|
|
|
|
|
particles = 10000
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
###############################################################################
|
2016-04-25 10:37:06 -05:00
|
|
|
# Exporting to OpenMC materials.xml file
|
2014-10-13 09:19:55 -04:00
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
|
|
# Instantiate a Material and register the Nuclide
|
|
|
|
|
fuel = openmc.Material(material_id=1, name='fuel')
|
2014-11-03 20:05:34 -05:00
|
|
|
fuel.set_density('g/cc', 4.5)
|
2016-12-15 21:06:12 +00:00
|
|
|
fuel.add_nuclide('U235', 1.)
|
2014-10-13 09:19:55 -04:00
|
|
|
|
2016-04-29 16:14:02 -05:00
|
|
|
# Instantiate a Materials collection and export to XML
|
|
|
|
|
materials_file = openmc.Materials([fuel])
|
2014-11-03 20:05:34 -05:00
|
|
|
materials_file.export_to_xml()
|
2014-10-13 09:19:55 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
###############################################################################
|
2016-04-25 10:37:06 -05:00
|
|
|
# Exporting to OpenMC geometry.xml file
|
2014-10-13 09:19:55 -04:00
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
|
|
# Instantiate Surfaces
|
|
|
|
|
surf1 = openmc.XPlane(surface_id=1, x0=-1, name='surf 1')
|
|
|
|
|
surf2 = openmc.XPlane(surface_id=2, x0=+1, name='surf 2')
|
|
|
|
|
surf3 = openmc.YPlane(surface_id=3, y0=-1, name='surf 3')
|
|
|
|
|
surf4 = openmc.YPlane(surface_id=4, y0=+1, name='surf 4')
|
|
|
|
|
surf5 = openmc.ZPlane(surface_id=5, z0=-1, name='surf 5')
|
|
|
|
|
surf6 = openmc.ZPlane(surface_id=6, z0=+1, name='surf 6')
|
|
|
|
|
|
2015-04-22 00:50:03 -05:00
|
|
|
surf1.boundary_type = 'vacuum'
|
|
|
|
|
surf2.boundary_type = 'vacuum'
|
|
|
|
|
surf3.boundary_type = 'reflective'
|
|
|
|
|
surf4.boundary_type = 'reflective'
|
|
|
|
|
surf5.boundary_type = 'reflective'
|
|
|
|
|
surf6.boundary_type = 'reflective'
|
2014-10-13 09:19:55 -04:00
|
|
|
|
|
|
|
|
# Instantiate Cell
|
|
|
|
|
cell = openmc.Cell(cell_id=1, name='cell 1')
|
|
|
|
|
|
2015-10-03 09:55:58 +07:00
|
|
|
# Use surface half-spaces to define region
|
|
|
|
|
cell.region = +surf1 & -surf2 & +surf3 & -surf4 & +surf5 & -surf6
|
2014-10-13 09:19:55 -04:00
|
|
|
|
|
|
|
|
# Register Material with Cell
|
2015-04-22 00:50:03 -05:00
|
|
|
cell.fill = fuel
|
2014-10-13 09:19:55 -04:00
|
|
|
|
|
|
|
|
# Instantiate Universes
|
|
|
|
|
root = openmc.Universe(universe_id=0, name='root universe')
|
|
|
|
|
|
|
|
|
|
# Register Cell with Universe
|
2014-11-03 20:05:34 -05:00
|
|
|
root.add_cell(cell)
|
2014-10-13 09:19:55 -04:00
|
|
|
|
2016-04-26 07:08:03 -05:00
|
|
|
# Instantiate a Geometry, register the root Universe, and export to XML
|
2016-05-25 10:02:27 -05:00
|
|
|
geometry = openmc.Geometry(root)
|
2016-04-25 10:37:06 -05:00
|
|
|
geometry.export_to_xml()
|
2014-10-13 09:19:55 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
###############################################################################
|
2016-04-25 10:37:06 -05:00
|
|
|
# Exporting to OpenMC settings.xml file
|
2014-10-13 09:19:55 -04:00
|
|
|
###############################################################################
|
|
|
|
|
|
2016-04-25 10:37:06 -05:00
|
|
|
# Instantiate a Settings object, set all runtime parameters, and export to XML
|
|
|
|
|
settings_file = openmc.Settings()
|
2015-04-22 00:50:03 -05:00
|
|
|
settings_file.batches = batches
|
|
|
|
|
settings_file.inactive = inactive
|
|
|
|
|
settings_file.particles = particles
|
2016-04-08 12:26:02 -04:00
|
|
|
|
|
|
|
|
# Create an initial uniform spatial source distribution over fissionable zones
|
|
|
|
|
uniform_dist = openmc.stats.Box(*cell.region.bounding_box,
|
|
|
|
|
only_fissionable=True)
|
|
|
|
|
settings_file.source = openmc.source.Source(space=uniform_dist)
|
|
|
|
|
|
2014-11-03 20:05:34 -05:00
|
|
|
settings_file.export_to_xml()
|