Calculates gyro correction for Guiding Center MC distribution calculation
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(LocalEMFields), | intent(in) | :: | fields | Electromagnetic fields at guiding center |
||
real(kind=Float64), | intent(in) | :: | energy | Energy of particle |
||
real(kind=Float64), | intent(in) | :: | pitch | Particle pitch w.r.t the magnetic field |
||
real(kind=Float64), | intent(in) | :: | Ai | Atomic mass of Ion |
||
real(kind=Float64), | intent(out), | dimension(3) | :: | rp | Particle position |
|
real(kind=Float64), | intent(out), | dimension(3) | :: | vp | Particle velocity |
|
real(kind=Float64), | intent(in), | optional | :: | theta_in | Gyro-angle |
subroutine gyro_correction(fields, energy, pitch, Ai, rp, vp, theta_in)
!+ Calculates gyro correction for Guiding Center MC distribution calculation
type(LocalEMFields), intent(in) :: fields
!+ Electromagnetic fields at guiding center
real(Float64), intent(in) :: energy
!+ Energy of particle
real(Float64), intent(in) :: pitch
!+ Particle pitch w.r.t the magnetic field
real(Float64), intent(in) :: Ai
!+ Atomic mass of Ion
real(Float64), dimension(3), intent(out) :: rp
!+ Particle position
real(Float64), dimension(3), intent(out) :: vp
!+ Particle velocity
real(Float64), intent(in), optional :: theta_in
!+ Gyro-angle
real(Float64), dimension(3) :: vi_norm, r_step
real(Float64), dimension(1) :: randomu
real(Float64) :: vabs, theta
vabs = sqrt(energy/(v2_to_E_per_amu*Ai))
if(present(theta_in)) then
theta = theta_in
else
!! Sample gyroangle
call randu(randomu)
theta = 2*pi*randomu(1)
endif
!! Calculate velocity vector
call pitch_to_vec(pitch, theta, fields, vi_norm)
vp = vabs*vi_norm
!! Move to particle location
call gyro_step(vp, fields, Ai, r_step)
rp = fields%pos - r_step
end subroutine gyro_correction