@@ -222,6 +222,10 @@ class Settings:
222222 Number of random numbers allocated for each source particle history
223223 source : Iterable of openmc.SourceBase
224224 Distribution of source sites in space, angle, and energy
225+ source_rejection_fraction : float
226+ Minimum fraction of source sites that must be accepted when applying
227+ rejection sampling based on constraints. If not specified, the default
228+ value is 0.05.
225229 sourcepoint : dict
226230 Options for writing source points. Acceptable keys are:
227231
@@ -357,6 +361,7 @@ def __init__(self, **kwargs):
357361
358362 # Source subelement
359363 self ._source = cv .CheckedList (SourceBase , 'source distributions' )
364+ self ._source_rejection_fraction = None
360365
361366 self ._confidence_intervals = None
362367 self ._electron_treatment = None
@@ -1224,6 +1229,17 @@ def use_decay_photons(self, value):
12241229 cv .check_type ('use decay photons' , value , bool )
12251230 self ._use_decay_photons = value
12261231
1232+ @property
1233+ def source_rejection_fraction (self ) -> float :
1234+ return self ._source_rejection_fraction
1235+
1236+ @source_rejection_fraction .setter
1237+ def source_rejection_fraction (self , source_rejection_fraction : float ):
1238+ cv .check_type ('source_rejection_fraction' , source_rejection_fraction , Real )
1239+ cv .check_greater_than ('source_rejection_fraction' , source_rejection_fraction , 0 )
1240+ cv .check_less_than ('source_rejection_fraction' , source_rejection_fraction , 1 )
1241+ self ._source_rejection_fraction = source_rejection_fraction
1242+
12271243 def _create_run_mode_subelement (self , root ):
12281244 elem = ET .SubElement (root , "run_mode" )
12291245 elem .text = self ._run_mode .value
@@ -1685,6 +1701,11 @@ def _create_random_ray_subelement(self, root, mesh_memo=None):
16851701 subelement = ET .SubElement (element , key )
16861702 subelement .text = str (value )
16871703
1704+ def _create_source_rejection_fraction_subelement (self , root ):
1705+ if self ._source_rejection_fraction is not None :
1706+ element = ET .SubElement (root , "source_rejection_fraction" )
1707+ element .text = str (self ._source_rejection_fraction )
1708+
16881709 def _eigenvalue_from_xml_element (self , root ):
16891710 elem = root .find ('eigenvalue' )
16901711 if elem is not None :
@@ -2104,6 +2125,11 @@ def _use_decay_photons_from_xml_element(self, root):
21042125 if text is not None :
21052126 self .use_decay_photons = text in ('true' , '1' )
21062127
2128+ def _source_rejection_fraction_from_xml_element (self , root ):
2129+ text = get_text (root , 'source_rejection_fraction' )
2130+ if text is not None :
2131+ self .source_rejection_fraction = float (text )
2132+
21072133 def to_xml_element (self , mesh_memo = None ):
21082134 """Create a 'settings' element to be written to an XML file.
21092135
@@ -2171,6 +2197,7 @@ def to_xml_element(self, mesh_memo=None):
21712197 self ._create_max_tracks_subelement (element )
21722198 self ._create_random_ray_subelement (element , mesh_memo )
21732199 self ._create_use_decay_photons_subelement (element )
2200+ self ._create_source_rejection_fraction_subelement (element )
21742201
21752202 # Clean the indentation in the file to be user-readable
21762203 clean_indentation (element )
@@ -2279,6 +2306,7 @@ def from_xml_element(cls, elem, meshes=None):
22792306 settings ._max_tracks_from_xml_element (elem )
22802307 settings ._random_ray_from_xml_element (elem )
22812308 settings ._use_decay_photons_from_xml_element (elem )
2309+ settings ._source_rejection_fraction_from_xml_element (elem )
22822310
22832311 return settings
22842312
0 commit comments