Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
GIDI::Transporting::Particle Class Reference

#include <GIDI.hpp>

Public Member Functions

 Particle (std::string const &a_pid, MultiGroup const &a_multiGroup, Functions::Function3dForm const &a_fluxes, Transporting::Mode a_mode=Transporting::Mode::multiGroup)
 Particle (std::string const &a_pid, Transporting::Mode a_mode=Transporting::Mode::multiGroup)
 Particle (std::string const &a_pid, MultiGroup const &a_multiGroup, Transporting::Mode a_mode=Transporting::Mode::multiGroup)
 Particle (Particle const &a_particle)
 ~Particle ()
std::string const & pid () const
Transporting::Mode mode () const
Transporting::Conserve conserve () const
int multiGroupIndexFromEnergy (double a_e_in, bool a_encloseOutOfRange) const
std::size_t numberOfGroups () const
MultiGroup multiGroup () const
MultiGroup fineMultiGroup () const
int appendFlux (Flux const &a_flux)
ProcessedFlux const * nearestProcessedFluxToTemperature (double a_temperature) const
std::vector< std::size_t > const & collapseIndices () const
void process (Transportable const &a_transportable, double a_epsilon=1e-6)
void print (std::string const &a_indent) const

Detailed Description

Specifies particle information as mainly needed for multi-group transport. For example, the coarse and fine multi-group data.

Definition at line 3642 of file GIDI.hpp.

Constructor & Destructor Documentation

◆ Particle() [1/4]

GIDI::Transporting::Particle::Particle ( std::string const & a_pid,
MultiGroup const & a_multiGroup,
Functions::Function3dForm const & a_fluxes,
Transporting::Mode a_mode = Transporting::Mode::multiGroup )
Parameters
a_pid[in] Particle id for the particle.
a_multiGroup[in] The multi-group boundaries.
a_fluxes[in] The fluxes as f(T,E,mu).
a_mode[in] Should probably be deprecated.

Definition at line 174 of file GIDI_settings_particle.cc.

175 :
176 m_pid( a_pid ),
177 m_mode( a_mode ),
178 m_conserve( Transporting::Conserve::number ),
179 m_multiGroup( a_multiGroup ) {
180
181 std::vector<Transporting::Flux> fluxes = settingsFluxesFromFunction3d( a_fluxes );
182
183 for( auto flux = fluxes.begin( ); flux != fluxes.end( ); ++flux ) appendFlux( *flux );
184}
std::vector< Transporting::Flux > settingsFluxesFromFunction3d(Functions::Function3dForm const &a_function3d)

Referenced by Particle().

◆ Particle() [2/4]

GIDI::Transporting::Particle::Particle ( std::string const & a_pid,
Transporting::Mode a_mode = Transporting::Mode::multiGroup )
Parameters
a_pid[in] Particle id for the particle.
a_mode[in] Should probably be deprecated.

Definition at line 191 of file GIDI_settings_particle.cc.

191 :
192 m_pid( a_pid ),
193 m_mode( a_mode ),
194 m_conserve( Transporting::Conserve::number ) {
195
196}

◆ Particle() [3/4]

GIDI::Transporting::Particle::Particle ( std::string const & a_pid,
MultiGroup const & a_group,
Transporting::Mode a_mode = Transporting::Mode::multiGroup )
Parameters
a_pid[in] Particle id for the particle.
a_group[in] The multi-group boundaries.
a_mode[in] Should probably be deprecated.

Definition at line 204 of file GIDI_settings_particle.cc.

204 :
205 m_pid( a_pid ),
206 m_mode( a_mode ),
207 m_conserve( Transporting::Conserve::number ),
208 m_multiGroup( a_group ) {
209
210}

◆ Particle() [4/4]

GIDI::Transporting::Particle::Particle ( Particle const & a_particle)
Parameters
a_particle[in] The Particle instance to copy.

Definition at line 216 of file GIDI_settings_particle.cc.

216 :
217 m_pid( a_particle.pid( ) ),
218 m_mode( a_particle.mode( ) ),
219 m_conserve( a_particle.conserve( ) ),
220 m_multiGroup( a_particle.multiGroup( ) ),
221 m_collapseIndices( a_particle.collapseIndices( ) ) {
222
223 for( std::vector<Flux>::const_iterator iter = a_particle.m_fluxes.begin( ); iter != a_particle.m_fluxes.end( ); ++iter ) {
224 m_fluxes.push_back( *iter );
225 }
226
227 for( std::vector<ProcessedFlux>::const_iterator iter = a_particle.m_processedFluxes.begin( ); iter != a_particle.m_processedFluxes.end( ); ++iter ) {
228 m_processedFluxes.push_back( *iter );
229 }
230}

◆ ~Particle()

GIDI::Transporting::Particle::~Particle ( )

Definition at line 235 of file GIDI_settings_particle.cc.

235 {
236
237}

Member Function Documentation

◆ appendFlux()

int GIDI::Transporting::Particle::appendFlux ( Flux const & a_flux)

Adds a flux at a specified temperature to the list of fluxes. Currently, the temperature of the flux must be greater than temperatures for the currently listed fluxes.

Parameters
a_flux[in] The flux to add.
Returns
An error code. If not error, returns 0, otherwise returns non-0 value.

Definition at line 247 of file GIDI_settings_particle.cc.

247 {
248
249 double temperature = a_flux.temperature( );
250 std::vector<Flux>::iterator iter;
251
252 for( iter = m_fluxes.begin( ); iter != m_fluxes.end( ); ++iter ) {
253 if( temperature <= iter->temperature( ) ) break;
254 }
255 if( iter != m_fluxes.end( ) ) return( 1 );
256 m_fluxes.insert( iter, a_flux );
257 return( 0 );
258}

Referenced by Particle().

◆ collapseIndices()

std::vector< std::size_t > const & GIDI::Transporting::Particle::collapseIndices ( ) const
inline

Returns the value of the m_collapseIndices member.

Definition at line 3672 of file GIDI.hpp.

Referenced by GIDI::collapse(), GIDI::collapse(), and Particle().

◆ conserve()

Transporting::Conserve GIDI::Transporting::Particle::conserve ( ) const
inline

Returns the value of the m_conserve member.

Definition at line 3664 of file GIDI.hpp.

Referenced by Particle().

◆ fineMultiGroup()

MultiGroup GIDI::Transporting::Particle::fineMultiGroup ( ) const
inline

Returns the value of the m_fineMultiGroup member.

Definition at line 3669 of file GIDI.hpp.

Referenced by GIDI::Transporting::Settings::multiGroupZeroMatrix(), and GIDI::Transporting::Settings::multiGroupZeroVector().

◆ mode()

Transporting::Mode GIDI::Transporting::Particle::mode ( ) const
inline

Returns the value of the m_mode member.

Definition at line 3663 of file GIDI.hpp.

Referenced by Particle().

◆ multiGroup()

MultiGroup GIDI::Transporting::Particle::multiGroup ( ) const
inline

Returns the value of the m_multiGroup member.

Definition at line 3668 of file GIDI.hpp.

Referenced by MCGIDI::MultiGroupHash::MultiGroupHash(), and Particle().

◆ multiGroupIndexFromEnergy()

int GIDI::Transporting::Particle::multiGroupIndexFromEnergy ( double a_e_in,
bool a_encloseOutOfRange ) const
inline

Returns the coarse multi-group index corresponding to energy a_e_in. See MultiGroup::multiGroupIndexFromEnergy.

Definition at line 3665 of file GIDI.hpp.

◆ nearestProcessedFluxToTemperature()

ProcessedFlux const * GIDI::Transporting::Particle::nearestProcessedFluxToTemperature ( double a_temperature) const

Returns the multi-group flux with its temperature closes to a_temperature.

Parameters
a_temperature[in] The temperature of the desired flux.

Definition at line 266 of file GIDI_settings_particle.cc.

266 {
267
268 double priorTemperature, lastTemperature = 0; // initialize to silence compiler warning
269 std::vector<ProcessedFlux>::const_iterator iter;
270
271 if( m_processedFluxes.size( ) == 0 ) return( nullptr );
272
273 priorTemperature = m_processedFluxes[0].temperature( );
274 for( iter = m_processedFluxes.begin( ); iter != m_processedFluxes.end( ); ++iter ) {
275 lastTemperature = iter->temperature( );
276 if( lastTemperature > a_temperature ) break;
277 }
278 if( iter == m_processedFluxes.end( ) ) {
279 --iter; }
280 else {
281 if( fabs( lastTemperature - a_temperature ) < fabs( a_temperature - priorTemperature ) ) --iter;
282 }
283 return( &(*iter) );
284}

Referenced by GIDI::collapse(), and GIDI::collapse().

◆ numberOfGroups()

std::size_t GIDI::Transporting::Particle::numberOfGroups ( ) const
inline

Returns the number of coarse multi-group groups.

Definition at line 3667 of file GIDI.hpp.

Referenced by GIDI::Transporting::Settings::multiGroupZeroMatrix(), and GIDI::Transporting::Settings::multiGroupZeroVector().

◆ pid()

std::string const & GIDI::Transporting::Particle::pid ( ) const
inline

Returns the value of the m_pid member.

Definition at line 3662 of file GIDI.hpp.

Referenced by GIDI::Transporting::Particles::add(), and Particle().

◆ print()

void GIDI::Transporting::Particle::print ( std::string const & a_indent) const

Print Particle data to std::cout. Mainly for debugging.

Parameters
a_indent[in] The indent for each printed line.

Definition at line 364 of file GIDI_settings_particle.cc.

364 {
365
366 std::string indent2( " " );
367 indent2 += a_indent;
368
369 std::cout << a_indent << "particle: id = " << m_pid << std::endl;
370 m_multiGroup.print( indent2 );
371
372 std::cout << indent2;
373 for( auto iter = m_collapseIndices.begin( ); iter != m_collapseIndices.end( ); ++iter ) std::cout << " " << *iter;
374 std::cout << std::endl;
375
376}

◆ process()

void GIDI::Transporting::Particle::process ( Transportable const & a_transportable,
double a_epsilon = 1e-6 )

For internal use only: should only be called from Particles::process. Determines the mapping of fine multi-group boundaries to coarse multi-group boundaries, and calculated multi-group fluxes from m_fluxes.

Parameters
a_transportable[in] The Transportable instance that specified the coarse multi-group information for collapsing.
a_epsilon[in] Specifies how close a coarse multi-group boundary must be to a fine multi-group boundary to be considered the same boundary.

Definition at line 294 of file GIDI_settings_particle.cc.

294 {
295
296 std::vector<double> groupBoundaries = a_transportable.groupBoundaries( );
297 std::string errInfo( "cannot collapse particle '" + m_pid
298 + "' from multi-group '" + a_transportable.group( ).label( ) + "' of size " + std::to_string( groupBoundaries.size( ) )
299 + " to multi-group '" + m_multiGroup.label( ) + "' of size " + std::to_string( m_multiGroup.boundaries( ).size( ) ) );
300
302 if( m_multiGroup.size( ) == 0 ) {
303 m_multiGroup = MultiGroup( a_transportable.group( ).label( ), groupBoundaries );
304 }
305 if( m_fineMultiGroup.size( ) > 0 ) {
306 if( m_fineMultiGroup.size( ) != groupBoundaries.size( ) )
307 throw Exception( "For particle '" + m_pid + "', redefining particle's fine multi-group of different size not allowed." );
308 for( std::size_t i1 = 0; i1 < m_fineMultiGroup.size( ); ++i1 ) {
309 if( fabs( m_fineMultiGroup[i1] - groupBoundaries[i1] ) > a_epsilon * m_fineMultiGroup[i1] )
310 throw Exception( "For particle '" + m_pid + "', redefining particle's fine multi-group not allowed." );
311 }
312 return; // Processing already done.
313 }
314
315 std::size_t i1 = 0, n1 = groupBoundaries.size( );
316
317 while( i1 < n1 ) {
318 if( fabs( m_multiGroup[0] - groupBoundaries[i1] ) <= a_epsilon * groupBoundaries[i1] ) break;
319 ++i1;
320 }
321 if( i1 == n1 ) throw Exception( "Groups not compatible: " + errInfo + "." );
322 m_collapseIndices.push_back( i1 );
323
324 for( std::size_t i2 = 1; i2 < m_multiGroup.size( ); ++i2 ) {
325 while( i1 < n1 ) {
326 if( fabs( m_multiGroup[i2] - groupBoundaries[i1] ) <= a_epsilon * groupBoundaries[i1] ) break;
327 ++i1;
328 }
329 if( i1 == n1 ) throw Exception( "Group boundaries not compatible: " + errInfo + "." );
330 m_collapseIndices.push_back( i1 );
331 }
332
333 if( m_fluxes.size( ) == 0 ) {
334 std::vector<double> fluxes;
335 for( std::size_t index = 0; index < groupBoundaries.size( ) - 1; ++index ) {
336 fluxes.push_back( groupBoundaries[index+1] - groupBoundaries[index] );
337 }
338 m_processedFluxes.push_back( ProcessedFlux( 0.0, fluxes ) ); }
339 else {
340 for( std::size_t i2 = 0; i2 < m_fluxes.size( ); ++i2 ) {
341 ProcessedFlux __processedFlux( m_fluxes[i2].process( groupBoundaries ) );
342 m_processedFluxes.push_back( __processedFlux );
343 }
344 }
345
346 m_fineMultiGroup = a_transportable.group( );
347 }
348
349 if( a_transportable.conserve() == GIDI_conserveNumberChars ) {
351 } else if( a_transportable.conserve() == GIDI_conserveEnergyOutChars ) {
353 } else {
354 throw Exception( "Unrecognized particle conserve flag '" + a_transportable.conserve() + "'" );
355 }
356}
#define GIDI_conserveEnergyOutChars
Definition GIDI.hpp:466
#define GIDI_conserveNumberChars
Definition GIDI.hpp:465
void process(Transportable const &a_transportable, double a_epsilon=1e-6)
std::string to_string(G4FermiAtomicMass mass)

Referenced by process().


The documentation for this class was generated from the following files: