Report Typos and Errors    
Semi-Lagrangian Library
Modular library for kinetic and gyrokinetic simulations of plasmas in fusion energy devices.
sll_m_tsi_2d_initializer.F90
Go to the documentation of this file.
2 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 #include "sll_assert.h"
4 #include "sll_working_precision.h"
5 
6  use sll_m_constants, only: &
8 
11 
15 
16  implicit none
17 
18  public :: &
20 
21  private
22 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
23 
25  !class(sll_mapped_mesh_2d_base), pointer :: mesh
26  class(sll_c_coordinate_transformation_2d_base), pointer :: transf
27  sll_real64 :: eps
28  sll_real64 :: kx
29  sll_real64 :: xi
30  sll_real64 :: v0
31  sll_int32 :: is_delta_f
32  contains
33  procedure, pass(init_obj) :: init => initialize_tsi_2d
34  procedure, pass(init_obj) :: f_of_x1x2 => f_x1x2_tsi_2d
35  end type sll_t_init_tsi_2d
36 
37 contains
38 
39  subroutine initialize_tsi_2d(init_obj, transf, data_position, eps_val, &
40  kx_val, v0_val, is_delta_f)
41  class(sll_t_init_tsi_2d), intent(inout) :: init_obj
42  class(sll_c_coordinate_transformation_2d_base), pointer :: transf
43  sll_int32 :: data_position
44  sll_real64, intent(in), optional :: eps_val
45  sll_real64, intent(in), optional :: kx_val
46  sll_real64, intent(in), optional :: v0_val
47  sll_int32, intent(in), optional :: is_delta_f
48 
49  init_obj%data_position = data_position
50  if (present(eps_val)) then
51  init_obj%eps = eps_val
52  else
53  init_obj%eps = 0.01_f64 ! just some default value
54  end if
55  if (present(kx_val)) then
56  init_obj%kx = kx_val
57  else
58  init_obj%kx = 0.2_f64 ! just some default value
59  end if
60  if (present(v0_val)) then
61  init_obj%v0 = v0_val
62  else
63  init_obj%v0 = 2.4_f64 ! just some default value
64  end if
65  if (present(is_delta_f)) then
66  init_obj%is_delta_f = is_delta_f
67  else
68  init_obj%is_delta_f = 1 ! just some default value
69  end if
70  init_obj%transf => transf
71  end subroutine
72 
73  subroutine f_x1x2_tsi_2d(init_obj, data_out)
74  class(sll_t_init_tsi_2d), intent(inout) :: init_obj
75  class(sll_c_coordinate_transformation_2d_base), pointer :: transf
76  sll_real64, dimension(:, :), intent(out) :: data_out
77  sll_int32 :: i
78  sll_int32 :: j
79  sll_int32 :: num_pts1
80  sll_int32 :: num_pts2
81  sll_real64 :: eps
82  !sll_real64 :: xi
83  sll_real64 :: v0
84  sll_real64 :: kx
85  sll_real64 :: x
86  sll_real64 :: v
87 
88  eps = init_obj%eps
89  v0 = init_obj%v0
90  transf => init_obj%transf
91 
92  if (init_obj%data_position == sll_p_node_centered_field) then
93  num_pts1 = transf%mesh%num_cells1 + 1
94  num_pts2 = transf%mesh%num_cells2 + 1
95  else if (init_obj%data_position == sll_p_node_centered_field) then
96  num_pts1 = transf%mesh%num_cells1
97  num_pts2 = transf%mesh%num_cells2
98  end if
99  kx = init_obj%kx
100  sll_assert(size(data_out, 1) .ge. num_pts1)
101  sll_assert(size(data_out, 2) .ge. num_pts2)
102  do j = 1, num_pts2
103  do i = 1, num_pts1
104  if (init_obj%data_position == sll_p_node_centered_field) then
105  v = transf%x2_at_node(i, j)
106  x = transf%x1_at_node(i, j)
107  else if (init_obj%data_position == sll_p_node_centered_field) then
108  v = transf%x2_at_cell(i, j)
109  x = transf%x1_at_cell(i, j)
110  else
111  print *, 'f_x1x2_tsi_2d:', init_obj%data_position, 'not defined'
112  end if
113  if (init_obj%is_delta_f == 0) then ! delta_f code
114  data_out(i, j) = (1.0_f64 + eps*cos(kx*x))*0.5_f64/sqrt(2*sll_p_pi) &
115  *(exp(-.5_f64*(v - v0)**2) + exp(-.5_f64*(v + v0)**2))
116  else
117  data_out(i, j) = (1.0_f64 + eps*cos(kx*x))*0.5_f64/sqrt(2*sll_p_pi) &
118  *(exp(-.5_f64*(v - v0)**2) + exp(-.5_f64*(v + v0)**2))
119  end if
120  end do
121  end do
122  end subroutine
123 
124 end module sll_m_tsi_2d_initializer
Fortran module where set some physical and mathematical constants.
real(kind=f64), parameter, public sll_p_pi
Abstract class for coordinate transformations.
subroutine f_x1x2_tsi_2d(init_obj, data_out)
subroutine initialize_tsi_2d(init_obj, transf, data_position, eps_val, kx_val, v0_val, is_delta_f)
    Report Typos and Errors