HalfToFull Subroutine

public subroutine HalfToFull(nFlux, y_half, y_full)

Uses

  • proc~~halftofull~~UsesGraph proc~halftofull HalfToFull module~modgvec_cubic_spline MODgvec_cubic_spline proc~halftofull->module~modgvec_cubic_spline module~modgvec_globals MODgvec_Globals module~modgvec_cubic_spline->module~modgvec_globals module~sll_m_bsplines sll_m_bsplines module~modgvec_cubic_spline->module~sll_m_bsplines iso_fortran_env iso_fortran_env module~modgvec_globals->iso_fortran_env module~sll_m_assert sll_m_assert module~sll_m_bsplines->module~sll_m_assert module~sll_m_bsplines_base sll_m_bsplines_base module~sll_m_bsplines->module~sll_m_bsplines_base module~sll_m_bsplines_non_uniform sll_m_bsplines_non_uniform module~sll_m_bsplines->module~sll_m_bsplines_non_uniform module~sll_m_bsplines_uniform sll_m_bsplines_uniform module~sll_m_bsplines->module~sll_m_bsplines_uniform module~sll_m_errors sll_m_errors module~sll_m_bsplines->module~sll_m_errors module~sll_m_working_precision sll_m_working_precision module~sll_m_bsplines->module~sll_m_working_precision module~sll_m_bsplines_base->module~sll_m_assert module~sll_m_bsplines_base->module~sll_m_working_precision module~sll_m_bsplines_non_uniform->module~sll_m_assert module~sll_m_bsplines_non_uniform->module~sll_m_bsplines_base module~sll_m_bsplines_non_uniform->module~sll_m_working_precision module~sll_m_bsplines_uniform->module~sll_m_assert module~sll_m_bsplines_uniform->module~sll_m_bsplines_base module~sll_m_bsplines_uniform->module~sll_m_errors module~sll_m_bsplines_uniform->module~sll_m_working_precision module~sll_m_errors->iso_fortran_env

Fit disrete data along flux surfaces as spline and then interpolate to full data

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: nFlux

number of flux surfaces

real(kind=wp), intent(in) :: y_half(2:nFlux)

value number 2 at axis+1/2 grid point,last at 1-1/2dx

real(kind=wp), intent(out) :: y_full(1:nFlux)

values at full grid (first on axis)


Calls

proc~~halftofull~~CallsGraph proc~halftofull HalfToFull proc~cubspl_eval t_cubspl%cubspl_eval proc~halftofull->proc~cubspl_eval eval_basis eval_basis proc~cubspl_eval->eval_basis eval_basis_and_n_derivs eval_basis_and_n_derivs proc~cubspl_eval->eval_basis_and_n_derivs

Called by

proc~~halftofull~~CalledByGraph proc~halftofull HalfToFull proc~readnemec ReadNEMEC proc~readnemec->proc~halftofull proc~readvmec ReadVMEC proc~readvmec->proc~readnemec proc~initvmec InitVMEC proc~initvmec->proc~readvmec

Source Code

SUBROUTINE HalfToFull(nFlux,y_half,y_full)
! MODULES
  USE MODgvec_cubic_spline, ONLY:t_cubspl
! IMPLICIT VARIABLE HANDLING
  IMPLICIT NONE
!-----------------------------------------------------------------------------------------------------------------------------------
! INPUT VARIABLES
  INTEGER, INTENT(IN) :: nFlux          !! number of flux surfaces
  REAL(wp),INTENT(IN) :: y_half(2:nFlux)  !! value number 2 at axis+1/2 grid point,last at 1-1/2dx
!-----------------------------------------------------------------------------------------------------------------------------------
! OUTPUT VARIABLES
! LOCAL VARIABLES
  REAL(wp),INTENT(OUT):: y_full(1:nFlux) !! values at full grid (first on axis)
!-----------------------------------------------------------------------------------------------------------------------------------
! LOCAL VARIABLES
  INTEGER           :: iFlux
  REAL(wp)          :: y_half_Spl(nFlux+1)  ! point values fitted on half grid
  REAL(wp)          :: rho(1:nFlux)
  REAL(wp)          :: rho_half(1:nFlux+1)
  INTEGER           :: iFlag
  CHARACTER(len=100):: message
  TYPE(t_cubspl),ALLOCATABLE    :: spl_half ! spline on half grid
!===================================================================================================================================
  rho(1)=0.
  DO iFlux=2,nFlux
    rho(iFlux)=REAL(iFlux-1,wp)/REAL(nFlux-1,wp) !equidistant grid [0,1]
    rho_half(iFlux)=SQRT(0.5_wp*(rho(iFlux)+rho(iFlux-1))) !halfgrid scaled with sqrt
  END DO
  rho=SQRT(rho) !full grid scaled with sqrt
  !add end points
  rho_half(1)=0.0_wp
  rho_half(nFlux+1)=1.0_wp

  y_half_Spl=0.
  DO iFlux=2,nFlux
      y_half_Spl(iFlux)=y_half(iFlux)
  END DO !i
  !Parabolic extrapolation to axis with dx'(rho=0)=0.0_wp
  y_Half_Spl(1)=(y_Half_Spl(2)*rho_half(3)**2-y_Half_Spl(3)*rho_half(2)**2) /(rho_half(3)**2-rho_half(2)**2)
  !Extrapolate to Edge
  y_Half_Spl(nFlux+1)= ( y_half_Spl(nFlux  )*(rho_half(nFlux+1)-rho_half(nFlux-1))     &
                        -y_half_Spl(nFlux-1)*(rho_half(nFlux+1)-rho_half(nFlux  )) )   &
                      /(  rho_half(nFlux)   -rho_half(nFlux-1) )
  spl_half=t_cubspl(rho_half,y_half_spl(:), BC=(/1,0/))
  iflag=0
  message=''
  y_full(:)=spl_half%eval(rho,0)
  !redo extrapolation with rho
  y_full(1)  =(y_full(2)*rho(3)**2-y_full(3)*rho(2)**2) /(rho(3)**2-rho(2)**2)

END SUBROUTINE HalfToFull