diff --git a/ParticleObjects/Source/fissionSource_class.f90 b/ParticleObjects/Source/fissionSource_class.f90 index 6901c302a..bf3176c54 100644 --- a/ParticleObjects/Source/fissionSource_class.f90 +++ b/ParticleObjects/Source/fissionSource_class.f90 @@ -3,7 +3,8 @@ module fissionSource_class use numPrecision use endfConstants use universalVariables, only : OUTSIDE_MAT, VOID_MAT - use genericProcedures, only : fatalError, rotateVector + use genericProcedures, only : rotateVector, numToChar + use errors_mod, only : fatalError use dictionary_class, only : dictionary use RNG_class, only : RNG @@ -28,17 +29,17 @@ module fissionSource_class !! Neutron Source from distributed fission sites !! !! Places fission sites uniformly in regions with fissile material. - !! Spectrum of the fission neutron is such as if it fission was caused by incdent - !! neutron with CE energy E or MG with group G. + !! Spectrum of the fission neutron is such as if it fission was caused by + !! incident neutron with CE energy E or MG with group G. !! Angular distribution is isotropic. !! !! Private members: - !! isMG -> is the source multi-group? (default = .false.) - !! bottom -> Bottom corner (x_min, y_min, z_min) - !! top -> Top corner (x_max, y_max, z_max) - !! E -> Fission site energy [MeV] (default = 1.0E-6) - !! G -> Fission site Group (default = 1) - !! + !! isMG -> is the source multi-group? (default = .false.) + !! bottom -> Bottom corner (x_min, y_min, z_min) + !! top -> Top corner (x_max, y_max, z_max) + !! E -> Fission site energy [MeV] (default = 1.0E-6) + !! G -> Fission site Group (default = 1) + !! attempts -> Maximum number of attempts to find a fissile material !! Interface: !! source_inter Interface !! @@ -48,6 +49,9 @@ module fissionSource_class !! #data MG; # !! #E 15.0; # !! #G 7; # + !! #attempts 100000; # (default: 10000) + !! #top (1.0 1.0 1.0); # + !! #bottom (0.0 0.0 0.0); # !! } !! type, public,extends(source) :: fissionSource @@ -57,6 +61,7 @@ module fissionSource_class real(defReal), dimension(3) :: top = ZERO real(defReal) :: E = ZERO integer(shortInt) :: G = 0 + integer(shortInt) :: attempts = 10000 contains procedure :: init procedure :: sampleParticle @@ -76,6 +81,7 @@ subroutine init(self, dict, geom) class(geometry), pointer, intent(in) :: geom character(nameLen) :: type real(defReal), dimension(6) :: bounds + real(defReal), allocatable, dimension(:) :: temp character(100), parameter :: Here = 'init (fissionSource_class.f90)' ! Provide geometry info to source @@ -98,10 +104,39 @@ subroutine init(self, dict, geom) call dict % getOrDefault(self % E, 'E', 1.0E-6_defReal) call dict % getOrDefault(self % G, 'G', 1) + ! Load the number of allowed attempts + call dict % getOrDefault(self % attempts, 'attempts', 10000) + + if (self % attempts < 1) then + call fatalError(Here, 'Number of attempts must be greater than 0. Is: ' // numToChar(self % attempts)) + end if + ! Set bounding region - bounds = self % geom % bounds() - self % bottom = bounds(1:3) - self % top = bounds(4:6) + if (dict % isPresent('top') .or. dict % isPresent('bottom')) then + ! Get top and bottom from dictionary + call dict % get(temp, 'top') + if (size(temp) /= 3) then + call fatalError(Here, "Top point must have 3 coordinates.") + end if + self % top = temp + + call dict % get(temp, 'bottom') + if (size(temp) /= 3) then + call fatalError(Here, "Bottom point must have 3 coordinates.") + end if + self % bottom = temp + + ! Check that top and bottom are valid + if (any(self % top < self % bottom)) then + call fatalError(Here, "Top point must have all coordinates greater than bottom point.") + end if + + else ! Get bounds from geometry + bounds = self % geom % bounds() + self % bottom = bounds(1:3) + self % top = bounds(4:6) + end if + end subroutine init @@ -136,9 +171,9 @@ function sampleParticle(self, rand) result(p) rejection : do ! Protect against infinite loop i = i +1 - if ( i > 200) then - call fatalError(Here, 'Infinite loop in sampling of fission sites. Please check that& - & defined volume contains fissile material.') + if (i > self % attempts) then + call fatalError(Here, "Failed to find a fissile material in: "// numToChar(self % attempts) // " attempts.& + & Increase the number of maximum attempts or verify that fissile materials are present.") end if ! Sample Position diff --git a/docs/User Manual.rst b/docs/User Manual.rst index e1512e501..f2cb8e4cf 100644 --- a/docs/User Manual.rst +++ b/docs/User Manual.rst @@ -25,8 +25,8 @@ eigenPhysicsPackage, used for criticality (or eigenvalue) calculations * XSdata: keyword to the name of the nuclearDataHandle used * seed (*optional*): initial seed for the pseudo random number generator * outputFile (*optional*, default = 'output'): name of the output file -* outputFormat (*optional*, default = ``asciiMATLAB``): type of output file. - Choices are ``asciiMATLAB`` and ``asciiJSON`` +* outputFormat (*optional*, default = ``asciiMATLAB``): type of output file. + Choices are ``asciiMATLAB`` and ``asciiJSON`` * printSource (*optional*, default = 0): 1 for true; 0 for false; requests to print the particle source (location, direction, energy of each particle in the particleDungeon) to a text file @@ -71,19 +71,19 @@ fixedSourcePhysicsPackage, used for fixed source calculations * XSdata: keyword to the name of the nuclearDataHandle used * seed (*optional*): initial seed for the pseudo random number generator * outputFile (*optional*, default = 'output'): name of the output file -* outputFormat (*optional*, default = ``asciiMATLAB``): type of output file. - Choices are ``asciiMATLAB`` and ``asciiJSON`` +* outputFormat (*optional*, default = ``asciiMATLAB``): type of output file. + Choices are ``asciiMATLAB`` and ``asciiJSON`` * printSource (*optional*, default = 0): 1 for true; 0 for false; requests to print the particle source (location, direction, energy of each particle in the particleDungeon) to a text file -* buffer (*optional*, default = 50): size of the particle bank used by each +* buffer (*optional*, default = 50): size of the particle bank used by each OpenMP thread to store secondary particles -* commonBufferSize (*optional*): if not included, the common buffer is not - used; if included, after each particle history the particles in each - thread-private buffer (or bank, or dungeon) are moved to a buffer +* commonBufferSize (*optional*): if not included, the common buffer is not + used; if included, after each particle history the particles in each + thread-private buffer (or bank, or dungeon) are moved to a buffer common to all threads to avoid long histories -* bufferShift (*optional*, default = 10): threshold of particles to be - stored in a thread-private buffer, after which particles are shifted to +* bufferShift (*optional*, default = 10): threshold of particles to be + stored in a thread-private buffer, after which particles are shifted to the common buffer Example: :: @@ -154,7 +154,7 @@ Example: :: Source ------ -For the moment, the only possible external **source** types in SCONE are point source +For the moment, the only possible external **source** types in SCONE are point source and material source. pointSource @@ -185,21 +185,42 @@ It is a type of volumetric source. For the moment it is constrained to neutrons. The properties of a material source are: * mat: the name of the material from which to sample (must be defined in materials). -* data (*optional*, default = continuous energy): data type for source particles. Can be ``ce`` +* data (*optional*, default = continuous energy): data type for source particles. Can be ``ce`` or ``mg``. -* E (*optional*, default = 1E-6): energy of the particles emitted, for continuous energy +* E (*optional*, default = 1E-6): energy of the particles emitted, for continuous energy calculations. [MeV] -* G (*optional*, default = 1): energy group of the particles emitted, for multi-group +* G (*optional*, default = 1): energy group of the particles emitted, for multi-group calculations. -* boundingBox (*optional*, default is the geometry bounding box): - (x_min y_min z_min x_max y_max z_max) vector describing a bounding box to improve sampling +* boundingBox (*optional*, default is the geometry bounding box): + (x_min y_min z_min x_max y_max z_max) vector describing a bounding box to improve sampling efficiency or to localise material sampling to a particular region. Hence, an input would look like: :: - source { type materialSource; mat myMat; data ce; E 2.0; + source { type materialSource; mat myMat; data ce; E 2.0; boundingBox (-5.0 -3.0 2.0 5.0 4.0 3.0); } +fissionSource +############# + +A source intended to initialise eigenvalue calculations. If it is not defined in the input file, it is +used with the default settings. It is a type of volumetric source, which uniformly distributes fission +sites in the geometry. The energy spectrum of the fission neutrons is based on a fixed incident +energy provided by the user. The properties of a fission source are: + +* data (*optional*, default='ce'): data type for source particles. Can be ``ce`` + or ``mg``. +* E (*optional*, default=1E-6): energy of the incident neutron causing fission [MeV]. Makes + sense for continuous energy source only. +* G (*optional*, default=1): energy group of the incident neutron causing fission. Makes + sense for multi-group source only. +* attempts (*optional*, default=10000): number of attempts to sample a fission site in a cell + before throwing an error. +* bottom (*optional*): Lower point determining axis-aligned bounding box where to sample points. If + provided ``top`` must also be provided. +* top (*optional*): Upper point determining axis-aligned bounding box where to sample points. If + provided ``bottom`` must also be provided. + Transport Operator ------------------ @@ -634,8 +655,8 @@ vtk * corner: (x y z) array with the corner of the geometry [cm] * width: (x y z) array with the width of the mesh in each direction [cm] * vox: (x y z) array with the number of voxels requested in each direction -* what (*optional*, default = material): defines what is highlighted in the - plot; options are ``material`` and ``uniqueID``, where ``uniqueID`` +* what (*optional*, default = material): defines what is highlighted in the + plot; options are ``material`` and ``uniqueID``, where ``uniqueID`` highlights unique cell IDs Example: :: @@ -651,17 +672,17 @@ bmp with the width of the geometry plotted in each direction [cm] * res: (y z), (x z) or (x y) array with the resolution of the mesh in each direction * output: name of the output file, with extension ``.bmp`` -* what (*optional*, default = material): defines what is highlighted in the - plot; options are ``material`` and ``uniqueID``, where ``uniqueID`` +* what (*optional*, default = material): defines what is highlighted in the + plot; options are ``material`` and ``uniqueID``, where ``uniqueID`` highlights unique cell IDs Example: :: plotBMP { type bmp; axis z; centre (0.0 0.0 0.0); width (50 10); res (1000 200); output geomZ; what material; } - -.. note:: - SCONE can be run to visualise geometry without actually doing transport, by - including ``--plot`` when running the application. In this case the visualiser + +.. note:: + SCONE can be run to visualise geometry without actually doing transport, by + including ``--plot`` when running the application. In this case the visualiser has to be included in the file. Nuclear Data