Gets plasma parameters at position pos
or beam_grid indices ind
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(LocalProfiles), | intent(out) | :: | plasma | Plasma parameters at |
||
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 |
integer(kind=Int32), | intent(in), | optional | :: | input_coords | Indicates coordinate system of inputs. Beam grid (0), machine (1) and cylindrical (2) |
|
integer(kind=Int32), | intent(in), | optional | :: | output_coords | Indicates coordinate system of outputs. Beam grid (0), machine (1) and cylindrical (2) |
subroutine get_plasma(plasma, pos, ind, input_coords, output_coords)
!+ Gets plasma parameters at position `pos` or [[libfida:beam_grid]] indices `ind`
type(LocalProfiles), intent(out) :: plasma
!+ Plasma parameters at `pos`/`ind`
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
integer(Int32), intent(in), optional :: input_coords
!+ Indicates coordinate system of inputs. Beam grid (0), machine (1) and cylindrical (2)
integer(Int32), intent(in), optional :: output_coords
!+ Indicates coordinate system of outputs. Beam grid (0), machine (1) and cylindrical (2)
logical :: inp
type(InterpolCoeffs3D) :: coeffs
real(Float64), dimension(3) :: xyz, uvw, cyl, vrot_uvw
real(Float64) :: phi, s, c
integer :: i, j, k, k2, ics, ocs
plasma%in_plasma = .False.
if(present(input_coords)) then
ics = input_coords
else
ics = 0
endif
if(present(output_coords)) then
ocs = output_coords
else
ocs = 0
endif
if(present(ind)) then
if(ics.eq.0) then
call get_position(ind,xyz)
endif
if(ics.eq.2) then
call get_position(ind,xyz,input_coords=2)
endif
endif
if(present(pos)) then
if(ics.eq.0) then
xyz = pos
call xyz_to_uvw(xyz, uvw)
endif
if(ics.eq.1) then
uvw = pos
call uvw_to_xyz(uvw, xyz)
endif
endif
call in_plasma(xyz,inp,0,coeffs)
if(inp) then
phi = atan2(uvw(2),uvw(1))
i = coeffs%i
j = coeffs%j
k = coeffs%k
if(inter_grid%nphi .eq. 1) then
k2 = min(k+1,inter_grid%nphi)
else
k2 = k+1
endif
plasma = coeffs%b111*equil%plasma(i,j,k) + coeffs%b121*equil%plasma(i,j+1,k) + &
coeffs%b112*equil%plasma(i,j,k2) + coeffs%b122*equil%plasma(i,j+1,k2) + &
coeffs%b211*equil%plasma(i+1,j,k) + coeffs%b221*equil%plasma(i+1,j+1,k) + &
coeffs%b212*equil%plasma(i+1,j,k2) + coeffs%b222*equil%plasma(i+1,j+1,k2)
s = sin(phi) ; c = cos(phi)
vrot_uvw(1) = plasma%vr*c - plasma%vt*s
vrot_uvw(2) = plasma%vr*s + plasma%vt*c
vrot_uvw(3) = plasma%vz
if(ocs.eq.0) then
plasma%vrot = matmul(beam_grid%inv_basis,vrot_uvw)
plasma%pos = xyz
endif
if(ocs.eq.1) then
plasma%vrot = vrot_uvw
plasma%pos = uvw
endif
plasma%uvw = uvw
plasma%in_plasma = .True.
plasma%b = coeffs
endif
end subroutine get_plasma