Subroutine that calculates and returns the analytic electric and magnetic field for each particle in the simulation.
The analytical magnetic field is given by:
where is the aspect ratio, the constant denotes the magnitude of the toroidal magnetic field, and is the poloidal magnetic field with safety factor . The constant is the safety factor at the magnetic axis and the constant is obtained from the values of and at the plasma edge . On the other hand, the analytical electric fields is given by:
where is the electric field as measured at the mangetic axis.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(FIELDS), | intent(in) | :: | F | An instance of the KORC derived type FIELDS. |
||
real(kind=rp), | intent(in), | DIMENSION(:,:), ALLOCATABLE | :: | Y | Toroidal coordinates of each particle in the simulation; Y(1,:) = , Y(2,:) = , Y(3,:) = . |
|
real(kind=rp), | intent(inout), | DIMENSION(:,:), ALLOCATABLE | :: | E | Electric field components in Cartesian coordinates; E(1,:) = , E(2,:) = , E(3,:) = |
|
real(kind=rp), | intent(inout), | DIMENSION(:,:), ALLOCATABLE | :: | B | Magnetic field components in Cartesian coordinates; B(1,:) = , B(2,:) = , B(3,:) = |
|
integer(kind=is), | intent(in), | DIMENSION(:), ALLOCATABLE | :: | flag | Flag for each particle to decide whether it is being followed (flag=T) or not (flag=F). |
subroutine analytical_fields(F,Y,E,B,flag)
!! @note Subroutine that calculates and returns the analytic electric and
!! magnetic field for each particle in the simulation. @endnote
!! The analytical magnetic field is given by:
!!
!! $$\mathbf{B}(r,\vartheta) = \frac{1}{1 + \eta \cos{\vartheta}}
!! \left[ B_0 \hat{e}_\zeta + B_\vartheta(r) \hat{e}_\vartheta \right],$$
!!
!! where \(\eta = r/R_0\) is the aspect ratio, the constant \(B_0\)
!! denotes the magnitude of the toroidal magnetic field,
!! and \(B_\vartheta(r) = \eta B_0/q(r)\) is the poloidal magnetic
!! field with
!! safety factor \(q(r) = q_0\left( 1 + \frac{r^2}{\lambda^2} \right)\).
!! The constant \(q_0\) is the safety factor at the magnetic axis and
!! the constant \(\lambda\) is obtained from the values of \(q_0\)
!! and \(q(r)\) at the plasma edge \(r=r_{edge}\). On the other hand,
!! the analytical electric fields is given by:
!!
!! $$\mathbf{E}(r,\vartheta) = \frac{1}{1 + \eta \cos{\vartheta}}
!! E_0 \hat{e}_\zeta,$$
!!
!! where \(E_0\) is the electric field as measured at the mangetic axis.
TYPE(FIELDS), INTENT(IN) :: F
!! An instance of the KORC derived type FIELDS.
REAL(rp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: Y
!! Toroidal coordinates of each particle in the simulation;
!! Y(1,:) = \(r\), Y(2,:) = \(\theta\), Y(3,:) = \(\zeta\).
REAL(rp), DIMENSION(:,:), ALLOCATABLE, INTENT(INOUT) :: B
!! Magnetic field components in Cartesian coordinates;
!! B(1,:) = \(B_x\), B(2,:) = \(B_y\), B(3,:) = \(B_z\)
REAL(rp), DIMENSION(:,:), ALLOCATABLE, INTENT(INOUT) :: E
!! Electric field components in Cartesian coordinates;
!! E(1,:) = \(E_x\), E(2,:) = \(E_y\), E(3,:) = \(E_z\)
INTEGER(is), DIMENSION(:), ALLOCATABLE, INTENT(IN) :: flag
!! Flag for each particle to decide whether it is being followed (flag=T)
!! or not (flag=F).
REAL(rp) :: Ezeta
!! Toroidal electric field \(E_\zeta\).
REAL(rp) :: Bzeta
!! Toroidal magnetic field \(B_\zeta\).
REAL(rp) :: Bp
!! Poloidal magnetic field \(B_\theta(r)\).
REAL(rp) :: eta
!! Aspect ratio \(\eta\).
REAL(rp) :: q
!! Safety profile \(q(r)\).
INTEGER(ip) :: pp ! Iterator(s)
!! Particle iterator.
INTEGER(ip) :: ss
!! Particle species iterator.
ss = SIZE(Y,1)
!$OMP PARALLEL DO FIRSTPRIVATE(ss) PRIVATE(pp,Ezeta,Bp,Bzeta,eta,q) &
!$OMP& SHARED(F,Y,E,B,flag)
do pp=1_idef,ss
if ( flag(pp) .EQ. 1_is ) then
eta = Y(pp,1)/F%Ro
q = F%AB%qo*(1.0_rp + (Y(pp,1)/F%AB%lambda)**2)
Bp = -eta*F%AB%Bo/(q*(1.0_rp + eta*COS(Y(pp,2))))
Bzeta = F%AB%Bo/( 1.0_rp + eta*COS(Y(pp,2)) )
B(pp,1) = Bzeta*COS(Y(pp,3)) - Bp*SIN(Y(pp,2))*SIN(Y(pp,3))
B(pp,2) = -Bzeta*SIN(Y(pp,3)) - Bp*SIN(Y(pp,2))*COS(Y(pp,3))
B(pp,3) = Bp*COS(Y(pp,2))
if (abs(F%Eo) > 0) then
Ezeta = -F%Eo/( 1.0_rp + eta*COS(Y(pp,2)) )
E(pp,1) = Ezeta*COS(Y(pp,3))
E(pp,2) = -Ezeta*SIN(Y(pp,3))
E(pp,3) = 0.0_rp
end if
end if
end do
!$OMP END PARALLEL DO
end subroutine analytical_fields