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

#include <MCGIDI_functions.hpp>

Inheritance diagram for MCGIDI::Probabilities::Watt2d:

Public Member Functions

LUPI_HOST_DEVICE Watt2d ()
LUPI_HOST Watt2d (GIDI::Functions::Watt2d const &a_Watt2d)
LUPI_HOST_DEVICE ~Watt2d ()
LUPI_HOST_DEVICE double evaluate (double a_x2, double a_x1) const
template<typename RNG>
LUPI_HOST_DEVICE double sample (double a_x2, double a_rngValue, RNG &&a_rng) const
LUPI_HOST_DEVICE void serialize (LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode)
template<typename RNG>
LUPI_HOST_DEVICE double sample (double a_x2, LUPI_maybeUnused double a_rngValue, RNG &&a_rng) const
Public Member Functions inherited from MCGIDI::Probabilities::ProbabilityBase2d_d2
LUPI_HOST_DEVICE ProbabilityBase2d_d2 ()
LUPI_HOST ProbabilityBase2d_d2 (GIDI::Functions::FunctionForm const &a_probabilty)
LUPI_HOST ProbabilityBase2d_d2 (GIDI::Functions::FunctionForm const &a_probabilty, Vector< double > const &a_Xs)
LUPI_HOST_DEVICE double evaluate (double a_x2, double a_x1) const
template<typename RNG>
LUPI_HOST_DEVICE double sample (double a_x2, double a_rngValue, RNG &&a_rng) const
template<typename RNG>
LUPI_HOST_DEVICE double sample2dOf3d (double a_x2, double a_rngValue, RNG &&a_rng, double *a_x1_1, double *a_x1_2) const
Public Member Functions inherited from MCGIDI::Probabilities::ProbabilityBase2d_d1
LUPI_HOST_DEVICE ProbabilityBase2d_d1 ()
LUPI_HOST ProbabilityBase2d_d1 (GIDI::Functions::FunctionForm const &a_probabilty)
LUPI_HOST ProbabilityBase2d_d1 (GIDI::Functions::FunctionForm const &a_probabilty, Vector< double > const &a_Xs)
LUPI_HOST_DEVICE double evaluate (double a_x2, double a_x1) const
template<typename RNG>
LUPI_HOST_DEVICE double sample (double a_x2, double a_rngValue, RNG &&a_rng) const
template<typename RNG>
LUPI_HOST_DEVICE double sample2dOf3d (double a_x2, double a_rngValue, RNG &&a_rng, double *a_x1_1, double *a_x1_2) const
Public Member Functions inherited from MCGIDI::Probabilities::ProbabilityBase2d
LUPI_HOST_DEVICE ProbabilityBase2d ()
LUPI_HOST ProbabilityBase2d (GIDI::Functions::FunctionForm const &a_probabilty)
LUPI_HOST ProbabilityBase2d (GIDI::Functions::FunctionForm const &a_probabilty, Vector< double > const &a_Xs)
LUPI_HOST_DEVICE ~ProbabilityBase2d ()
LUPI_HOST_DEVICE ProbabilityBase2dType type () const
LUPI_HOST_DEVICE String typeString () const
LUPI_HOST_DEVICE MCGIDI_VIRTUAL_FUNCTION double evaluate (double a_x2, double a_x1) const MCGIDI_TRUE_VIRTUAL
template<typename RNG>
LUPI_HOST_DEVICE MCGIDI_VIRTUAL_FUNCTION double sample (double a_x2, double a_rngValue, RNG &&a_rng) const MCGIDI_TRUE_VIRTUAL
LUPI_HOST_DEVICE void serialize (LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode)
template<typename RNG>
LUPI_HOST_DEVICE double sample (double a_x2, double a_rngValue, RNG &&a_rng) const
Public Member Functions inherited from MCGIDI::Probabilities::ProbabilityBase
LUPI_HOST_DEVICE ProbabilityBase ()
LUPI_HOST ProbabilityBase (GIDI::Functions::FunctionForm const &a_probabilty)
LUPI_HOST ProbabilityBase (GIDI::Functions::FunctionForm const &a_probabilty, Vector< double > const &a_Xs)
LUPI_HOST_DEVICE ~ProbabilityBase ()
LUPI_HOST_DEVICE void serialize (LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode)
Public Member Functions inherited from MCGIDI::Functions::FunctionBase
LUPI_HOST_DEVICE FunctionBase ()
LUPI_HOST FunctionBase (GIDI::Functions::FunctionForm const &a_function)
LUPI_HOST_DEVICE FunctionBase (int a_dimension, double a_domainMin, double a_domainMax, Interpolation a_interpolation, double a_outerDomainValue=0)
virtual LUPI_HOST_DEVICE ~FunctionBase ()=0
LUPI_HOST_DEVICE Interpolation interpolation () const
LUPI_HOST_DEVICE double domainMin () const
LUPI_HOST_DEVICE double domainMax () const
LUPI_HOST_DEVICE double outerDomainValue () const
LUPI_HOST_DEVICE void serialize (LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode)

Additional Inherited Members

Protected Attributes inherited from MCGIDI::Probabilities::ProbabilityBase2d
ProbabilityBase2dType m_type
Protected Attributes inherited from MCGIDI::Probabilities::ProbabilityBase
Vector< double > m_Xs

Detailed Description

Definition at line 690 of file MCGIDI_functions.hpp.

Constructor & Destructor Documentation

◆ Watt2d() [1/2]

LUPI_HOST_DEVICE MCGIDI::Probabilities::Watt2d::Watt2d ( )

Definition at line 2205 of file MCGIDI_functions.cc.

2205 :
2206 m_U( 0.0 ),
2207 m_a( nullptr ),
2208 m_b( nullptr ) {
2209
2211}

◆ Watt2d() [2/2]

LUPI_HOST MCGIDI::Probabilities::Watt2d::Watt2d ( GIDI::Functions::Watt2d const & a_Watt2d)

Definition at line 2215 of file MCGIDI_functions.cc.

2215 :
2216 ProbabilityBase2d_d2( a_Watt2d ),
2217 m_U( a_Watt2d.U( ) ),
2218 m_a( Functions::parseFunction1d_d1( a_Watt2d.a( ) ) ),
2219 m_b( Functions::parseFunction1d_d1( a_Watt2d.b( ) ) ) {
2220
2222}
LUPI_HOST Function1d_d1 * parseFunction1d_d1(Transporting::MC const &a_settings, GIDI::Suite const &a_suite)

◆ ~Watt2d()

LUPI_HOST_DEVICE MCGIDI::Probabilities::Watt2d::~Watt2d ( )

Definition at line 2227 of file MCGIDI_functions.cc.

2227 {
2228
2229 delete m_a;
2230 delete m_b;
2231}

Member Function Documentation

◆ evaluate()

LUPI_HOST_DEVICE double MCGIDI::Probabilities::Watt2d::evaluate ( double a_x2,
double a_x1 ) const

Definition at line 2235 of file MCGIDI_functions.cc.

2235 {
2236
2237 double Watt_a = m_a->evaluate( a_x2 );
2238 double E_U_a = ( a_x2 - m_U ) / Watt_a;
2239
2240 if( E_U_a < 0 ) return( 0.0 );
2241
2242 double Watt_b = m_b->evaluate( a_x2 );
2243 double sqrt_ab_4 = 0.5 * sqrt( Watt_a * Watt_b );
2244 double sqrt_E_U_a = sqrt( E_U_a );
2245
2246 double I = 0.5 * sqrt_ab_4 * Watt_a * sqrt( M_PI ) * ( erf( sqrt_E_U_a - sqrt_ab_4 ) + erf( sqrt_E_U_a + sqrt_ab_4 ) )
2247 - Watt_a * exp( -E_U_a ) * sinh( 2.0 * sqrt_E_U_a * sqrt_ab_4 );
2248 return( exp( -a_x1 / Watt_a ) * sinh( sqrt( Watt_b * a_x1 ) ) / I );
2249}
#define M_PI
Definition SbMath.h:33

◆ sample() [1/2]

template<typename RNG>
LUPI_HOST_DEVICE double MCGIDI::Probabilities::Watt2d::sample ( double a_x2,
double a_rngValue,
RNG && a_rng ) const

◆ sample() [2/2]

template<typename RNG>
LUPI_HOST_DEVICE double MCGIDI::Probabilities::Watt2d::sample ( double a_x2,
LUPI_maybeUnused double a_rngValue,
RNG && a_rng ) const

Definition at line 2074 of file MCGIDI_headerSource.hpp.

2074 {
2075/*
2076* From MCAPM via Sample Watt Spectrum as in TART ( Kalos algorithm ).
2077*/
2078 double WattMin = 0., WattMax = a_x2 - m_U, x, y, z, energyOut, rand1, rand2;
2079 double Watt_a = 1./m_a->evaluate( a_x2 ); // Kalos algorithm uses the inverse of the 'a' parameter stored in GNDS
2080 double Watt_b = m_b->evaluate( a_x2 );
2081
2082 x = 1. + ( Watt_b / ( 8. * Watt_a ) );
2083 y = ( x + sqrt( x * x - 1. ) ) / Watt_a;
2084 z = Watt_a * y - 1.;
2085 do {
2086 rand1 = -log( a_rng( ) );
2087 rand2 = -log( a_rng( ) );
2088 energyOut = y * rand1;
2089 } while( ( ( rand2 - z * ( rand1 + 1. ) ) * ( rand2 - z * ( rand1 + 1. ) ) > Watt_b * y * rand1 ) ||
2090 ( energyOut < WattMin ) || ( energyOut > WattMax ) );
2091 return( energyOut );
2092}

◆ serialize()

LUPI_HOST_DEVICE void MCGIDI::Probabilities::Watt2d::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 2259 of file MCGIDI_functions.cc.

2259 {
2260
2261 ProbabilityBase2d::serialize( a_buffer, a_mode );
2262 DATA_MEMBER_DOUBLE( m_U, a_buffer, a_mode );
2263 m_a = serializeFunction1d_d1( a_buffer, a_mode, m_a );
2264 m_b = serializeFunction1d_d1( a_buffer, a_mode, m_b );
2265}
#define DATA_MEMBER_DOUBLE(member, buf, mode)
LUPI_HOST_DEVICE void serialize(LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode)
LUPI_HOST_DEVICE Functions::Function1d_d1 * serializeFunction1d_d1(LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode, Functions::Function1d_d1 *a_function1d)

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