Merge pull request #632 from paulromano/pyapi-various-improvements

Various improvements and bug fixes, mostly relating to Python API
This commit is contained in:
Will Boyd 2016-04-26 09:40:27 -04:00
commit 5863cc5c99
68 changed files with 839 additions and 917 deletions

View file

@ -0,0 +1,6 @@
{{ fullname }}
{{ underline }}
.. currentmodule:: {{ module }}
.. autofunction:: {{ objname }}

View file

@ -4,7 +4,7 @@
License Agreement
=================
Copyright © 2011-2015 Massachusetts Institute of Technology
Copyright © 2011-2016 Massachusetts Institute of Technology
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in

View file

@ -201,7 +201,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"With our material, we can now create a `MaterialsFile` object that can be exported to an actual XML file."
"With our material, we can now create a `Materials` object that can be exported to an actual XML file."
]
},
{
@ -212,8 +212,8 @@
},
"outputs": [],
"source": [
"# Instantiate a MaterialsFile, register all Materials, and export to XML\n",
"materials_file = openmc.MaterialsFile()\n",
"# Instantiate a Materials object, register all Materials, and export to XML\n",
"materials_file = openmc.Materials()\n",
"materials_file.default_xs = '71c'\n",
"materials_file.add_material(inf_medium)\n",
"materials_file.export_to_xml()"
@ -290,7 +290,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"We now must create a geometry that is assigned a root universe, put the geometry into a `GeometryFile` object, and export it to XML."
"We now must create a geometry that is assigned a root universe and export it to XML."
]
},
{
@ -305,12 +305,8 @@
"openmc_geometry = openmc.Geometry()\n",
"openmc_geometry.root_universe = root_universe\n",
"\n",
"# Instantiate a GeometryFile\n",
"geometry_file = openmc.GeometryFile()\n",
"geometry_file.geometry = openmc_geometry\n",
"\n",
"# Export to \"geometry.xml\"\n",
"geometry_file.export_to_xml()"
"openmc_geometry.export_to_xml()"
]
},
{
@ -333,8 +329,8 @@
"inactive = 10\n",
"particles = 2500\n",
"\n",
"# Instantiate a SettingsFile\n",
"settings_file = openmc.SettingsFile()\n",
"# Instantiate a Settings object\n",
"settings_file = openmc.Settings()\n",
"settings_file.batches = batches\n",
"settings_file.inactive = inactive\n",
"settings_file.particles = particles\n",
@ -455,7 +451,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"The `Absorption` object includes tracklength tallies for the 'absorption' and 'flux' scores in the 2-group structure in cell 1. Now that each `MGXS` object contains the tallies that it needs, we must add these tallies to a `TalliesFile` object to generate the \"tallies.xml\" input file for OpenMC."
"The `Absorption` object includes tracklength tallies for the 'absorption' and 'flux' scores in the 2-group structure in cell 1. Now that each `MGXS` object contains the tallies that it needs, we must add these tallies to a `Tallies` object to generate the \"tallies.xml\" input file for OpenMC."
]
},
{
@ -466,8 +462,8 @@
},
"outputs": [],
"source": [
"# Instantiate an empty TalliesFile\n",
"tallies_file = openmc.TalliesFile()\n",
"# Instantiate an empty Tallies object\n",
"tallies_file = openmc.Tallies()\n",
"\n",
"# Add total tallies to the tallies file\n",
"for tally in total.tallies.values():\n",
@ -644,8 +640,7 @@
],
"source": [
"# Run OpenMC\n",
"executor = openmc.Executor()\n",
"executor.run_simulation()"
"openmc.run()"
]
},
{

View file

@ -122,7 +122,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"With our materials, we can now create a `MaterialsFile` object that can be exported to an actual XML file."
"With our materials, we can now create a `Materials` object that can be exported to an actual XML file."
]
},
{
@ -133,8 +133,8 @@
},
"outputs": [],
"source": [
"# Instantiate a MaterialsFile, add Materials\n",
"materials_file = openmc.MaterialsFile()\n",
"# Instantiate a Materials object, add Materials\n",
"materials_file = openmc.Materials()\n",
"materials_file.add_material(fuel)\n",
"materials_file.add_material(water)\n",
"materials_file.add_material(zircaloy)\n",
@ -238,7 +238,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"We now must create a geometry that is assigned a root universe, put the geometry into a `GeometryFile` object, and export it to XML."
"We now must create a geometry that is assigned a root universe and export it to XML."
]
},
{
@ -253,12 +253,8 @@
"openmc_geometry = openmc.Geometry()\n",
"openmc_geometry.root_universe = root_universe\n",
"\n",
"# Instantiate a GeometryFile\n",
"geometry_file = openmc.GeometryFile()\n",
"geometry_file.geometry = openmc_geometry\n",
"\n",
"# Export to \"geometry.xml\"\n",
"geometry_file.export_to_xml()"
"openmc_geometry.export_to_xml()"
]
},
{
@ -281,8 +277,8 @@
"inactive = 10\n",
"particles = 10000\n",
"\n",
"# Instantiate a SettingsFile\n",
"settings_file = openmc.SettingsFile()\n",
"# Instantiate a Settings object\n",
"settings_file = openmc.Settings()\n",
"settings_file.batches = batches\n",
"settings_file.inactive = inactive\n",
"settings_file.particles = particles\n",
@ -396,8 +392,8 @@
},
"outputs": [],
"source": [
"# Instantiate an empty TalliesFile\n",
"tallies_file = openmc.TalliesFile()\n",
"# Instantiate an empty Tallies object\n",
"tallies_file = openmc.Tallies()\n",
"\n",
"# Iterate over all cells and cross section types\n",
"for cell in openmc_cells:\n",
@ -607,8 +603,7 @@
],
"source": [
"# Run OpenMC\n",
"executor = openmc.Executor()\n",
"executor.run_simulation(output=True)"
"openmc.run(output=True)"
]
},
{
@ -1360,7 +1355,7 @@
],
"source": [
"# Generate tracks for OpenMOC\n",
"track_generator = openmoc.TrackGenerator(openmoc_geometry, num_azim=128, spacing=0.1)\n",
"track_generator = openmoc.TrackGenerator(openmoc_geometry, num_azim=128, azim_spacing=0.1)\n",
"track_generator.generateTracks()\n",
"\n",
"# Run OpenMOC\n",
@ -1699,7 +1694,7 @@
],
"source": [
"# Generate tracks for OpenMOC\n",
"track_generator = openmoc.TrackGenerator(openmoc_geometry, num_azim=128, spacing=0.1)\n",
"track_generator = openmoc.TrackGenerator(openmoc_geometry, num_azim=128, azim_spacing=0.1)\n",
"track_generator.generateTracks()\n",
"\n",
"# Run OpenMOC\n",

View file

@ -122,7 +122,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"With our three materials, we can now create a `MaterialsFile` object that can be exported to an actual XML file."
"With our three materials, we can now create a `Materials` object that can be exported to an actual XML file."
]
},
{
@ -133,8 +133,8 @@
},
"outputs": [],
"source": [
"# Instantiate a MaterialsFile, add Materials\n",
"materials_file = openmc.MaterialsFile()\n",
"# Instantiate a Materials object, add Materials\n",
"materials_file = openmc.Materials()\n",
"materials_file.add_material(fuel)\n",
"materials_file.add_material(water)\n",
"materials_file.add_material(zircaloy)\n",
@ -331,7 +331,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"We now must create a geometry that is assigned a root universe, put the geometry into a `GeometryFile` object, and export it to XML."
"We now must create a geometry that is assigned a root universe and export it to XML."
]
},
{
@ -355,12 +355,8 @@
},
"outputs": [],
"source": [
"# Instantiate a GeometryFile\n",
"geometry_file = openmc.GeometryFile()\n",
"geometry_file.geometry = geometry\n",
"\n",
"# Export to \"geometry.xml\"\n",
"geometry_file.export_to_xml()"
"geometry.export_to_xml()"
]
},
{
@ -383,8 +379,8 @@
"inactive = 10\n",
"particles = 2500\n",
"\n",
"# Instantiate a SettingsFile\n",
"settings_file = openmc.SettingsFile()\n",
"# Instantiate a Settings object\n",
"settings_file = openmc.Settings()\n",
"settings_file.batches = batches\n",
"settings_file.inactive = inactive\n",
"settings_file.particles = particles\n",
@ -403,7 +399,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Let us also create a `PlotsFile` that we can use to verify that our fuel assembly geometry was created successfully."
"Let us also create a `Plots` file that we can use to verify that our fuel assembly geometry was created successfully."
]
},
{
@ -422,8 +418,8 @@
"plot.width = [-10.71*2, -10.71*2]\n",
"plot.color = 'mat'\n",
"\n",
"# Instantiate a PlotsFile, add Plot, and export to \"plots.xml\"\n",
"plot_file = openmc.PlotsFile()\n",
"# Instantiate a Plots object, add Plot, and export to \"plots.xml\"\n",
"plot_file = openmc.Plots()\n",
"plot_file.add_plot(plot)\n",
"plot_file.export_to_xml()"
]
@ -455,8 +451,7 @@
],
"source": [
"# Run openmc in plotting mode\n",
"executor = openmc.Executor()\n",
"executor.plot_geometry(output=False)"
"openmc.plot_geometry(output=False)"
]
},
{
@ -643,7 +638,7 @@
"source": [
"The tallies can now be export to a \"tallies.xml\" input file for OpenMC. \n",
"\n",
"**NOTE**: At this point the `Library` has constructed nearly 100 distinct `Tally` objects. The overhead to tally in OpenMC scales as $O(N)$ for $N$ tallies, which can become a bottleneck for large tally datasets. To compensate for this, the Python API's `Tally`, `Filter` and `TalliesFile` classes allow for the smart *merging* of tallies when possible. The `Library` class supports this runtime optimization with the use of the optional `merge` paramter (`False` by default) for the `Library.add_to_tallies_file(...)` method, as shown below."
"**NOTE**: At this point the `Library` has constructed nearly 100 distinct `Tally` objects. The overhead to tally in OpenMC scales as $O(N)$ for $N$ tallies, which can become a bottleneck for large tally datasets. To compensate for this, the Python API's `Tally`, `Filter` and `Tallies` classes allow for the smart *merging* of tallies when possible. The `Library` class supports this runtime optimization with the use of the optional `merge` paramter (`False` by default) for the `Library.add_to_tallies_file(...)` method, as shown below."
]
},
{
@ -655,7 +650,7 @@
"outputs": [],
"source": [
"# Create a \"tallies.xml\" file for the MGXS Library\n",
"tallies_file = openmc.TalliesFile()\n",
"tallies_file = openmc.Tallies()\n",
"mgxs_lib.add_to_tallies_file(tallies_file, merge=True)"
]
},
@ -690,7 +685,7 @@
"tally.filters = [mesh_filter]\n",
"tally.scores = ['fission', 'nu-fission']\n",
"\n",
"# Add mesh and Tally to TalliesFile\n",
"# Add mesh and tally to Tallies\n",
"tallies_file.add_mesh(mesh)\n",
"tallies_file.add_tally(tally)"
]
@ -860,7 +855,7 @@
],
"source": [
"# Run OpenMC\n",
"executor.run_simulation()"
"openmc.run()"
]
},
{
@ -1449,7 +1444,7 @@
],
"source": [
"# Generate tracks for OpenMOC\n",
"track_generator = openmoc.TrackGenerator(openmoc_geometry, num_azim=32, spacing=0.1)\n",
"track_generator = openmoc.TrackGenerator(openmoc_geometry, num_azim=32, azim_spacing=0.1)\n",
"track_generator.generateTracks()\n",
"\n",
"# Run OpenMOC\n",

View file

@ -108,8 +108,8 @@
},
"outputs": [],
"source": [
"# Instantiate a MaterialsFile, add Materials\n",
"materials_file = openmc.MaterialsFile()\n",
"# Instantiate a Materials object, add Materials\n",
"materials_file = openmc.Materials()\n",
"materials_file.add_material(fuel)\n",
"materials_file.add_material(water)\n",
"materials_file.add_material(zircaloy)\n",
@ -239,7 +239,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"We now must create a geometry that is assigned a root universe, put the geometry into a `GeometryFile` object, and export it to XML."
"We now must create a geometry that is assigned a root universe and export it to XML."
]
},
{
@ -263,12 +263,8 @@
},
"outputs": [],
"source": [
"# Instantiate a GeometryFile\n",
"geometry_file = openmc.GeometryFile()\n",
"geometry_file.geometry = geometry\n",
"\n",
"# Export to \"geometry.xml\"\n",
"geometry_file.export_to_xml()"
"geometry.export_to_xml()"
]
},
{
@ -292,8 +288,8 @@
"inactive = 5\n",
"particles = 2500\n",
"\n",
"# Instantiate a SettingsFile\n",
"settings_file = openmc.SettingsFile()\n",
"# Instantiate a Settings object\n",
"settings_file = openmc.Settings()\n",
"settings_file.batches = min_batches\n",
"settings_file.inactive = inactive\n",
"settings_file.particles = particles\n",
@ -333,8 +329,8 @@
"plot.pixels = [250, 250]\n",
"plot.color = 'mat'\n",
"\n",
"# Instantiate a PlotsFile, add Plot, and export to \"plots.xml\"\n",
"plot_file = openmc.PlotsFile()\n",
"# Instantiate a Plots object, add Plot, and export to \"plots.xml\"\n",
"plot_file = openmc.Plots()\n",
"plot_file.add_plot(plot)\n",
"plot_file.export_to_xml()"
]
@ -366,8 +362,7 @@
],
"source": [
"# Run openmc in plotting mode\n",
"executor = openmc.Executor()\n",
"executor.plot_geometry(output=False)"
"openmc.plot_geometry(output=False)"
]
},
{
@ -412,8 +407,8 @@
},
"outputs": [],
"source": [
"# Instantiate an empty TalliesFile\n",
"tallies_file = openmc.TalliesFile()\n",
"# Instantiate an empty Tallies object\n",
"tallies_file = openmc.Tallies()\n",
"tallies_file._tallies = []"
]
},
@ -453,7 +448,7 @@
"tally.filters = [mesh_filter, energy_filter]\n",
"tally.scores = ['fission', 'nu-fission']\n",
"\n",
"# Add mesh and Tally to TalliesFile\n",
"# Add mesh and Tally to Tallies\n",
"tallies_file.add_mesh(mesh)\n",
"tallies_file.add_tally(tally)"
]
@ -482,7 +477,7 @@
"tally.scores = ['scatter-y2']\n",
"tally.nuclides = [u235, u238]\n",
"\n",
"# Add mesh and tally to TalliesFile\n",
"# Add mesh and tally to Tallies\n",
"tallies_file.add_tally(tally)"
]
},
@ -514,7 +509,7 @@
"tally.scores = ['absorption', 'scatter']\n",
"tally.triggers = [trigger]\n",
"\n",
"# Add mesh and tally to TalliesFile\n",
"# Add mesh and tally to Tallies\n",
"tallies_file.add_tally(tally)"
]
},
@ -669,8 +664,8 @@
"# Remove old HDF5 (summary, statepoint) files\n",
"!rm statepoint.*\n",
"\n",
"# Run OpenMC with MPI!\n",
"executor.run_simulation()"
"# Run OpenMC!\n",
"openmc.run()"
]
},
{

View file

@ -104,8 +104,8 @@
},
"outputs": [],
"source": [
"# Instantiate a MaterialsFile, add Materials\n",
"materials_file = openmc.MaterialsFile()\n",
"# Instantiate a Materials object, add Materials\n",
"materials_file = openmc.Materials()\n",
"materials_file.add_material(fuel)\n",
"materials_file.add_material(water)\n",
"materials_file.add_material(zircaloy)\n",
@ -236,12 +236,8 @@
},
"outputs": [],
"source": [
"# Instantiate a GeometryFile\n",
"geometry_file = openmc.GeometryFile()\n",
"geometry_file.geometry = geometry\n",
"\n",
"# Export to \"geometry.xml\"\n",
"geometry_file.export_to_xml()"
"geometry.export_to_xml()"
]
},
{
@ -264,8 +260,8 @@
"inactive = 10\n",
"particles = 5000\n",
"\n",
"# Instantiate a SettingsFile\n",
"settings_file = openmc.SettingsFile()\n",
"# Instantiate a Settings object\n",
"settings_file = openmc.Settings()\n",
"settings_file.batches = batches\n",
"settings_file.inactive = inactive\n",
"settings_file.particles = particles\n",
@ -302,8 +298,8 @@
"plot.pixels = [250, 250]\n",
"plot.color = 'mat'\n",
"\n",
"# Instantiate a PlotsFile, add Plot, and export to \"plots.xml\"\n",
"plot_file = openmc.PlotsFile()\n",
"# Instantiate a Plots object, add Plot, and export to \"plots.xml\"\n",
"plot_file = openmc.Plots()\n",
"plot_file.add_plot(plot)\n",
"plot_file.export_to_xml()"
]
@ -335,8 +331,7 @@
],
"source": [
"# Run openmc in plotting mode\n",
"executor = openmc.Executor()\n",
"executor.plot_geometry(output=False)"
"openmc.plot_geometry(output=False)"
]
},
{
@ -381,8 +376,8 @@
},
"outputs": [],
"source": [
"# Instantiate an empty TalliesFile\n",
"tallies_file = openmc.TalliesFile()"
"# Instantiate an empty Tallies object\n",
"tallies_file = openmc.Tallies()"
]
},
{
@ -634,7 +629,7 @@
],
"source": [
"# Run OpenMC!\n",
"executor.run_simulation()"
"openmc.run()"
]
},
{

View file

@ -126,8 +126,8 @@
},
"outputs": [],
"source": [
"# Instantiate a MaterialsFile, add Materials\n",
"materials_file = openmc.MaterialsFile()\n",
"# Instantiate a Materials object, add Materials\n",
"materials_file = openmc.Materials()\n",
"materials_file.add_material(fuel)\n",
"materials_file.add_material(water)\n",
"materials_file.add_material(zircaloy)\n",
@ -258,12 +258,8 @@
},
"outputs": [],
"source": [
"# Instantiate a GeometryFile\n",
"geometry_file = openmc.GeometryFile()\n",
"geometry_file.geometry = geometry\n",
"\n",
"# Export to \"geometry.xml\"\n",
"geometry_file.export_to_xml()"
"geometry.export_to_xml()"
]
},
{
@ -286,8 +282,8 @@
"inactive = 5\n",
"particles = 2500\n",
"\n",
"# Instantiate a SettingsFile\n",
"settings_file = openmc.SettingsFile()\n",
"# Instantiate a Settings object\n",
"settings_file = openmc.Settings()\n",
"settings_file.batches = batches\n",
"settings_file.inactive = inactive\n",
"settings_file.particles = particles\n",
@ -325,8 +321,8 @@
"plot.pixels = [250, 250]\n",
"plot.color = 'mat'\n",
"\n",
"# Instantiate a PlotsFile, add Plot, and export to \"plots.xml\"\n",
"plot_file = openmc.PlotsFile()\n",
"# Instantiate a Plots object, add Plot, and export to \"plots.xml\"\n",
"plot_file = openmc.Plots()\n",
"plot_file.add_plot(plot)\n",
"plot_file.export_to_xml()"
]
@ -358,8 +354,7 @@
],
"source": [
"# Run openmc in plotting mode\n",
"executor = openmc.Executor()\n",
"executor.plot_geometry(output=False)"
"openmc.plot_geometry(output=False)"
]
},
{
@ -404,8 +399,8 @@
},
"outputs": [],
"source": [
"# Instantiate an empty TalliesFile\n",
"tallies_file = openmc.TalliesFile()"
"# Instantiate an empty Tallies object\n",
"tallies_file = openmc.Tallies()"
]
},
{
@ -673,8 +668,8 @@
"# Remove old HDF5 (summary, statepoint) files\n",
"!rm statepoint.*\n",
"\n",
"# Run OpenMC with MPI!\n",
"executor.run_simulation()"
"# Run OpenMC!\n",
"openmc.run()"
]
},
{

View file

@ -29,7 +29,7 @@ Classes
:template: myclass.rst
openmc.XSdata
openmc.MGXSLibraryFile
openmc.MGXSLibrary
Functions
+++++++++
@ -50,7 +50,7 @@ Simulation Settings
openmc.Source
openmc.ResonanceScattering
openmc.SettingsFile
openmc.Settings
Material Specification
----------------------
@ -64,7 +64,7 @@ Material Specification
openmc.Element
openmc.Macroscopic
openmc.Material
openmc.MaterialsFile
openmc.Materials
Building geometry
-----------------
@ -96,7 +96,6 @@ Building geometry
openmc.RectLattice
openmc.HexLattice
openmc.Geometry
openmc.GeometryFile
Many of the above classes are derived from several abstract classes:
@ -121,7 +120,7 @@ Constructing Tallies
openmc.Mesh
openmc.Trigger
openmc.Tally
openmc.TalliesFile
openmc.Tallies
Coarse Mesh Finite Difference Acceleration
------------------------------------------
@ -132,7 +131,7 @@ Coarse Mesh Finite Difference Acceleration
:template: myclass.rst
openmc.CMFDMesh
openmc.CMFDFile
openmc.CMFD
Plotting
--------
@ -143,7 +142,7 @@ Plotting
:template: myclass.rst
openmc.Plot
openmc.PlotsFile
openmc.Plots
Running OpenMC
--------------
@ -151,9 +150,10 @@ Running OpenMC
.. autosummary::
:toctree: generated
:nosignatures:
:template: myclass.rst
:template: myfunction.rst
openmc.Executor
openmc.run
openmc.plot_geometry
Post-processing
---------------

View file

@ -12,7 +12,7 @@ particles = 10000
###############################################################################
# Exporting to OpenMC materials.xml File
# Exporting to OpenMC materials.xml file
###############################################################################
# Instantiate some Nuclides
@ -31,15 +31,15 @@ fuel = openmc.Material(material_id=40, name='fuel')
fuel.set_density('g/cc', 4.5)
fuel.add_nuclide(u235, 1.)
# Instantiate a MaterialsFile, register all Materials, and export to XML
materials_file = openmc.MaterialsFile()
# Instantiate a Materials collection, register all Materials, and export to XML
materials_file = openmc.Materials()
materials_file.default_xs = '71c'
materials_file.add_materials([moderator, fuel])
materials_file.export_to_xml()
###############################################################################
# Exporting to OpenMC geometry.xml File
# Exporting to OpenMC geometry.xml file
###############################################################################
# Instantiate ZCylinder surfaces
@ -74,22 +74,18 @@ cell1.fill = universe1
universe1.add_cells([cell2, cell3])
root.add_cells([cell1, cell4])
# Instantiate a Geometry and register the root Universe
# Instantiate a Geometry, register the root Universe, and export to XML
geometry = openmc.Geometry()
geometry.root_universe = root
# Instantiate a GeometryFile, register Geometry, and export to XML
geometry_file = openmc.GeometryFile()
geometry_file.geometry = geometry
geometry_file.export_to_xml()
geometry.export_to_xml()
###############################################################################
# Exporting to OpenMC settings.xml File
# Exporting to OpenMC settings.xml file
###############################################################################
# Instantiate a SettingsFile, set all runtime parameters, and export to XML
settings_file = openmc.SettingsFile()
# 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
@ -103,7 +99,7 @@ settings_file.export_to_xml()
###############################################################################
# Exporting to OpenMC tallies.xml File
# Exporting to OpenMC tallies.xml file
###############################################################################
# Instantiate some tally Filters
@ -128,8 +124,8 @@ third_tally = openmc.Tally(tally_id=3, name='third tally')
third_tally.filters = [cell_filter, energy_filter, energyout_filter]
third_tally.scores = ['scatter', 'nu-scatter', 'nu-fission']
# Instantiate a TalliesFile, register all Tallies, and export to XML
tallies_file = openmc.TalliesFile()
# Instantiate a Tallies collection, register all Tallies, and export to XML
tallies_file = openmc.Tallies()
tallies_file.add_tally(first_tally)
tallies_file.add_tally(second_tally)
tallies_file.add_tally(third_tally)

View file

@ -36,15 +36,15 @@ moderator.add_nuclide(h1, 2.)
moderator.add_nuclide(o16, 1.)
moderator.add_s_alpha_beta('HH2O', '71t')
# Instantiate a MaterialsFile, register all Materials, and export to XML
materials_file = openmc.MaterialsFile()
# Instantiate a Materials collection, register all Materials, and export to XML
materials_file = openmc.Materials()
materials_file.default_xs = '71c'
materials_file.add_materials([fuel1, fuel2, moderator])
materials_file.export_to_xml()
###############################################################################
# Exporting to OpenMC geometry.xml File
# Exporting to OpenMC geometry.xml file
###############################################################################
# Instantiate planar surfaces
@ -97,22 +97,18 @@ outer_box.fill = moderator
root = openmc.Universe(universe_id=0, name='root universe')
root.add_cells([inner_box, middle_box, outer_box])
# Instantiate a Geometry and register the root Universe
# Instantiate a Geometry, register the root Universe, and export to XML
geometry = openmc.Geometry()
geometry.root_universe = root
# Instantiate a GeometryFile, register Geometry, and export to XML
geometry_file = openmc.GeometryFile()
geometry_file.geometry = geometry
geometry_file.export_to_xml()
geometry.export_to_xml()
###############################################################################
# Exporting to OpenMC settings.xml File
###############################################################################
# Instantiate a SettingsFile, set all runtime parameters, and export to XML
settings_file = openmc.SettingsFile()
# 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
@ -133,7 +129,7 @@ plot.width = [20, 20]
plot.pixels = [200, 200]
plot.color = 'cell'
# Instantiate a PlotsFile, add Plot, and export to XML
plot_file = openmc.PlotsFile()
# Instantiate a Plots collection, add Plot, and export to XML
plot_file = openmc.Plots()
plot_file.add_plot(plot)
plot_file.export_to_xml()

View file

@ -35,15 +35,15 @@ iron = openmc.Material(material_id=3, name='iron')
iron.set_density('g/cc', 7.9)
iron.add_nuclide(fe56, 1.)
# Instantiate a MaterialsFile, register all Materials, and export to XML
materials_file = openmc.MaterialsFile()
# Instantiate a Materials collection, register all Materials, and export to XML
materials_file = openmc.Materials()
materials_file.default_xs = '71c'
materials_file.add_materials([moderator, fuel, iron])
materials_file.export_to_xml()
###############################################################################
# Exporting to OpenMC geometry.xml File
# Exporting to OpenMC geometry.xml file
###############################################################################
# Instantiate Surfaces
@ -105,22 +105,18 @@ lattice.outer = univ2
# Fill Cell with the Lattice
cell1.fill = lattice
# Instantiate a Geometry and register the root Universe
# Instantiate a Geometry, register the root Universe, and export to XML
geometry = openmc.Geometry()
geometry.root_universe = root
# Instantiate a GeometryFile, register Geometry, and export to XML
geometry_file = openmc.GeometryFile()
geometry_file.geometry = geometry
geometry_file.export_to_xml()
geometry.export_to_xml()
###############################################################################
# Exporting to OpenMC settings.xml File
# Exporting to OpenMC settings.xml file
###############################################################################
# Instantiate a SettingsFile, set all runtime parameters, and export to XML
settings_file = openmc.SettingsFile()
# 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
@ -137,7 +133,7 @@ settings_file.export_to_xml()
###############################################################################
# Exporting to OpenMC plots.xml File
# Exporting to OpenMC plots.xml file
###############################################################################
plot_xy = openmc.Plot(plot_id=1)
@ -155,8 +151,8 @@ plot_yz.width = [8, 8]
plot_yz.pixels = [400, 400]
plot_yz.color = 'mat'
# Instantiate a PlotsFile, add Plot, and export to XML
plot_file = openmc.PlotsFile()
# Instantiate a Plots collection, add plots, and export to XML
plot_file = openmc.Plots()
plot_file.add_plot(plot_xy)
plot_file.add_plot(plot_yz)
plot_file.export_to_xml()
@ -171,7 +167,7 @@ tally = openmc.Tally(tally_id=1)
tally.filters = [openmc.Filter(type='distribcell', bins=[cell2.id])]
tally.scores = ['total']
# Instantiate a TalliesFile, register Tally/Mesh, and export to XML
tallies_file = openmc.TalliesFile()
# Instantiate a Tallies collection, register Tally/Mesh, and export to XML
tallies_file = openmc.Tallies()
tallies_file.add_tally(tally)
tallies_file.export_to_xml()

View file

@ -11,7 +11,7 @@ particles = 10000
###############################################################################
# Exporting to OpenMC materials.xml File
# Exporting to OpenMC materials.xml file
###############################################################################
# Instantiate some Nuclides
@ -30,15 +30,15 @@ moderator.add_nuclide(h1, 2.)
moderator.add_nuclide(o16, 1.)
moderator.add_s_alpha_beta('HH2O', '71t')
# Instantiate a MaterialsFile, register all Materials, and export to XML
materials_file = openmc.MaterialsFile()
# Instantiate a Materials collection, register all Materials, and export to XML
materials_file = openmc.Materials()
materials_file.default_xs = '71c'
materials_file.add_materials([moderator, fuel])
materials_file.export_to_xml()
###############################################################################
# Exporting to OpenMC geometry.xml File
# Exporting to OpenMC geometry.xml file
###############################################################################
# Instantiate Surfaces
@ -116,22 +116,18 @@ lattice2.universes = [[univ4, univ4],
cell1.fill = lattice2
cell2.fill = lattice1
# Instantiate a Geometry and register the root Universe
# Instantiate a Geometry, register the root Universe, and export to XML
geometry = openmc.Geometry()
geometry.root_universe = root
# Instantiate a GeometryFile, register Geometry, and export to XML
geometry_file = openmc.GeometryFile()
geometry_file.geometry = geometry
geometry_file.export_to_xml()
geometry.export_to_xml()
###############################################################################
# Exporting to OpenMC settings.xml File
# Exporting to OpenMC settings.xml file
###############################################################################
# Instantiate a SettingsFile, set all runtime parameters, and export to XML
settings_file = openmc.SettingsFile()
# 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
@ -145,7 +141,7 @@ settings_file.export_to_xml()
###############################################################################
# Exporting to OpenMC plots.xml File
# Exporting to OpenMC plots.xml file
###############################################################################
plot = openmc.Plot(plot_id=1)
@ -154,14 +150,14 @@ plot.width = [4, 4]
plot.pixels = [400, 400]
plot.color = 'mat'
# Instantiate a PlotsFile, add Plot, and export to XML
plot_file = openmc.PlotsFile()
# Instantiate a Plots object, add Plot, and export to XML
plot_file = openmc.Plots()
plot_file.add_plot(plot)
plot_file.export_to_xml()
###############################################################################
# Exporting to OpenMC tallies.xml File
# Exporting to OpenMC tallies.xml file
###############################################################################
# Instantiate a tally mesh
@ -180,8 +176,8 @@ tally = openmc.Tally(tally_id=1)
tally.filters = [mesh_filter]
tally.scores = ['total']
# Instantiate a TalliesFile, register Tally/Mesh, and export to XML
tallies_file = openmc.TalliesFile()
# Instantiate a Tallies collection, register Tally/Mesh, and export to XML
tallies_file = openmc.Tallies()
tallies_file.add_mesh(mesh)
tallies_file.add_tally(tally)
tallies_file.export_to_xml()

View file

@ -11,7 +11,7 @@ particles = 10000
###############################################################################
# Exporting to OpenMC materials.xml File
# Exporting to OpenMC materials.xml file
###############################################################################
# Instantiate some Nuclides
@ -30,15 +30,15 @@ moderator.add_nuclide(h1, 2.)
moderator.add_nuclide(o16, 1.)
moderator.add_s_alpha_beta('HH2O', '71t')
# Instantiate a MaterialsFile, register all Materials, and export to XML
materials_file = openmc.MaterialsFile()
# Instantiate a Materials collection, register all Materials, and export to XML
materials_file = openmc.Materials()
materials_file.default_xs = '71c'
materials_file.add_materials([moderator, fuel])
materials_file.export_to_xml()
###############################################################################
# Exporting to OpenMC geometry.xml File
# Exporting to OpenMC geometry.xml file
###############################################################################
# Instantiate Surfaces
@ -106,22 +106,18 @@ lattice.universes = [[univ1, univ2, univ1, univ2],
# Fill Cell with the Lattice
cell1.fill = lattice
# Instantiate a Geometry and register the root Universe
# Instantiate a Geometry, register the root Universe, and export to XML
geometry = openmc.Geometry()
geometry.root_universe = root
# Instantiate a GeometryFile, register Geometry, and export to XML
geometry_file = openmc.GeometryFile()
geometry_file.geometry = geometry
geometry_file.export_to_xml()
geometry.export_to_xml()
###############################################################################
# Exporting to OpenMC settings.xml File
# Exporting to OpenMC settings.xml file
###############################################################################
# Instantiate a SettingsFile, set all runtime parameters, and export to XML
settings_file = openmc.SettingsFile()
# 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
@ -137,7 +133,7 @@ settings_file.export_to_xml()
###############################################################################
# Exporting to OpenMC plots.xml File
# Exporting to OpenMC plots.xml file
###############################################################################
plot = openmc.Plot(plot_id=1)
@ -146,14 +142,14 @@ plot.width = [4, 4]
plot.pixels = [400, 400]
plot.color = 'mat'
# Instantiate a PlotsFile, add Plot, and export to XML
plot_file = openmc.PlotsFile()
# Instantiate a Plots collection, add Plot, and export to XML
plot_file = openmc.Plots()
plot_file.add_plot(plot)
plot_file.export_to_xml()
###############################################################################
# Exporting to OpenMC tallies.xml File
# Exporting to OpenMC tallies.xml file
###############################################################################
# Instantiate a tally mesh
@ -177,8 +173,8 @@ tally.filters = [mesh_filter]
tally.scores = ['total']
tally.triggers = [trigger]
# Instantiate a TalliesFile, register Tally/Mesh, and export to XML
tallies_file = openmc.TalliesFile()
# Instantiate a Tallies collection, register Tally/Mesh, and export to XML
tallies_file = openmc.Tallies()
tallies_file.add_mesh(mesh)
tallies_file.add_tally(tally)
tallies_file.export_to_xml()

View file

@ -11,7 +11,7 @@ particles = 1000
###############################################################################
# Exporting to OpenMC materials.xml File
# Exporting to OpenMC materials.xml file
###############################################################################
# Instantiate some Nuclides
@ -100,15 +100,15 @@ borated_water.add_nuclide(o16, 2.4672e-2)
borated_water.add_nuclide(o17, 6.0099e-5)
borated_water.add_s_alpha_beta('HH2O', '71t')
# Instantiate a MaterialsFile, register all Materials, and export to XML
materials_file = openmc.MaterialsFile()
# Instantiate a Materials collection, register all Materials, and export to XML
materials_file = openmc.Materials()
materials_file.default_xs = '71c'
materials_file.add_materials([uo2, helium, zircaloy, borated_water])
materials_file.export_to_xml()
###############################################################################
# Exporting to OpenMC geometry.xml File
# Exporting to OpenMC geometry.xml file
###############################################################################
# Instantiate ZCylinder surfaces
@ -149,22 +149,18 @@ root = openmc.Universe(universe_id=0, name='root universe')
# Register Cells with Universe
root.add_cells([fuel, gap, clad, water])
# Instantiate a Geometry and register the root Universe
# Instantiate a Geometry, register the root Universe, and export to XML
geometry = openmc.Geometry()
geometry.root_universe = root
# Instantiate a GeometryFile, register Geometry, and export to XML
geometry_file = openmc.GeometryFile()
geometry_file.geometry = geometry
geometry_file.export_to_xml()
geometry.export_to_xml()
###############################################################################
# Exporting to OpenMC settings.xml File
# Exporting to OpenMC settings.xml file
###############################################################################
# Instantiate a SettingsFile, set all runtime parameters, and export to XML
settings_file = openmc.SettingsFile()
# 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
@ -181,7 +177,7 @@ settings_file.export_to_xml()
###############################################################################
# Exporting to OpenMC tallies.xml File
# Exporting to OpenMC tallies.xml file
###############################################################################
# Instantiate a tally mesh
@ -201,8 +197,8 @@ tally = openmc.Tally(tally_id=1, name='tally 1')
tally.filters = [energy_filter, mesh_filter]
tally.scores = ['flux', 'fission', 'nu-fission']
# Instantiate a TalliesFile, register all Tallies, and export to XML
tallies_file = openmc.TalliesFile()
# Instantiate a Tallies collection, register all Tallies, and export to XML
tallies_file = openmc.Tallies()
tallies_file.add_mesh(mesh)
tallies_file.add_tally(tally)
tallies_file.export_to_xml()

View file

@ -12,7 +12,7 @@ inactive = 10
particles = 1000
###############################################################################
# Exporting to OpenMC mg_cross_sections.xml File
# Exporting to OpenMC mg_cross_sections.xml file
###############################################################################
# Instantiate the energy group data
@ -59,13 +59,13 @@ scatter = [[[0.0444777, 0.1134000, 0.0007235, 0.0000037, 0.0000001, 0.0000000, 0
[0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.1324400, 2.4807000]]]
h2o_xsdata.scatter = np.array(scatter)
mg_cross_sections_file = openmc.MGXSLibraryFile(groups)
mg_cross_sections_file = openmc.MGXSLibrary(groups)
mg_cross_sections_file.add_xsdatas([uo2_xsdata,h2o_xsdata])
mg_cross_sections_file.export_to_xml()
###############################################################################
# Exporting to OpenMC materials.xml File
# Exporting to OpenMC materials.xml file
###############################################################################
# Instantiate some Macroscopic Data
@ -81,15 +81,15 @@ water = openmc.Material(material_id=2, name='Water')
water.set_density('macro', 1.0)
water.add_macroscopic(h2o_data)
# Instantiate a MaterialsFile, register all Materials, and export to XML
materials_file = openmc.MaterialsFile()
# Instantiate a Materials collection, register all Materials, and export to XML
materials_file = openmc.Materials()
materials_file.default_xs = '300K'
materials_file.add_materials([uo2, water])
materials_file.export_to_xml()
###############################################################################
# Exporting to OpenMC geometry.xml File
# Exporting to OpenMC geometry.xml file
###############################################################################
# Instantiate ZCylinder surfaces
@ -122,22 +122,18 @@ root = openmc.Universe(universe_id=0, name='root universe')
# Register Cells with Universe
root.add_cells([fuel, moderator])
# Instantiate a Geometry and register the root Universe
# Instantiate a Geometry, register the root Universe, and export to XML
geometry = openmc.Geometry()
geometry.root_universe = root
# Instantiate a GeometryFile, register Geometry, and export to XML
geometry_file = openmc.GeometryFile()
geometry_file.geometry = geometry
geometry_file.export_to_xml()
geometry.export_to_xml()
###############################################################################
# Exporting to OpenMC settings.xml File
# Exporting to OpenMC settings.xml file
###############################################################################
# Instantiate a SettingsFile, set all runtime parameters, and export to XML
settings_file = openmc.SettingsFile()
# Instantiate a Settings object, set all runtime parameters, and export to XML
settings_file = openmc.Settings()
settings_file.energy_mode = "multi-group"
settings_file.cross_sections = "./mg_cross_sections.xml"
settings_file.batches = batches
@ -152,7 +148,7 @@ settings_file.source = openmc.source.Source(space=uniform_dist)
settings_file.export_to_xml()
###############################################################################
# Exporting to OpenMC tallies.xml File
# Exporting to OpenMC tallies.xml file
###############################################################################
# Instantiate a tally mesh
@ -177,8 +173,8 @@ tally.add_score('flux')
tally.add_score('fission')
tally.add_score('nu-fission')
# Instantiate a TalliesFile, register all Tallies, and export to XML
tallies_file = openmc.TalliesFile()
# Instantiate a Tallies collection, register all Tallies, and export to XML
tallies_file = openmc.Tallies()
tallies_file.add_mesh(mesh)
tallies_file.add_tally(tally)
tallies_file.export_to_xml()

View file

@ -12,7 +12,7 @@ particles = 10000
###############################################################################
# Exporting to OpenMC materials.xml File
# Exporting to OpenMC materials.xml file
###############################################################################
# Instantiate a Nuclides
@ -23,15 +23,15 @@ fuel = openmc.Material(material_id=1, name='fuel')
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()
# Instantiate a Materials collection, register Material, and export to XML
materials_file = openmc.Materials()
materials_file.default_xs = '71c'
materials_file.add_material(fuel)
materials_file.export_to_xml()
###############################################################################
# Exporting to OpenMC geometry.xml File
# Exporting to OpenMC geometry.xml file
###############################################################################
# Instantiate Surfaces
@ -64,22 +64,18 @@ root = openmc.Universe(universe_id=0, name='root universe')
# Register Cell with Universe
root.add_cell(cell)
# Instantiate a Geometry and register the root Universe
# Instantiate a Geometry, register the root Universe, and export to XML
geometry = openmc.Geometry()
geometry.root_universe = root
# Instantiate a GeometryFile, register Geometry, and export to XML
geometry_file = openmc.GeometryFile()
geometry_file.geometry = geometry
geometry_file.export_to_xml()
geometry.export_to_xml()
###############################################################################
# Exporting to OpenMC settings.xml File
# Exporting to OpenMC settings.xml file
###############################################################################
# Instantiate a SettingsFile, set all runtime parameters, and export to XML
settings_file = openmc.SettingsFile()
# 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

View file

@ -187,7 +187,7 @@ class CMFDMesh(object):
return element
class CMFDFile(object):
class CMFD(object):
"""Parameters that control the use of coarse-mesh finite difference acceleration
in OpenMC. This corresponds directly to the cmfd.xml input file.

View file

@ -1,131 +1,103 @@
from __future__ import print_function
import subprocess
from numbers import Integral
import os
import sys
from openmc.checkvalue import check_type
if sys.version_info[0] >= 3:
basestring = str
class Executor(object):
"""Control execution of OpenMC
def _run(command, output, cwd):
# Launch a subprocess
p = subprocess.Popen(command, shell=True, cwd=cwd, stdout=subprocess.PIPE,
universal_newlines=True)
Attributes
# Capture and re-print OpenMC output in real-time
while True:
# If OpenMC is finished, break loop
line = p.stdout.readline()
if not line and p.poll() != None:
break
# If user requested output, print to screen
if output:
print(line, end='')
# Return the returncode (integer, zero if no problems encountered)
return p.returncode
def plot_geometry(output=True, openmc_exec='openmc', cwd='.'):
"""Run OpenMC in plotting mode
Parameters
----------
working_directory : str
Path to working directory to run in
output : bool
Capture OpenMC output from standard out
openmc_exec : str
Path to OpenMC executable
cwd : str, optional
Path to working directory to run in. Defaults to the current working directory.
"""
def __init__(self):
self._working_directory = '.'
return _run(openmc_exec + ' -p', output, cwd)
def _run_openmc(self, command, output):
# Launch a subprocess to run OpenMC
p = subprocess.Popen(command, shell=True,
cwd=self._working_directory,
stdout=subprocess.PIPE,
universal_newlines=True)
# Capture and re-print OpenMC output in real-time
while True:
# If OpenMC is finished, break loop
line = p.stdout.readline()
if not line and p.poll() != None:
break
def run(particles=None, threads=None, geometry_debug=False,
restart_file=None, tracks=False, mpi_procs=1, output=True,
openmc_exec='openmc', mpi_exec='mpiexec', cwd='.'):
"""Run an OpenMC simulation.
# If user requested output, print to screen
if output:
print(line, end='')
Parameters
----------
particles : int, optional
Number of particles to simulate per generation.
threads : int, optional
Number of OpenMP threads. If OpenMC is compiled with OpenMP threading
enabled, the default is implementation-dependent but is usually equal to
the number of hardware threads available (or a value set by the
OMP_NUM_THREADS environment variable).
geometry_debug : bool, optional
Turn on geometry debugging during simulation. Defaults to False.
restart_file : str, optional
Path to restart file to use
tracks : bool, optional
Write tracks for all particles. Defaults to False.
mpi_procs : int, optional
Number of MPI processes.
output : bool, optional
Capture OpenMC output from standard out. Defaults to True.
openmc_exec : str, optional
Path to OpenMC executable. Defaults to 'openmc'.
mpi_exec : str, optional
MPI execute command. Defaults to 'mpiexec'.
cwd : str, optional
Path to working directory to run in. Defaults to the current working directory.
# Return the returncode (integer, zero if no problems encountered)
return p.returncode
"""
@property
def working_directory(self):
return self._working_directory
post_args = ' '
pre_args = ''
@working_directory.setter
def working_directory(self, working_directory):
check_type("Executor's working directory", working_directory,
basestring)
if not os.path.isdir(working_directory):
msg = 'Unable to set Executor\'s working directory to "{0}" ' \
'which does not exist'.format(working_directory)
raise ValueError(msg)
if isinstance(particles, Integral) and particles > 0:
post_args += '-n {0} '.format(particles)
self._working_directory = working_directory
if isinstance(threads, Integral) and threads > 0:
post_args += '-s {0} '.format(threads)
def plot_geometry(self, output=True, openmc_exec='openmc'):
"""Run OpenMC in plotting mode"""
if geometry_debug:
post_args += '-g '
return self._run_openmc(openmc_exec + ' -p', output)
if isinstance(restart_file, basestring):
post_args += '-r {0} '.format(restart_file)
def run_simulation(self, particles=None, threads=None,
geometry_debug=False, restart_file=None,
tracks=False, mpi_procs=1, output=True,
openmc_exec='openmc', mpi_exec=None):
"""Run an OpenMC simulation.
if tracks:
post_args += '-t'
Parameters
----------
particles : int
Number of particles to simulate per generation
threads : int
Number of OpenMP threads
geometry_debug : bool
Turn on geometry debugging during simulation
restart_file : str
Path to restart file to use
tracks : bool
Write tracks for all particles
mpi_procs : int
Number of MPI processes
output : bool
Capture OpenMC output from standard out
openmc_exec : str
Path to OpenMC executable
if isinstance(mpi_procs, Integral) and mpi_procs > 1:
pre_args += '{} -n {} '.format(mpi_exec, mpi_procs)
"""
command = pre_args + openmc_exec + ' ' + post_args
post_args = ' '
pre_args = ''
if isinstance(particles, Integral) and particles > 0:
post_args += '-n {0} '.format(particles)
if isinstance(threads, Integral) and threads > 0:
post_args += '-s {0} '.format(threads)
if geometry_debug:
post_args += '-g '
if isinstance(restart_file, basestring):
post_args += '-r {0} '.format(restart_file)
if tracks:
post_args += '-t'
if isinstance(mpi_procs, Integral) and mpi_procs > 1:
np_present = True
else:
np_present = False
if mpi_exec is not None and isinstance(mpi_exec, basestring):
mpi_exec_present = True
else:
mpi_exec_present = False
if np_present or mpi_exec_present:
if mpi_exec_present:
pre_args += mpi_exec + ' '
else:
pre_args += 'mpirun '
pre_args += '-n {0} '.format(mpi_procs)
command = pre_args + openmc_exec + ' ' + post_args
return self._run_openmc(command, output)
return _run(command, output, cwd)

View file

@ -27,7 +27,8 @@ class Filter(object):
type : str
The type of the tally filter. Acceptable values are "universe",
"material", "cell", "cellborn", "surface", "mesh", "energy",
"energyout", and "distribcell".
"energyout", "distribcell", "mu", "polar", "azimuthal", and
"delayedgroup".
bins : Integral or Iterable of Integral or Iterable of Real
The bins for the filter. This takes on different meaning for different
filters. See the OpenMC online documentation for more details.

View file

@ -23,7 +23,6 @@ class Geometry(object):
"""
def __init__(self):
# Initialize Geometry class attributes
self._root_universe = None
self._offsets = {}
@ -42,6 +41,27 @@ class Geometry(object):
self._root_universe = root_universe
def export_to_xml(self):
"""Create a geometry.xml file that can be used for a simulation.
"""
# Clear OpenMC written IDs used to optimize XML generation
openmc.universe.WRITTEN_IDS = {}
# Create XML representation
geometry_file = ET.Element("geometry")
self.root_universe.create_xml_subelement(geometry_file)
# Clean the indentation in the file to be user-readable
sort_xml_elements(geometry_file)
clean_xml_indentation(geometry_file)
# Write the XML Tree to the geometry.xml file
tree = ET.ElementTree(geometry_file)
tree.write("geometry.xml", xml_declaration=True, encoding='utf-8',
method="xml")
def get_cell_instance(self, path):
"""Return the instance number for the final cell in a geometry path.
@ -436,52 +456,3 @@ class Geometry(object):
lattices = list(lattices)
lattices.sort(key=lambda x: x.id)
return lattices
class GeometryFile(object):
"""Geometry file used for an OpenMC simulation. Corresponds directly to the
geometry.xml input file.
Attributes
----------
geometry : openmc.Geometry
The geometry to be used
"""
def __init__(self):
# Initialize GeometryFile class attributes
self._geometry = None
self._geometry_file = ET.Element("geometry")
@property
def geometry(self):
return self._geometry
@geometry.setter
def geometry(self, geometry):
check_type('the geometry', geometry, Geometry)
self._geometry = geometry
def export_to_xml(self):
"""Create a geometry.xml file that can be used for a simulation.
"""
# Clear OpenMC written IDs used to optimize XML generation
openmc.universe.WRITTEN_IDS = {}
# Reset xml element tree
self._geometry_file.clear()
root_universe = self.geometry.root_universe
root_universe.create_xml_subelement(self._geometry_file)
# Clean the indentation in the file to be user-readable
sort_xml_elements(self._geometry_file)
clean_xml_indentation(self._geometry_file)
# Write the XML Tree to the geometry.xml file
tree = ET.ElementTree(self._geometry_file)
tree.write("geometry.xml", xml_declaration=True,
encoding='utf-8', method="xml")

View file

@ -7,7 +7,7 @@ import sys
import numpy as np
import openmc.checkvalue as cv
from openmc.universe import Universe, AUTO_UNIVERSE_ID
import openmc
if sys.version_info[0] >= 3:
basestring = str
@ -93,9 +93,8 @@ class Lattice(object):
@id.setter
def id(self, lattice_id):
if lattice_id is None:
global AUTO_UNIVERSE_ID
self._id = AUTO_UNIVERSE_ID
AUTO_UNIVERSE_ID += 1
self._id = openmc.universe.AUTO_UNIVERSE_ID
openmc.universe.AUTO_UNIVERSE_ID += 1
else:
cv.check_type('lattice ID', lattice_id, Integral)
cv.check_greater_than('lattice ID', lattice_id, 0, equality=True)
@ -111,12 +110,12 @@ class Lattice(object):
@outer.setter
def outer(self, outer):
cv.check_type('outer universe', outer, Universe)
cv.check_type('outer universe', outer, openmc.Universe)
self._outer = outer
@universes.setter
def universes(self, universes):
cv.check_iterable_type('lattice universes', universes, Universe,
cv.check_iterable_type('lattice universes', universes, openmc.Universe,
min_depth=2, max_depth=3)
self._universes = np.asarray(universes)
@ -127,20 +126,20 @@ class Lattice(object):
-------
universes : collections.OrderedDict
Dictionary whose keys are universe IDs and values are
:class:`Universe` instances
:class:`openmc.Universe` instances
"""
univs = OrderedDict()
for k in range(len(self._universes)):
for j in range(len(self._universes[k])):
if isinstance(self._universes[k][j], Universe):
if isinstance(self._universes[k][j], openmc.Universe):
u = self._universes[k][j]
univs[u._id] = u
else:
for i in range(len(self._universes[k][j])):
u = self._universes[k][j][i]
assert isinstance(u, Universe)
assert isinstance(u, openmc.Universe)
univs[u._id] = u
if self.outer is not None:
@ -615,10 +614,10 @@ class HexLattice(Lattice):
# clockwise fashion.
# Check to see if the given universes look like a 2D or a 3D array.
if isinstance(self._universes[0][0], Universe):
if isinstance(self._universes[0][0], openmc.Universe):
n_dims = 2
elif isinstance(self._universes[0][0][0], Universe):
elif isinstance(self._universes[0][0][0], openmc.Universe):
n_dims = 3
else:

View file

@ -25,9 +25,6 @@ def reset_auto_material_id():
DENSITY_UNITS = ['g/cm3', 'g/cc', 'kg/cm3', 'atom/b-cm', 'atom/cm3', 'sum',
'macro']
# Constant for density when not needed
NO_DENSITY = 99999.
class Material(object):
"""A material composed of a collection of nuclides/elements that can be
@ -141,9 +138,9 @@ class Material(object):
string += '{0: <16}\n'.format('\tElements')
for element in self._elements:
percent = self._nuclides[element][1]
percent_type = self._nuclides[element][2]
string += '{0: >16}'.format('\t{0}'.format(element))
percent = self._elements[element][1]
percent_type = self._elements[element][2]
string += '{0: <16}'.format('\t{0}'.format(element))
string += '=\t{0: <12} [{1}]\n'.format(percent, percent_type)
return string
@ -218,13 +215,13 @@ class Material(object):
else:
self._name = ''
def set_density(self, units, density=NO_DENSITY):
def set_density(self, units, density=None):
"""Set the density of the material
Parameters
----------
units : str
Physical units of density
units : {'g/cm3', 'g/cc', 'km/cm3', 'atom/b-cm', 'atom/cm3', 'sum', 'macro'}
Physical units of density.
density : float, optional
Value of the density. Must be specified unless units is given as
'sum'.
@ -235,8 +232,8 @@ class Material(object):
density, Real)
check_value('density units', units, DENSITY_UNITS)
if density == NO_DENSITY and units is not 'sum':
msg = 'Unable to set the density Material ID="{0}" ' \
if density is None and units is not 'sum':
msg = 'Unable to set the density for Material ID="{0}" ' \
'because a density must be set when not using ' \
'sum unit'.format(self._id)
raise ValueError(msg)
@ -274,7 +271,7 @@ class Material(object):
Nuclide to add
percent : float
Atom or weight percent
percent_type : str
percent_type : {'ao', 'wo'}
'ao' for atom percent and 'wo' for weight percent
"""
@ -394,7 +391,7 @@ class Material(object):
Element to add
percent : float
Atom or weight percent
percent_type : str
percent_type : {'ao', 'wo'}
'ao' for atom percent and 'wo' for weight percent
"""
@ -420,7 +417,10 @@ class Material(object):
raise ValueError(msg)
# Copy this Element to separate it from same Element in other Materials
element = deepcopy(element)
if isinstance(element, openmc.Element):
element = deepcopy(element)
else:
element = openmc.Element(element)
self._elements[element._name] = (element, percent, percent_type)
@ -498,7 +498,7 @@ class Material(object):
xml_element.set("name", nuclide[0]._name)
if not distrib:
if nuclide[2] is 'ao':
if nuclide[2] == 'ao':
xml_element.set("ao", str(nuclide[1]))
else:
xml_element.set("wo", str(nuclide[1]))
@ -525,11 +525,14 @@ class Material(object):
xml_element.set("name", str(element[0]._name))
if not distrib:
if element[2] is 'ao':
if element[2] == 'ao':
xml_element.set("ao", str(element[1]))
else:
xml_element.set("wo", str(element[1]))
if element[0].xs is not None:
xml_element.set("xs", element[0].xs)
if not element[0].scattering is None:
xml_element.set("scattering", element[0].scattering)
@ -639,9 +642,9 @@ class Material(object):
return element
class MaterialsFile(object):
"""Materials file used for an OpenMC simulation. Corresponds directly to the
materials.xml input file.
class Materials(object):
"""Collection of Materials used for an OpenMC simulation. Corresponds directly
to the materials.xml input file.
Attributes
----------
@ -652,7 +655,6 @@ class MaterialsFile(object):
"""
def __init__(self):
# Initialize MaterialsFile class attributes
self._materials = []
self._default_xs = None
self._materials_file = ET.Element("materials")
@ -678,7 +680,7 @@ class MaterialsFile(object):
if not isinstance(material, Material):
msg = 'Unable to add a non-Material "{0}" to the ' \
'MaterialsFile'.format(material)
'Materials instance'.format(material)
raise ValueError(msg)
self._materials.append(material)
@ -713,7 +715,7 @@ class MaterialsFile(object):
if not isinstance(material, Material):
msg = 'Unable to remove a non-Material "{0}" from the ' \
'MaterialsFile'.format(material)
'Materials instance'.format(material)
raise ValueError(msg)
self._materials.remove(material)

View file

@ -354,8 +354,8 @@ class Library(object):
Parameters
----------
tallies_file : openmc.TalliesFile
A TalliesFile object to add each MGXS' tallies to generate a
tallies_file : openmc.Tallies
A Tallies collection to add each MGXS' tallies to generate a
"tallies.xml" input file for OpenMC
merge : bool
Indicate whether tallies should be merged when possible. Defaults
@ -363,7 +363,7 @@ class Library(object):
"""
cv.check_type('tallies_file', tallies_file, openmc.TalliesFile)
cv.check_type('tallies_file', tallies_file, openmc.Tallies)
# Add tallies from each MGXS for each domain and mgxs type
for domain in self.domains:

View file

@ -412,7 +412,7 @@ class MGXS(object):
# Otherwise, return all nuclides in the spatial domain
else:
nuclides = self.domain.get_all_nuclides()
return nuclides.keys()
return list(nuclides.keys())
def get_nuclide_density(self, nuclide):
"""Get the atomic number density in units of atoms/b-cm for a nuclide

View file

@ -647,7 +647,7 @@ class XSdata(object):
return element
class MGXSLibraryFile(object):
class MGXSLibrary(object):
"""Multi-Group Cross Sections file used for an OpenMC simulation.
Corresponds directly to the MG version of the cross_sections.xml input file.
@ -662,7 +662,6 @@ class MGXSLibraryFile(object):
"""
def __init__(self, energy_groups):
# Initialize MGXSLibraryFile class attributes
self._xsdatas = []
self._energy_groups = energy_groups
self._inverse_velocities = None
@ -701,12 +700,12 @@ class MGXSLibraryFile(object):
# Check the type
if not isinstance(xsdata, XSdata):
msg = 'Unable to add a non-XSdata "{0}" to the ' \
'MGXSLibraryFile'.format(xsdata)
'MGXSLibrary instance'.format(xsdata)
raise ValueError(msg)
# Make sure energy groups match.
if xsdata.energy_groups != self._energy_groups:
msg = 'Energy groups of XSdata do not match that of MGXSLibraryFile!'
msg = 'Energy groups of XSdata do not match that of MGXSLibrary.'
raise ValueError(msg)
self._xsdatas.append(xsdata)
@ -741,7 +740,7 @@ class MGXSLibraryFile(object):
if not isinstance(xsdata, XSdata):
msg = 'Unable to remove a non-XSdata "{0}" from the ' \
'XSdatasFile'.format(xsdata)
'MGXSLibrary instance'.format(xsdata)
raise ValueError(msg)
self._xsdatas.remove(xsdata)

View file

@ -125,7 +125,7 @@ class Plot(object):
return self._background
@property
def mask_componenets(self):
def mask_components(self):
return self._mask_components
@property
@ -227,7 +227,7 @@ class Plot(object):
self._col_spec = col_spec
@mask_componenets.setter
@mask_components.setter
def mask_components(self, mask_components):
cv.check_type('plot mask_components', mask_components, Iterable, Integral)
for component in mask_components:
@ -401,14 +401,13 @@ class Plot(object):
return element
class PlotsFile(object):
"""Plots file used for an OpenMC simulation. Corresponds directly to the
plots.xml input file.
class Plots(object):
"""Collection of Plots used for an OpenMC simulation. Corresponds directly to
the plots.xml input file.
"""
def __init__(self):
# Initialize PlotsFile class attributes
self._plots = []
self._plots_file = ET.Element("plots")
@ -423,7 +422,7 @@ class PlotsFile(object):
"""
if not isinstance(plot, Plot):
msg = 'Unable to add a non-Plot "{0}" to the PlotsFile'.format(plot)
msg = 'Unable to add a non-Plot "{0}" to the Plots instance'.format(plot)
raise ValueError(msg)
self._plots.append(plot)

View file

@ -16,7 +16,7 @@ if sys.version_info[0] >= 3:
basestring = str
class SettingsFile(object):
class Settings(object):
"""Settings file used for an OpenMC simulation. Corresponds directly to the
settings.xml input file.

File diff suppressed because it is too large Load diff

View file

@ -3419,14 +3419,13 @@ class Tally(object):
return new_tally
class TalliesFile(object):
"""Tallies file used for an OpenMC simulation. Corresponds directly to the
tallies.xml input file.
class Tallies(object):
"""Collection of Tallies used for an OpenMC simulation. Corresponds directly to
the tallies.xml input file.
"""
def __init__(self):
# Initialize TalliesFile class attributes
self._tallies = []
self._meshes = []
self._tallies_file = ET.Element("tallies")
@ -3453,7 +3452,7 @@ class TalliesFile(object):
"""
if not isinstance(tally, Tally):
msg = 'Unable to add a non-Tally "{0}" to the TalliesFile'.format(tally)
msg = 'Unable to add a non-Tally "{0}" to the Tallies instance'.format(tally)
raise ValueError(msg)
if merge:
@ -3524,7 +3523,7 @@ class TalliesFile(object):
"""
if not isinstance(mesh, Mesh):
msg = 'Unable to add a non-Mesh "{0}" to the TalliesFile'.format(mesh)
msg = 'Unable to add a non-Mesh "{0}" to the Tallies instance'.format(mesh)
raise ValueError(msg)
self._meshes.append(mesh)

View file

@ -52,9 +52,9 @@ contains
! Write version information
write(UNIT=OUTPUT_UNIT, FMT=*) &
' Copyright: 2011-2015 Massachusetts Institute of Technology'
' Copyright: 2011-2016 Massachusetts Institute of Technology'
write(UNIT=OUTPUT_UNIT, FMT=*) &
' License: http://mit-crpg.github.io/openmc/license.html'
' License: http://openmc.readthedocs.org/en/latest/license.html'
write(UNIT=OUTPUT_UNIT, FMT='(6X,"Version:",8X,I1,".",I1,".",I1)') &
VERSION_MAJOR, VERSION_MINOR, VERSION_RELEASE
#ifdef GIT_SHA1

View file

@ -1,7 +1,7 @@
module simulation
#ifdef MPI
use mpi
use message_passing
#endif
use cmfd_execute, only: cmfd_init_batch, execute_cmfd

View file

@ -5,9 +5,9 @@ from openmc.stats import Box
class InputSet(object):
def __init__(self):
self.settings = openmc.SettingsFile()
self.materials = openmc.MaterialsFile()
self.geometry = openmc.GeometryFile()
self.settings = openmc.Settings()
self.materials = openmc.Materials()
self.geometry = openmc.Geometry()
self.tallies = None
self.plots = None
@ -550,11 +550,8 @@ class InputSet(object):
root.add_cells((c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12))
# Define the geometry file.
geometry = openmc.Geometry()
geometry.root_universe = root
self.geometry.geometry = geometry
# Assign root universe to geometry
self.geometry.root_universe = root
def build_default_settings(self):
self.settings.batches = 10
@ -630,12 +627,8 @@ class MGInputSet(InputSet):
root.add_cells((c1,c2,c3))
# Define the geometry file.
geometry = openmc.Geometry()
geometry.root_universe = root
self.geometry.geometry = geometry
# Assign root universe to geometry
self.geometry.root_universe = root
def build_default_settings(self):
self.settings.batches = 10
@ -656,8 +649,3 @@ class MGInputSet(InputSet):
plot.color = 'mat'
self.plots.add_plot(plot)

View file

@ -1 +1 @@
b9b4222c4beea80fe6083590f6b785303d174972d80671fb661bac8e030db6f4a61648240cfad6162799361fc0e08a23c61d31aff844d978528d6dad5b5fbc63
9b859eb5501c05b6a652d299bd0cadc0a924ffae31117babbdc9f7f8ca87689322c275818eb0dde0ff5fa78317d8d8f1585b18dcc772e3ff4ed499de8a491dc3

View file

@ -7,8 +7,6 @@ import hashlib
sys.path.insert(0, os.pardir)
from testing_harness import PyAPITestHarness
import openmc
from openmc.source import Source
from openmc.stats import Box
class AsymmetricLatticeTestHarness(PyAPITestHarness):
@ -20,7 +18,7 @@ class AsymmetricLatticeTestHarness(PyAPITestHarness):
self._input_set.build_default_materials_and_geometry()
# Extract universes encapsulating fuel and water assemblies
geometry = self._input_set.geometry.geometry
geometry = self._input_set.geometry
water = geometry.get_universes_by_name('water assembly (hot)')[0]
fuel = geometry.get_universes_by_name('fuel assembly (hot)')[0]
@ -49,7 +47,7 @@ class AsymmetricLatticeTestHarness(PyAPITestHarness):
root_univ.add_cell(root_cell)
# Over-ride geometry in the input set with this 3x3 lattice
self._input_set.geometry.geometry.root_universe = root_univ
self._input_set.geometry.root_universe = root_univ
# Initialize a "distribcell" filter for the fuel pin cell
distrib_filter = openmc.Filter(type='distribcell', bins=[27])
@ -60,7 +58,7 @@ class AsymmetricLatticeTestHarness(PyAPITestHarness):
tally.add_score('nu-fission')
# Initialize the tallies file
tallies_file = openmc.TalliesFile()
tallies_file = openmc.Tallies()
tallies_file.add_tally(tally)
# Assign the tallies file to the input set
@ -70,7 +68,7 @@ class AsymmetricLatticeTestHarness(PyAPITestHarness):
self._input_set.build_default_settings()
# Specify summary output and correct source sampling box
source = Source(space=Box([-32, -32, 0], [32, 32, 32]))
source = openmc.Source(space=openmc.stats.Box([-32, -32, 0], [32, 32, 32]))
source.space.only_fissionable = True
self._input_set.settings.source = source
self._input_set.settings.output = {'summary': True}

View file

@ -1 +1 @@
401b8be1b296db7f21ccae089c7ac480044d953b7264ca0ae8e34bb79e24cbb57195bcb568deda6f2f7e07366bbfac408a92306351b9169edd04499723707e1b
96c54eb4f1da175445bf2187449ee32c9ff435d8c60e9421a4a16497aae9f233e3e494f531892dd55f6ac1a06e0240799503ff19e14e2436a0b0f0d83ba56cb8

View file

@ -28,7 +28,7 @@ class DistribmatTestHarness(PyAPITestHarness):
light_fuel.set_density('g/cc', 2.0)
light_fuel.add_nuclide('U-235', 1.0)
mats_file = openmc.MaterialsFile()
mats_file = openmc.Materials()
mats_file.default_xs = '71c'
mats_file.add_materials([moderator, dense_fuel, light_fuel])
mats_file.export_to_xml()
@ -74,16 +74,14 @@ class DistribmatTestHarness(PyAPITestHarness):
geometry = openmc.Geometry()
geometry.root_universe = root_univ
geo_file = openmc.GeometryFile()
geo_file.geometry = geometry
geo_file.export_to_xml()
geometry.export_to_xml()
####################
# Settings
####################
sets_file = openmc.SettingsFile()
sets_file = openmc.Settings()
sets_file.batches = 5
sets_file.inactive = 0
sets_file.particles = 1000
@ -96,7 +94,7 @@ class DistribmatTestHarness(PyAPITestHarness):
# Plots
####################
plots_file = openmc.PlotsFile()
plots_file = openmc.Plots()
plot = openmc.Plot(plot_id=1)
plot.basis = 'xy'

View file

@ -1 +1 @@
e0409e0660d58857a6a96ff5cb539ccc41c82f0e443e8081ee00bbee7b6c81b0ad43c870950ae37d4a18c329067b09479a27aa171c3a3f5771f53b384496fe61
85faac9b8c725ec9242ebc3793b70dcd1c8e58aeb4296345aefd8031304263bd66eaad0c6f1c61a1c644b73f397699856ab3d76d2b397295176650b4069acc9e

View file

@ -1 +1 @@
04b4a5099f0097bbe02983c67dea691d0d0d4ece7fb7c264b9b2c29955baa9e870b6fa999480da08ead1e5a0c078ae33ce1b0a5c8594ad465aedf9bf3933e104
2fdba76bad058eec6e43657692ef759de79c934076067d4ec5c9f2bdb131877e001f67e16b16bb14889e5e0a1ba84c780979b9d6772573aa6f82d979774c2af8

View file

@ -1 +1 @@
abe20c626d613e73ccb1a3f8468ad1b9aecca528afa9e8131a411d754eb86b8ab64a6fb1fdc9c0b8b8158ff7c82f548de5912041bf035aa5a2d4532cfe0c9510
7f7465abaf559b3ef56cb6b0f28050c12f392f55db33dc5d2cefc14b92beb2c9068834c05273e51323d3516643e8a385e4c177a7a471678c961808d19055a30f

View file

@ -68,7 +68,7 @@ class MGNuclideInputSet(MGInputSet):
geometry = openmc.Geometry()
geometry.root_universe = root
self.geometry.geometry = geometry
self.geometry = geometry
class MGMaxOrderTestHarness(PyAPITestHarness):
def __init__(self, statepoint_name, tallies_present, mg=False):

View file

@ -1 +1 @@
c9f9e7211bfb2af58130bedfd64592d093b7bfa424953eba433ecf08940595a96b8de7a892f12d1ab465cebd8e5dd784114c1b1299b534ed329df92752c9ed1f
825dee3ca35d48788f1a4d5364789bbd83b36e33af9a990da758dd73c3bfcbee14bce2a41e6c80e0147f45575e59078653c8dfa8590cd361c09f19c26dc8c88e

View file

@ -67,7 +67,7 @@ class MGNuclideInputSet(MGInputSet):
geometry = openmc.Geometry()
geometry.root_universe = root
self.geometry.geometry = geometry
self.geometry = geometry
class MGNuclideTestHarness(PyAPITestHarness):
def __init__(self, statepoint_name, tallies_present, mg=False):

View file

@ -1 +1 @@
ca8490e0e4549fed727ddc75b6d92cfe5162e11b905218a0afaa3ce2ee0763e2ff38074de27aaa678818624f49c5823650475dfa8f66f502a98fc03145399c0d
6c437c3f9281c52a80a9b166971aa0f5db7ff8b6cf65c79b6d7bf294fad30cc7044f6a665cd9059f8580441bcbb581f7152ff5bccbc21fbcc407847ea6fe3306

View file

@ -41,7 +41,7 @@ class MGTalliesTestHarness(PyAPITestHarness):
tally2.add_score('scatter')
tally2.add_score('nu-scatter')
self._input_set.tallies = openmc.TalliesFile()
self._input_set.tallies = openmc.Tallies()
self._input_set.tallies.add_mesh(mesh)
self._input_set.tallies.add_tally(tally1)
self._input_set.tallies.add_tally(tally2)

View file

@ -1 +1 @@
53b1740921b71e4ead909ab9e4c25f7d43990fe7d7051fde6f66c39c0a6082177385640244010e1b9dbeaf5f34adf1627e9603088af729fadd6b589c19102edc
3e7b4ee62e0a53b92d4241f33493786532934f20ebcf47d92825bb1ee2f67c52aa8e7832cf28a9911221f802da205fba2b23c7228899780089da69e21042743c

View file

@ -23,7 +23,7 @@ class MGXSTestHarness(PyAPITestHarness):
energy_groups = openmc.mgxs.EnergyGroups(group_edges=[0, 0.625e-6, 20.])
# Initialize MGXS Library for a few cross section types
self.mgxs_lib = openmc.mgxs.Library(self._input_set.geometry.geometry)
self.mgxs_lib = openmc.mgxs.Library(self._input_set.geometry)
self.mgxs_lib.by_nuclide = False
self.mgxs_lib.mgxs_types = ['transport', 'nu-fission',
'nu-scatter matrix', 'chi']
@ -32,7 +32,7 @@ class MGXSTestHarness(PyAPITestHarness):
self.mgxs_lib.build_library()
# Initialize a tallies file
self._input_set.tallies = openmc.TalliesFile()
self._input_set.tallies = openmc.Tallies()
self.mgxs_lib.add_to_tallies_file(self._input_set.tallies, merge=False)
self._input_set.tallies.export_to_xml()

View file

@ -1 +1 @@
224a9e84e87c8a21385326d34ef27c046107d4a2ace6ee85d7a36142a3726e12532e2fc1a318ab707437e0b306a81c6d2b80c531d4c3210d4162242e6265ba70
2c078f650fed5fc241f42b2d7404fb7fae59d782102fad66b4cd2c8a4b1f266d64e8ce1ec0556117c2a2b1fe49aa583f340dc43df3ddc9320557aa97bb554c05

View file

@ -24,7 +24,7 @@ class MGXSTestHarness(PyAPITestHarness):
# Initialize MGXS Library for a few cross section types
# for one material-filled cell in the geometry
self.mgxs_lib = openmc.mgxs.Library(self._input_set.geometry.geometry)
self.mgxs_lib = openmc.mgxs.Library(self._input_set.geometry)
self.mgxs_lib.by_nuclide = False
self.mgxs_lib.mgxs_types = ['transport', 'nu-fission',
'nu-scatter matrix', 'chi']
@ -35,7 +35,7 @@ class MGXSTestHarness(PyAPITestHarness):
self.mgxs_lib.build_library()
# Initialize a tallies file
self._input_set.tallies = openmc.TalliesFile()
self._input_set.tallies = openmc.Tallies()
self.mgxs_lib.add_to_tallies_file(self._input_set.tallies, merge=False)
self._input_set.tallies.export_to_xml()

View file

@ -1 +1 @@
53b1740921b71e4ead909ab9e4c25f7d43990fe7d7051fde6f66c39c0a6082177385640244010e1b9dbeaf5f34adf1627e9603088af729fadd6b589c19102edc
3e7b4ee62e0a53b92d4241f33493786532934f20ebcf47d92825bb1ee2f67c52aa8e7832cf28a9911221f802da205fba2b23c7228899780089da69e21042743c

View file

@ -24,7 +24,7 @@ class MGXSTestHarness(PyAPITestHarness):
energy_groups = openmc.mgxs.EnergyGroups(group_edges=[0, 0.625e-6, 20.])
# Initialize MGXS Library for a few cross section types
self.mgxs_lib = openmc.mgxs.Library(self._input_set.geometry.geometry)
self.mgxs_lib = openmc.mgxs.Library(self._input_set.geometry)
self.mgxs_lib.by_nuclide = False
self.mgxs_lib.mgxs_types = ['transport', 'nu-fission',
'nu-scatter matrix', 'chi']
@ -33,7 +33,7 @@ class MGXSTestHarness(PyAPITestHarness):
self.mgxs_lib.build_library()
# Initialize a tallies file
self._input_set.tallies = openmc.TalliesFile()
self._input_set.tallies = openmc.Tallies()
self.mgxs_lib.add_to_tallies_file(self._input_set.tallies, merge=False)
self._input_set.tallies.export_to_xml()
@ -51,7 +51,7 @@ class MGXSTestHarness(PyAPITestHarness):
# Load the MGXS library from the statepoint
self.mgxs_lib.load_from_statepoint(sp)
# Export the MGXS Library to an HDF5 file
self.mgxs_lib.build_hdf5_store(directory='.')
@ -67,7 +67,7 @@ class MGXSTestHarness(PyAPITestHarness):
outstr += str(f[key][...]) + '\n'
key = 'material/{0}/{1}/std. dev.'.format(domain.id, mgxs_type)
outstr += str(f[key][...]) + '\n'
# Close the MGXS HDF5 file
f.close()

View file

@ -1 +1 @@
53b1740921b71e4ead909ab9e4c25f7d43990fe7d7051fde6f66c39c0a6082177385640244010e1b9dbeaf5f34adf1627e9603088af729fadd6b589c19102edc
3e7b4ee62e0a53b92d4241f33493786532934f20ebcf47d92825bb1ee2f67c52aa8e7832cf28a9911221f802da205fba2b23c7228899780089da69e21042743c

View file

@ -23,7 +23,7 @@ class MGXSTestHarness(PyAPITestHarness):
energy_groups = openmc.mgxs.EnergyGroups(group_edges=[0, 0.625e-6, 20.])
# Initialize MGXS Library for a few cross section types
self.mgxs_lib = openmc.mgxs.Library(self._input_set.geometry.geometry)
self.mgxs_lib = openmc.mgxs.Library(self._input_set.geometry)
self.mgxs_lib.by_nuclide = False
self.mgxs_lib.mgxs_types = ['transport', 'nu-fission',
'nu-scatter matrix', 'chi']
@ -32,7 +32,7 @@ class MGXSTestHarness(PyAPITestHarness):
self.mgxs_lib.build_library()
# Initialize a tallies file
self._input_set.tallies = openmc.TalliesFile()
self._input_set.tallies = openmc.Tallies()
self.mgxs_lib.add_to_tallies_file(self._input_set.tallies, merge=False)
self._input_set.tallies.export_to_xml()

View file

@ -1 +1 @@
c6a2a1c707bc723fd38bafd18efcfb22beaac0bd5953d7524ced1d47866cc1e1ee4152e39234d32a06fe43aff446fb12f8c5b62a44075607f274778b49110762
b035f783fa75ada619b0a58675913e318fef94e519c85cae6982f650d7655cb130f625572fde2058e005b490359180cb9d1e1095f5d35d41c9a0f8ff6e0dc3c1

View file

@ -23,7 +23,7 @@ class MGXSTestHarness(PyAPITestHarness):
energy_groups = openmc.mgxs.EnergyGroups(group_edges=[0, 0.625e-6, 20.])
# Initialize MGXS Library for a few cross section types
self.mgxs_lib = openmc.mgxs.Library(self._input_set.geometry.geometry)
self.mgxs_lib = openmc.mgxs.Library(self._input_set.geometry)
self.mgxs_lib.by_nuclide = True
self.mgxs_lib.mgxs_types = ['transport', 'nu-fission',
'nu-scatter matrix', 'chi']
@ -32,7 +32,7 @@ class MGXSTestHarness(PyAPITestHarness):
self.mgxs_lib.build_library()
# Initialize a tallies file
self._input_set.tallies = openmc.TalliesFile()
self._input_set.tallies = openmc.Tallies()
self.mgxs_lib.add_to_tallies_file(self._input_set.tallies, merge=False)
self._input_set.tallies.export_to_xml()

View file

@ -9,7 +9,7 @@ from testing_harness import TestHarness
import h5py
from openmc import Executor
import openmc
class PlotTestHarness(TestHarness):
@ -19,8 +19,7 @@ class PlotTestHarness(TestHarness):
self._plot_names = plot_names
def _run_openmc(self):
executor = Executor()
returncode = executor.plot_geometry(openmc_exec=self._opts.exe)
returncode = openmc.plot_geometry(openmc_exec=self._opts.exe)
assert returncode == 0, 'OpenMC did not exit successfully.'
def _test_output_created(self):

View file

@ -17,7 +17,7 @@ class ResonanceScatteringTestHarness(PyAPITestHarness):
mat.add_nuclide('Pu-239', 0.02)
mat.add_nuclide('H-1', 20.0)
mats_file = openmc.MaterialsFile()
mats_file = openmc.Materials()
mats_file.default_xs = '71c'
mats_file.add_material(mat)
mats_file.export_to_xml()
@ -35,9 +35,7 @@ class ResonanceScatteringTestHarness(PyAPITestHarness):
geometry = openmc.Geometry()
geometry.root_universe = root_univ
geo_file = openmc.GeometryFile()
geo_file.geometry = geometry
geo_file.export_to_xml()
geometry.export_to_xml()
# Settings
nuclide = openmc.Nuclide('U-238', '71c')
@ -67,7 +65,7 @@ class ResonanceScatteringTestHarness(PyAPITestHarness):
res_scatt_ares.E_min = 1e-6
res_scatt_ares.E_max = 210e-6
sets_file = openmc.SettingsFile()
sets_file = openmc.Settings()
sets_file.batches = 10
sets_file.inactive = 5
sets_file.particles = 1000

View file

@ -9,8 +9,6 @@ import numpy as np
sys.path.insert(0, os.pardir)
from testing_harness import PyAPITestHarness
import openmc
import openmc.stats
from openmc.source import Source
class SourceTestHarness(PyAPITestHarness):
@ -18,7 +16,7 @@ class SourceTestHarness(PyAPITestHarness):
mat1 = openmc.Material(material_id=1)
mat1.set_density('g/cm3', 4.5)
mat1.add_nuclide(openmc.Nuclide('U-235', '71c'), 1.0)
materials = openmc.MaterialsFile()
materials = openmc.Materials()
materials.add_material(mat1)
materials.export_to_xml()
@ -31,9 +29,7 @@ class SourceTestHarness(PyAPITestHarness):
root.add_cell(inside_sphere)
geometry = openmc.Geometry()
geometry.root_universe = root
geometry_xml = openmc.GeometryFile()
geometry_xml.geometry = geometry
geometry_xml.export_to_xml()
geometry.export_to_xml()
# Create an array of different sources
x_dist = openmc.stats.Uniform(-3., 3.)
@ -56,11 +52,11 @@ class SourceTestHarness(PyAPITestHarness):
energy2 = openmc.stats.Watt(0.988, 2.249)
energy3 = openmc.stats.Tabular(E, p, interpolation='histogram')
source1 = Source(spatial1, angle1, energy1, strength=0.5)
source2 = Source(spatial2, angle2, energy2, strength=0.3)
source3 = Source(spatial3, angle3, energy3, strength=0.2)
source1 = openmc.Source(spatial1, angle1, energy1, strength=0.5)
source2 = openmc.Source(spatial2, angle2, energy2, strength=0.3)
source3 = openmc.Source(spatial3, angle3, energy3, strength=0.2)
settings = openmc.SettingsFile()
settings = openmc.Settings()
settings.batches = 10
settings.inactive = 5
settings.particles = 1000

View file

@ -5,8 +5,7 @@ import os
import sys
sys.path.insert(0, os.pardir)
from testing_harness import TestHarness
from openmc.statepoint import StatePoint
from openmc.executor import Executor
import openmc
class StatepointRestartTestHarness(TestHarness):
@ -50,17 +49,15 @@ class StatepointRestartTestHarness(TestHarness):
statepoint = statepoint[0]
# Run OpenMC
executor = Executor()
if self._opts.mpi_exec is not None:
returncode = executor.run_simulation(mpi_procs=self._opts.mpi_np,
restart_file=statepoint,
openmc_exec=self._opts.exe,
mpi_exec=self._opts.mpi_exec)
returncode = openmc.run(mpi_procs=self._opts.mpi_np,
restart_file=statepoint,
openmc_exec=self._opts.exe,
mpi_exec=self._opts.mpi_exec)
else:
returncode = executor.run_simulation(openmc_exec=self._opts.exe,
restart_file=statepoint)
returncode = openmc.run(openmc_exec=self._opts.exe,
restart_file=statepoint)
assert returncode == 0, 'OpenMC did not exit successfully.'

View file

@ -1 +1 @@
5e168146d91b7b5fadecb80a32df9edc906718fb2d70b68b4c18dbed0641739251a1c16177c9f4d47516dfd528ec930879534292ff0eb82af89eca2c3fa4a3e0
0597eff3fddbc45a09b5b324c9704e540b694b07c136f2040426fdcfe5ec544f036073e4afa34a5fb0fbd721a4c0a609b9b68bf17ce4ec78302023b46b71930c

View file

@ -4,7 +4,7 @@ import os
import sys
sys.path.insert(0, os.pardir)
from testing_harness import PyAPITestHarness
from openmc import Filter, Mesh, Tally, TalliesFile
from openmc import Filter, Mesh, Tally, Tallies
from openmc.source import Source
from openmc.stats import Box
@ -170,7 +170,7 @@ class TalliesTestHarness(PyAPITestHarness):
all_nuclide_tallies[0].estimator = 'tracklength'
all_nuclide_tallies[0].estimator = 'collision'
self._input_set.tallies = TalliesFile()
self._input_set.tallies = Tallies()
self._input_set.tallies.add_tally(azimuthal_tally1)
self._input_set.tallies.add_tally(azimuthal_tally2)
self._input_set.tallies.add_tally(azimuthal_tally3)

View file

@ -1 +1 @@
530a5e969901e153531f74aed46246b1e8783a0e2f347e472f7554c9970152f45d85499f17d7df9c35c74fed6f78d449aa70bf0c1f8947cd34d3a829483a0055
f819f1b3564ca1df1e235f120f4bd65003cd80935fa8261f0a5982b7e7ec5b2e7497716673c142fab99f3fb26c174ac7a12e145b9a6f2caf707d2a07702f6eb2

View file

@ -16,7 +16,7 @@ class TallyAggregationTestHarness(PyAPITestHarness):
self._input_set.settings.output = {'summary': True}
# Initialize the tallies file
tallies_file = openmc.TalliesFile()
tallies_file = openmc.Tallies()
# Initialize the nuclides
u235 = openmc.Nuclide('U-235')

View file

@ -1 +1 @@
57384883e37964076aa82c19fa542434331cdb09735d710485b5aa0ca3445d543729e40cb9c7b6a70e7101ef186923eb1ff6315c73b01ff257052838add68fc7
bb7e730630f7bb4694a27fd77c3c0171f70c78df2681acc26b0ef88bcff367523b11335f487b46269325adbcee7faeb756484af64055c3c91b0103f7ed962053

View file

@ -16,7 +16,7 @@ class TallyArithmeticTestHarness(PyAPITestHarness):
self._input_set.settings.output = {'summary': True}
# Initialize the tallies file
tallies_file = openmc.TalliesFile()
tallies_file = openmc.Tallies()
# Initialize the nuclides
u235 = openmc.Nuclide('U-235')

View file

@ -1 +1 @@
8d1ab9e4add51b99045e990ac9c3dad9447e9720d811bc430d4bfdd7c2c035424bcb7750e4a4d0ec0460ea1ef4be46ac58372ed01d55f5d8cfeebbce75559066
bb4ae3b75445846bd5db05a06cc20e7589990154ccef8302f276cd8356630d585c513ebb6bfa99f9fc93dd2d30c42bfbb67dd3454134f4c9fcb3bac128d1f1c5

View file

@ -17,7 +17,7 @@ class TallySliceMergeTestHarness(PyAPITestHarness):
self._input_set.settings.output = {'summary': True}
# Initialize the tallies file
tallies_file = openmc.TalliesFile()
tallies_file = openmc.Tallies()
# Define nuclides and scores to add to both tallies
self.nuclides = ['U-235', 'U-238']
@ -69,8 +69,8 @@ class TallySliceMergeTestHarness(PyAPITestHarness):
for nuclide in self.nuclides:
distribcell_tally.add_nuclide(nuclide)
# Add tallies to a TalliesFile
tallies_file = openmc.TalliesFile()
# Add tallies to a Tallies object
tallies_file = openmc.Tallies()
tallies_file.add_tally(tallies[0])
tallies_file.add_tally(distribcell_tally)
@ -95,7 +95,7 @@ class TallySliceMergeTestHarness(PyAPITestHarness):
# Slice the tallies by cell filter bins
cell_filter_prod = itertools.product(tallies, self.cell_filters)
tallies = map(lambda tf: tf[0].get_slice(filters=[tf[1].type],
tallies = map(lambda tf: tf[0].get_slice(filters=[tf[1].type],
filter_bins=[tf[1].get_bin(0)]), cell_filter_prod)
# Slice the tallies by energy filter bins
@ -133,11 +133,11 @@ class TallySliceMergeTestHarness(PyAPITestHarness):
# Extract the distribcell tally
distribcell_tally = sp.get_tally(name='distribcell tally')
# Sum up a few subdomains from the distribcell tally
sum1 = distribcell_tally.summation(filter_type='distribcell',
# Sum up a few subdomains from the distribcell tally
sum1 = distribcell_tally.summation(filter_type='distribcell',
filter_bins=[0,100,2000,30000])
# Sum up a few subdomains from the distribcell tally
sum2 = distribcell_tally.summation(filter_type='distribcell',
sum2 = distribcell_tally.summation(filter_type='distribcell',
filter_bins=[500,5000,50000])
# Merge the distribcell tally slices

View file

@ -13,9 +13,7 @@ import numpy as np
sys.path.insert(0, os.path.join(os.pardir, os.pardir))
from input_set import InputSet, MGInputSet
from openmc.statepoint import StatePoint
from openmc.executor import Executor
import openmc.particle_restart as pr
import openmc
class TestHarness(object):
@ -63,15 +61,13 @@ class TestHarness(object):
self._cleanup()
def _run_openmc(self):
executor = Executor()
if self._opts.mpi_exec is not None:
returncode = executor.run_simulation(mpi_procs=self._opts.mpi_np,
openmc_exec=self._opts.exe,
mpi_exec=self._opts.mpi_exec)
returncode = openmc.run(mpi_procs=self._opts.mpi_np,
openmc_exec=self._opts.exe,
mpi_exec=self._opts.mpi_exec)
else:
returncode = executor.run_simulation(openmc_exec=self._opts.exe)
returncode = openmc.run(openmc_exec=self._opts.exe)
assert returncode == 0, 'OpenMC did not exit successfully.'
@ -90,7 +86,7 @@ class TestHarness(object):
"""Digest info in the statepoint and return as a string."""
# Read the statepoint file.
statepoint = glob.glob(os.path.join(os.getcwd(), self._sp_name))[0]
sp = StatePoint(statepoint)
sp = openmc.StatePoint(statepoint)
# Write out k-combined.
outstr = 'k-combined:\n'
@ -158,7 +154,7 @@ class CMFDTestHarness(TestHarness):
"""Digest info in the statepoint and return as a string."""
# Read the statepoint file.
statepoint = glob.glob(os.path.join(os.getcwd(), self._sp_name))[0]
sp = StatePoint(statepoint)
sp = openmc.StatePoint(statepoint)
# Write out the eigenvalue and tallies.
outstr = super(CMFDTestHarness, self)._get_results()
@ -195,13 +191,12 @@ class ParticleRestartTestHarness(TestHarness):
'mpi_exec': self._opts.mpi_exec})
# Initial run
executor = Executor()
returncode = executor.run_simulation(**args)
returncode = openmc.run(**args)
assert returncode == 0, 'OpenMC did not exit successfully.'
# Run particle restart
args.update({'restart_file': self._sp_name})
returncode = executor.run_simulation(**args)
returncode = openmc.run(**args)
assert returncode == 0, 'OpenMC did not exit successfully.'
def _test_output_created(self):
@ -216,7 +211,7 @@ class ParticleRestartTestHarness(TestHarness):
"""Digest info in the statepoint and return as a string."""
# Read the particle restart file.
particle = glob.glob(os.path.join(os.getcwd(), self._sp_name))[0]
p = pr.Particle(particle)
p = openmc.Particle(particle)
# Write out the properties.
outstr = ''