CheckFieldPeriodicity Subroutine

public subroutine CheckFieldPeriodicity(sf, sgn_rot, error_nfp)

Check that the TNB frame really has the field periodicity of NFP: assumption for now is that the origin is fixed at rot_origin=(/0.,0.,0./) and the rotation axis is fixed at rot_axis=(/0.,0.,1./) sign of the rotation 'sgn_rot' is now accounted for in the transformation to xhat, so it has to be passed here.

Arguments

Type IntentOptional Attributes Name
class(t_hmap_axisNB), intent(in) :: sf
integer, intent(in) :: sgn_rot

sign of rotation

integer, intent(out) :: error_nfp

Calls

proc~~checkfieldperiodicity~~CallsGraph proc~checkfieldperiodicity CheckFieldPeriodicity proc~hmap_axisnb_eval_tnb_hat t_hmap_axisNB%hmap_axisNB_eval_TNB_hat proc~checkfieldperiodicity->proc~hmap_axisnb_eval_tnb_hat proc~rodrigues rodrigues proc~checkfieldperiodicity->proc~rodrigues __matvec_n __matvec_n proc~hmap_axisnb_eval_tnb_hat->__matvec_n proc~fbase_eval t_fBase%fBase_eval proc~hmap_axisnb_eval_tnb_hat->proc~fbase_eval interface~cross CROSS proc~rodrigues->interface~cross interface~cross->interface~cross proc~fbase_eval_xn t_fBase%fBase_eval_xn proc~fbase_eval->proc~fbase_eval_xn

Called by

proc~~checkfieldperiodicity~~CalledByGraph proc~checkfieldperiodicity CheckFieldPeriodicity proc~hmap_axisnb_init_params hmap_axisNB_init_params proc~hmap_axisnb_init_params->proc~checkfieldperiodicity interface~t_hmap_axisnb t_hmap_axisNB interface~t_hmap_axisnb->proc~hmap_axisnb_init_params proc~hmap_axisnb_init hmap_axisNB_init interface~t_hmap_axisnb->proc~hmap_axisnb_init proc~hmap_axisnb_init->proc~hmap_axisnb_init_params

Source Code

SUBROUTINE CheckFieldPeriodicity( sf ,sgn_rot,error_nfp)
! MODULES
IMPLICIT NONE
!-----------------------------------------------------------------------------------------------------------------------------------
! INPUT VARIABLES
  CLASS(t_hmap_axisNB), INTENT(IN) :: sf
  INTEGER, INTENT(in)   :: sgn_rot !! sign of rotation
!-----------------------------------------------------------------------------------------------------------------------------------
! OUTPUT VARIABLES
  INTEGER, INTENT(out)  :: error_nfp
!-----------------------------------------------------------------------------------------------------------------------------------
! LOCAL VARIABLES
  REAL(wp)              :: dzeta_fp
  REAL(wp),DIMENSION(3) :: X0_a,T,N_a,B_a,Np,Bp
  REAL(wp),DIMENSION(3) :: X0_b,N_b,B_b
  INTEGER               :: ifp,iz,error_x,error_n,error_b
!===================================================================================================================================
  error_nfp=0

  dzeta_fp=TWOPI/REAL(sf%nfp,wp)
  CALL sf%eval_TNB(sf%zeta(1),X0_a,T,N_a,B_a,Np,Bp)
  CALL sf%eval_TNB(sf%zeta(1)+dzeta_fp,X0_b,T,N_b,B_b,Np,Bp)
  DO ifp=0,sf%nfp
    error_x=0
    error_n=0
    error_b=0
    DO iz=1,sf%nzeta
      CALL sf%eval_TNB(sf%zeta(iz)+ ifp*dzeta_fp   ,X0_a,T,N_a,B_a,Np,Bp)
      CALL sf%eval_TNB(sf%zeta(iz)+(ifp+1)*dzeta_fp,X0_b,T,N_b,B_b,Np,Bp)
      IF(.NOT.(SUM((X0_b -  rodrigues(X0_a,sgn_rot*dzeta_fp))**2).LT.1.0e-12))THEN
        error_x=error_x+1
      END IF
      IF(.NOT.(SUM((X0_b+N_b -  rodrigues(X0_a+N_a,sgn_rot*dzeta_fp))**2).LT.1.0e-12))THEN
        error_n=error_n+1
      END IF
      IF(.NOT.(SUM((X0_b+B_b -  rodrigues(X0_a+B_a,sgn_rot*dzeta_fp))**2).LT.1.0e-12))THEN
        error_b=error_b+1
      END IF
    END DO !iz
    IF(error_x.NE.0)THEN
      WRITE(UNIT_stdOut,*)'problem in CheckFieldPeriodicity: at least one pair of two axis points do not match at NFP'
      error_nfp=-10
      IF(error_n.NE.0)THEN
        WRITE(UNIT_stdOut,*)'problem in CheckFieldPeriodicity: at least one pair of two normal vectors do not match at NFP'
        error_nfp=-20
      ELSEIF(error_b.NE.0)THEN
        WRITE(UNIT_stdOut,*)'problem in CheckFieldPeriodicity: at least one pair of two bi-normal vectors do not match at NFP'
        error_nfp=-30
      END IF
    END IF
  END DO !ifp

END SUBROUTINE CheckFieldPeriodicity