Skip to content

Commit c423a76

Browse files
GuyStenclaudepaulromano
authored
Deprecate surf_source_read in favor of a file source (#4123)
Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
1 parent 5fd7e39 commit c423a76

5 files changed

Lines changed: 28 additions & 3 deletions

File tree

‎docs/source/io_formats/settings.rst‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,6 +1329,13 @@ attributes/sub-elements:
13291329

13301330
*Default*: ``surface_source.h5`` in current working directory
13311331

1332+
.. deprecated::
1333+
The ``<surf_source_read>`` element is deprecated and will be removed in a
1334+
future release. A deprecation warning is emitted when it is present. Use a
1335+
file source instead, e.g. ``<source type="file" file="surface_source.h5"/>``,
1336+
which is equivalent but additionally supports a source strength and source
1337+
constraints.
1338+
13321339
-------------------------------
13331340
``<surf_source_write>`` Element
13341341
-------------------------------

‎docs/source/usersguide/settings.rst‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,11 @@ As an example, to write a maximum of three surface source files:::
422422
'max_source_files': 3
423423
}
424424

425+
A surface source file is read back like any other source file, with the
426+
:class:`openmc.FileSource` class::
427+
428+
settings.source = openmc.FileSource('surface_source.h5')
429+
425430
.. _compiled_source:
426431

427432
Compiled Sources

‎include/openmc/settings.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ extern bool source_write; //!< write source in HDF5 files?
8080
extern bool source_mcpl_write; //!< write source in mcpl files?
8181
extern bool surf_source_write; //!< write surface source file?
8282
extern bool surf_mcpl_write; //!< write surface mcpl file?
83-
extern bool surf_source_read; //!< read surface source file?
8483
extern bool survival_biasing; //!< use survival biasing?
8584
extern bool survival_normalization; //!< use survival normalization?
8685
extern bool temperature_multipole; //!< use multipole data?

‎openmc/settings.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,9 @@ class Settings:
297297
Options for reading surface source points. Acceptable keys are:
298298
299299
:path: Path to surface source file (str).
300+
301+
.. deprecated:: 0.17.0
302+
Use :class:`openmc.FileSource` as a source distribution instead.
300303
surf_source_write : dict
301304
Options for writing surface source points. Acceptable keys are:
302305
@@ -888,6 +891,13 @@ def surf_source_read(self) -> dict:
888891

889892
@surf_source_read.setter
890893
def surf_source_read(self, ssr: dict):
894+
warnings.warn(
895+
"The surf_source_read attribute has been deprecated. Use a "
896+
"FileSource as a source distribution instead, i.e., "
897+
"settings.source = openmc.FileSource('surface_source.h5'), which "
898+
"additionally supports a source strength and source constraints.",
899+
FutureWarning, stacklevel=2
900+
)
891901
cv.check_type('surface source reading options', ssr, Mapping)
892902
for key, value in ssr.items():
893903
cv.check_value('surface source reading key', key,

‎src/settings.cpp‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ bool source_write {true};
7575
bool source_mcpl_write {false};
7676
bool surf_source_write {false};
7777
bool surf_mcpl_write {false};
78-
bool surf_source_read {false};
7978
bool survival_biasing {false};
8079
bool survival_normalization {false};
8180
bool temperature_multipole {false};
@@ -667,7 +666,12 @@ void read_settings_xml(pugi::xml_node root)
667666

668667
// Check if the user has specified to read surface source
669668
if (check_for_node(root, "surf_source_read")) {
670-
surf_source_read = true;
669+
if (mpi::master)
670+
warning("The <surf_source_read> element has been deprecated. Use a file "
671+
"source instead, i.e., <source type=\"file\" "
672+
"file=\"surface_source.h5\"/>, which additionally supports a "
673+
"source strength and source constraints.");
674+
671675
// Get surface source read node
672676
xml_node node_ssr = root.child("surf_source_read");
673677

0 commit comments

Comments
 (0)