Commit d1058505 authored by Caneses Marin, Juan Francisco's avatar Caneses Marin, Juan Francisco
Browse files

Added plasmaTYP to RF operator succesfully

parent 6590deac
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
&in_nml
! Simulation name:
! ===============
in%fileDescriptor = '2021_02_16c',
in%fileDescriptor = '2021_02_16d',

! Magnetic field input data:
! =========================
+1 −1
Original line number Diff line number Diff line
&in_nml
! Simulation name:
! ===============
in%fileDescriptor = '2021_02_16b',
in%fileDescriptor = '2021_02_16d',

! Magnetic field input data:
! =========================
+31 −12
Original line number Diff line number Diff line
@@ -267,7 +267,7 @@ RETURN
END SUBROUTINE CyclotronResonanceNumber

! =======================================================================================================
SUBROUTINE RFHeatingOperator(zp0,kep0,xip0,ecnt,pcnt,in0,spline_B,spline_dB,spline_ddB,spline_dV)
SUBROUTINE RFHeatingOperator(i,plasma,ecnt,pcnt,in0,spline_B,spline_dB,spline_ddB,spline_dV)
! =======================================================================================================
USE local
USE spline_fits
@@ -275,10 +275,15 @@ USE PhysicalConstants
USE dataTYP

IMPLICIT NONE
! Define interface variables:
INTEGER(i4)    , INTENT(IN)    :: i
TYPE(plasmaTYP), INTENT(INOUT) :: plasma
REAL(r8)       , INTENT(INOUT) :: ecnt, pcnt
TYPE(inTYP)    , INTENT(IN)    :: in0
TYPE(splTYP)   , INTENT(IN)    :: spline_B, spline_dB, spline_ddB, spline_dV

! Define local variables:
TYPE(inTYP)  :: in0
TYPE(splTYP) :: spline_B, spline_dB, spline_ddB, spline_dV
REAL(r8) :: zp0, kep0, xip0, ecnt, pcnt
REAL(r8) :: zp0, kep0, xip0
REAL(r8) :: u0, upar0, uper0
REAL(r8) :: kep_par0, kep_per0
REAL(r8) :: dB, ddB, dV
@@ -291,6 +296,11 @@ REAL(r8) :: kep_per1, kep_par1
REAL(r8) :: upar1, u1
REAL(r8) :: Ma, qa

! Input variables:
zp0  = plasma%zp(i)
kep0 = plasma%kep(i)
xip0 = plasma%xip(i)

! Test particle mass:
Ma = in0%Ma

@@ -375,14 +385,14 @@ if (kep1 .LT. 0) then
end if

! Assign value of the new energy:
kep0 = kep1
plasma%kep(i) = kep1

! Calculate the new pitch angle:
upar1 = sqrt( (2.*e_c/Ma)*abs(kep_par1) )*dsign(1.d0,xip0)*dsign(1.d0,kep_par1)
u1    = sqrt( (2.*e_c/Ma)*kep1 )
!WRITE(*,*) "zp0", zp0
!WRITE(*,*) "xip0", xip0
xip0 = upar1/u1
plasma%xip(i) = upar1/u1
!WRITE(*,*) "xip1", xip0

! Record resonance event:
@@ -394,15 +404,19 @@ RETURN
END SUBROUTINE RFHeatingOperator

! =======================================================================================================
SUBROUTINE loadParticles(zp0,kep0,xip0,in0)
SUBROUTINE loadParticles(i,plasma,in0)
! =======================================================================================================
  USE local
  use PhysicalConstants
  USE dataTYP

  IMPLICIT NONE
  ! Define interface variables:
  INTEGER(i4)    , INTENT(IN)    :: i
  TYPE(plasmaTYP), INTENT(INOUT) :: plasma
  TYPE(inTYP)    , INTENT(IN)    :: in0

  ! Declare internal variables:
  TYPE(inTYP) :: in0
  REAL(r8) :: zp0, kep0, xip0
  REAL(r8) :: X1, X2, X3, X4
  REAL(r8) :: R_1, R_2, R_3, R_4, t_2, t_4
@@ -410,18 +424,23 @@ SUBROUTINE loadParticles(zp0,kep0,xip0,in0)
  REAL(r8) :: zmin, zmax, sigma_v, Ma
  REAL(r8) :: Ux, Uy, Uz, vT, U, T, E
  
  ! Input variables:
  zp0  = plasma%zp(i)
  kep0 = plasma%kep(i)
  xip0 = plasma%xip(i)

  ! Particle position:
  zmin = in0%zmin !+ .01*(in0%zmax-in0%zmin)
  zmax = in0%zmax !- .01*(in0%zmax-in0%zmin)
  if (in0%IC_Type .EQ. 1) then
      ! Uniform load
      call random_number(X1)
      zp0 = zmin + (zmax - zmin)*X1
      plasma%zp(i) = zmin + (zmax - zmin)*X1
  elseif (in0%IC_Type .EQ. 2) then
      ! Gaussian load
      call random_number(X1)
      call random_number(X2)
      zp0 = in0%IC_zp_std*sqrt(-2.*log(X1))*cos(2.*pi*X2)  +  in0%IC_zp_mean
      plasma%zp(i) = in0%IC_zp_std*sqrt(-2.*log(X1))*cos(2.*pi*X2)  +  in0%IC_zp_mean
  end if

  ! Particle kinetic energy and pitch angle:
@@ -458,8 +477,8 @@ SUBROUTINE loadParticles(zp0,kep0,xip0,in0)
  v = sqrt( vx**2. + vy**2. + vz**2. )

  ! Populate output variables:
  kep0 = 0.5*(Ma/e_c)*v**2
  xip0 = vz/v
  plasma%kep(i) = 0.5*(Ma/e_c)*v**2
  plasma%xip(i) = vz/v

RETURN
END SUBROUTINE loadParticles
+2 −3
Original line number Diff line number Diff line
@@ -188,7 +188,7 @@ if (OMP_GET_THREAD_NUM() .EQ. 0) then
end if
!$OMP DO
DO i = 1,in%Nparts
  CALL loadParticles(plasma%zp(i),plasma%kep(i),plasma%xip(i),in)
  CALL loadParticles(i,plasma,in)
END DO
!$OMP END DO
!$OMP END PARALLEL
@@ -259,8 +259,7 @@ AllTime: do j = 1,in%Nsteps
           CALL CyclotronResonanceNumber(i,plasma,resNum1,in,spline_B)
           dresNum = dsign(1.d0,resNum0*resNum1)
           if (dresNum .LT. 0 .AND. plasma%zp(i) .GT. in%zRes1 .AND. plasma%zp(i) .LT. in%zRes2)  then
              !WRITE(*,*) 'Resonance at zp: ', zp(i)
        CALL RFHeatingOperator(plasma%zp(i),plasma%kep(i),plasma%xip(i),ecnt3,pcnt3,in,spline_B,spline_dB,spline_ddB,spline_dV)
              CALL RFHeatingOperator(i,plasma,ecnt3,pcnt3,in,spline_B,spline_dB,spline_ddB,spline_dV)
           end if
        end if