Updated sample input scripts for Python API to conform to new API specs

This commit is contained in:
Will Boyd 2014-11-03 20:05:34 -05:00
parent 2767d3f53f
commit 3bb1f8faf7
8 changed files with 291 additions and 330 deletions

View file

@ -20,14 +20,14 @@ u235 = openmc.Nuclide('U-235')
# Instantiate a Material and register the Nuclide
fuel = openmc.Material(material_id=1, name='fuel')
fuel.setDensity('g/cc', 4.5)
fuel.addNuclide(u235, 1.)
fuel.set_density('g/cc', 4.5)
fuel.add_nuclide(u235, 1.)
# Instantiate a MaterialsFile, register Material, and export to XML
materials_file = openmc.MaterialsFile()
materials_file.setDefaultXS('71c')
materials_file.addMaterial(fuel)
materials_file.exportToXML()
materials_file.set_default_xs('71c')
materials_file.add_material(fuel)
materials_file.export_to_xml()
###############################################################################
@ -42,41 +42,41 @@ 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')
surf1.setBoundaryType('vacuum')
surf2.setBoundaryType('vacuum')
surf3.setBoundaryType('reflective')
surf4.setBoundaryType('reflective')
surf5.setBoundaryType('reflective')
surf6.setBoundaryType('reflective')
surf1.set_boundary_type('vacuum')
surf2.set_boundary_type('vacuum')
surf3.set_boundary_type('reflective')
surf4.set_boundary_type('reflective')
surf5.set_boundary_type('reflective')
surf6.set_boundary_type('reflective')
# Instantiate Cell
cell = openmc.Cell(cell_id=1, name='cell 1')
# Register Surfaces with Cell
cell.addSurface(surface=surf1, halfspace=+1)
cell.addSurface(surface=surf2, halfspace=-1)
cell.addSurface(surface=surf3, halfspace=+1)
cell.addSurface(surface=surf4, halfspace=-1)
cell.addSurface(surface=surf5, halfspace=+1)
cell.addSurface(surface=surf6, halfspace=-1)
cell.add_surface(surface=surf1, halfspace=+1)
cell.add_surface(surface=surf2, halfspace=-1)
cell.add_surface(surface=surf3, halfspace=+1)
cell.add_surface(surface=surf4, halfspace=-1)
cell.add_surface(surface=surf5, halfspace=+1)
cell.add_surface(surface=surf6, halfspace=-1)
# Register Material with Cell
cell.setFill(fuel)
cell.set_fill(fuel)
# Instantiate Universes
root = openmc.Universe(universe_id=0, name='root universe')
# Register Cell with Universe
root.addCell(cell)
root.add_cell(cell)
# Instantiate a Geometry and register the root Universe
geometry = openmc.Geometry()
geometry.setRootUniverse(root)
geometry.set_root_universe(root)
# Instantiate a GeometryFile, register Geometry, and export to XML
geometry_file = openmc.GeometryFile()
geometry_file.setGeometry(geometry)
geometry_file.exportToXML()
geometry_file.set_geometry(geometry)
geometry_file.export_to_xml()
###############################################################################
@ -85,8 +85,8 @@ geometry_file.exportToXML()
# 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', [-1, -1, -1, 1, 1, 1])
settings_file.exportToXML()
settings_file.set_batches(batches)
settings_file.set_inactive(inactive)
settings_file.set_particles(particles)
settings_file.set_source_space('box', [-1, -1, -1, 1, 1, 1])
settings_file.export_to_xml()

View file

@ -1,17 +0,0 @@
<?xml version='1.0' encoding='utf-8'?>
<geometry>
<!--cell 1-->
<cell id="1" material="1" surfaces="1 -2 3 -4 5 -6" universe="0" />
<!--surf 1-->
<surface boundary="vacuum" coeffs="-1" id="1" type="x-plane" />
<!--surf 2-->
<surface boundary="vacuum" coeffs="1" id="2" type="x-plane" />
<!--surf 3-->
<surface boundary="reflective" coeffs="-1" id="3" type="y-plane" />
<!--surf 4-->
<surface boundary="reflective" coeffs="1" id="4" type="y-plane" />
<!--surf 5-->
<surface boundary="reflective" coeffs="-1" id="5" type="z-plane" />
<!--surf 6-->
<surface boundary="reflective" coeffs="1" id="6" type="z-plane" />
</geometry>

View file

@ -1,9 +0,0 @@
<?xml version='1.0' encoding='utf-8'?>
<materials>
<default_xs>71c</default_xs>
<!--fuel-->
<material id="1">
<density units="g/cc" value="4.5" />
<nuclide ao="1.0" name="U-235" />
</material>
</materials>

View file

@ -1,13 +0,0 @@
<?xml version='1.0' encoding='utf-8'?>
<settings>
<eigenvalue>
<particles>10000</particles>
<batches>500</batches>
<inactive>10</inactive>
</eigenvalue>
<source>
<space type="box">
<parameters>-1 -1 -1 1 1 1</parameters>
</space>
</source>
</settings>