Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
MCGIDI::GRIN_inelastic Class Reference

#include <MCGIDI.hpp>

Public Member Functions

LUPI_HOST_DEVICE GRIN_inelastic ()
LUPI_HOST GRIN_inelastic (SetupInfo &a_setupInfo, GIDI::GRIN::GRIN_continuumGammas const &GRIN_continuumGammas)
LUPI_HOST_DEVICE ~GRIN_inelastic ()
LUPI_HOST void setUserParticleIndex (int a_particleIndex, int a_userParticleIndex)
LUPI_HOST void setUserParticleIndexViaIntid (int a_particleIntid, int a_userParticleIndex)
template<typename RNG, typename PUSHBACK>
LUPI_HOST_DEVICE bool sampleProducts (ProtareSingle const *a_protare, double a_projectileEnergy, Sampling::Input &a_input, RNG &&a_rng, PUSHBACK &&a_push_back, Sampling::ProductHandler &a_products) const
LUPI_HOST_DEVICE void serialize (LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode)

Detailed Description

This class represents GRIN inelastic continuum reaction data which has simulated levels.

Definition at line 1055 of file MCGIDI.hpp.

Constructor & Destructor Documentation

◆ GRIN_inelastic() [1/2]

LUPI_HOST_DEVICE MCGIDI::GRIN_inelastic::GRIN_inelastic ( )

Definition at line 195 of file MCGIDI_GRIN.cc.

195 {
196
197}

Referenced by GRIN_inelastic(), and GRIN_inelastic().

◆ GRIN_inelastic() [2/2]

LUPI_HOST MCGIDI::GRIN_inelastic::GRIN_inelastic ( SetupInfo & a_setupInfo,
GIDI::GRIN::GRIN_continuumGammas const & GRIN_continuumGammas )
Parameters
a_setupInfo[in] Used internally when constructing a Protare to pass information to other constructors.
GRIN_continuumGammas[in] GIDI instance containing the GRIN capture data.

Definition at line 204 of file MCGIDI_GRIN.cc.

204 :
205 m_neutronIndex( a_setupInfo.m_neutronIndex ),
206 m_neutronUserParticleIndex( -1 ),
207 m_neutronMass( a_setupInfo.m_protare.projectileMass( ) ),
208
209 m_targetIntid( a_setupInfo.m_protare.targetIntid( ) ),
210 m_targetIndex( a_setupInfo.m_protare.targetIndex( ) ),
211 m_targetUserParticleIndex( -1 ),
212 m_targetMass( a_setupInfo.m_protare.targetMass( ) ) {
213
214 PoPI::Database const &pops = GRIN_continuumGammas.pops( );
215 GIDI::Suite const &inelasticIncidentEnergies = GRIN_continuumGammas.inelasticIncidentEnergies( );
216 m_energies.reserve( inelasticIncidentEnergies.size( ) );
217 m_inelasticForEnergy.reserve( inelasticIncidentEnergies.size( ) );
218 for( std::size_t index = 0; index < inelasticIncidentEnergies.size( ); ++index ) {
219
220 GIDI::GRIN::InelasticIncidentEnergy const *inelasticIncidentEnergy = inelasticIncidentEnergies.get<GIDI::GRIN::InelasticIncidentEnergy>( index );
221
222 m_energies.push_back( inelasticIncidentEnergy->energy( ) );
223 m_inelasticForEnergy.push_back( new GRIN_inelasticForEnergy( a_setupInfo, m_neutronMass, m_targetMass, pops, inelasticIncidentEnergy ) );
224 }
225}
T * get(std::size_t a_Index)
Definition GIDI.hpp:2642
std::size_t size() const
Definition GIDI.hpp:2591

◆ ~GRIN_inelastic()

LUPI_HOST_DEVICE MCGIDI::GRIN_inelastic::~GRIN_inelastic ( )

Definition at line 230 of file MCGIDI_GRIN.cc.

230 {
231
232 for( auto iter = m_inelasticForEnergy.begin( ); iter != m_inelasticForEnergy.end( ); ++iter ) delete *iter;
233}

Member Function Documentation

◆ sampleProducts()

template<typename RNG, typename PUSHBACK>
LUPI_HOST_DEVICE bool MCGIDI::GRIN_inelastic::sampleProducts ( ProtareSingle const * a_protare,
double a_projectileEnergy,
Sampling::Input & a_input,
RNG && a_rng,
PUSHBACK && a_push_back,
Sampling::ProductHandler & a_products ) const
inline

This method adds sampled products to a_products.

Parameters
a_protare[in] The ProtareSingle this Reaction belongs to.
a_projectileEnergy[in] The energy of the projectile.
a_input[in] Sample options requested by user.
a_rng[in] The random number generator function that returns a double in the range [0, 1.0).
a_products[in] The object to add all sampled products to.

Definition at line 3119 of file MCGIDI_headerSource.hpp.

3120 {
3121
3122 std::size_t index = 1;
3123 for( ; index < m_energies.size( ); ++index ) {
3124 if( m_energies[index] > a_projectileEnergy ) break;
3125 }
3126 --index;
3127
3128 GRIN_inelasticForEnergy *inelasticForEnergy = m_inelasticForEnergy[index];
3129 int levelIndex = inelasticForEnergy->sampleLevelIndex( a_projectileEnergy, a_rng( ) );
3130 if( levelIndex < 0 ) return( false );
3131
3132 NuclideGammaBranchStateInfo const *nuclideGammaBranchStateInfo = a_protare->nuclideGammaBranchStateInfos( )[static_cast<std::size_t>(levelIndex)];
3133
3134 a_input.m_GRIN_intermediateResidual = nuclideGammaBranchStateInfo->intid( );
3135
3136 double residualMass = m_targetMass + nuclideGammaBranchStateInfo->nuclearLevelEnergy( );
3137 double initialMass = m_neutronMass + m_targetMass;
3138 double finalMass = m_neutronMass + residualMass;
3139 double twoBodyThreshold = 0.5 * ( finalMass * finalMass - initialMass * initialMass ) / m_targetMass;
3140 double betaBoast = sqrt( a_projectileEnergy * ( a_projectileEnergy + 2. * m_neutronMass ) )
3141 / ( a_projectileEnergy + m_neutronMass + m_targetMass ); // betaBoast = v/c.
3142 double _x = m_targetMass * ( a_projectileEnergy - twoBodyThreshold ) / ( finalMass * finalMass );
3143 if( _x < 0 ) _x = 0.; // FIXME There needs to be a better test here.
3144 double Kp;
3145 if( _x < 2e-5 ) {
3146 Kp = finalMass * _x * ( 1 - 0.5 * _x * ( 1 - _x ) ); }
3147 else { // This is the relativistic formula derived from E^2 - (pc)^2 is frame independent.
3148 Kp = sqrt( finalMass * finalMass + 2 * m_targetMass * ( a_projectileEnergy - twoBodyThreshold ) ) - finalMass;
3149 }
3150 if( Kp < 0 ) Kp = 0.; // FIXME There needs to be a better test here.
3151
3152 a_input.setSampledType( Sampling::SampledType::firstTwoBody );
3153 a_input.m_mu = 1.0 - 2.0 * a_rng( );
3154 a_input.m_phi = 2. * M_PI * a_rng( );
3155 kinetics_COMKineticEnergy2LabEnergyAndMomentum( betaBoast, Kp, m_neutronMass, residualMass, a_input );
3156
3157 a_input.m_delayedNeutronIndex = -1;
3158 a_input.m_delayedNeutronDecayRate = 0.0;
3159 a_products.add( a_projectileEnergy, PoPI::Intids::neutron, m_neutronIndex, m_neutronUserParticleIndex, m_neutronMass, a_input, a_rng,
3160 a_push_back, false );
3161 a_products.add( a_projectileEnergy, m_targetIntid, m_targetIndex, m_targetUserParticleIndex,
3162 m_targetMass, a_input, a_rng, a_push_back, false );
3163
3164 a_protare->sampleBranchingGammas( a_input, a_projectileEnergy, levelIndex, a_rng, a_push_back, a_products );
3165
3166 return( true );
3167}
LUPI_HOST_DEVICE void kinetics_COMKineticEnergy2LabEnergyAndMomentum(double a_beta, double a_kinetic_com, double a_m3cc, double a_m4cc, MCGIDI::Sampling::Input &a_input)
#define M_PI
Definition SbMath.h:33
static int constexpr neutron
Definition PoPI.hpp:177

◆ serialize()

LUPI_HOST_DEVICE void MCGIDI::GRIN_inelastic::serialize ( LUPI::DataBuffer & a_buffer,
LUPI::DataBuffer::Mode a_mode )

This method serializes this for broadcasting as needed for MPI and GPUs. The method can count the number of required bytes, pack this or unpack this depending on a_mode.

Parameters
a_buffer[in] The buffer to read or write data to depending on a_mode.
a_mode[in] Specifies the action of this method.

Definition at line 269 of file MCGIDI_GRIN.cc.

269 {
270
271 DATA_MEMBER_INT( m_neutronIndex, a_buffer, a_mode );
272 DATA_MEMBER_INT( m_neutronUserParticleIndex, a_buffer, a_mode );
273 DATA_MEMBER_DOUBLE( m_neutronMass, a_buffer, a_mode );
274
275 DATA_MEMBER_INT( m_targetIntid, a_buffer, a_mode );
276 DATA_MEMBER_INT( m_targetIndex, a_buffer, a_mode );
277 DATA_MEMBER_INT( m_targetUserParticleIndex, a_buffer, a_mode );
278 DATA_MEMBER_DOUBLE( m_targetMass, a_buffer, a_mode );
279
280 DATA_MEMBER_VECTOR_DOUBLE( m_energies, a_buffer, a_mode );
281
282 std::size_t vectorSize = m_inelasticForEnergy.size( );
283 int vectorSizeInt = (int) vectorSize;
284 DATA_MEMBER_INT( vectorSizeInt, a_buffer, a_mode );
285 vectorSize = (std::size_t) vectorSizeInt;
286
287 if( a_mode == LUPI::DataBuffer::Mode::Unpack ) {
288 m_inelasticForEnergy.resize( vectorSize, &a_buffer.m_placement );
289 for( std::size_t vectorIndex = 0; vectorIndex < vectorSize; ++vectorIndex ) {
290 if( a_buffer.m_placement != nullptr ) {
291 m_inelasticForEnergy[vectorIndex] = new(a_buffer.m_placement) GRIN_inelasticForEnergy;
292 a_buffer.incrementPlacement( sizeof( GRIN_inelasticForEnergy ) ); }
293 else {
294 m_inelasticForEnergy[vectorIndex] = new GRIN_inelasticForEnergy;
295 }
296 } }
297 else if( a_mode == LUPI::DataBuffer::Mode::Memory ) {
298 a_buffer.m_placement += m_inelasticForEnergy.internalSize( );
299 a_buffer.incrementPlacement( sizeof( GRIN_inelasticForEnergy ) * vectorSize );
300 }
301
302 for( std::size_t vectorIndex = 0; vectorIndex < vectorSize; ++vectorIndex ) {
303 m_inelasticForEnergy[vectorIndex]->serialize( a_buffer, a_mode );
304 }
305}
#define DATA_MEMBER_VECTOR_DOUBLE(member, buf, mode)
#define DATA_MEMBER_DOUBLE(member, buf, mode)
#define DATA_MEMBER_INT( member, buf, mode)
LUPI_HOST_DEVICE void incrementPlacement(std::size_t a_delta)

◆ setUserParticleIndex()

LUPI_HOST void MCGIDI::GRIN_inelastic::setUserParticleIndex ( int a_particleIndex,
int a_userParticleIndex )

Updates the m_userParticleIndex to a_userParticleIndex for all particles with PoPs index a_particleIndex.

Parameters
a_particleIndex[in] The PoPs index of the particle whose user index is to be set.
a_userParticleIndex[in] The particle index specified by the user.

Definition at line 242 of file MCGIDI_GRIN.cc.

242 {
243
244 if( m_neutronIndex == a_particleIndex ) m_neutronUserParticleIndex = a_userParticleIndex;
245 if( m_targetIndex == a_particleIndex ) m_targetUserParticleIndex = a_userParticleIndex;
246}

◆ setUserParticleIndexViaIntid()

LUPI_HOST void MCGIDI::GRIN_inelastic::setUserParticleIndexViaIntid ( int a_particleIntid,
int a_userParticleIndex )

Updates the m_userParticleIndex to a_userParticleIndex for all particles with PoPs intid a_particleIntid.

Parameters
a_particleIntid[in] The PoPs intid of the particle whose user index is to be set.
a_userParticleIndex[in] The particle index specified by the user.

Definition at line 255 of file MCGIDI_GRIN.cc.

255 {
256
257 if( PoPI::Intids::neutron == a_particleIntid ) m_neutronUserParticleIndex = a_userParticleIndex;
258 if( m_targetIntid == a_particleIntid ) m_targetUserParticleIndex = a_userParticleIndex;
259}

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