Report Typos and Errors    
Semi-Lagrangian Library
Modular library for kinetic and gyrokinetic simulations of plasmas in fusion energy devices.
sll_m_singular_mapping_analytic_czarny.F90
Go to the documentation of this file.
1 ! This module implements the analytical mapping given by
2 ! equation (3) of https://doi.org/10.1016/j.jcp.2019.108889:
3 !
4 ! x(s,theta)=(1-sqrt(1+epsilon*(epsilon+2*s*cos(theta))))/epsilon
5 ! y(s,theta)=y0+(e*xi*s*sin(theta))/(1+epsilon*x(s,theta))
6 
8 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
9 #include "sll_assert.h"
10 
11  use sll_m_working_precision, only: f64
12 
13  use sll_m_constants, only: sll_p_twopi
14 
16 
17  implicit none
18 
20 
21  private
22 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
23 
25  integer, parameter :: wp = f64
26 
29 
30  ! Default values (no specific meaning), can be overwritten from 'init' method
31  real(wp) :: x0(2) = [0.0_wp, 0.0_wp]
32  real(wp) :: e = 1.0_wp
33  real(wp) :: eps = 1.0_wp
34 
35  contains
36 
38  procedure :: eval => f_singular_mapping_analytic_czarny__eval
39  procedure :: jmat => f_singular_mapping_analytic_czarny__jmat ! Jacobian matrix
40  procedure :: jmat_comp => f_singular_mapping_analytic_czarny__jmat_comp
41 
43 
44 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
45 contains
46 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
47 
48  subroutine s_singular_mapping_analytic_czarny__init(self, x0, e, eps)
49  class(sll_t_singular_mapping_analytic_czarny), intent(inout) :: self
50  real(wp), optional, intent(in) :: x0(2)
51  real(wp), optional, intent(in) :: e
52  real(wp), optional, intent(in) :: eps
53 
54  ! Overwrite parameters
55  if (present(x0)) self%x0 = x0
56  if (present(e)) self%e = e
57  if (present(eps)) self%eps = eps
58 
60 
61  !-----------------------------------------------------------------------------
62  sll_pure function f_singular_mapping_analytic_czarny__eval(self, eta) result(x)
63  class(sll_t_singular_mapping_analytic_czarny), intent(in) :: self
64  real(wp), intent(in) :: eta(2)
65  real(wp) :: x(2)
66 
67  associate(s => eta(1), t => eta(2), x0 => self%x0, e => self%e, eps => self%eps)
68 
69  ! TODO: check if x0(1) can be added to x(1) as well
70  x(1) = (1.0_wp - sqrt(1.0_wp + eps*(eps + 2.0_wp*s*cos(t))))/eps
71  x(2) = x0(2) + e*s*sin(t)/((1.0_wp + eps*x(1))*sqrt(1.0_wp - eps**2*0.25_wp))
72 
73  end associate
74 
75  end function f_singular_mapping_analytic_czarny__eval
76 
77  !-----------------------------------------------------------------------------
78  sll_pure function f_singular_mapping_analytic_czarny__jmat(self, eta) result(jmat)
79  class(sll_t_singular_mapping_analytic_czarny), intent(in) :: self
80  real(wp), intent(in) :: eta(2)
81  real(wp) :: jmat(2, 2)
82 
83  real(wp) :: tmp1, tmp2
84 
85  associate(s => eta(1), t => eta(2), e => self%e, eps => self%eps)
86 
87  tmp1 = sqrt(1.0_wp + eps*(eps + 2.0_wp*s*cos(t)))
88  tmp2 = sqrt(1.0_wp - eps**2*0.25_wp)
89 
90  ! J_11 = d(x1)/d(eta1)
91  ! J_12 = d(x1)/d(eta2)
92  ! J_21 = d(x2)/d(eta1)
93  ! J_22 = d(x2)/d(eta2)
94  jmat(1, 1) = -cos(t)/tmp1
95  jmat(1, 2) = s*sin(t)/tmp1
96  jmat(2, 1) = e*sin(t)/((2.0_wp - tmp1)*tmp2) + eps*e*s*sin(t)*cos(t)/(tmp1*tmp2*(2.0_wp - tmp1)**2)
97  jmat(2, 2) = e*s*cos(t)/((2.0_wp - tmp1)*tmp2) - eps*e*s**2*sin(t)**2/(tmp1*tmp2*(2.0_wp - tmp1)**2)
98 
99  end associate
100 
101  end function f_singular_mapping_analytic_czarny__jmat
102 
103  !-----------------------------------------------------------------------------
104  sll_pure function f_singular_mapping_analytic_czarny__jmat_comp(self, eta) result(jmat_comp)
105  class(sll_t_singular_mapping_analytic_czarny), intent(in) :: self
106  real(wp), intent(in) :: eta(2)
107  real(wp) :: jmat_comp(2, 2)
108 
109  real(wp) :: tmp1, tmp2
110 
111  associate(s => eta(1), t => eta(2), e => self%e, eps => self%eps)
112 
113  tmp1 = sqrt(1.0_wp + eps*(eps + 2.0_wp*s*cos(t)))
114  tmp2 = sqrt(1.0_wp - eps**2*0.25_wp)
115 
116  jmat_comp(1, 1) = e/(tmp2*(2.0_wp - tmp1))
117  jmat_comp(1, 2) = 0.0_wp
118  jmat_comp(2, 1) = -e*eps*s*sin(t)/(tmp1*tmp2*(2.0_wp - tmp1)**2)
119  jmat_comp(2, 2) = -1.0_wp/tmp1
120 
121  jmat_comp = jmat_comp/(-e/(tmp1*tmp2*(2.0_wp - tmp1)))
122 
123  end associate
124 
125  end function f_singular_mapping_analytic_czarny__jmat_comp
126 
Fortran module where set some physical and mathematical constants.
real(kind=f64), parameter, public sll_p_twopi
Module to select the kind parameter.
integer, parameter, public f64
f64 is the kind type for 64-bit reals (double precision)
    Report Typos and Errors