A subroutine to calculate the time-averaged antenna current j_ext = kperp^2 A_antenna.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(diagnostics_type), | intent(in) | :: | gnostics | |||
real, | intent(out), | dimension(:,:) | :: | j_ext |
subroutine calc_jext (gnostics, j_ext)
use mp, only: proc0
use antenna, only: antenna_apar
use volume_averages, only: average_theta
use theta_grid, only: ntgrid
use kt_grids, only: kperp2, ntheta0, naky
use diagnostics_config, only: diagnostics_type
implicit none
!Passed
type(diagnostics_type), intent(in) :: gnostics
integer:: istep
real, dimension(:,:), intent(out) :: j_ext
complex, dimension(:,:,:), allocatable :: j_extz
!Local
integer :: i
istep = gnostics%istep
!call get_jext(j_ext)
allocate (j_extz(-ntgrid:ntgrid, ntheta0, naky)) ; j_extz = 0.
call antenna_apar (kperp2, j_extz)
j_extz(ntgrid-1,:,:) = 0.
call average_theta(real(j_extz), j_ext, gnostics%distributed)
deallocate (j_extz)
!Do averages with a history variable
if (proc0) then
!Save variable to history
if (gnostics%navg > 1) then
! This looks a little odd as we ignore the first step
if (istep > 1) j_ext_hist(:,:,mod(istep,gnostics%navg)) = j_ext(:,:)
!Use average of history
if (istep >= gnostics%navg) then
j_ext=0.
do i=0,gnostics%navg-1
j_ext(:,:) = j_ext(:,:) + j_ext_hist(:,:,i) / real(gnostics%navg)
end do
end if
end if
end if
end subroutine calc_jext