From b546aeafd8efd02ffcc46d112e0ee9e7b2cc6f9d Mon Sep 17 00:00:00 2001 From: andrewjohnson Date: Wed, 7 Mar 2018 11:30:24 -0500 Subject: [PATCH] Added some documentation on the samplers --- docs/api/sampler.rst | 40 +++++++++++++++++++++++++-- docs/welcome/about.rst | 2 ++ serpentTools/objects/materials.py | 3 +- serpentTools/samplers/depletion.py | 6 ++-- serpentTools/tests/__init__.py | 9 ------ serpentTools/tests/test_depSampler.py | 13 +++++++++ serpentTools/tests/test_detSampler.py | 22 ++++++++++----- 7 files changed, 72 insertions(+), 23 deletions(-) diff --git a/docs/api/sampler.rst b/docs/api/sampler.rst index 62523b49..ba0400c4 100644 --- a/docs/api/sampler.rst +++ b/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 diff --git a/docs/welcome/about.rst b/docs/welcome/about.rst index 460cb945..03f31f10 100644 --- a/docs/welcome/about.rst +++ b/docs/welcome/about.rst @@ -1,3 +1,5 @@ +.. _welcome: + ============= serpent-tools ============= diff --git a/serpentTools/objects/materials.py b/serpentTools/objects/materials.py index 0e80af95..de99445f 100644 --- a/serpentTools/objects/materials.py +++ b/serpentTools/objects/materials.py @@ -179,7 +179,6 @@ def _getRowIndices(self, isotopes): class DepletedMaterial(DepletedMaterialBase): - __doc__ = DepletedMaterialBase.__doc__ def addData(self, variable, rawData): @@ -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. diff --git a/serpentTools/samplers/depletion.py b/serpentTools/samplers/depletion.py index 6b95e25e..ba87d77b 100644 --- a/serpentTools/samplers/depletion.py +++ b/serpentTools/samplers/depletion.py @@ -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 ---------- @@ -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` """ diff --git a/serpentTools/tests/__init__.py b/serpentTools/tests/__init__.py index dd39814d..783a0f5f 100644 --- a/serpentTools/tests/__init__.py +++ b/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 diff --git a/serpentTools/tests/test_depSampler.py b/serpentTools/tests/test_depSampler.py index 03605c24..cd79edc9 100644 --- a/serpentTools/tests/test_depSampler.py +++ b/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 diff --git a/serpentTools/tests/test_detSampler.py b/serpentTools/tests/test_detSampler.py index 923d83e6..5b7be76b 100644 --- a/serpentTools/tests/test_detSampler.py +++ b/serpentTools/tests/test_detSampler.py @@ -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