mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 21:55:41 -04:00
Implemented reflective example input file using Python API
This commit is contained in:
parent
b0e5c88b57
commit
368184371e
5 changed files with 118 additions and 35 deletions
92
examples/python/reflective/build-xml.py
Normal file
92
examples/python/reflective/build-xml.py
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
import openmc
|
||||
|
||||
|
||||
###############################################################################
|
||||
# Simulation Input File Parameters
|
||||
###############################################################################
|
||||
|
||||
# OpenMC simulation parameters
|
||||
batches = 500
|
||||
inactive = 10
|
||||
particles = 10000
|
||||
|
||||
|
||||
###############################################################################
|
||||
# Exporting to OpenMC materials.xml File
|
||||
###############################################################################
|
||||
|
||||
# Instantiate a Nuclides
|
||||
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.)
|
||||
|
||||
# Instantiate a MaterialsFile, register Material, and export to XML
|
||||
materials_file = openmc.MaterialsFile()
|
||||
materials_file.setDefaultXS('71c')
|
||||
materials_file.addMaterial(fuel)
|
||||
materials_file.exportToXML()
|
||||
|
||||
|
||||
###############################################################################
|
||||
# Exporting to OpenMC geometry.xml File
|
||||
###############################################################################
|
||||
|
||||
# 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')
|
||||
|
||||
surf1.setBoundaryType('vacuum')
|
||||
surf2.setBoundaryType('vacuum')
|
||||
surf3.setBoundaryType('reflective')
|
||||
surf4.setBoundaryType('reflective')
|
||||
surf5.setBoundaryType('reflective')
|
||||
surf6.setBoundaryType('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)
|
||||
|
||||
# Register Material with Cell
|
||||
cell.setFill(fuel)
|
||||
|
||||
# Instantiate Universes
|
||||
root = openmc.Universe(universe_id=0, name='root universe')
|
||||
|
||||
# Register Cell with Universe
|
||||
root.addCell(cell)
|
||||
|
||||
# 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', [-1, -1, -1, 1, 1, 1])
|
||||
settings_file.exportToXML()
|
||||
|
|
@ -1,19 +1,17 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<geometry>
|
||||
|
||||
<!-- Definition of Cells -->
|
||||
<cell id="1">
|
||||
<universe>0</universe>
|
||||
<material>1</material>
|
||||
<surfaces>1 -2 3 -4 5 -6</surfaces>
|
||||
</cell>
|
||||
|
||||
<!-- Defition of Surfaces -->
|
||||
<surface id="1" type="x-plane" coeffs="-1" boundary="vacuum" />
|
||||
<surface id="2" type="x-plane" coeffs="1" boundary="vacuum" />
|
||||
<surface id="3" type="y-plane" coeffs="-1" boundary="reflective" />
|
||||
<surface id="4" type="y-plane" coeffs="1" boundary="reflective" />
|
||||
<surface id="5" type="z-plane" coeffs="-1" boundary="reflective" />
|
||||
<surface id="6" type="z-plane" coeffs="1" boundary="reflective" />
|
||||
|
||||
<!--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>
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<materials>
|
||||
|
||||
<default_xs>71c</default_xs>
|
||||
|
||||
<material id="1">
|
||||
<density value="4.5" units="g/cc" />
|
||||
<nuclide name="U-235" ao="1.0" />
|
||||
<!--fuel-->
|
||||
<material id="1">
|
||||
<density units="g/cc" value="4.5" />
|
||||
<nuclide ao="1.0" name="U-235" />
|
||||
</material>
|
||||
|
||||
</materials>
|
||||
|
|
|
|||
|
|
@ -1,18 +1,13 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<settings>
|
||||
|
||||
<!-- Parameters for k-eigenvalue calculation -->
|
||||
<eigenvalue>
|
||||
<batches>500</batches>
|
||||
<inactive>10</inactive>
|
||||
<particles>10000</particles>
|
||||
<batches>500</batches>
|
||||
<inactive>10</inactive>
|
||||
</eigenvalue>
|
||||
|
||||
<!-- Starting source -->
|
||||
<source>
|
||||
<source>
|
||||
<space type="box">
|
||||
<parameters>-1 -1 -1 1 1 1</parameters>
|
||||
<parameters>-1 -1 -1 1 1 1</parameters>
|
||||
</space>
|
||||
</source>
|
||||
|
||||
</settings>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue