Download CUDAMCML - Atomic Physics
Transcript
A.2.2 LaunchPhoton() Definition: __device__ void LaunchPhoton(PhotonStruct* p, unsigned long long* x, unsigned int* a) This function is used to set the initial state of a photon (by setting all the fields of the corresponding PhotonStruct to suitable values). The function uses the constant device memory variable start_weight_dc to set the initial weight of the photon, taking the specular reflection into account. The two variables used for the RNG are provided as arguments for future applications where the initial photon state is in any way randomized. A.2.3 Spin() Definition: __device__ void Spin(PhotonStruct* p, float g, unsigned long long* x, unsigned int* a) This function calculates a new direction for the photon, based on the anisotropy-factor g, provided as an argument. The function is very similar to the MCML equivalent with one minor, but potentially important addition. After the spin calculation, the direction is normalized. Since 32-bit floats has worse precision than the double precision floats used in MCML, the numerical accuracy in all calculations are reduced. When performing several operation on a set of floats, the numerical error will accumulate and after a while the length of a previously normalized vector will differ from unity. This problem isn’t to bad for ordinary MCML simulations, but for future applications this might be an issue and hence the normalization is provided. A.2.4 Reflect() Definition: __device__ unsigned int Reflect(PhotonStruct* p, int new_layer, unsigned long long* x, unsigned int* a) This function calculates whether the photon is reflected or not. The PhotonStruct-pointer p contains the information on the current layer index (the field layer) and the argument new_layer carries the index of the second layer. The function is very similar to it’s MCML equivalent but the actual calculations have been rewritten. This, less clear, implementation of the calculations is slightly faster and requires fewer registers. The function returns 1 if the photon is reflected and 0 if it is transmitted. Regardless, p is updated with the new photon direction and layer. A.2.5 PhotonSurvive() Definition: __device__ unsigned int PhotonSurvive(PhotonStruct* p, unsigned long long* x, unsigned int* a) 21