47 for(
auto particleIter = m_particles.begin( ); particleIter != m_particles.end( ); ++particleIter ) {
65 std::string
const &pid = a_particle.
pid( );
67 if( m_particles.find( pid ) != m_particles.end( ) )
return(
false );
68 m_particles.insert( std::pair<std::string, Particle>( pid,
Particle( a_particle ) ) );
82 std::map<std::string, Particle>::iterator
particle = m_particles.find( a_pid );
84 if(
particle == m_particles.end( ) )
return(
false );
85 m_particles.erase( a_pid );
99 return(
particle( a_id ) !=
nullptr );
113 if( a_label ==
"" )
return;
122 for( std::map<std::string, Particle>::iterator iter = m_particles.begin( ); iter != m_particles.end( ); ++iter ) {
123 std::string pid = iter->first;
140 std::vector<std::string> keys;
142 for( std::map<std::string, Particle>::const_iterator iter = m_particles.begin( ); iter != m_particles.end( ); ++iter ) keys.push_back( (*iter).first );
153 std::cout <<
"particles:" << std::endl;
155 std::vector<std::string> IDs =
sortedIDs( );
156 for( std::vector<std::string>::const_iterator iter = IDs.begin( ); iter != IDs.end( ); ++iter ) {
179 m_multiGroup( a_multiGroup ) {
208 m_multiGroup( a_group ) {
217 m_pid( a_particle.
pid( ) ),
218 m_mode( a_particle.
mode( ) ),
219 m_conserve( a_particle.
conserve( ) ),
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 );
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 );
250 std::vector<Flux>::iterator iter;
252 for( iter = m_fluxes.begin( ); iter != m_fluxes.end( ); ++iter ) {
253 if( temperature <= iter->temperature( ) )
break;
255 if( iter != m_fluxes.end( ) )
return( 1 );
256 m_fluxes.insert( iter, a_flux );
268 double priorTemperature, lastTemperature = 0;
269 std::vector<ProcessedFlux>::const_iterator iter;
271 if( m_processedFluxes.size( ) == 0 )
return(
nullptr );
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;
278 if( iter == m_processedFluxes.end( ) ) {
281 if( fabs( lastTemperature - a_temperature ) < fabs( a_temperature - priorTemperature ) ) --iter;
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( ) ) );
302 if( m_multiGroup.size( ) == 0 ) {
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." );
315 std::size_t i1 = 0, n1 = groupBoundaries.size( );
318 if( fabs( m_multiGroup[0] - groupBoundaries[i1] ) <= a_epsilon * groupBoundaries[i1] )
break;
321 if( i1 == n1 )
throw Exception(
"Groups not compatible: " + errInfo +
"." );
322 m_collapseIndices.push_back( i1 );
324 for( std::size_t i2 = 1; i2 < m_multiGroup.size( ); ++i2 ) {
326 if( fabs( m_multiGroup[i2] - groupBoundaries[i1] ) <= a_epsilon * groupBoundaries[i1] )
break;
329 if( i1 == n1 )
throw Exception(
"Group boundaries not compatible: " + errInfo +
"." );
330 m_collapseIndices.push_back( i1 );
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] );
340 for( std::size_t i2 = 0; i2 < m_fluxes.size( ); ++i2 ) {
342 m_processedFluxes.push_back( __processedFlux );
346 m_fineMultiGroup = a_transportable.
group( );
354 throw Exception(
"Unrecognized particle conserve flag '" + a_transportable.
conserve() +
"'" );
366 std::string indent2(
" " );
369 std::cout << a_indent <<
"particle: id = " << m_pid << std::endl;
370 m_multiGroup.print( indent2 );
372 std::cout << indent2;
373 for(
auto iter = m_collapseIndices.begin( ); iter != m_collapseIndices.end( ); ++iter ) std::cout <<
" " << *iter;
374 std::cout << std::endl;
390 m_temperature( a_temperature ),
391 m_multiGroupFlux( a_multiGroupFlux ) {
#define GIDI_conserveEnergyOutChars
#define GIDI_conserveNumberChars
#define GIDI_heatedMultiGroupStyleChars
#define GIDI_SnElasticUpScatterStyleChars
virtual Styles::Suite & styles()=0
Transportable const & transportable(std::string const &a_ID) const
T * get(std::size_t a_Index)
std::string const & conserve() const
std::vector< double > groupBoundaries() const
Group const & group() const
double temperature() const
MultiGroup multiGroup() const
void process(Transportable const &a_transportable, double a_epsilon=1e-6)
Transporting::Mode mode() const
void print(std::string const &a_indent) const
Transporting::Conserve conserve() const
std::vector< std::size_t > const & collapseIndices() const
Particle(std::string const &a_pid, MultiGroup const &a_multiGroup, Functions::Function3dForm const &a_fluxes, Transporting::Mode a_mode=Transporting::Mode::multiGroup)
ProcessedFlux const * nearestProcessedFluxToTemperature(double a_temperature) const
std::string const & pid() const
int appendFlux(Flux const &a_flux)
bool add(Particle const &a_particle)
void process(Protare const &a_protare, std::string const &a_label)
bool remove(std::string const &a_particleID)
Particle const * particle(std::string const &a_particleID) const
bool hasParticle(std::string const &a_id) const
std::vector< std::string > sortedIDs(bool a_orderIsAscending=true) const
double temperature() const
ProcessedFlux(double a_temperature, std::vector< double > const &a_multiGroupFlux)
std::vector< double > const & multiGroupFlux() const
@ MonteCarloContinuousEnergy
std::vector< std::string > sortedListOfStrings(std::vector< std::string > const &a_strings, bool a_orderIsAscending=true)
std::vector< Transporting::Flux > settingsFluxesFromFunction3d(Functions::Function3dForm const &a_function3d)
bool compareSpecialParticleIDs(std::string const &a_id1, std::string const &a_id2)
std::string to_string(G4FermiAtomicMass mass)