get_ep_denf Subroutine

public subroutine get_ep_denf(energy, pitch, denf, pos, ind, coeffs)

Get guiding center fast-ion density at given energy and pitch at position pos or beam_grid indices ind

Arguments

Type IntentOptional AttributesName
real(kind=Float64), intent(in) :: energy

Energy [keV]

real(kind=Float64), intent(in) :: pitch

Pitch

real(kind=Float64), intent(out) :: denf

Fast-ion density [fast-ions/(cm^3dEdp)]

real(kind=Float64), intent(in), optional dimension(3):: pos

Position in beam grid coordinates

integer(kind=Int32), intent(in), optional dimension(3):: ind

beam_grid indices

type(InterpolCoeffs2D), intent(in), optional :: coeffs

Precomputed Linear Interpolation Coefficients


Calls

proc~~get_ep_denf~~CallsGraph proc~get_ep_denf get_ep_denf interface~interpol interpol proc~get_ep_denf->interface~interpol proc~xyz_to_uvw xyz_to_uvw proc~get_ep_denf->proc~xyz_to_uvw proc~interpol2d_arr interpol2D_arr interface~interpol->proc~interpol2d_arr proc~interpol1d_arr interpol1D_arr interface~interpol->proc~interpol1d_arr proc~interpol2d_2d_arr interpol2D_2D_arr interface~interpol->proc~interpol2d_2d_arr interface~interpol_coeff interpol_coeff proc~interpol2d_arr->interface~interpol_coeff proc~interpol1d_arr->interface~interpol_coeff proc~interpol2d_2d_arr->interface~interpol_coeff proc~interpol2d_coeff interpol2D_coeff interface~interpol_coeff->proc~interpol2d_coeff proc~interpol1d_coeff interpol1D_coeff interface~interpol_coeff->proc~interpol1d_coeff proc~interpol2d_coeff_arr interpol2D_coeff_arr interface~interpol_coeff->proc~interpol2d_coeff_arr proc~interpol1d_coeff_arr interpol1D_coeff_arr interface~interpol_coeff->proc~interpol1d_coeff_arr proc~interpol2d_coeff_arr->proc~interpol2d_coeff proc~interpol1d_coeff_arr->proc~interpol1d_coeff

Called by

proc~~get_ep_denf~~CalledByGraph proc~get_ep_denf get_ep_denf proc~fida_weights_mc fida_weights_mc proc~fida_weights_mc->proc~get_ep_denf program~fidasim fidasim program~fidasim->proc~fida_weights_mc

Contents

Source Code


Source Code

subroutine get_ep_denf(energy, pitch, denf, pos, ind, coeffs)
    !+ Get guiding center fast-ion density at given energy and pitch
    !+ at position `pos` or [[libfida:beam_grid]] indices `ind`
    real(Float64), intent(in)                          :: energy
        !+ Energy [keV]
    real(Float64), intent(in)                          :: pitch
        !+ Pitch
    real(Float64), intent(out)                         :: denf
        !+ Fast-ion density [fast-ions/(cm^3*dE*dp)]
    real(Float64), dimension(3), intent(in), optional  :: pos
        !+ Position in beam grid coordinates
    integer(Int32), dimension(3), intent(in), optional :: ind
        !+ [[libfida:beam_grid]] indices
    type(InterpolCoeffs2D), intent(in), optional       :: coeffs
        !+ Precomputed Linear Interpolation Coefficients

    real(Float64), dimension(3) :: xyz, uvw
    real(Float64), dimension(fbm%nenergy,fbm%npitch)  :: fbeam
    integer(Int32), dimension(2) :: epi
    integer(Int32), dimension(1) :: dummy
    real(Float64) :: R, Z
    real(Float64) :: dE, dp
    integer :: err

    dummy = minloc(abs(fbm%energy - energy))
    epi(1) = dummy(1)
    dummy = minloc(abs(fbm%pitch - pitch))
    epi(2) = dummy(1)
    dE = abs(fbm%energy(epi(1)) - energy)
    dp = abs(fbm%pitch(epi(2)) - pitch)

    if((dE.le.fbm%dE).and.(dp.le.fbm%dp)) then
        if(present(coeffs)) then
            call interpol(inter_grid%r, inter_grid%z, fbm%f, R, Z, fbeam, err, coeffs)
        else
            if(present(ind)) call get_position(ind,xyz)
            if(present(pos)) xyz = pos

            !! Convert to machine coordinates
            call xyz_to_uvw(xyz,uvw)
            R = sqrt(uvw(1)*uvw(1) + uvw(2)*uvw(2))
            Z = uvw(3)

            call interpol(inter_grid%r, inter_grid%z, fbm%f, R, Z, fbeam, err)
        endif
        denf = fbeam(epi(1),epi(2))
    else
        denf = 0.0
    endif

end subroutine get_ep_denf