Skip to content

Commit

Permalink
Fix volume calculation IO format docs and sample_external_source bug (
Browse files Browse the repository at this point in the history
  • Loading branch information
paulromano committed Sep 27, 2023
1 parent f7bb27e commit fd91729
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 8 deletions.
47 changes: 39 additions & 8 deletions docs/source/io_formats/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1068,8 +1068,14 @@ The ``<volume_calc>`` element indicates that a stochastic volume calculation
should be run at the beginning of the simulation. This element has the following
sub-elements/attributes:

:cells:
The unique IDs of cells for which the volume should be estimated.
:domain_type:
The type of each domain for the volume calculation ("cell", "material", or
"universe").

*Default*: None

:domain_ids:
The unique IDs of domains for which the volume should be estimated.

*Default*: None

Expand All @@ -1079,16 +1085,41 @@ sub-elements/attributes:
*Default*: None

:lower_left:
The lower-left Cartesian coordinates of a bounding box that is used to
sample points within.
The lower-left Cartesian coordinates of a bounding box that is used to
sample points within.

*Default*: None
*Default*: None

:upper_right:
The upper-right Cartesian coordinates of a bounding box that is used to
sample points within.
The upper-right Cartesian coordinates of a bounding box that is used to
sample points within.

*Default*: None
*Default*: None

:threshold:
Presence of a ``<threshold>`` sub-element indicates that the volume
calculation will be halted based on a threshold on the error. It has the
following sub-elements/attributes:

:type:
The type of the trigger. Accepted options are "variance", "std_dev",
and "rel_err".

:variance:
Variance of the mean, :math:`\sigma^2`

:std_dev:
Standard deviation of the mean, :math:`\sigma`

:rel_err:
Relative error of the mean, :math:`\frac{\sigma}{\mu}`

*Default*: None

:threshold:
The trigger's convergence criterion for the given type.

*Default*: None

----------------------------
``<weight_windows>`` Element
Expand Down
5 changes: 5 additions & 0 deletions src/source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,11 @@ extern "C" int openmc_sample_external_source(
return OPENMC_E_INVALID_ARGUMENT;
}

if (model::external_sources.empty()) {
set_errmsg("No external sources have been defined.");
return OPENMC_E_OUT_OF_BOUNDS;
}

auto sites_array = static_cast<SourceSite*>(sites);
for (size_t i = 0; i < n; ++i) {
sites_array[i] = sample_external_source(seed);
Expand Down

0 comments on commit fd91729

Please sign in to comment.