Given theta, R, Z, B and psi on 2D grids calculate the index space derivatives in the two grid dimensions and use these to find gradients in cartesian and Bishop space.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(abstract_geo_type), | intent(inout) | :: | self |
pure subroutine calculate_gradients(self)
implicit none
class(abstract_geo_type), intent(in out) :: self
! The following quantities represent changes between adjacent grid
! points. The first two dimensions are usually minor radius and theta,
! respectively. The last dimension is the difference along either
! the (minor) radial or theta directions, respectively
!> Major radius differences on theta, minor radius grids
real, allocatable, dimension (:,:,:) :: drm
!> Vertical differences on theta, minor radius grids
real, allocatable, dimension (:,:,:) :: dzm
!> Temporary version used to hold minor radius(psi), theta or B index space derivatives
real, allocatable, dimension (:,:,:) :: dtmp_m
! Need drm and dzm for all eqdcart calls
allocate(drm(self%nr, self%nt, 2), dzm(self%nr, self%nt, 2))
call self%derm(self%R_psi, drm, 'E')
call self%derm(self%Z_psi, dzm, 'O')
! grad(psi) in cartesian and bishop form
allocate(dtmp_m(self%nr, self%nt, 2))
call self%derm(self%eqpsi_2d, dtmp_m, 'E')
call self%eqdcart(dtmp_m, drm, dzm, self%dpcart)
call self%eqdbish(self%dpcart, self%dpcart, self%dpbish)
! grad(B) in cartesian and bishop form
call self%derm(self%B_psi, dtmp_m, 'E')
call self%eqdcart(dtmp_m, drm, dzm, self%dbcart)
call self%eqdbish(self%dbcart, self%dpcart, self%dbbish)
! grad(theta) in cartesian and bishop form
call self%derm(self%eqth, dtmp_m, 'T')
call self%eqdcart(dtmp_m, drm, dzm, self%dtcart)
call self%eqdbish(self%dtcart, self%dpcart, self%dtbish)
deallocate(dtmp_m, drm, dzm)
end subroutine calculate_gradients