1 -- 2 -- Patricia Fasel 3 -- Los Alamos National Laboratory 4 -- 1990 August 5 -- 6 module Pair (pair) where 7 8 import GamtebType 9 import Consts 10 import Utils 11 12 -- pair production after a collision 13 14 pair :: Particle -> (Particle, Probability, Bool) 15 pair (Part pos dir w e eIndx cell seed) = 16 if (e' <= ergCut) 17 then (Part pos dir w' e' eIndx' cell seed', prob', True) 18 else (Part pos dir' w' e' eIndx' cell seed', prob', False) 19 where 20 (seed', r2) = genRand seed 21 (r3, r4) = genRand r2 22 e' = 0.511008 23 (eIndx', prob') = xsectInterp e' 24 w' = 2*w 25 dir' = isos r3 26 27 28 -- sample a direction u,v,w isotropically 29 -- isotropic emission lab system 30 31 isos :: Random -> Point 32 isos r = 33 isos' t1 t2 (t1*t1 + t2*t2) 34 where 35 (r1, r2) = genRand r 36 (r3, r4) = genRand r2 37 t1 = 2*r4 - 1 38 t2 = 2*r3 - 1 39 isos' t1 t2 rsq 40 | rsq > 1 = 41 let 42 (r1, r2) = genRand r1 43 (r3, r4) = genRand r2 44 t1 = 2*r4 - 1 45 t2 = 2*r3 - 1 46 in 47 isos' t1 t2 (t1*t1 + t2*t2) 48 | otherwise = 49 let 50 u = 2*rsq - 1 51 t3 = sqrt (1 - u*u) / rsq 52 v = t1*t3 53 w = t2*t3 54 in 55 (u,v,w)