korc_energy_pdfs Module

@brief Module that contains subroutines and functions to sample various energy distributions.


Uses

  • module~~korc_energy_pdfs~~UsesGraph module~korc_energy_pdfs korc_energy_pdfs module~korc_input korc_input module~korc_energy_pdfs->module~korc_input module~korc_hpc korc_hpc module~korc_energy_pdfs->module~korc_hpc module~korc_hdf5 korc_HDF5 module~korc_energy_pdfs->module~korc_hdf5 module~korc_constants korc_constants module~korc_energy_pdfs->module~korc_constants module~korc_types korc_types module~korc_energy_pdfs->module~korc_types module~korc_input->module~korc_hpc module~korc_input->module~korc_types module~korc_hpc->module~korc_types omp_lib omp_lib module~korc_hpc->omp_lib mpi mpi module~korc_hpc->mpi module~korc_hdf5->module~korc_hpc module~korc_hdf5->module~korc_constants module~korc_hdf5->module~korc_types HDF5 HDF5 module~korc_hdf5->HDF5 module~korc_constants->module~korc_types iso_c_binding iso_c_binding module~korc_types->iso_c_binding

Used by

  • module~~korc_energy_pdfs~~UsedByGraph module~korc_energy_pdfs korc_energy_pdfs module~korc_velocity_distribution korc_velocity_distribution module~korc_velocity_distribution->module~korc_energy_pdfs module~korc_initialize korc_initialize module~korc_initialize->module~korc_velocity_distribution program~main main program~main->module~korc_initialize

Contents


Variables

TypeVisibility AttributesNameInitial
type(GAMMA_PARAMS), private :: gamma_pdf_params
real(kind=rp), private, parameter:: co =(C_E*1.0E6)/(C_ME*C_C**2)

@f$f_\Gamma(\mathcal{E},\kappa,\theta)@f$ from MeV to Joules.

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

using a Metropolis-Hastings method to sample a distribution.


Derived Types

type, private :: GAMMA_PARAMS

@brief KORC derived type that contains information about a given Gamma distribution function @f$f_\Gamma(x,\kappa,\theta)@f$. @details We write a given Gamma distribution function in terms of its shape factor @f$\kappa@f$ and scale factor @f$\theta@f$, so that:

Read more…

Components

TypeVisibility AttributesNameInitial
real(kind=rp), public :: min_energy
real(kind=rp), public :: max_energy
real(kind=rp), public :: min_p
real(kind=rp), public :: max_p
real(kind=rp), public :: k
real(kind=rp), public :: t

Functions

private function deg2rad(x)

@brief Function that converts @f$x@f$ from degrees to radians.

Read more…

Arguments

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

Return Value real(kind=rp)

private function fGamma(x, k, t)

@brief Function that calculates the value of the Gamma distribution @f$f_\Gamma(x,\kappa,\theta) = \frac{1}{\Gamma(\kappa) \theta^\kappa}x^{\kappa-1}\exp{\left(-x/\theta\right)}@f$.

Read more…

Arguments

Type IntentOptional AttributesName
real(kind=rp), intent(in) :: x
real(kind=rp), intent(in) :: k
real(kind=rp), intent(in) :: t

Return Value real(kind=rp)

private function fRE(p)

Evaluation of the energy distribution function @f$f_{RE}(\mathcal{E})@f$ of runaway electrons as function of the normalized momentum @f$p' = p/m_ec@f$. Here, @f$p'@f$ is the normalized momentum and @f$m_e@f$ and @f$c@f$ are the electron mass and the speed of light.

Read more…

Arguments

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

Return Value real(kind=rp)

private function random_norm(mean, sigma)

@brief Gaussian random number generator. @details This function returns a deviate of a Gaussian distribution @f$f_G(x;\mu,\sigma) = \frac{1}{\sigma\sqrt{2\pi}} \exp{\left( -(x-\mu)^2/2\sigma^2 \right)}@f$, with mean @f$\mu@f$, and standard deviation @f$\sigma@f$.

Read more…

Arguments

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

Return Value real(kind=rp)


Subroutines

public subroutine get_gamma_distribution(params, g, go)

@brief Subroutine that contains calls to subroutine to generate a gamma distribution for the energy distribution of a given species in the simulation.

Read more…

Arguments

Type IntentOptional AttributesName
type(KORC_PARAMS), intent(in) :: params
real(kind=rp), intent(inout), DIMENSION(:), ALLOCATABLE:: g
real(kind=rp), intent(out) :: go

private subroutine initialize_gamma_params(params)

@brief Subroutine that reads from the input file the parameters of the Gamma distribution @f$f_\Gamma(x,\kappa,\theta) = \frac{1}{\Gamma(\kappa) \theta^\kappa}x^{\kappa-1}\exp{\left(-x/\theta\right)}@f$.

Read more…

Arguments

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

private subroutine sample_gamma_distribution(params, g, go)

@brief Subroutine that samples a Gamma distribution representing the runaways' (marginal) energy distribution function. @details This subroutine uses the Metropolis-Hastings method for sampling the Gamma distribution representing the runaways' (marginal) energy distribution function. Unlike the typical Metropolis-Hasting method, after setting the boundaries of the region we want to sample, we perform a sampling in a larger region that contains the original sampling area plus a buffer region. After finishing the first sampling, we only keep the particles in the original sampling region, the particles in the p_buffer are sampled again until all of them lie within the original sampling region. This method ensures that the boundaries are well sampled.

Read more…

Arguments

Type IntentOptional AttributesName
type(KORC_PARAMS), intent(in) :: params
real(kind=rp), intent(inout), DIMENSION(:), ALLOCATABLE:: g
real(kind=rp), intent(out) :: go

private subroutine save_gamma_params(params)

@brief Surboutine that saves the Gamma distribution parameters to the HDF5 file gamma_distribution_parameters.h5.

Read more…

Arguments

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