korc_spatial_distribution Module

@param f Value of function. @param r Guess value of radial position of the particles. @param a Minor radius of the toroidal distribution @param ko Decay rate of radial distribution, see of \ref korc_spatial_distribution.exponential_torus. @param P Deviate of a random uniform distribution in the interval . @brief Subroutine that generates a exponentially decaying radial distribution of particles in a circular cross-section torus of major and minor radi and , respectively. @details We generate this exponentially decaying radial distribution following the same approach as in \ref korc_spatial_distribution.disk, but this time, the radial distribution is given by:

The radial position of the particles is obtained using the Inverse Trasnform Sampling method, finding numerically through the Newton-Raphson method. First, we calculate the particles' radial distribution in a disk centered at . Then, we transfor to a new set of coordinates where the disk is centered at . Finally, we generate the toroidal distribution by givin each particle a toroidal angle which follows a uniform distribution in the interval .

@param[in] params Core KORC simulation parameters. @param[in,out] spp An instance of the derived type SPECIES containing all the parameters and simulation variables of the different species in the simulation. @param fl Variable used in the Newton-Raphson method for finding the radial position of each particle. @param fr Variable used in the Newton-Raphson method for finding the radial position of each particle. @param fm Variable used in the Newton-Raphson method for finding the radial position of each particle. @param rl Variable used in the Newton-Raphson method for finding the radial position of each particle. @param rr Variable used in the Newton-Raphson method for finding the radial position of each particle. @param rm Variable used in the Newton-Raphson method for finding the radial position of each particle. @param relerr Tolerance used to determine when to stop iterating the Newton-Raphson method for finding . @param r Radial position of the particles . @param theta Uniform deviates in the range representing the uniform poloidal angle distribution of the particles. @param zeta Uniform deviates in the range representing the uniform toroidal angle distribution of the particles. @param pp Particle iterator. @brief Subroutine that generates an exponentially decaying radial distribution in an elliptic torus as the initial spatial condition of a given particle species in the simulation. @details As a first step, we generate an exponentially decaying radial distribution in a circular cross-section torus as in \ref korc_spatial_distribution.exponential_torus. Then we transform this spatial distribution to a one in an torus with an elliptic cross section, this following the same approach as in \ref korc_spatial_distribution.elliptic_torus.

@param[in] params Core KORC simulation parameters. @param[in,out] spp An instance of the derived type SPECIES containing all the parameters and simulation variables of the different species in the simulation. @param fl Variable used in the Newton-Raphson method for finding the radial position of each particle. @param fr Variable used in the Newton-Raphson method for finding the radial position of each particle. @param fm Variable used in the Newton-Raphson method for finding the radial position of each particle. @param rl Variable used in the Newton-Raphson method for finding the radial position of each particle. @param rr Variable used in the Newton-Raphson method for finding the radial position of each particle. @param rm Variable used in the Newton-Raphson method for finding the radial position of each particle. @param relerr Tolerance used to determine when to stop iterating the Newton-Raphson method for finding . @param rotation_angle This is the angle in \ref korc_spatial_distribution.elliptic_torus. @param r Radial position of the particles . @param theta Uniform deviates in the range representing the uniform poloidal angle distribution of the particles. @param zeta Uniform deviates in the range representing the uniform toroidal angle distribution of the particles. @param X Auxiliary vector used in the coordinate transformations. @param Y Auxiliary vector used in the coordinate transformations. @param X1 Auxiliary vector used in the coordinate transformations. @param Y1 Auxiliary vector used in the coordinate transformations. @param pp Particle iterator. @brief Subroutine that generates a Gaussian radial distribution in an elliptic torus as the initial spatial condition of a given particle species in the simulation. @details As a first step, we generate an Gaussian radial distribution in a circular cross-section torus as in \ref korc_spatial_distribution.gaussian_torus. Then we transform this spatial distribution to a one in an torus with an elliptic cross section, this following the same approach as in \ref korc_spatial_distribution.elliptic_torus.

@param[in] params Core KORC simulation parameters. @param[in,out] spp An instance of the derived type SPECIES containing all the parameters and simulation variables of the different species in the simulation. @param rotation_angle This is the angle in \ref korc_spatial_distribution.elliptic_torus. @param r Radial position of the particles . @param theta Uniform deviates in the range representing the uniform poloidal angle distribution of the particles. @param zeta Uniform deviates in the range representing the uniform toroidal angle distribution of the particles. @param X Auxiliary vector used in the coordinate transformations. @param Y Auxiliary vector used in the coordinate transformations. @param X1 Auxiliary vector used in the coordinate transformations. @param Y1 Auxiliary vector used in the coordinate transformations. @param sigma Standard deviation of the radial distribution function. @param pp Particle iterator. @brief Subroutine that generates a Gaussian radial distribution of particles in a circular cross-section torus of major and minor radi and , respectively. @details We generate this exponentially decaying radial distribution following the same approach as in \ref korc_spatial_distribution.disk, but this time, the radial distribution is given by:

The radial position of the particles is obtained using the Inverse Trasnform Sampling method, finding numerically through the Newton-Raphson method. First, we calculate the particles' radial distribution in a disk centered at . Then, we transfor to a new set of coordinates where the disk is centered at . Finally, we generate the toroidal distribution by givin each particle a toroidal angle which follows a uniform distribution in the interval .

@param[in] params Core KORC simulation parameters. @param[in,out] spp An instance of the derived type SPECIES containing all the parameters and simulation variables of the different species in the simulation. @param fl Variable used in the Newton-Raphson method for finding the radial position of each particle. @param fr Variable used in the Newton-Raphson method for finding the radial position of each particle. @param fm Variable used in the Newton-Raphson method for finding the radial position of each particle. @param rl Variable used in the Newton-Raphson method for finding the radial position of each particle. @param rr Variable used in the Newton-Raphson method for finding the radial position of each particle. @param rm Variable used in the Newton-Raphson method for finding the radial position of each particle. @param relerr Tolerance used to determine when to stop iterating the Newton-Raphson method for finding . @param r Radial position of the particles . @param theta Uniform deviates in the range representing the uniform poloidal angle distribution of the particles. @param zeta Uniform deviates in the range representing the uniform toroidal angle distribution of the particles. @param pp Particle iterator.



Contents


Variables

TypeVisibility AttributesNameInitial
real(kind=rp), private, parameter:: minmax_buffer_size =10.0_rp

Functions

private function fzero(r, a, ko, P) result(f)

Arguments

Type IntentOptional AttributesName
real(kind=rp), intent(in) :: r
real(kind=rp), intent(in) :: a
real(kind=rp), intent(in) :: ko
real(kind=rp), intent(in) :: P

Return Value real(kind=rp)

private function PSI_ROT(R, R0, sigR, Z, Z0, sigZ, theta)

Arguments

Type IntentOptional AttributesName
real(kind=rp), intent(in) :: R

R-coordinate of MH sampled location

real(kind=rp), intent(in) :: R0

R-coordinate of center of 2D Gaussian

real(kind=rp), intent(in) :: sigR

Variance of first dimension of 2D Gaussian

real(kind=rp), intent(in) :: Z

Z-coordinate of MH sampled location

real(kind=rp), intent(in) :: Z0

Z-coordinate of center of 2D Gaussian

real(kind=rp), intent(in) :: sigZ

Variance of second dimension of 2D Gaussian

real(kind=rp), intent(in) :: theta

Angle of counter-clockwise rotation (in radians), of 2D Gaussian distribution relative to R,Z

Return Value real(kind=rp)

Argument of exponential comprising 2D Gaussian distribution

private function indicator(psi, psi_max)

Arguments

Type IntentOptional AttributesName
real(kind=rp), intent(in) :: psi
real(kind=rp), intent(in) :: psi_max

Return Value real(kind=rp)

public function random_norm(mean, sigma)

Arguments

Type IntentOptional AttributesName
real(kind=rp), intent(in) :: mean
real(kind=rp), intent(in) :: sigma

Return Value real(kind=rp)

private function Spong_2D(R0, b, w, dlam, R, Z, T)

Arguments

Type IntentOptional AttributesName
real(kind=rp), intent(in) :: R0
real(kind=rp), intent(in) :: b
real(kind=rp), intent(in) :: w
real(kind=rp), intent(in) :: dlam
real(kind=rp), intent(in) :: R
real(kind=rp), intent(in) :: Z
real(kind=rp), intent(in) :: T

Return Value real(kind=rp)


Subroutines

private subroutine uniform(spp)

Read more…

Arguments

Type IntentOptional AttributesName
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.

private subroutine disk(params, spp)

Read more…

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.

private subroutine torus(params, spp)

Read more…

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.

private subroutine elliptic_torus(params, spp)

Read more…

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.

private subroutine exponential_torus(params, spp)

Arguments

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

private subroutine exponential_elliptic_torus(params, spp)

Arguments

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

private subroutine gaussian_elliptic_torus(params, spp)

Arguments

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

private subroutine MH_gaussian_elliptic_torus(params, spp)

Read more…

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.

private subroutine gaussian_torus(params, spp)

Arguments

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

private subroutine Spong_3D(params, spp)

Read more…

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.

Read more…

private subroutine MH_psi(params, spp, F)

Read more…

Arguments

Type IntentOptional AttributesName
type(KORC_PARAMS), intent(inout) :: 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.

type(FIELDS), intent(in) :: F

An instance of the KORC derived type FIELDS.

public subroutine intitial_spatial_distribution(params, spp, P, F)

Read more…

Arguments

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

Core KORC simulation parameters.

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

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

type(PROFILES), intent(in) :: P

An instance of the KORC derived type PROFILES.

type(FIELDS), intent(in) :: F

An instance of the KORC derived type FIELDS.