Indicator subroutine to determine if a position is in a region where the plasma parameter and fields are valid/known
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=Float64), | intent(in), | dimension(3) | :: | xyz | Position in beam coordinates |
|
logical, | intent(out) | :: | inp | Indicates whether plasma parameters and fields are valid/known |
||
logical, | intent(in), | optional | :: | machine_coords | Indicates that xyz is in machine coordinates |
|
type(InterpolCoeffs2D), | intent(out), | optional | :: | coeffs | Linear Interpolation coefficients used in calculation |
|
real(kind=Float64), | intent(out), | optional | dimension(3) | :: | uvw_out | Position in machine coordinates |
subroutine in_plasma(xyz, inp, machine_coords, coeffs, uvw_out)
!+ Indicator subroutine to determine if a position is in a region where
!+ the plasma parameter and fields are valid/known
real(Float64), dimension(3), intent(in) :: xyz
!+ Position in beam coordinates
logical, intent(out) :: inp
!+ Indicates whether plasma parameters and fields are valid/known
logical, intent(in), optional :: machine_coords
!+ Indicates that xyz is in machine coordinates
type(InterpolCoeffs2D), intent(out), optional :: coeffs
!+ Linear Interpolation coefficients used in calculation
real(Float64), dimension(3), intent(out), optional :: uvw_out
!+ Position in machine coordinates
real(Float64), dimension(3) :: uvw
type(InterpolCoeffs2D) :: c
real(Float64) :: R, W, mask
logical :: mc
integer :: i, j, err
err = 1
mc = .False.
if(present(machine_coords)) mc = machine_coords
if(mc) then
uvw = xyz
else
!! Convert to machine coordinates
call xyz_to_uvw(xyz,uvw)
endif
R = sqrt(uvw(1)*uvw(1) + uvw(2)*uvw(2))
W = uvw(3)
!! Interpolate mask value
call interpol_coeff(inter_grid%r, inter_grid%z, R, W, c, err)
inp = .False.
if(err.eq.0) then
i = c%i
j = c%j
mask = c%b11*equil%mask(i,j) + c%b12*equil%mask(i,j+1) + &
c%b21*equil%mask(i+1,j) + c%b22*equil%mask(i+1,j+1)
if((mask.ge.0.5).and.(err.eq.0)) then
inp = .True.
endif
endif
if(present(coeffs)) coeffs = c
if(present(uvw_out)) uvw_out = uvw
end subroutine in_plasma