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(out), | dimension(3) | :: | rp | Particle position |
|
real(kind=Float64), | intent(out), | dimension(3) | :: | vp | Particle velocity |
|
real(kind=Float64), | intent(in), | optional | :: | phi_in | Gyro-angle |
subroutine gyro_correction(fields, energy, pitch, rp, vp, phi_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), dimension(3), intent(out) :: rp
!+ Particle position
real(Float64), dimension(3), intent(out) :: vp
!+ Particle velocity
real(Float64), intent(in), optional :: phi_in
!+ Gyro-angle
real(Float64), dimension(3) :: vi_norm, r_step
real(Float64), dimension(1) :: randomu
real(Float64) :: vabs, phi
vabs = sqrt(energy/(v2_to_E_per_amu*inputs%ab))
if(present(phi_in)) then
phi = phi_in
else
!! Sample gyroangle
call randu(randomu)
phi = 2*pi*randomu(1)
endif
!! Calculate velocity vector
call pitch_to_vec(pitch, phi, fields, vi_norm)
vp = vabs*vi_norm
!! Move to particle location
call gyro_step(vp, fields, r_step)
rp = fields%pos - r_step
end subroutine gyro_correction