disk Subroutine

private subroutine disk(params, spp)

This uniform disk/ring distribution is generated using the Inverse Transform Sampling method. In this case, the (toroidal) radial distribution function of the particles is:

where and are the inner and outer radius of the uniform ring distribution, and is the cylindrical radial position of the center of the disk/ring distribution. This distribution is so that , where is the poloidal angle, and is the Jacobian of the transformation of Cartesian coordinates to toroidal coordinates. Notice that in the case of a disk . As a convention, this spatial distribution will be generated on the -plane. Using the Inverse Transform Sampling method we sample , and obtain the radial position of the particles as , where is a uniform deviate in .

Arguments

Type IntentOptional AttributesName
type(KORC_PARAMS), intent(in) :: params

Core KORC simulation parameters.

type(SPECIES), intent(inout) :: spp

An instance of the derived type SPECIES containing all the parameters and simulation variables of the different species in the simulation.


Calls

proc~~disk~~CallsGraph proc~disk disk proc~init_u_random init_u_random proc~disk->proc~init_u_random proc~init_random_seed init_random_seed proc~disk->proc~init_random_seed proc~rand_int64 rand_int64 proc~init_u_random->proc~rand_int64

Contents

Source Code


Source Code

subroutine disk(params,spp)
  !! @note Subrotuine for generating a uniform disk/ring as the 
  !! initial spatial condition of a given species of particles  
  !! in the simulation. @endnote
  !! This uniform disk/ring distribution is generated using the 
  !! Inverse Transform Sampling method. In this case, the (toroidal) 
  !! radial distribution function of the particles is:
  !!
  !! $$f(r) = \left\{ \begin{array}{ll} 0 & r<r_{min} \\
  !! \frac{1}{2\pi^2(r_{max}^2-r_{min}^2)R_0} 
  !! & r_{min}<r<r_{max} \\ 0 & r>r_{max} \end{array} \right.,$$
  !!
  !! where \(r_{min}\) and \(r_{max}\) are the inner and outer 
  !! radius of the uniform ring distribution, and \(R_0\) is the 
  !! cylindrical radial position of the center of the disk/ring distribution.
  !! This distribution is so that \(\int_0^{2\pi}\int_{r_{min}}^{r_{max}} f(r)
  !! J(r,\theta) drd\theta = 1 \), where \(\theta\) is the poloidal angle,
  !! and \(J(r,\theta)=r(R_0 + r\cos\theta)\) is the Jacobian of the 
  !! transformation of Cartesian coordinates to toroidal coordinates.
  !! Notice that in the case of a disk \(r_{min}=0\). As a convention, 
  !! this spatial distribution will be generated on the \(xz\)-plane.
  !! Using the Inverse Transform Sampling method we sample \(f(r)\), 
  !! and obtain the radial position of the particles as \(r = \sqrt{(r_{max}^2 
  !! - r_{min}^2)U + r_{min}^2}\), where \(U\) is a uniform deviate in \([0,1]\).
  TYPE(KORC_PARAMS), INTENT(IN) 	:: params
    !! Core KORC simulation parameters.
  TYPE(SPECIES), INTENT(INOUT) 		:: spp
    !! An instance of the derived type SPECIES containing all 
    !! the parameters and simulation variables of the different 
    !! species in the simulation.
  REAL(rp), DIMENSION(:), ALLOCATABLE 	:: r
    !! Radial position of the particles \(r\).
  REAL(rp), DIMENSION(:), ALLOCATABLE 	:: theta
    !! Uniform deviates in the range \([0,2\pi]\) representing 
    !! the uniform poloidal angle \(\theta\) distribution of the particles.

  ALLOCATE( theta(spp%ppp) )
  ALLOCATE( r(spp%ppp) )

  ! Initial condition of uniformly distributed particles on a disk in the xz-plane
  ! A unique velocity direction
  call init_u_random(10986546_8)

  call init_random_seed()
  call RANDOM_NUMBER(theta)
  
  theta = 2.0_rp*C_PI*theta

  ! Uniform distribution on a disk at a fixed azimuthal theta
  call init_random_seed()
  call RANDOM_NUMBER(r)

  r = SQRT((spp%r_outter**2 - spp%r_inner**2)*r + spp%r_inner**2)
  spp%vars%X(:,1) = ( spp%Ro + r*COS(theta) )*COS(spp%PHIo)
  spp%vars%X(:,2) = ( spp%Ro + r*COS(theta) )*SIN(spp%PHIo)
  spp%vars%X(:,3) = spp%Zo + r*SIN(theta)

  DEALLOCATE(theta)
  DEALLOCATE(r)
end subroutine disk