fokker_planck_calculus

moment_kinetics.fokker_planck_calculus.YY_collision_operator_arraysType

Struct to store the elemental nonlinear stiffness matrices used to express the finite-element weak form of the collision operator. The arrays are indexed so that the contraction in the assembly step is carried out over the fastest accessed indices, i.e., for YY0perp[i,j,k,iel], we contract over i and j to give data for the field position index k, all for the 1D element indexed by iel.

source
moment_kinetics.fokker_planck_calculus.algebraic_solve!Method

Same as elliptic_solve!() above but no Dirichlet boundary conditions are imposed, because the function is only used where the lu_object_lhs is derived from a mass matrix. The source is made of two different terms with different weak matrices because of the form of the only algebraic equation that we consider.

Note: algebraic_solve!() run only in serial. They do not handle shared-memory parallelism themselves. The calling site must ensure that algebraic_solve!() is only called by one process in a shared-memory block.

source
moment_kinetics.fokker_planck_calculus.assemble_explicit_collision_operator_rhs_parallel!Method

Function to assemble the RHS of the kinetic equation due to the collision operator, in weak form. Once the array rhsvpavperp contains the assembled weak-form collision operator, a mass matrix solve still must be carried out to find the time derivative of the distribution function due to collisions. This function uses a purely parallel algorithm and may be tested by comparing to assemble_explicit_collision_operator_rhs_serial!(). The inner-most loop of the function is in assemble_explicit_collision_operator_rhs_parallel_inner_loop().

source
moment_kinetics.fokker_planck_calculus.assemble_explicit_collision_operator_rhs_serial!Method

Function to assemble the RHS of the kinetic equation due to the collision operator, in weak form. Once the array rhsvpavperp contains the assembled weak-form collision operator, a mass matrix solve still must be carried out to find the time derivative of the distribution function due to collisions. This function uses a purely serial algorithm for testing purposes.

source
moment_kinetics.fokker_planck_calculus.assemble_matrix_operators_dirichlet_bcMethod

Function to contruct the global sparse matrices used to solve the elliptic PDEs for the Rosenbluth potentials. Uses a dense matrix construction method. The matrices are 2D in the compound index ic which indexes the velocity space labelled by ivpa,ivperp. Dirichlet boundary conditions are imposed in the appropriate stiffness matrices by setting the boundary row to be the Kronecker delta (0 except where ivpa = ivpap and ivperp = ivperpp). Used for testing.

source
moment_kinetics.fokker_planck_calculus.assemble_matrix_operators_dirichlet_bc_sparseMethod

Function to contruct the global sparse matrices used to solve the elliptic PDEs for the Rosenbluth potentials. Uses a sparse matrix construction method. The matrices are 2D in the compound index ic which indexes the velocity space labelled by ivpa,ivperp. Dirichlet boundary conditions are imposed in the appropriate stiffness matrices by setting the boundary row to be the Kronecker delta (0 except where ivpa = ivpap and ivperp = ivperpp). See also assemble_matrix_operators_dirichlet_bc().

source
moment_kinetics.fokker_planck_calculus.calculate_boundary_data!Method

Function to carry out the direct integration of a formal definition of one of the Rosenbluth potentials, on the boundaries of the (vpa,vperp) domain, using the precomputed integration weights with dimension 4. The result is stored in an instance of vpa_vperp_boundary_data. Used in testing.

source
moment_kinetics.fokker_planck_calculus.calculate_boundary_data!Method

Function to carry out the direct integration of a formal definition of one of the Rosenbluth potentials, on the boundaries of the (vpa,vperp) domain, using the precomputed integration weights with dimension 3. The result is stored in an instance of vpa_vperp_boundary_data.

source
moment_kinetics.fokker_planck_calculus.calculate_rosenbluth_integrals!Method

Function to carry out the integration of the revelant distribution functions to form the required coefficients for the full-F operator. We assume that the weights are precalculated. The function takes as arguments the arrays of coefficients (which we fill), the required distributions, the precomputed weights, the indicies of the `field' velocities, and the sizes of the primed vpa and vperp coordinates arrays.

source
moment_kinetics.fokker_planck_calculus.calculate_rosenbluth_potentials_via_elliptic_solve!Method

Function to solve the appropriate elliptic PDEs to find the Rosenbluth potentials. First, we calculate the Rosenbluth potentials at the boundary with the direct integration method. Then, we use this data to solve the elliptic PDEs with the boundary data providing an accurate Dirichlet boundary condition on the maximum vpa and vperp of the domain. We use the sparse LU decomposition from the LinearAlgebra package to solve the PDE matrix equations.

source
moment_kinetics.fokker_planck_calculus.elliptic_solve!Method

Elliptic solve function.

field: the solution
source: the source function on the RHS
boundary data: the known values of field at infinity
lu_object_lhs: the object for the differential operator that defines field
matrix_rhs: the weak matrix acting on the source vector
vpa, vperp: coordinate structs

Note: all variants of elliptic_solve!() run only in serial. They do not handle shared-memory parallelism themselves. The calling site must ensure that elliptic_solve!() is only called by one process in a shared-memory block.

source
moment_kinetics.fokker_planck_calculus.get_global_compound_indexMethod
get_global_compound_index(vpa,vperp,ielement_vpa,ielement_vperp,ivpa_local,ivperp_local)

For local (within the single element specified by ielement_vpa and ielement_vperp) indices ivpa_local and ivperp_local, get the global index in the 'linear-indexed' 2d space of size (vperp.n, vpa.n) (as returned by ic_func).

source
moment_kinetics.fokker_planck_calculus.get_scaled_x_w_with_divergences!Method

Function to get the local integration grid and quadrature weights to integrate a 1D element in the 2D representation of the velocity space distribution functions. This function assumes that there is a divergence at the point coord_val, and splits the grid and integration weights appropriately, using Gauss-Laguerre points near the divergence and Gauss-Legendre points away from the divergence.

source
moment_kinetics.fokker_planck_calculus.ic_funcMethod
ic_func(ivpa::mk_int,ivperp::mk_int,nvpa::mk_int)

Get the 'linear index' corresponding to ivpa and ivperp. Defined so that the linear index corresponds to the underlying layout in memory of a 2d array indexed by [ivpa,ivperp], i.e. for a 2d array f2d:

  • size(f2d) == (vpa.n, vperp.n)
  • For a reference to f2d that is reshaped to a vector (a 1d array) f1d = vec(f2d) than for any ivpa and ivperp it is true that f1d[ic_func(ivpa,ivperp)] == f2d[ivpa,ivperp].
source
moment_kinetics.fokker_planck_calculus.interpolate_2D_vspace!Method

Function to interpolate f(vpa,vperp) from one velocity grid to another, assuming that both grids are represented by (vpa,vperp) in normalised units, but have different normalisation factors defining the meaning of these grids in physical units. E.g.,

 vpai, vperpi = ci * vpa, ci * vperp
 vpae, vperpe = ce * vpa, ce * vperp

with ci = sqrt(Ti/mi), ce = sqrt(Te/mi)

scalefac = ci / ce is the ratio of the two reference speeds.

source
moment_kinetics.fokker_planck_calculus.local_element_integration!Method

Base level function for computing the integration kernals for the Rosenbluth potential integration. Note the definitions of ellipe(m) ($E(m)$) and ellipk(m) ($K(m)$). https://specialfunctions.juliamath.org/stable/functions_list/#SpecialFunctions.ellipe https://specialfunctions.juliamath.org/stable/functions_list/#SpecialFunctions.ellipk

\[E(m) = \int^{\pi/2}_0 \sqrt{ 1 - m \sin^2(\theta)} d \theta\]

\[K(m) = \int^{\pi/2}_0 \frac{1}{\sqrt{ 1 - m \sin^2(\theta)}} d \theta\]

source
moment_kinetics.fokker_planck_calculus.loop_over_vpa_elements!Method

Function for computing the quadratures and carrying out the loop over the primed vpa coordinate in doing the numerical integration. Splits the integrand into three pieces – two which use Gauss-Legendre quadrature assuming no divergences in the integrand, and one which assumes a logarithmic divergence and uses a Gauss-Laguerre quadrature with an (exponential) change of variables to mitigate this divergence.

source
moment_kinetics.fokker_planck_calculus.loop_over_vperp_vpa_elements!Method

Function for computing the quadratures and carrying out the loop over the primed vperp coordinate in doing the numerical integration. Splits the integrand into three pieces – two which use Gauss-Legendre quadrature assuming no divergences in the integrand, and one which assumes a logarithmic divergence and uses a Gauss-Laguerre quadrature with an (exponential) change of variables to mitigate this divergence. This function calls loop_over_vpa_elements_no_divergences!() and loop_over_vpa_elements!() to carry out the primed vpa loop within the primed vperp loop.

source
moment_kinetics.fokker_planck_calculus.loop_over_vperp_vpa_elements_no_divergences!Method

The function loop_over_vperp_vpa_elements_no_divergences!() was used for debugging. By changing the source where loop_over_vperp_vpa_elements!() is called to instead call this function we can verify that the Gauss-Legendre quadrature is adequate for integrating a divergence-free integrand. This function should be kept until we understand the problems preventing machine-precision accurary in the pure integration method of computing the Rosenbluth potentials.

source