Samples a Guiding Center Fast-ion distribution function at a given beam_grid index
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in), | dimension(3) | :: | ind | beam_grid index |
|
type(LocalEMFields), | intent(out) | :: | fields | Electromagnetic fields at the guiding center |
||
real(kind=Float64), | intent(out) | :: | eb | Energy of the fast ion |
||
real(kind=Float64), | intent(out) | :: | ptch | Pitch of the fast ion |
||
real(kind=Float64), | intent(out) | :: | denf | Fast-ion density at guiding center |
subroutine mc_fastion(ind,fields,eb,ptch,denf)
!+ Samples a Guiding Center Fast-ion distribution function at a given [[libfida:beam_grid]] index
integer, dimension(3), intent(in) :: ind
!+ [[libfida:beam_grid]] index
type(LocalEMFields), intent(out) :: fields
!+ Electromagnetic fields at the guiding center
real(Float64), intent(out) :: eb
!+ Energy of the fast ion
real(Float64), intent(out) :: ptch
!+ Pitch of the fast ion
real(Float64), intent(out) :: denf
!+ Fast-ion density at guiding center
real(Float64), dimension(fbm%nenergy,fbm%npitch) :: fbeam
real(Float64), dimension(3) :: rg
real(Float64), dimension(3) :: randomu3
integer, dimension(2,1) :: ep_ind
call mc_beam_grid(ind, rg)
denf=0.d0
call get_fields(fields,pos=rg)
if(.not.fields%in_plasma) return
call get_distribution(fbeam,denf,pos=rg, coeffs=fields%b)
call randind(fbeam,ep_ind)
call randu(randomu3)
eb = fbm%energy(ep_ind(1,1)) + fbm%dE*(randomu3(1)-0.5)
ptch = fbm%pitch(ep_ind(2,1)) + fbm%dp*(randomu3(2)-0.5)
end subroutine mc_fastion