Report Typos and Errors    
Semi-Lagrangian Library
Modular library for kinetic and gyrokinetic simulations of plasmas in fusion energy devices.
sll_m_profile_functions.F90
Go to the documentation of this file.
1 
5  !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6 #include "sll_working_precision.h"
7 #include "sll_errors.h"
8 
9  use sll_m_constants, only : &
11 
12  implicit none
13 
14  public :: &
16 
17  private
18 
20  sll_real64 :: a = 0._f64
21  sll_real64 :: rbar = 0.5_f64
22  sll_real64 :: rhobar = 1._f64
23  sll_real64 :: kr = 0._f64
24  sll_real64 :: wr = 1._f64
25  sll_real64 :: tibar = 1._f64
26  sll_real64 :: kti = 0._f64
27  sll_real64 :: wti = 1._f64
28  sll_real64 :: tebar = 1._f64
29  sll_real64 :: kte = 0._f64
30  sll_real64 :: wte = 1._f64
31 
32  contains
33  procedure :: init => init_profile_functions
34  procedure :: rho_0
35  procedure :: drho_0
36  procedure :: t_i
37  procedure :: dt_i
38  procedure :: t_e
39  procedure :: radial_distrib
40  !procedure :: dradial_distrib
42 
43 contains
44 
45 
46  subroutine init_profile_functions(self, input_file)
47  class(sll_t_profile_functions), intent( inout ) :: self
48  sll_int32, intent(in) :: input_file
49  !local variables
50  sll_int32 :: io_stat
51  sll_real64 :: a, rbar, rhobar, kr, omegar, tibar, kti, omegati, tebar, kte, omegate
52 
53  namelist /profile_parameters/ a, rbar, rhobar, kr, omegar, tibar, kti, omegati, tebar, kte, omegate
54 
55  read(input_file, profile_parameters,iostat=io_stat)
56 !!$ open(newunit = input_file, file=trim(filename), status='old',IOStat=io_stat)
57  if (io_stat /= 0) then
58  self%a = 0._f64
59  self%rbar = 0.5_f64
60  self%rhobar = 1._f64
61  self%kr = 0._f64
62  self%wr = 1._f64
63  self%tibar = 1._f64
64  self%kti = 0._f64
65  self%wti = 1._f64
66  self%tebar = 1._f64
67  self%kte = 0._f64
68  self%wte = 1._f64
69 
70  else
71  self%a = a
72  self%rbar = rbar
73  self%rhobar = rhobar
74  self%kr = kr
75  self%wr = omegar
76  self%tibar = tibar
77  self%kti = kti
78  self%wti = omegati
79  self%tebar = tebar
80  self%kte = kte
81  self%wte = omegate
82  end if
83 
84  end subroutine init_profile_functions
85 
86  function rho_0(self, r)
87  class(sll_t_profile_functions), intent( inout ) :: self
88  sll_real64 :: rho_0
89  sll_real64, intent(in) :: r
90 
91  rho_0 = self%rhobar * exp( -self%kr*self%wr*tanh(self%a*(r-self%rbar)/self%wr) )
92  end function rho_0
93 
94 
95  function drho_0(self, r)
96  class(sll_t_profile_functions), intent( inout ) :: self
97  sll_real64 :: drho_0
98  sll_real64, intent(in) :: r
99 
100  drho_0 = -self%kr/(cosh(self%a*(r-self%rbar)/self%wr)**2) *self%rho_0(r)
101  end function drho_0
102 
103  function t_i(self, r)
104  class(sll_t_profile_functions), intent( inout ) :: self
105  sll_real64 :: t_i
106  sll_real64, intent(in) :: r
107 
108  t_i = self%tibar*(1._f64-self%kti*self%wti*tanh(self%a*(r-self%rbar)/self%wti) )
109  !T_i = self%tibar * exp( -self%kti*self%wti*tanh(self%a*(r-self%rbar)/self%wti) )
110  if( t_i< 0._f64) then
111  sll_error('T_i','error in temperature in T_i')
112  end if
113  end function t_i
114 
115  function dt_i(self, r)
116  class(sll_t_profile_functions), intent( inout ) :: self
117  sll_real64 :: dt_i
118  sll_real64, intent(in) :: r
119 
120  dt_i = -self%tibar*self%kti/cosh(self%a*(r-self%rbar)/self%wti)**2
121  !dT_i = -self%kti/(cosh(self%a*(r-self%rbar)/self%wti)**2)*self%T_i(r)
122 
123  end function dt_i
124 
125  function t_e(self, r)
126  class(sll_t_profile_functions), intent( inout ) :: self
127  sll_real64 :: t_e
128  sll_real64, intent(in) :: r
129 
130  t_e = self%tebar * exp( -self%kte*self%wte*tanh(self%a*(r-self%rbar)/self%wte) )
131  if( t_e< 0._f64) then
132  sll_error('T_e','error in temperature in T_e')
133  end if
134 
135  end function t_e
136 
137  function radial_distrib(self, r)
138  class(sll_t_profile_functions), intent( inout ) :: self
139  sll_real64 :: radial_distrib
140  sll_real64, intent(in) :: r
141 
142  radial_distrib = sin(sll_p_pi*r)
143  !radial_distrib = exp(-self%wti*(self%a*(r-self%rbar))**2/(4._f64*self%wr) )
144  end function radial_distrib
145 
146 !!$ function dradial_distrib(self, r)
147 !!$ class(sll_t_profile_functions), intent( inout ) :: self
148 !!$ sll_real64 :: dradial_distrib
149 !!$ sll_real64, intent(in) :: r
150 !!$
151 !!$ dradial_distrib = 0._f64!-self%a*2._f64*(self%a*(r-rbar))/(self%wr/self%wti)*self%radial_distrib(r)
152 !!$ end function dradial_distrib
153 
154 end module sll_m_profile_functions
Fortran module where set some physical and mathematical constants.
real(kind=f64), parameter, public sll_p_pi
real(kind=f64), parameter, public sll_p_twopi
functions for initial profile of the particle distribution function
real(kind=f64) function rho_0(self, r)
real(kind=f64) function t_i(self, r)
real(kind=f64) function dt_i(self, r)
real(kind=f64) function radial_distrib(self, r)
subroutine init_profile_functions(self, input_file)
real(kind=f64) function drho_0(self, r)
real(kind=f64) function t_e(self, r)
    Report Typos and Errors