Report Typos and Errors    
Semi-Lagrangian Library
Modular library for kinetic and gyrokinetic simulations of plasmas in fusion energy devices.
sll_m_distribution_function_initializer_6d.F90
Go to the documentation of this file.
1 
10 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
11 #include "sll_assert.h"
12 #include "sll_errors.h"
13 #include "sll_working_precision.h"
14 
15  use sll_m_collective, only : &
18 
19  use sll_m_constants, only: &
21 
22  use mpi, only : &
23  mpi_sum
24 
25 #ifdef _OPENMP
26  use omp_lib
27 #define OMP_COLLAPSE collapse(1)
28 #define OMP_SCHEDULE schedule(static)
29 #endif
30 
31  implicit none
32 
33  public :: sll_s_set_local_grid, &
35  sll_t_array, &
43  sll_p_pslab, &
44  sll_p_delta, &
45  sll_p_pslab2, &
49 
50  private
51 
52 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
53 
55  sll_int32, parameter :: sll_p_landau_prod = 0
56  sll_int32, parameter :: sll_p_landau_sum = 1
57  sll_int32, parameter :: sll_p_landau_diag = 2
58  sll_int32, parameter :: sll_p_pslab = 3
59  sll_int32, parameter :: sll_p_twogaussian_prod = 4
60  sll_int32, parameter :: sll_p_twogaussian_sum = 5
61  sll_int32, parameter :: sll_p_twogaussian_diag = 6
62  sll_int32, parameter :: sll_p_pslab2 = 7
63  sll_int32, parameter :: sll_p_delta = 9
64  sll_int32, parameter :: sll_p_landau_sum_df = 8
65 
67  type :: sll_t_array
68  sll_real64, allocatable :: vals(:)
69  end type sll_t_array
70 
71 
73  type, abstract :: sll_c_distribution_params_6d
74  sll_int32 :: distrib_type
75 
76  contains
77  procedure( signature_init ), deferred :: init
78  procedure( signature_eval ), deferred :: eval
79  procedure( signature_eval_v ), deferred :: eval_v
80 
82 
85  sll_real64 :: v_thermal(3)
86  sll_real64 :: alpha(3)
87  sll_real64 :: kx(3)
88  sll_real64 :: phase(3)
89  sll_real64 :: v_max(3)
90  sll_real64 :: factor
91 
92  contains
93 
94  procedure :: init => init_landau_sum
95  procedure :: eval => eval_landau_sum
96  procedure :: eval_v => eval_landau_v_sum
97 
99 
100 
103 
104  contains
105  procedure :: eval => eval_landau_sum_df
106 
108 
111  sll_real64 :: v_thermal(3)
112  sll_real64 :: alpha
113  sll_real64 :: kx(3)
114  sll_real64 :: v_max(3)
115  sll_real64 :: factor
116 
117  contains
118 
119  procedure :: init => init_landau_prod
120  procedure :: eval => eval_landau_prod
121  procedure :: eval_v => eval_landau_v
122 
124 
127 
128  contains
129  procedure :: eval => eval_landau_diag
130 
132 
133 
136  sll_real64 :: v_thermal(2,3)
137  sll_real64 :: v_mean(2,3)
138  sll_real64 :: alpha
139  sll_real64 :: kx(3)
140  sll_real64 :: v_max(3)
141  sll_real64 :: factor
142  sll_real64 :: delta(2)
143 
144  contains
145 
146  procedure :: init => init_twogaussian
147  procedure :: eval => eval_twogaussian_sum
148  procedure :: eval_v => eval_twogaussian_v
149 
151 
154  sll_real64 :: v_thermal(3)
155  sll_real64 :: kappa_n0
156  sll_real64 :: kappa_ti
157  sll_real64 :: kappa_te
158  sll_real64 :: delta_rn0
159  sll_real64 :: delta_rti
160  sll_real64 :: delta_rte
161  sll_real64 :: kx(3)
162  sll_real64 :: alpha
163  sll_real64 :: b0
164  sll_real64 :: c_te
165  sll_real64 :: rp
166  end type sll_t_itg_parameters_6d
167 
170  sll_real64 :: kappa_ti
171  sll_real64 :: kx(3)
172  sll_real64 :: alpha
173  sll_real64 :: b0
174  sll_real64 :: c_te
175  sll_real64 :: factor
176  sll_real64 :: v_thermal(3)
177  sll_real64 :: v_mean(3)
178 
179  contains
180  procedure :: init => init_pslab
181  procedure :: eval => eval_pslab
182  procedure :: eval_v => eval_pslab_v
183 
185 
186 
187 
188 
191 
192  sll_real64 :: randarray(509)= (/-0.2664, 0.014, -0.3229, -0.3171, -0.0291, -0.0062, -0.4745, 0.4168, &
193  0.1802, -0.3243, 0.3694, -0.1246, -0.1856, -0.0366, 0.0695, -0.2344, &
194  -0.4531, 0.0384, -0.0048, -0.4186, -0.4135, 0.0035, 0.473, -0.3343, &
195  0.4867, -0.0914, 0.2798, -0.0493, -0.4807, -0.275, 0.3846, -0.3377, &
196  -0.4438, -0.3822, -0.3808, -0.2062, 0.3435, -0.465, -0.4356, 0.1279, &
197  -0.4913, 0.2428, 0.0293, -0.0828, -0.3102, 0.3547, 0.4727, 0.1805, &
198  -0.4724, -0.1745, -0.3345, -0.2994, 0.0773, 0.0896, 0.2664, 0.299, &
199  -0.1944, -0.2085, 0.3635, 0.1152, -0.4352, -0.1202, -0.1496, 0.4634, &
200  0.4438, -0.3141, 0.3368, -0.3054, 0.2811, -0.2799, -0.453, -0.3705, &
201  -0.3277, 0.3093, 0.293, -0.3352, 0.2645, -0.2042, -0.0412, -0.1305, &
202  0.3631, 0.2099, 0.1429, 0.3308, 0.1216, -0.3194, -0.4364, -0.4331, &
203  0.2451, -0.1217, -0.0064, -0.4491, 0.474, 0.0612, 0.4629, 0.2188, &
204  -0.2955, -0.2415, 0.309, 0.3778, 0.1484, 0.1198, -0.0777, 0.3699, &
205  0.415, -0.2132, 0.01, -0.045, -0.4163, 0.3464, -0.1753, -0.2682, &
206  0.3636, -0.4797, 0.1802, -0.1344, -0.3197, 0.3575, -0.0722, 0.372, &
207  -0.2739, -0.3028, -0.1227, -0.0174, -0.4454, 0.3344, 0.3524, -0.481, &
208  0.0944, -0.325, -0.4205, 0.3596, -0.3042, -0.2806, -0.429, 0.2148, &
209  -0.1049, 0.1622, -0.0293, 0.2618, 0.3408, -0.3008, 0.061, 0.2094, &
210  0.1375, 0.1928, -0.0813, -0.484, 0.2006, 0.0031, -0.1039, -0.4471, &
211  0.4876, -0.007, -0.2788, 0.1259, 0.4924, -0.2759, 0.4467, 0.4321, &
212  -0.0065, 0.3155, -0.0429, 0.1107, 0.2936, -0.239, 0.382, 0.2367, &
213  -0.3248, -0.4305, -0.304, -0.1935, -0.1988, 0.2261, 0.1036, -0.1348, &
214  -0.3115, 0.363, 0.2836, 0.2853, 0.4983, 0.4221, 0.3994, 0.4019, &
215  0.2773, -0.2255, -0.0043, -0.0997, -0.2185, 0.1486, -0.4017, 0.3383, &
216  0.167, -0.3125, -0.1966, 0.2756, -0.0057, 0.3256, 0.1876, -0.3863, &
217  -0.0464, 0.2262, 0.2781, -0.246, -0.1694, -0.0606, -0.4085, 0.4251, &
218  0.2965, 0.3739, -0.4765, 0.2349, -0.2762, -0.3162, 0.1564, -0.058, &
219  0.264, -0.0621, 0.2979, -0.1459, 0.4982, -0.1117, -0.3846, -0.2493, &
220  -0.1303, -0.2645, 0.2048, -0.3789, 0.4384, -0.196, -0.2605, -0.3464, &
221  0.443, 0.3775, -0.093, 0.1543, 0.3666, 0.0055, 0.015, 0.124, &
222  0.3759, -0.0529, -0.4103, -0.1574, -0.0722, -0.116, 0.3529, 0.3186, &
223  -0.4562, -0.3968, -0.4112, 0.0024, 0.0191, 0.2281, -0.3646, -0.3362, &
224  0.4484, -0.1759, -0.0501, 0.4268, 0.1152, -0.4264, -0.1195, 0.2677, &
225  0.0351, -0.1557, -0.0494, 0.3777, -0.2088, -0.4571, -0.4257, 0.004, &
226  0.0283, -0.2383, 0.3535, 0.3623, -0.4942, 0.0078, 0.0773, -0.2971, &
227  -0.2633, 0.081, -0.2694, 0.2239, -0.2029, 0.1425, 0.0181, 0.2826, &
228  -0.3549, -0.3291, -0.3042, 0.0888, -0.161, 0.01, 0.4109, -0.026, &
229  0.4173, 0.1474, -0.377, -0.4248, 0.3494, -0.4673, -0.2663, 0.0858, &
230  0.2815, -0.0831, 0.1734, -0.1101, 0.3472, -0.4237, -0.499, -0.4278, &
231  0.0403, -0.2564, 0.106, -0.1339, 0.2183, -0.4593, 0.3897, 0.1814, &
232  0.3096, 0.3329, -0.2162, -0.1349, -0.3752, -0.1155, -0.4494, -0.0356, &
233  -0.1776, -0.2952, -0.4692, -0.2821, 0.1987, 0.1159, -0.1637, -0.3908, &
234  -0.4081, -0.311, 0.1897, -0.4715, 0.4399, -0.4585, -0.2052, -0.3093, &
235  -0.0484, -0.0195, 0.3651, -0.3401, -0.2006, 0.0011, 0.2373, -0.1851, &
236  -0.2044, 0.0305, -0.3288, -0.3535, -0.051, 0.2206, -0.0382, 0.325, &
237  0.4449, -0.0674, 0.1765, 0.2122, 0.2747, 0.364, 0.3926, 0.2361, &
238  -0.4706, -0.0562, 0.0346, -0.4615, 0.2632, 0.2095, 0.346, -0.0197, &
239  -0.3338, 0.4065, -0.3779, -0.0901, 0.0981, -0.1179, -0.1619, -0.2831, &
240  0.4709, 0.3433, -0.0723, 0.1744, -0.2182, -0.0365, 0.3851, -0.4263, &
241  0.2903, -0.0463, 0.4824, -0.349, -0.2941, 0.1386, 0.228, -0.026, &
242  0.1105, -0.3866, 0.417, -0.0021, 0.4718, -0.4834, -0.0377, 0.2265, &
243  0.4044, -0.4975, 0.0467, -0.4142, -0.1741, 0.2117, 0.4677, -0.1504, &
244  -0.1259, -0.4895, 0.1251, -0.45, 0.4062, -0.2606, 0.0356, 0.2806, &
245  -0.4247, 0.2262, -0.3132, -0.0803, -0.0144, 0.2835, -0.0234, -0.2817, &
246  -0.1099, -0.0675, -0.3592, 0.131, -0.0506, 0.4867, 0.0172, -0.1996, &
247  0.2327, -0.1522, 0.3792, 0.0062, -0.1455, 0.4794, -0.4917, 0.3584, &
248  0.387, -0.4079, 0.2842, -0.4815, 0.1635, 0.0122, -0.4488, -0.3681, &
249  -0.4737, 0.3576, 0.2158, 0.0163, 0.0637, -0.4268, -0.2131, 0.2677, &
250  -0.0808, 0.0681, 0.3314, 0.1626, -0.489, -0.2921, 0.1211, 0.3653, &
251  0.224, 0.427, -0.0387, 0.4869, -0.0176, -0.4717, 0.4876, -0.2194, &
252  -0.4679, -0.1669, 0.1821, 0.0641, -0.1187, 0.4273, -0.1504, 0.2218, &
253  0.1033, 0.2177, -0.4011, 0.0596, 0.0083, 0.4719, -0.3228, -0.1893, &
254  -0.3938, 0.233, -0.3116, 0.1987, -0.0399, -0.3335, 0.4565, 0.0106, &
255  0.1017, 0.1004, 0.3754, 0.4765, -0.1246 /)
256 
257  contains
258  procedure :: eval => eval_pslab2
259 
260 
261 
263 
264 
266 
267  contains
268  procedure :: init => init_delta
269  procedure :: eval => eval_delta
270 
272 !
273 
274 
275  abstract interface
276  subroutine signature_init ( self, file_id )
279  class( sll_c_distribution_params_6d ), intent( out ) :: self
280  sll_int32 :: file_id
281 
282  end subroutine signature_init
283  end interface
284 
285 
286  abstract interface
287  function signature_eval ( self, x ) result(res)
290  class( sll_c_distribution_params_6d ), intent( in ) :: self
291  sll_real64, intent(in) :: x(6)
292  sll_real64 :: res
293 
294 
295  end function signature_eval
296  end interface
297 
298  abstract interface
299  function signature_eval_v ( self, x ) result(res)
302  class( sll_c_distribution_params_6d ), intent( in ) :: self
303  sll_real64, intent(in) :: x(3)
304  sll_real64 :: res
305 
306 
307  end function signature_eval_v
308  end interface
309 
310 contains
311 
312  subroutine sll_s_set_local_grid(&
313  local_sizes, &
314  indices_min, &
315  eta_min, &
316  delta_eta, &
317  tensor_grid)
318  sll_int32, intent(in) :: local_sizes(6)
319  sll_int32, intent(in) :: indices_min(6)
320  sll_real64, intent(in) :: eta_min(6)
321  sll_real64, intent(in) :: delta_eta(6)
322  type(sll_t_array), intent(out) :: tensor_grid(6)
323 
324  sll_int32 :: j, k, ierr
325 
326  do j=1,6
327  allocate(tensor_grid(j)%vals(local_sizes(j)), stat=ierr)
328  sll_assert(ierr == 0 )
329  do k=1,local_sizes(j)
330  tensor_grid(j)%vals(k) = eta_min(j) + &
331  delta_eta(j) * real(indices_min(j)-2+k, f64)
332  end do
333  end do
334 
335  end subroutine sll_s_set_local_grid
336 
337 
338 
340  local_sizes, &
341  indices_min, &
342  eta_min, &
343  delta_eta, &
344  tensor_grid)
345  sll_int32, intent(in) :: local_sizes(6)
346  sll_int32, intent(in) :: indices_min(6)
347  sll_real64, intent(in) :: eta_min(6)
348  sll_real64, intent(in) :: delta_eta(6)
349  type(sll_t_array), intent(out) :: tensor_grid(6)
350  sll_real64 :: vtrans
351 
352  sll_int32 :: j, k, ierr
353 
354  do j=1,6
355  allocate(tensor_grid(j)%vals(local_sizes(j)), stat=ierr)
356  sll_assert(ierr == 0 )
357  do k=1,local_sizes(j)
358  if (j .gt. 3) then
359  call sll_s_compute_velocity_transformation_en(eta_min(j) + &
360  delta_eta(j) * real(indices_min(j)-2+k, f64), vtrans)
361  tensor_grid(j)%vals(k) = vtrans
362  else
363  tensor_grid(j)%vals(k) = eta_min(j) + &
364  delta_eta(j) * real(indices_min(j)-2+k, f64)
365  endif
366  end do
367  end do
368 
369  end subroutine sll_s_set_local_grid_en
370 
371 
372 
373  subroutine sll_s_distribution_params_6d_new( params, distrib_type, file_id )
374  class( sll_c_distribution_params_6d ), allocatable, intent( out ) :: params
375  character(*), intent(in) :: distrib_type
376  sll_int32 :: file_id
377 
378  select case ( distrib_type )
379  case ( "landau_sum" )
380  allocate( sll_t_landau_sum_parameters_6d :: params )
381  params%distrib_type = sll_p_landau_sum
382  case ( "landau_prod" )
383  allocate( sll_t_landau_prod_parameters_6d :: params )
384  params%distrib_type = sll_p_landau_prod
385  case ( "landau_diag" )
386  allocate( sll_t_landau_diag_parameters_6d :: params )
387  params%distrib_type = sll_p_landau_diag
388  case ( "landau_sum_df" )
389  allocate( sll_t_landau_sum_df_parameters_6d :: params )
390  params%distrib_type = sll_p_landau_sum_df
391  case ( "pslab" )
392  allocate( sll_t_pslab_parameters_6d :: params )
393  params%distrib_type = sll_p_pslab
394  case ( "delta" )
395  allocate( sll_t_delta_parameters_6d :: params )
396  params%distrib_type = sll_p_delta
397  case ( "pslab2" )
398  allocate( sll_t_pslab2_parameters_6d :: params )
399  params%distrib_type = sll_p_pslab2
400  case ( "twogaussian_sum" )
401  allocate( sll_t_twogaussian_parameters_6d :: params )
402  params%distrib_type = sll_p_twogaussian_sum
403  case default
404  sll_error('Type of initial distribution not implemented.', 'sll_s_distribution_params_6d_new')
405  end select
406 
407  call params%init( file_id )
408 
409  end subroutine sll_s_distribution_params_6d_new
410 
411 
414  local_sizes, &
415  data_indices_min, &
416  params, &
417  tensor_grid, &
418  fdistrib)
419  sll_int32, intent(in) :: local_sizes(6)
420  sll_int32, intent(in) :: data_indices_min(6)
421  class(sll_c_distribution_params_6d),intent(in) :: params
422  type(sll_t_array), intent(in) :: tensor_grid(6)
423  sll_real64, intent(out) :: fdistrib(1:,1:,1:,1:,1:,1:)
424  sll_int32 :: i,j,k,l,m,n
425 
426 
427 !$omp parallel default(shared) private(i,j,k,l,m,n)
428 !$omp do OMP_COLLAPSE OMP_SCHEDULE
429  do n=1, local_sizes(6)
430  do m=1, local_sizes(5)
431  do l=1, local_sizes(4)
432  do k=1, local_sizes(3)
433  do j=1, local_sizes(2)
434  do i=1, local_sizes(1)
435  fdistrib(i,j,k,l,m,n) = &
436  params%eval( [tensor_grid(1)%vals(i), tensor_grid(2)%vals(j), tensor_grid(3)%vals(k), tensor_grid(4)%vals(l), tensor_grid(5)%vals(m), tensor_grid(6)%vals(n)])
437  end do
438  end do
439  end do
440  end do
441  end do
442  end do
443 !$omp end do
444 !$omp end parallel
445  end subroutine sll_s_distribution_initializer_6d
446 
447 
448 
449 
451  sll_real64, intent(in) :: vin
452  sll_real64, intent(out) :: vtrans
453 
454  sll_real64 :: vmax = 6.
455  sll_real64 :: e = exp(1.)
456  sll_real64 :: pi=4.d0*datan(1.d0)
457 
458 
459 !
460 ! vtrans = 1.6766955862167576*((10*vmax*Sin((11.242085967477433*vin)/vmax**2))/(7.*Pi) &
461 ! - (5*vmax*Sin((22.484171934954865*vin)/vmax**2))/(21.*Pi) &
462 ! + (10*vmax*Sin((33.726257902432295*vin)/vmax**2))/(693.*Pi) &
463 ! + (5*vmax*Sin((44.96834386990973*vin)/vmax**2))/(6006.*Pi) &
464 ! + (2*vmax*Sin((56.21042983738717*vin)/vmax**2))/(15015.*Pi))
465 
466  vtrans = (vmax*(211629600.*sin((pi*vin)/vmax) &
467  - 79361100.*sin((2*pi*vin)/vmax) &
468  + 32558400.*sin((3*pi*vin)/vmax) &
469  - 12209400.*sin((4*pi*vin)/vmax) &
470  + 3907008.*sin((5*pi*vin)/vmax) &
471  - 4275.*(238.*sin((6*pi*vin)/vmax)&
472  - 48.*sin((7.*pi*vin)/vmax)&
473  + 7.*sin((8.*pi*vin)/vmax)) &
474  + 2800.*sin((9.*pi*vin)/vmax)&
475  - 126.*sin((10.*pi*vin)/vmax)))/(1.1639628e8*pi)
476 
477 ! 1.4909655684059773*((5.*vmax*Sin((12.642515911142883*vin)/vmax**2))/(3.*Pi) &
478 ! - (10.*vmax*Sin((25.285031822285767*vin)/vmax**2))/(21.*Pi)&
479 ! + (5.*vmax*Sin((37.927547733428646*vin)/vmax**2))/(42.*Pi) &
480 ! - (5.*vmax*Sin((50.57006364457153*vin)/vmax**2))/(252.*Pi)&
481 ! + (vmax*Sin((63.21257955571442*vin)/vmax**2))/(630.*Pi))
482 
483  end subroutine
484 
485 
487  sll_real64, intent(in) :: vin
488  sll_real64, intent(out) :: vtrans
489 
490  sll_real64 :: vmax = 6.
491  sll_real64 :: e = exp(1.)
492  sll_real64 :: pi=4.d0*datan(1.d0)
493 
494 
495 
496  vtrans = vin!1.6766955862167576*((10*vmax*Sin((11.242085967477433*vin)/vmax**2))/(7.*Pi) &
497 ! - (5*vmax*Sin((22.484171934954865*vin)/vmax**2))/(21.*Pi) &
498 ! + (10*vmax*Sin((33.726257902432295*vin)/vmax**2))/(693.*Pi) &
499 ! + (5*vmax*Sin((44.96834386990973*vin)/vmax**2))/(6006.*Pi) &
500 ! + (2*vmax*Sin((56.21042983738717*vin)/vmax**2))/(15015.*Pi))
501 
502 
503 ! vtrans = Sqrt(vmax**2*(196163108820. - 62249523265.*Cos((Pi*vin)/vmax) &
504 ! + 16481327830.*Cos((2*Pi*vin)/vmax) - 4782807075.*Cos((3*Pi*vin)/vmax) &
505 ! + 1302114020.*Cos((4*Pi*vin)/vmax) - 304886885.*Cos((5*Pi*vin)/vmax) &
506 ! + 57244242.*Cos((6*Pi*vin)/vmax) - 7953631.*Cos((7*Pi*vin)/vmax) &
507 ! + 720496.*Cos((8*Pi*vin)/vmax) - 31752.*Cos((9*Pi*vin)/vmax))&
508 ! *Sin((Pi*vin)/(2.*vmax))**2)/(630.*Sqrt(92378.)*Pi)
509 !
510 ! 1.4909655684059773*((5.*vmax*Sin((12.642515911142883*vin)/vmax**2))/(3.*Pi) &
511 ! - (10.*vmax*Sin((25.285031822285767*vin)/vmax**2))/(21.*Pi)&
512 ! + (5.*vmax*Sin((37.927547733428646*vin)/vmax**2))/(42.*Pi) &
513 ! - (5.*vmax*Sin((50.57006364457153*vin)/vmax**2))/(252.*Pi)&
514 ! + (vmax*Sin((63.21257955571442*vin)/vmax**2))/(630.*Pi))
515 
516  end subroutine
517 
518 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
519 !
520 ! Now the section defining the various types of paramters that are currently available.
521 !
522 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
523 
524  ! First the init functions
525 
526  subroutine init_landau_sum( self, file_id )
527  class( sll_t_landau_sum_parameters_6d ), intent( out ) :: self
528  sll_int32 :: file_id
529 
530  sll_real64 :: v_thermal(3)
531  sll_real64 :: alpha(3)
532  sll_real64 :: kx(3)
533  sll_real64 :: phase(3) = [0.0_f64,0.0_f64,0.0_f64]
534 
535  namelist /landau_params/ v_thermal, alpha, kx, phase
536 
537  read(file_id, landau_params)
538 
539  self%v_thermal = v_thermal
540  self%kx = kx
541  self%alpha = alpha
542  self%phase = phase
543  self%factor = 1.0_f64/(sqrt(sll_p_twopi)**3*product(self%v_thermal))
544 
545  end subroutine init_landau_sum
546 
547  subroutine init_landau_prod ( self, file_id )
548  class( sll_t_landau_prod_parameters_6d ), intent( out ) :: self
549  sll_int32 :: file_id
550 
551  sll_real64 :: v_thermal(3)
552  sll_real64 :: alpha
553  sll_real64 :: kx(3)
554 
555  namelist /landau_params/ v_thermal, alpha, kx
556 
557  read(file_id, landau_params)
558 
559  self%v_thermal = v_thermal
560  self%kx = kx
561  self%alpha = alpha
562  self%factor = 1.0_f64/(sqrt(sll_p_twopi)**3*product(self%v_thermal))
563 
564  end subroutine init_landau_prod
565 
566 
567  subroutine init_twogaussian ( self, file_id )
568  class( sll_t_twogaussian_parameters_6d ), intent( out ) :: self
569  sll_int32 :: file_id
570 
571  sll_real64 :: v_thermal1(3)
572  sll_real64 :: v_thermal2(3)
573  sll_real64 :: v_mean1(3)
574  sll_real64 :: v_mean2(3)
575  sll_real64 :: portion
576  sll_real64 :: alpha
577  sll_real64 :: kx(3)
578 
579  namelist /twogaussian_params/ v_thermal1, v_thermal2, v_mean1, v_mean2, portion, alpha, kx
580 
581  read(file_id, twogaussian_params)
582 
583  self%v_thermal(1,:) = v_thermal1
584  self%v_thermal(2,:) = v_thermal2
585  self%v_mean(1,:) = v_mean1
586  self%v_mean(2,:) = v_mean2
587  self%kx = kx
588  self%alpha = alpha
589 ! self%delta = [1-portion, portion]
590  self%delta = [(1-portion)/sqrt(product(v_thermal1)), &
591  portion/sqrt(product(v_thermal2))]
592  self%factor = 1.0_f64/(sqrt(sll_p_twopi)**3)
593 
594  end subroutine init_twogaussian
595 
596 
597  subroutine init_pslab ( self, file_id )
598  class( sll_t_pslab_parameters_6d ), intent( out ) :: self
599  sll_int32 :: file_id
600 
601  sll_real64 :: kappa_ti
602  sll_real64 :: c_te
603  sll_real64 :: b0
604  sll_real64 :: v_thermal(3) = [1.0_f64, 1.0_f64, 1.0_f64]
605  sll_real64 :: v_mean(3) = [0.0_f64, 0.0_f64, 0.0_f64]
606  sll_real64 :: alpha
607  sll_real64 :: kx(3)
608 
609  namelist /landau_params/ v_thermal, alpha, kx, v_mean
610  namelist /pslab_params/ kappa_ti, b0, c_te
611 
612  read(file_id, landau_params)
613  read(file_id, pslab_params)
614 
615  self%kappa_ti = kappa_ti
616  self%c_te = c_te
617  self%b0 = b0
618  self%alpha = alpha
619  self%v_thermal = v_thermal
620  self%v_mean = v_mean
621  self%kx = kx
622  self%factor = 1.0_f64/(sqrt(sll_p_twopi)**3)
623 
624  end subroutine init_pslab
625 
626 
627 
628  subroutine init_delta ( self, file_id )
629  class( sll_t_delta_parameters_6d ), intent( out ) :: self
630  sll_int32 :: file_id
631 
632  sll_real64 :: kappa_ti
633  sll_real64 :: c_te
634  sll_real64 :: b0
635  sll_real64 :: v_thermal(3) = [1.0_f64, 1.0_f64, 1.0_f64]
636  sll_real64 :: v_mean(3) = [0.0_f64, 0.0_f64, 0.0_f64]
637  sll_real64 :: alpha
638  sll_real64 :: kx(3)
639 
640  namelist /landau_params/ v_thermal, alpha, kx, v_mean
641  namelist /pslab_params/ kappa_ti, b0, c_te
642 
643  read(file_id, landau_params)
644  read(file_id, pslab_params)
645 
646  self%kappa_ti = kappa_ti
647  self%c_te = c_te
648  self%b0 = b0
649  self%alpha = alpha
650  self%v_thermal = v_thermal
651  self%v_mean = v_mean
652  self%kx = kx
653  self%factor = 1.0_f64/(sqrt(sll_p_twopi)**3)
654 
655  end subroutine init_delta
656 
657  ! Now the eval functions
658  function eval_landau_sum ( self, x ) result(res)
659  class( sll_t_landau_sum_parameters_6d ), intent( in ) :: self
660  sll_real64, intent(in) :: x(6)
661  sll_real64 :: res
662 
663  res = self%factor*(1.0_f64 + &
664  self%alpha(1)*cos(self%kx(1)*x(1))+ &
665  self%alpha(2)*cos(self%kx(2)*x(2))+ &
666  self%alpha(3)*cos(self%kx(3)*x(3))) *&
667  exp(-0.5_f64*((x(4)/self%v_thermal(1))**2+ &
668  (x(5)/self%v_thermal(2))**2+ &
669  (x(6)/self%v_thermal(3))**2))
670 
671  end function eval_landau_sum
672 
673 
674  function eval_landau_sum_df ( self, x ) result(res)
675  class( sll_t_landau_sum_df_parameters_6d ), intent( in ) :: self
676  sll_real64, intent(in) :: x(6)
677  sll_real64 :: res
678 
679  res = self%factor*( &
680  self%alpha(1)*cos(self%kx(1)*x(1))+ &
681  self%alpha(2)*cos(self%kx(2)*x(2))+ &
682  self%alpha(3)*cos(self%kx(3)*x(3))) *&
683  exp(-0.5_f64*((x(4)/self%v_thermal(1))**2+ &
684  (x(5)/self%v_thermal(2))**2+ &
685  (x(6)/self%v_thermal(3))**2))
686 
687  end function eval_landau_sum_df
688 
689  function eval_landau_prod ( self, x ) result(res)
690  class( sll_t_landau_prod_parameters_6d ), intent( in ) :: self
691  sll_real64, intent(in) :: x(6)
692  sll_real64 :: res
693 
694  res = self%factor*(1.0_f64 + self%alpha*( &
695  cos(self%kx(1)*x(1))* &
696  cos(self%kx(2)*x(2))* &
697  cos(self%kx(3)*x(3)))) *&
698  exp(-0.5_f64*((x(4)/self%v_thermal(1))**2+ &
699  (x(5)/self%v_thermal(2))**2+ &
700  (x(6)/self%v_thermal(3))**2))
701 
702  end function eval_landau_prod
703 
704  function eval_landau_v ( self, x ) result(res)
705  class( sll_t_landau_prod_parameters_6d ), intent( in ) :: self
706  sll_real64, intent(in) :: x(3)
707  sll_real64 :: res
708 
709  res = self%factor* &
710  exp(-0.5_f64*((x(1)/self%v_thermal(1))**2+ &
711  (x(2)/self%v_thermal(2))**2+ &
712  (x(3)/self%v_thermal(3))**2))
713 
714  end function eval_landau_v
715 
716  function eval_landau_v_sum ( self, x ) result(res)
717  class( sll_t_landau_sum_parameters_6d ), intent( in ) :: self
718  sll_real64, intent(in) :: x(3)
719  sll_real64 :: res
720 
721  res = self%factor* &
722  exp(-0.5_f64*((x(1)/self%v_thermal(1))**2+ &
723  (x(2)/self%v_thermal(2))**2+ &
724  (x(3)/self%v_thermal(3))**2))
725 
726  end function eval_landau_v_sum
727 
728  function eval_landau_diag ( self, x ) result(res)
729  class( sll_t_landau_diag_parameters_6d ), intent( in ) :: self
730  sll_real64, intent(in) :: x(6)
731  sll_real64 :: res
732 
733  res = self%factor*(1.0_f64 + self%alpha*( &
734  cos(self%kx(1)*x(1)+ &
735  self%kx(2)*x(2)+ &
736  self%kx(3)*x(3)))) *&
737  exp(-0.5_f64*((x(4)/self%v_thermal(1))**2+ &
738  (x(5)/self%v_thermal(2))**2+ &
739  (x(6)/self%v_thermal(3))**2))
740 
741  end function eval_landau_diag
742 
743 
744 
745  function eval_twogaussian_sum ( self, x ) result(res)
746  class( sll_t_twogaussian_parameters_6d ), intent( in ) :: self
747  sll_real64, intent(in) :: x(6)
748  sll_real64 :: res
749 
750  res = self%factor*(1.0_f64 + self%alpha*( &
751  cos(self%kx(1)*x(1))+ &
752  cos(self%kx(2)*x(2))+ &
753  cos(self%kx(3)*x(3)))) *&
754  ( self%delta(1) * exp(-0.5_f64*(&
755  ((x(4)-self%v_mean(1,1))/self%v_thermal(1,1))**2+ &
756  ((x(5)-self%v_mean(1,2))/self%v_thermal(1,2))**2+ &
757  ((x(6)-self%v_mean(1,3))/self%v_thermal(1,3))**2)) + &
758  self%delta(2) * exp(-0.5_f64*(&
759  ((x(4)-self%v_mean(2,1))/self%v_thermal(2,1))**2+ &
760  ((x(5)-self%v_mean(2,2))/self%v_thermal(2,2))**2+ &
761  ((x(6)-self%v_mean(2,3))/self%v_thermal(2,3))**2)))
762 
763  end function eval_twogaussian_sum
764 
765  function eval_twogaussian_v ( self, x ) result(res)
766  class( sll_t_twogaussian_parameters_6d ), intent( in ) :: self
767  sll_real64, intent(in) :: x(3)
768  sll_real64 :: res
769 
770  res = self%factor *&
771  ( self%delta(1) * exp(-0.5_f64*(&
772  ((x(1)-self%v_mean(1,1))/self%v_thermal(1,1))**2+ &
773  ((x(2)-self%v_mean(1,2))/self%v_thermal(1,2))**2+ &
774  ((x(3)-self%v_mean(1,3))/self%v_thermal(1,3))**2)) + &
775  self%delta(2) * exp(-0.5_f64*(&
776  ((x(1)-self%v_mean(2,1))/self%v_thermal(2,1))**2+ &
777  ((x(2)-self%v_mean(2,2))/self%v_thermal(2,2))**2+ &
778  ((x(3)-self%v_mean(2,3))/self%v_thermal(2,3))**2)))
779 
780  end function eval_twogaussian_v
781 
782  function eval_pslab ( self, x ) result(res)
783  class( sll_t_pslab_parameters_6d ), intent( in ) :: self
784  sll_real64, intent(in) :: x(6)
785  sll_real64 :: res
786 
787 ! res = self%factor* &
788 ! (1.0_f64 + self%alpha* &
789 ! cos(self%kx(1)*x(1) + &
790 ! self%kx(2)*x(2) + &
791 ! self%kx(3)*x(3))* &
792 ! exp(-0.5_f64*((x(4)- self%v_mean(1))**2+ &
793 ! (x(5)-self%v_mean(2))**2+ &
794 ! (x(6)-self%v_mean(3))**2)))
795 
796  if (self%B0 .ne. 0)then
797 
798  res = self%factor* &
799  (1.0_f64 + self%alpha* &
800  (cos(self%kx(1)*(x(1)- &
801  x(5)/self%B0) + &
802  self%kx(2)*(x(2) + &
803  x(4)/self%B0) + &
804  self%kx(3)*x(3)) - &
805  0.5_f64*cos(self%kx(1)*x(1) + &
806  self%kx(2)*x(2) + &
807  self%kx(3)*x(3))* &
808  exp(-0.5_f64*(self%kx(1)**2+self%kx(2)**2)/self%B0**2)))*&
809  exp(-0.5_f64*((x(4)- self%v_mean(1))**2+ &
810  (x(5)-self%v_mean(2))**2+ &
811  (x(6)-self%v_mean(3))**2))
812  else
813  res = self%factor* &
814  (1.0_f64 + self%alpha* &
815  sin(self%kx(1)*(x(1)) + &
816  self%kx(2)*(x(2)) + &
817  self%kx(3)*x(3))) *&
818  exp(-0.5_f64*((x(4)- self%v_mean(1))**2+ &
819  (x(5)-self%v_mean(2))**2+ &
820  (x(6)-self%v_mean(3))**2))
821  endif
822  !
823 
824 ! res = self%factor* &
825 ! (1.0_f64 + self%alpha* &
826 ! exp(-(x(1)-x(5)/self%B0-sll_p_twopi/self%kx(1)/2)**2 * self%kx(1)**2)*&
827 ! exp(-(x(2)+x(4)/self%B0-sll_p_twopi/self%kx(2)/2)**2 * self%kx(2)**2)*&
828 ! exp(-(x(3)-sll_p_twopi/self%kx(3)/2)**2 * self%kx(3)**2)- &
829 ! 0.5/(exp(((3 + 4*self%kx(2)**2 + 4*self%kx(1)**2*(1 + self%kx(2)**2))*(sll_p_twopi/2.0)**2 + self%kx(2)**2*x(2)**2 + self%kx(3)**2*x(3)**2 + 2*self%kx(2)**2*self%kx(3)**2*x(3)**2 - 2*(sll_p_twopi/2.0)* (self%kx(1)*(x(1) + 2*self%kx(2)**2*x(1)) + self%kx(2)*x(2) + self%kx(3)*x(3) + 2*self%kx(2)**2*self%kx(3)*x(3) + 2*self%kx(1)**2*(self%kx(2)*x(2) + self%kx(3)*x(3) + 2*self%kx(2)**2*self%kx(3)*x(3))) +self%kx(1)**2*((1 + 2*self%kx(2)**2)*x(1)**2 + 2*self%kx(3)**2*x(3)**2 + 2*self%kx(2)**2*(x(2)**2 + 2*self%kx(3)**2*x(3)**2)))/((1 + 2*self%kx(1)**2)*(1 + 2*self%kx(2)**2)))*Sqrt(1 + 2*self%kx(1)**2)*Sqrt(1 + 2*self%kx(2)**2)))*&
830 ! exp(-0.5_f64*((x(4)- self%v_mean(1))**2+ &
831 ! (x(5)-self%v_mean(2))**2+ &
832 ! (x(6)-self%v_mean(3))**2))
833 
834  end function eval_pslab
835 
836  function eval_delta ( self, x ) result(res)
837  class( sll_t_delta_parameters_6d ), intent( in ) :: self
838  sll_real64, intent(in) :: x(6)
839  sll_real64 :: res,r
840 
841  res = 1.0
842 
843  r = self%randArray(modulo(int(x(1)*241+73)*int(x(2)*163+211)*int(x(3)*31+139),509)+1)
844 
845 
846  res = self%factor * (res+self%alpha*r)*exp(-0.5_f64*((x(4)- self%v_mean(1))**2+ &
847  (x(5)-self%v_mean(2))**2+ &
848  (x(6)-self%v_mean(3))**2))
849 
850 
851  end function eval_delta
852 
853 
854  function eval_pslab2 ( self, x ) result(res)
855  class( sll_t_pslab2_parameters_6d ), intent( in ) :: self
856  sll_real64, intent(in) :: x(6)
857  sll_real64 :: res,r
858  sll_int32 :: l,m,n
859 
860 ! print*, self%factor, self%alpha, self%kx, x, self%B,
861 !
862 ! res =self%factor* &
863 ! (1.0_f64 + self%alpha* &
864 ! (cos(self%kx(1)*(x(1)- &
865 ! x(5)/self%B0) + &
866 ! self%kx(2)*(x(2)+ &
867 ! x(4)/self%B0) + &
868 ! self%kx(3)*x(3)) - &
869 ! 0.5_f64*cos(self%kx(1)*(x(1)) + &
870 ! self%kx(2)*(x(2)) + &
871 ! self%kx(3)*x(3))* &
872 ! exp(-0.5_f64*(self%kx(1)**2+self%kx(2)**2)/self%B0**2)))*&
873 ! exp(-0.5_f64*((x(4)-self%v_mean(1))**2+ &
874 ! (x(5)-self%v_mean(2))**2+ &
875 ! (x(6)-self%v_mean(3))**2)) + &
876 ! 0.1_f64*self%factor* &
877 ! self%alpha* &
878 ! (cos(self%kx(2)*(x(2) + &
879 ! x(4)/self%B0) + &
880 ! self%kx(3)*x(3)) - &
881 ! 0.5_f64*cos(self%kx(2)*(x(2)) + &
882 ! self%kx(3)*x(3))* &
883 ! exp(-0.5_f64*(self%kx(2)**2)/self%B0**2))*&
884 ! exp(-0.5_f64*((x(4)-self%v_mean(1))**2+ &
885 ! (x(5)-self%v_mean(2))**2+ &
886 ! (x(6)-self%v_mean(3))**2))
887 !
888 !
889  res = 0.0
890 
891  do m=-4,4
892  do n=-4,4
893  do l=-4,4
894  if (n .ne. 0 .or. l .ne. 0 .or. m .ne. 0 ) then
895  r = self%randArray(modulo((m+8)*(n+8)*(l+8),512))
896 
897  res = res + r* 0.1*exp(-0.5_f64*(n**2+l**2+m**2) * 0.05) *&
898  self%alpha* &
899  (cos(l*self%kx(1)*(x(1)- &
900  x(5)/self%B0) + &
901  m*self%kx(2)*(x(2) + &
902  x(4)/self%B0) + &
903  n*self%kx(3)*x(3))- &
904  0.5_f64*cos(l*self%kx(1)*(x(1)) + &
905  m*self%kx(2)*(x(2)) + &
906  n*self%kx(3)*x(3))* &
907  exp(-0.5_f64*(l**2*self%kx(1)**2+m**2*self%kx(2)**2)/self%B0**2) )
908  end if
909  end do
910  end do
911  end do
912 
913 
914  res = self%factor*(1.0_f64 + self%alpha*(res))*&
915  exp(-0.5_f64*( (x(4)-self%v_mean(1))**2+ &
916  (x(5)-self%v_mean(2))**2+ &
917  (x(6)-self%v_mean(3))**2))
918 
919 
920 
921 
922  end function eval_pslab2
923 
924  function eval_pslab_v ( self, x ) result(res)
925  class( sll_t_pslab_parameters_6d ), intent( in ) :: self
926  sll_real64, intent(in) :: x(3)
927  sll_real64 :: res
928 
929  res = self%factor* &
930  exp(-0.5_f64*((x(1)- self%v_mean(1))**2+ &
931  (x(2)-self%v_mean(2))**2+ &
932  (x(3)-self%v_mean(3))**2))
933 
934  end function eval_pslab_v
935 
936  ! TODO: Old function, needs to be adapted.
937 !!$ !> Initialize distribution function with Landau initial value
938 !!$ subroutine sll_s_initialize_itg_6d( &
939 !!$ local_sizes, &
940 !!$ indices_min, &
941 !!$ eta_min, &
942 !!$ delta_eta, &
943 !!$ params, &
944 !!$ fdistrib, &
945 !!$ tensor_grid, &
946 !!$ Terdn0r)
947 !!$ sll_int32, intent(in) :: local_sizes(6)
948 !!$ sll_int32, intent(in) :: indices_min(6)
949 !!$ sll_real64, intent(in) :: eta_min(6)
950 !!$ sll_real64, intent(in) :: delta_eta(6)
951 !!$ type(sll_t_itg_parameters_6d), intent(in) :: params
952 !!$ sll_real64, intent(out) :: fdistrib(1:,1:,1:,1:,1:,1:)
953 !!$ type(sll_t_array), intent(out) :: tensor_grid(6)
954 !!$ sll_real64, intent(out) :: Terdn0r(:)
955 !!$
956 !!$ sll_int32 :: i,j,k,l,m,n
957 !!$ sll_real64 :: factor, x, cn0(1), cn0_local(1)
958 !!$ sll_real64, allocatable :: n0r(:), Ter(:), Tir(:)
959 !!$
960 !!$ factor = 1.0_f64/(sqrt(sll_p_twopi)**3*product(params%v_thermal))
961 !!$
962 !!$ call sll_s_set_local_grid(local_sizes, indices_min, eta_min, delta_eta, tensor_grid)
963 !!$
964 !!$
965 !!$ allocate(n0r(local_sizes(1)))
966 !!$ allocate(Ter(local_sizes(1)))
967 !!$ allocate(Tir(local_sizes(1)))
968 !!$
969 !!$
970 !!$ do i=1, local_sizes(1)
971 !!$ x = tensor_grid(1)%vals(i)
972 !!$ n0r(i) = exp(-params%kappa_n0*params%delta_rn0* &
973 !!$ tanh((x-params%rp)/params%delta_rn0))
974 !!$ Ter(i) = params%C_Te* exp(-params%kappa_Te*params%delta_rTe* &
975 !!$ tanh((x-params%rp)/params%delta_rTe))
976 !!$ Tir(i) = exp(-params%kappa_Ti*params%delta_rTi* &
977 !!$ tanh((x-params%rp)/params%delta_rTi))
978 !!$ Terdn0r(i) = Ter(i)/n0r(i)
979 !!$ end do
980 !!$ cn0_local = sum(n0r)
981 !!$ ! TODO: Exchange
982 !!$ call sll_o_collective_allreduce( sll_v_world_collective, cn0_local, 1, MPI_SUM, cn0 )
983 !!$
984 !!$ n0r = n0r/cn0
985 !!$ Terdn0r = Terdn0r*cn0
986 !!$
987 !!$
988 !!$ do n=1, local_sizes(6)
989 !!$ do m=1, local_sizes(5)
990 !!$ do l=1, local_sizes(4)
991 !!$ do k=1, local_sizes(3)
992 !!$ do j=1, local_sizes(2)
993 !!$ do i=1, local_sizes(1)
994 !!$ ! TODO: Update
995 !!$ fdistrib(i,j,k,l,m,n) = &
996 !!$ n0r(i)/(sll_p_twopi)**(1.5_f64)* &
997 !!$
998 !!$ factor*(1.0_f64 + params%alpha* &
999 !!$ cos(params%kx(1)*tensor_grid(1)%vals(i))* &
1000 !!$ cos(params%kx(2)*tensor_grid(2)%vals(j))* &
1001 !!$ cos(params%kx(3)*tensor_grid(3)%vals(k))) *&
1002 !!$ exp(-0.5_f64/Tir(i)*((tensor_grid(4)%vals(l)/params%v_thermal(1))**2+ &
1003 !!$ (tensor_grid(5)%vals(m)/params%v_thermal(2))**2+ &
1004 !!$ (tensor_grid(6)%vals(n)/params%v_thermal(3))**2))
1005 !!$ end do
1006 !!$ end do
1007 !!$ end do
1008 !!$ end do
1009 !!$ end do
1010 !!$ end do
1011 !!$
1012 !!$ end subroutine sll_s_initialize_itg_6d
1013 
1014 
1015 
Combines values from all processes and distributes the result back to all processes.
Parallelizing facility.
type(sll_t_collective_t), pointer, public sll_v_world_collective
Control of subset assignment. Processes with the same color are in the same new communicator.
Fortran module where set some physical and mathematical constants.
real(kind=f64), parameter, public sll_p_twopi
Data types that collect the parameters for various types of initial distributions and define the corr...
subroutine, public sll_s_set_local_grid(local_sizes, indices_min, eta_min, delta_eta, tensor_grid)
subroutine, public sll_s_distribution_params_6d_new(params, distrib_type, file_id)
subroutine, public sll_s_distribution_initializer_6d(local_sizes, data_indices_min, params, tensor_grid, fdistrib)
Initialize distribution function with given distribution parameter.
integer(kind=i32), parameter, public sll_p_landau_prod
Parameters describing various types of initial conditions.
subroutine, public sll_s_set_local_grid_en(local_sizes, indices_min, eta_min, delta_eta, tensor_grid)
Module to select the kind parameter.
Type to specify parameter for double Gaussian (includes bump-on-tail and TSI)
    Report Typos and Errors