Sample thermal Maxwellian distribution at beam_grid indices ind
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in), | dimension(3) | :: | ind | beam_grid indices |
|
real(kind=Float64), | intent(out), | dimension(3) | :: | vhalo | Velocity [cm/s] |
|
real(kind=Float64), | intent(out), | optional | dimension(3) | :: | ri | Position in beam_grid cell |
type(LocalProfiles), | intent(in), | optional | :: | plasma_in | Plasma parameters |
subroutine mc_halo(ind,vhalo,ri,plasma_in)
!+ Sample thermal Maxwellian distribution at [[libfida:beam_grid]] indices `ind`
integer, dimension(3), intent(in) :: ind
!+ [[libfida:beam_grid]] indices
real(Float64), dimension(3), intent(out) :: vhalo
!+ Velocity [cm/s]
real(Float64), dimension(3), intent(out), optional :: ri
!+ Position in [[libfida:beam_grid]] cell
type(LocalProfiles), intent(in), optional :: plasma_in
!+ Plasma parameters
type(LocalProfiles) :: plasma
real(Float64), dimension(3) :: random3
if(.not.present(plasma_in)) then
if(present(ri)) then
call randu(random3)
ri(1) = beam_grid%xc(ind(1)) + beam_grid%dr(1)*(random3(1) - 0.5)
ri(2) = beam_grid%yc(ind(2)) + beam_grid%dr(2)*(random3(2) - 0.5)
ri(3) = beam_grid%zc(ind(3)) + beam_grid%dr(3)*(random3(3) - 0.5)
call get_plasma(plasma,pos=ri)
else
call get_plasma(plasma,ind=ind)
endif
else
plasma=plasma_in
endif
call randn(random3)
vhalo = plasma%vrot + sqrt(plasma%ti*0.5/(v2_to_E_per_amu*inputs%ai))*random3 !![cm/s]
end subroutine mc_halo