From 8e8d5e0478efd90ee21115c45d78874208ddc0f7 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Mon, 24 Feb 2020 19:53:46 -0600 Subject: [PATCH] Documentation updates --- docs/source/io_formats/settings.rst | 23 +++++++++++----------- examples/xml/custom_source/source_ring.cpp | 3 ++- openmc/source.py | 18 ++++++++++------- 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/docs/source/io_formats/settings.rst b/docs/source/io_formats/settings.rst index 28754e7163..83aa0691f4 100644 --- a/docs/source/io_formats/settings.rst +++ b/docs/source/io_formats/settings.rst @@ -460,13 +460,13 @@ attributes/sub-elements: *Default*: None :library: - If this attribute is given, it indicates that the source is to be instanciated - from an externally compiled source function. This source can be as complex as - is required to define the source for your problem. The only requirement that - is made upon this source, is that there is a function called sample_source() - more documentation on how to build sources can be found in :ref:`custom_source` + If this attribute is given, it indicates that the source is to be + instantiated from an externally compiled source function. This source can be + as complex as is required to define the source for your problem. The only + requirement is that there is a function called ``sample_source()``. More + documentation on how to build sources can be found in :ref:`custom_source`. - *Deafult*: None + *Default*: None :space: An element specifying the spatial distribution of source sites. This element @@ -645,8 +645,8 @@ more complicated sources. .. note:: You should only use the openmc::prn() random number generator -In order to build your external source you need the following CMakeLists.txt -file +In order to build your external source, you will need to link it against the +OpenMC shared library. This can be done by writing a CMakeLists.txt file: .. code-block:: cmake @@ -656,9 +656,10 @@ file find_package(OpenMC REQUIRED HINTS ) target_link_libraries(source OpenMC::libopenmc) -You will now have a libsource.so (or .dylib) file in this directory, now point -the library attribute of the source XML element to this file and you will be -able to sample particles. +After running ``cmake`` and ``make``, you will have a libsource.so (or .dylib) +file in your build directory. Setting the :attr:`openmc.Source.library` +attribute to the path of this shared library will indicate that it should be +used for sampling source particles at runtime. .. _univariate: diff --git a/examples/xml/custom_source/source_ring.cpp b/examples/xml/custom_source/source_ring.cpp index 0feb287022..d68122dd75 100644 --- a/examples/xml/custom_source/source_ring.cpp +++ b/examples/xml/custom_source/source_ring.cpp @@ -1,4 +1,5 @@ -#include +#include // for M_PI + #include "openmc/random_lcg.h" #include "openmc/source.h" #include "openmc/particle.h" diff --git a/openmc/source.py b/openmc/source.py index 339d41723e..7b709321f1 100644 --- a/openmc/source.py +++ b/openmc/source.py @@ -8,20 +8,22 @@ from openmc.stats.multivariate import UnitSphere, Spatial import openmc.checkvalue as cv -class Source(object): +class Source: """Distribution of phase space coordinates for source sites. Parameters ---------- - space : openmc.stats.Spatial, optional + space : openmc.stats.Spatial Spatial distribution of source sites - angle : openmc.stats.UnitSphere, optional + angle : openmc.stats.UnitSphere Angular distribution of source sites - energy : openmc.stats.Univariate, optional + energy : openmc.stats.Univariate Energy distribution of source sites - filename : str, optional + filename : str Source file from which sites should be sampled - strength : Real + library : str + Path to a custom source library + strength : float Strength of the source particle : {'neutron', 'photon'} Source particle type @@ -36,7 +38,9 @@ class Source(object): Energy distribution of source sites file : str or None Source file from which sites should be sampled - strength : Real + library : str or None + Path to a custom source library + strength : float Strength of the source particle : {'neutron', 'photon'} Source particle type