Add subdivide convenience function

This commit is contained in:
Paul Romano 2017-11-09 15:53:57 -06:00
parent 671db024db
commit 198df07311
5 changed files with 41 additions and 5 deletions

View file

@ -40,13 +40,13 @@ Modules
-------
.. toctree::
:maxdepth: 2
:maxdepth: 1
base
stats
mgxs
model
examples
mgxs
stats
data
capi
examples
openmoc

View file

@ -2,6 +2,16 @@
:mod:`openmc.model` -- Model Building
-------------------------------------
Convenience Functions
---------------------
.. autosummary::
:toctree: generated
:nosignatures:
:template: myfunction.rst
openmc.model.subdivide
TRISO Fuel Modeling
-------------------

View file

@ -17,7 +17,6 @@ class _Bank(Structure):
('delayed_group', c_int)]
_dll.openmc_calculate_volumes.restype = None
_dll.openmc_finalize.restype = None
_dll.openmc_find.argtypes = [POINTER(c_double*3), c_int, POINTER(c_int32),
@ -168,6 +167,7 @@ def keff():
_dll.openmc_get_keff(k)
return tuple(k)
def next_batch():
"""Run next batch."""
return _dll.openmc_next_batch()

View file

@ -1,2 +1,3 @@
from .triso import *
from .model import *
from .funcs import *

25
openmc/model/funcs.py Normal file
View file

@ -0,0 +1,25 @@
def subdivide(surfaces):
"""Create regions separated by a series of surfaces.
This function allows regions to be constructed from a set of a surfaces that
are "in order". For example, if you had four instances of
:class:`openmc.ZPlane` at z=-10, z=-5, z=5, and z=10, this function would
return a list of regions corresponding to z < -10, -10 < z < -5, -5 < z < 5,
5 < z < 10, and 10 < z. That is, for n surfaces, n+1 regions are returned.
Parameters
----------
surfaces : sequence of openmc.Surface
Surfaces separating regions
Returns
-------
list of openmc.Region
Regions formed by the given surfaces
"""
regions = [-surfaces[0]]
for s0, s1 in zip(surfaces[:-1], surfaces[1:]):
regions.append(+s0 & -s1)
regions.append(+surfaces[-1])
return regions