Fit disrete data along flux surfaces as spline and then interpolate to full data
| Type | Intent | Optional | 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) |
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