Skip to content

Commit

Permalink
Added some documentation on the samplers
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewjohnson committed Mar 7, 2018
1 parent 342e4b0 commit b546aea
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 23 deletions.
40 changes: 38 additions & 2 deletions docs/api/sampler.rst
@@ -1,16 +1,52 @@
.. |serpentTools| replace:: :ref:`welcome`

.. |depletion| replace:: :ref:`depletion`

.. |detector| replace:: :ref:`detector-reader`

.. |sampler| replace:: :py:class:`~serpentTools.samplers.Sampler`

.. |detector-container| replace:: :py:class:`~serpentTools.objects.containers.Detector`

.. _samplerAPI:

Samplers
========

.. autoclass:: serpentTools.samplers.Sampler
A common practice in Monte Carlo analysis is repeat a single case
with a variety of new random number seeds.
Averaging the results from these runs reduces the impact of stochastic
uncertainty and can give a better picture of the *true* behavior of a
system. The |serpentTools| package supports reading multiple output
files of a common type and obtaining average values and associated
uncertainties, while retaining data structure and retrieval
methods similar to the single file cases.

.. autoclass:: serpentTools.samplers.SampledContainer

Detector Sampler
----------------

This sampler extends the |sampler| class for reading detector files.

.. autoclass:: serpentTools.samplers.detector.DetectorSampler

.. autoclass:: serpentTools.samplers.detector.SampledDetector

DepletionSampler
----------------

This sampler extends the |sampler| class for reading depletion files.

.. autoclass:: serpentTools.samplers.depletion.DepletionSampler

.. autoclass:: serpentTools.samplers.depletion.SampledDepletedMaterial


.. _sampler::

Base Classes
------------

.. autoclass:: serpentTools.samplers.Sampler

.. autoclass:: serpentTools.samplers.SampledContainer
2 changes: 2 additions & 0 deletions docs/welcome/about.rst
@@ -1,3 +1,5 @@
.. _welcome:

=============
serpent-tools
=============
Expand Down
3 changes: 1 addition & 2 deletions serpentTools/objects/materials.py
Expand Up @@ -179,7 +179,6 @@ def _getRowIndices(self, isotopes):


class DepletedMaterial(DepletedMaterialBase):

__doc__ = DepletedMaterialBase.__doc__

def addData(self, variable, rawData):
Expand All @@ -205,7 +204,7 @@ def addData(self, variable, rawData):
self.data[newName] = numpy.array(scratch)

def plot(self, xUnits, yUnits, timePoints=None, names=None, ax=None,
autolabel=True,legend=True, xlabel=None, ylabel=None, **kwargs):
autolabel=True, legend=True, xlabel=None, ylabel=None, **kwargs):
"""
Plot some data as a function of time for some or all isotopes.
Expand Down
6 changes: 3 additions & 3 deletions serpentTools/samplers/depletion.py
Expand Up @@ -132,12 +132,12 @@ class SampledDepletedMaterial(SampledContainer, DepletedMaterialBase):
__doc__ = """
Class that stores data from a variety of depleted materials
{equiv:s}
.. note ::
:py:func:`~serpentTools.samplers.depletion.SampledDepletedMaterial.free`
sets ``allData`` to an empty dictionary {free:s}
{equiv:s}
Parameters
----------
Expand Down Expand Up @@ -241,7 +241,7 @@ def plot(self, xUnits, yUnits, timePoints=None, names=None, ax=None,
See Also
--------
* :py:func:`~serpentTools.objects.materials.DepletedMaterialBase.getValues
* :py:meth:`~serpentTools.objects.materials.DepletedMaterialBase.getValues`
* :py:func:`matplotlib.pyplot.errorbar`
"""
Expand Down
9 changes: 0 additions & 9 deletions serpentTools/tests/__init__.py
@@ -1,14 +1,5 @@
"""
Module for testing the ``serpentTools`` package
.. note::
The relative error tolerances must be low, :math:`O(1)`, because the
error values themselves are incredibly low. In writing these tests,
a relative error of 1E-2 resulted in a 5% difference between
error quantities, which are all :math:`O(1E-3)`. A tight absolute
tolerance can still be achieved.
"""
from os import path

Expand Down
13 changes: 13 additions & 0 deletions serpentTools/tests/test_depSampler.py
@@ -1,5 +1,18 @@
"""
Class for testing the DepletionSampler
File Descriptions
-----------------
*. ``bwr_0`` and ``bwr_1`` are identical input files with
different seeds. The detectors are defined exactly the same.
*. ``bwr_badInventory`` has a different nuclide inventory
than ``bwr_0``, which would create data matrices such as ``adens``
of different sizes, breaking the sampling routines
*. ``bwr_longT`` has a much longer final burn step, but equal number
of burnup steps.
*. ``bwr_missingT`` is missing the final burnup step
"""
import unittest
from os import path
Expand Down
22 changes: 15 additions & 7 deletions serpentTools/tests/test_detSampler.py
Expand Up @@ -4,13 +4,21 @@
File Descriptions
-----------------
*. ``bwr_0_det0.m`` and ``bwr_1_det0.m`` are identical input files with
different seeds. The detectors are defined exactly the same.
*. ``bwr_noxy_det0.m`` is the same file as ``bwr_0_det0.m`` with the
``xymesh`` detector completely removed. All spatial and energy grid
data is removed from this file as well
*. ``bwr_smallxy_det0.m`` has the same detector definitions as
``bwr_0_det0.m``, except the spatial grid for ``xymesh`` is smaller.
*. ``bwr_0`` and ``bwr_1`` are identical input files with
different seeds. The detectors are defined exactly the same.
*. ``bwr_noxy`` is the same file as ``bwr_0`` with the
``xymesh`` detector completely removed. All spatial and energy grid
data is removed from this file as well
*. ``bwr_smallxy`` has the same detector definitions as
``bwr_0``, except the spatial grid for ``xymesh`` is smaller.
.. note::
The relative error tolerances must be low, :math:`O(1)`, because the
absolute error values themselves are low. In writing these tests,
a relative error of 1E-2 resulted in a 5% difference between
error quantities, which are all :math:`O(1E-3)`. A tight absolute
tolerance can still be achieved.
"""
from math import sqrt
Expand Down

0 comments on commit b546aea

Please sign in to comment.