Report Typos and Errors    
Semi-Lagrangian Library
Modular library for kinetic and gyrokinetic simulations of plasmas in fusion energy devices.
sll_m_common_array_initializers.F90
Go to the documentation of this file.
2 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 #include "sll_assert.h"
4 #include "sll_errors.h"
5 #include "sll_working_precision.h"
6 
7  use sll_m_constants, only: &
9 
10  use sll_m_gaussian, only: &
12 
13  implicit none
14 
15  public :: &
25  sll_f_dsg_2d, &
30  sll_f_khp1_2d, &
71 
72  private
73 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
74 
75  ! The functions specified here are meant to have the specific signature
76  ! described in the sll_m_parallel_array_initializer. Else, they could
77  ! not be used with this module.
78 
79  abstract interface
80  function sll_i_scalar_initializer_1d(x1, params)
82  sll_real64 :: sll_i_scalar_initializer_1d
83  sll_real64, intent(in) :: x1
84  sll_real64, dimension(:), intent(in) :: params
85  end function sll_i_scalar_initializer_1d
86  end interface
87 
88  abstract interface
89  function sll_i_scalar_initializer_2d(x1, x2, params)
91  sll_real64 :: sll_i_scalar_initializer_2d
92  sll_real64, intent(in) :: x1
93  sll_real64, intent(in) :: x2
94  sll_real64, dimension(:), intent(in) :: params
95  end function sll_i_scalar_initializer_2d
96  end interface
97 
98  abstract interface
99  function sll_i_scalar_initializer_4d(x1, x2, x3, x4, params)
101  sll_real64 :: sll_i_scalar_initializer_4d
102  sll_real64, intent(in) :: x1
103  sll_real64, intent(in) :: x2
104  sll_real64, intent(in) :: x3
105  sll_real64, intent(in) :: x4
106  sll_real64, dimension(:), intent(in) :: params
107  end function sll_i_scalar_initializer_4d
108  end interface
109 
110 contains
111 
112 !phi(i1,i2) =0.5_f64*(x1**2 + x2**2 - 0.1_f64*atan(x2/(x1+0.00001_f64))**2 )
113 
114  function sll_f_gaussian_initializer_2d(x_1, x_2, params)
115  sll_real64 :: sll_f_gaussian_initializer_2d
116  sll_real64, intent(in) :: x_1
117  sll_real64, intent(in) :: x_2
118  sll_real64, dimension(:), intent(in) :: params
119  sll_real64 :: xc_1
120  sll_real64 :: xc_2
121  sll_real64 :: sigma_1
122  sll_real64 :: sigma_2
123  !sll_real64 :: kx
124  !sll_real64 :: factor1
125 
126 !!$ if( .not. present(params) ) then
127 !!$ print *, 'sll_f_gaussian_initializer_2d, error: ', &
128 !!$ 'the params array must be passed.', &
129 !!$ ' params(1) = xc_1', &
130 !!$ ' params(2) = xc_2', &
131 !!$ ' params(3) = sigma_1', &
132 !!$ ' params(4) = sigma_2'
133 !!$ end if
134  sll_assert(size(params) >= 4)
135  xc_1 = params(1)
136  xc_2 = params(2)
137  sigma_1 = params(3)
138  sigma_2 = params(4)
140  exp(-0.5_f64*(x_1 - xc_1)**2/sigma_1**2 &
141  - 0.5_f64*(x_2 - xc_2)**2/sigma_2**2)
142  end function sll_f_gaussian_initializer_2d
143 
144  function sll_f_cos_bell_initializer_2d(x_1, x_2, params) result(res)
145  sll_real64 :: res
146  sll_real64, intent(in) :: x_1
147  sll_real64, intent(in) :: x_2
148  sll_real64, dimension(:), intent(in) :: params
149  sll_real64 :: xc_1
150  sll_real64 :: xc_2
151  sll_real64 :: r
152 
153 !!$ if( .not. present(params) ) then
154 !!$ print *, 'sll_f_cos_bell_initializer_2d, error: ', &
155 !!$ 'the params array must be passed.', &
156 !!$ ' params(1) = xc_1', &
157 !!$ ' params(2) = xc_2'
158 !!$ end if
159  sll_assert(size(params) >= 2)
160  xc_1 = params(1)
161  xc_2 = params(2)
162 
163  r = sqrt((x_1 - xc_1)**2 + (x_2 - xc_2)**2)
164 
165  if (r < 0.5_f64*sll_p_pi) then
166  res = cos(r)**6
167  else
168  res = 0._f64
169  end if
170 
171  end function sll_f_cos_bell_initializer_2d
172 
173  ! cossin flow
174  function sll_f_cos_sin_initializer_2d(x_1, x_2, params) result(res)
175  sll_real64 :: res
176  sll_real64, intent(in) :: x_1
177  sll_real64, intent(in) :: x_2
178  sll_real64, dimension(:), intent(in) :: params
179  sll_real64 :: a1
180  sll_real64 :: a2
181 
182 !!$ if( .not. present(params) ) then
183 !!$ print *, 'sll_f_cos_sin_initializer_2d, error: ', &
184 !!$ 'the params array must be passed.', &
185 !!$ ' params(1) = A1', &
186 !!$ ' params(2) = A2'
187 !!$ end if
188  sll_assert(size(params) >= 2)
189  a1 = params(1)
190  a2 = params(2)
191  res = (sin(x_1) - a1)*(cos(x_2) - a2)
192 
193  end function sll_f_cos_sin_initializer_2d
194 
195  function sll_f_cos_bell0_initializer_2d(x_1, x_2, params) result(res)
196  sll_real64 :: res
197  sll_real64, intent(in) :: x_1
198  sll_real64, intent(in) :: x_2
199  sll_real64, dimension(:), intent(in) :: params
200  sll_real64 :: xc_1
201  sll_real64 :: xc_2
202  sll_real64 :: cutx_value
203  sll_real64 :: cutf_value
204  sll_real64 :: r
205 
206 !!$ if( .not. present(params) ) then
207 !!$ print *, 'sll_f_cos_bell_initializer_2d, error: ', &
208 !!$ 'the params array must be passed.', &
209 !!$ ' params(1) = xc_1', &
210 !!$ ' params(2) = xc_2'
211 !!$ end if
212  sll_assert(size(params) >= 2)
213  xc_1 = params(1)
214  xc_2 = params(2)
215  if (size(params) >= 3) then
216  cutx_value = params(3)
217  else
218  cutx_value = 0.25_f64
219  end if
220  if (size(params) >= 4) then
221  cutf_value = params(4)
222  else
223  cutf_value = 1._f64
224  end if
225  r = sqrt((x_1 - xc_1)**2 + (x_2 - xc_2)**2)
226 
227  if (r < cutx_value*sll_p_pi) then
228  res = cutf_value
229  else
230  res = 0._f64
231  end if
232 
233  end function sll_f_cos_bell0_initializer_2d
234 
235  function sll_f_one_initializer_2d(x_1, x_2, params) result(res)
236  sll_real64 :: res
237  sll_real64, intent(in) :: x_1
238  sll_real64, intent(in) :: x_2
239  sll_real64, dimension(:), intent(in) :: params
240 #ifdef DEBUG
241  sll_real64 :: dummy
242  dummy = x_1 + x_2
243 #endif
244 
245  if (size(params) >= 1) then
246  res = params(1)
247  else
248  res = 0._f64
249  end if
250 
251  end function sll_f_one_initializer_2d
252 
253  !rotation flow
254  function sll_f_rotation_phi_initializer_2d(x_1, x_2, params) result(res)
255  sll_real64 :: res
256  sll_real64, intent(in) :: x_1
257  sll_real64, intent(in) :: x_2
258  sll_real64, dimension(:), intent(in) :: params
259 
260  res = -0.5_f64*(x_1**2 + x_2**2)
262 
263  function sll_f_rotation_a1_initializer_2d(x_1, x_2, params) result(res)
264  sll_real64 :: res
265  sll_real64, intent(in) :: x_1
266  sll_real64, intent(in) :: x_2
267  sll_real64, dimension(:), intent(in) :: params
268 #ifdef DEBUG
269  sll_real64 :: dummy
270  dummy = x_1 + x_2
271 #endif
272 
273  res = -x_2
275 
276  function sll_f_rotation_a2_initializer_2d(x_1, x_2, params) result(res)
277  sll_real64 :: res
278  sll_real64, intent(in) :: x_1
279  sll_real64, intent(in) :: x_2
280  sll_real64, dimension(:), intent(in) :: params
281 #ifdef DEBUG
282  sll_real64 :: dummy
283  dummy = x_1 + x_2
284 #endif
285 
286  res = x_1
288 
289  function sll_f_rotation_a1_exact_charac_2d(t, t0, x0_1, x0_2, params) result(res)
290  sll_real64 :: res
291  sll_real64, intent(in) :: t
292  sll_real64, intent(in) :: t0
293  sll_real64, intent(in) :: x0_1
294  sll_real64, intent(in) :: x0_2
295  sll_real64, dimension(:), intent(in) :: params
296 
297  res = x0_1*cos(t - t0) - x0_2*sin(t - t0)
299 
300  function sll_f_rotation_a2_exact_charac_2d(t, t0, x0_1, x0_2, params) result(res)
301  sll_real64 :: res
302  sll_real64, intent(in) :: t
303  sll_real64, intent(in) :: t0
304  sll_real64, intent(in) :: x0_1
305  sll_real64, intent(in) :: x0_2
306  sll_real64, dimension(:), intent(in) :: params
307 
308  res = x0_1*sin(t - t0) + x0_2*cos(t - t0)
310 
311  function sll_f_translation_phi_initializer_2d(x_1, x_2, params) result(res)
312  sll_real64 :: res
313  sll_real64, intent(in) :: x_1
314  sll_real64, intent(in) :: x_2
315  sll_real64, dimension(:), intent(in) :: params
316  sll_real64 :: a1
317  sll_real64 :: a2
318 
319  if (size(params) < 2) then
320  sll_error("sll_f_translation_phi_initializer_2d", "params should be of size >=2")
321  print *, 'size(params)', size(params)
322  end if
323  a1 = params(1)
324  a2 = params(2)
325 
326  res = -a2*x_1 + a1*x_2
328 
329  function sll_f_translation_a1_initializer_2d(x_1, x_2, params) result(res)
330  sll_real64 :: res
331  sll_real64, intent(in) :: x_1
332  sll_real64, intent(in) :: x_2
333  sll_real64, dimension(:), intent(in) :: params
334  sll_real64 :: a1
335 #ifdef DEBUG
336  sll_real64 :: dummy
337  dummy = x_1 + x_2
338 #endif
339 
340  if (size(params) < 2) then
341  sll_error("sll_f_translation_a1_initializer_2d", "params should be of size >=2")
342  print *, 'size(params)', size(params)
343  end if
344  a1 = params(1)
345 
346  res = a1
348 
349  function sll_f_translation_a2_initializer_2d(x_1, x_2, params) result(res)
350  sll_real64 :: res
351  sll_real64, intent(in) :: x_1
352  sll_real64, intent(in) :: x_2
353  sll_real64, dimension(:), intent(in) :: params
354  sll_real64 :: a2
355 #ifdef DEBUG
356  sll_real64 :: dummy
357  dummy = x_1 + x_2
358 #endif
359 
360  if (size(params) < 2) then
361  sll_error("sll_f_translation_a2_initializer_2d", "params should be of size >=2")
362  print *, 'size(params)', size(params)
363  end if
364  a2 = params(2)
365 
366  res = a2
368 
369  function sll_f_translation_a1_exact_charac_2d(t, t0, x0_1, x0_2, params) result(res)
370  sll_real64 :: res
371  sll_real64, intent(in) :: t
372  sll_real64, intent(in) :: t0
373  sll_real64, intent(in) :: x0_1
374  sll_real64, intent(in) :: x0_2
375  sll_real64, dimension(:), intent(in) :: params
376  sll_real64 :: a1
377 #ifdef DEBUG
378  sll_real64 :: dummy
379  dummy = x0_1 + x0_2
380 #endif
381 
382  if (size(params) < 2) then
383  sll_error("sll_f_translation_a1_exact_charac_2d", "params should be of size >=2")
384  print *, 'size(params)', size(params)
385  end if
386  a1 = params(1)
387 
388  res = x0_1 + (t - t0)*a1
390 
391  function sll_f_translation_a2_exact_charac_2d(t, t0, x0_1, x0_2, params) result(res)
392  sll_real64 :: res
393  sll_real64, intent(in) :: t
394  sll_real64, intent(in) :: t0
395  sll_real64, intent(in) :: x0_1
396  sll_real64, intent(in) :: x0_2
397  sll_real64, dimension(:), intent(in) :: params
398  sll_real64 :: a2
399 #ifdef DEBUG
400  sll_real64 :: dummy
401  dummy = x0_1 + x0_2
402 #endif
403 
404  if (size(params) < 2) then
405  sll_error("sll_f_translation_a2_exact_charac_2d", "params should be of size >=2")
406  print *, 'size(params)', size(params)
407  end if
408  a2 = params(2)
409 
410  res = x0_2 + (t - t0)*a2
412 
413  function sll_f_constant_time_initializer_1d(t, params) result(res)
414  sll_real64 :: res
415  sll_real64, intent(in) :: t
416  sll_real64, dimension(:), intent(in) :: params
417 
418  res = params(1)
419 
421 
422  !swirling deformation flow
423  function sll_f_sdf_phi_initializer_2d(x_1, x_2, params) result(res)
424  sll_real64 :: res
425  sll_real64, intent(in) :: x_1
426  sll_real64, intent(in) :: x_2
427  sll_real64, dimension(:), intent(in) :: params
428 
429  res = 2._f64*cos(0.5_f64*x_1)**2*cos(0.5_f64*x_2)**2
430  end function sll_f_sdf_phi_initializer_2d
431 
432  function sll_f_sdf_a1_initializer_2d(x_1, x_2, params) result(res)
433  sll_real64 :: res
434  sll_real64, intent(in) :: x_1
435  sll_real64, intent(in) :: x_2
436  sll_real64, dimension(:), intent(in) :: params
437 
438  res = -cos(0.5_f64*x_1)**2*sin(x_2)
439  end function sll_f_sdf_a1_initializer_2d
440 
441  function sll_f_sdf_a2_initializer_2d(x_1, x_2, params) result(res)
442  sll_real64 :: res
443  sll_real64, intent(in) :: x_1
444  sll_real64, intent(in) :: x_2
445  sll_real64, dimension(:), intent(in) :: params
446 
447  res = cos(0.5_f64*x_2)**2*sin(x_1)
448  end function sll_f_sdf_a2_initializer_2d
449 
450  function sll_f_sdf_a1_exact_charac_2d(t, t0, x0_1, x0_2, params) result(res)
451  sll_real64 :: res
452  sll_real64, intent(in) :: t
453  sll_real64, intent(in) :: t0
454  sll_real64, intent(in) :: x0_1
455  sll_real64, intent(in) :: x0_2
456  sll_real64, dimension(:), intent(in) :: params
457 #ifdef DEBUG
458  sll_real64 :: dummy
459  dummy = x0_1 + x0_2 + t + t0
460 #endif
461 
462  res = x0_1 !for the moment we take the same point
463  end function sll_f_sdf_a1_exact_charac_2d
464 
465  function sll_f_sdf_a2_exact_charac_2d(t, t0, x0_1, x0_2, params) result(res)
466  sll_real64 :: res
467  sll_real64, intent(in) :: t
468  sll_real64, intent(in) :: t0
469  sll_real64, intent(in) :: x0_1
470  sll_real64, intent(in) :: x0_2
471  sll_real64, dimension(:), intent(in) :: params
472 #ifdef DEBUG
473  sll_real64 :: dummy
474  dummy = x0_1 + x0_2 + t + t0
475 #endif
476 
477  res = x0_2 !for the moment we take the same point
478  end function sll_f_sdf_a2_exact_charac_2d
479 
480  function sll_f_sdf_time_initializer_1d(t, params) result(res)
481  sll_real64 :: res
482  sll_real64, intent(in) :: t
483  sll_real64, dimension(:), intent(in) :: params
484  sll_real64 :: time_period
485 
486 !!$ if( .not. present(params) ) then
487 !!$ print *, 'sll_f_sdf_time_initializer_1d, error: ', &
488 !!$ 'the params array must be passed.', &
489 !!$ ' params(1) = time_period'
490 !!$ stop
491 !!$ end if
492  sll_assert(size(params) >= 1)
493  time_period = params(1)
494  res = sll_p_pi*cos(sll_p_pi*t/time_period)
495  end function sll_f_sdf_time_initializer_1d
496 
497  ! -------------------------------------------------------------------------
498  !
499  ! Landau damping 2d initialization function
500  !
501  ! -------------------------------------------------------------------------
502  !
503  ! The params array is declared optional to conform with the expected
504  ! function signature of the initializer subroutines, but in the particular
505  ! case of the landau initializer, the params array must be passed.
506 
507  function sll_f_landau_initializer_2d(x, vx, params)
508  sll_real64 :: sll_f_landau_initializer_2d
509  sll_real64, intent(in) :: x
510  sll_real64, intent(in) :: vx
511 
512  sll_real64, dimension(:), intent(in) :: params
513  sll_real64 :: eps
514  sll_real64 :: kx
515  sll_real64 :: factor1
516  sll_real64 :: v0
517  sll_real64 :: sigma
518 
519 !!$ if( .not. present(params) ) then
520 !!$ print *, 'sll_f_landau_initializer_2d, error: the params array must ', &
521 !!$ 'be passed. params(1) = epsilon, params(2) = kx.'
522 !!$ stop
523 !!$ end if
524  sll_assert(size(params) >= 2)
525  kx = params(1)
526  eps = params(2)
527  v0 = 0._f64
528  if (size(params) >= 3) then
529  v0 = params(3)
530  end if
531  sigma = 1._f64
532  if (size(params) >= 4) then
533  sigma = params(4)
534  end if
535 
536  !factor1 = 1.0_f64/sqrt(2.0_f64*sll_p_pi)
537  factor1 = 1.0_f64/(sigma*sqrt(2.0_f64*sll_p_pi))
538  sll_f_landau_initializer_2d = factor1* &
539  (1.0_f64 + eps*cos(kx*x))*exp(-0.5_f64*(vx - v0)**2/sigma**2)
540  end function sll_f_landau_initializer_2d
541 
542  function sll_f_bump_on_tail_initializer_2d(x, vx, params) result(res)
543  sll_real64 :: res
544  sll_real64, intent(in) :: x
545  sll_real64, intent(in) :: vx
546 
547  sll_real64, dimension(:), intent(in) :: params
548  sll_real64 :: eps
549  sll_real64 :: kx
550  sll_real64 :: factor1
551 
552 !!$ if( .not. present(params) ) then
553 !!$ print *, 'sll_f_bump_on_tail_initializer_2d, error: the params array must ', &
554 !!$ 'be passed. params(1) = epsilon, params(2) = kx.'
555 !!$ stop
556 !!$ end if
557  sll_assert(size(params) >= 2)
558  kx = params(1)
559  eps = params(2)
560  factor1 = 1.0_f64/sqrt(2.0_f64*sll_p_pi)
561  res = factor1*(1._f64 + eps*cos(kx*x)) &
562  *(0.9_f64*exp(-0.5_f64*vx**2) + 0.2_f64*exp(-0.5_f64*(vx - 4.5_f64)**2/0.5**2))
563  !nbox = 3
565 
566  function sll_f_two_stream_instability_initializer_2d(x, vx, params) result(res)
567  sll_real64 :: res
568  sll_real64, intent(in) :: x
569  sll_real64, intent(in) :: vx
570 
571  sll_real64, dimension(:), intent(in) :: params
572  sll_real64 :: eps
573  sll_real64 :: kx
574  sll_real64 :: factor1
575  sll_real64 :: sigma
576 
577 !!$ if( .not. present(params) ) then
578 !!$ print *, 'sll_f_two_stream_instability_initializer_2d, error: the params array must ', &
579 !!$ 'be passed. params(1) = epsilon, params(2) = kx.'
580 !!$ stop
581 !!$ end if
582  sll_assert(size(params) >= 2)
583  kx = params(1)
584  eps = params(2)
585  factor1 = 1.0_f64/sqrt(2.0_f64*sll_p_pi)
586  sigma = 1._f64
587  if (size(params) >= 3) then
588  sigma = params(3)
589  end if
590  if (size(params) >= 4) then
591  factor1 = params(4)
592  end if
593 
594  res = factor1*(1._f64 + eps*cos(kx*x))*vx**2*exp(-0.5_f64*vx**2/sigma**2)
596 
597  function sll_f_diocotron_initializer_2d(r, theta, params) result(res)
598  sll_real64 :: res
599  sll_real64, intent(in) :: r
600  sll_real64, intent(in) :: theta
601 
602  sll_real64, dimension(:), intent(in) :: params
603  sll_real64 :: eps
604  sll_real64 :: k_mode
605  sll_real64 :: r_minus
606  sll_real64 :: r_plus
607 
608 !!$ if( .not. present(params) ) then
609 !!$ print *, '#sll_f_diocotron_initializer_2d, error: the params array must ', &
610 !!$ 'be passed. params(1) = r_minus'
611 !!$ print *,'#params(2)= r_plus params(3)=epsilon param(4)=k_mode'
612 !!$ stop
613 !!$ end if
614  sll_assert(size(params) >= 4)
615  r_minus = params(1)
616  r_plus = params(2)
617  eps = params(3)
618  k_mode = params(4)
619 
620  if ((r >= r_minus) .and. (r <= r_plus)) then
621  res = (1.0_f64 + eps*cos(k_mode*theta))
622  else
623  res = 0._f64
624  end if
625 
626  end function sll_f_diocotron_initializer_2d
627 
628  function sll_f_diocotron_initializer_2d2(x, y, params) result(res)
629  sll_real64 :: res
630  sll_real64, intent(in) :: x
631  sll_real64, intent(in) :: y
632 
633  sll_real64, dimension(:), intent(in) :: params
634  sll_real64 :: eps
635  sll_real64 :: k_mode
636  sll_real64 :: r_minus
637  sll_real64 :: r_plus
638  sll_real64 :: r
639  sll_real64 :: theta
640 
641 !!$ if( .not. present(params) ) then
642 !!$ print *, '#sll_f_diocotron_initializer_2d, error: the params array must ', &
643 !!$ 'be passed. params(1) = r_minus'
644 !!$ print *,'#params(2)= r_plus params(3)=epsilon param(4)=k_mode'
645 !!$ stop
646 !!$ end if
647  sll_assert(size(params) >= 4)
648  r_minus = params(1)
649  r_plus = params(2)
650  eps = params(3)
651  k_mode = params(4)
652 
653  r = sqrt(x**2 + y**2)
654 
655  if (y >= 0) then
656  theta = acos(x/r)
657  else
658  theta = 2._f64*sll_p_pi - acos(x/r)
659  end if
660  if ((r >= r_minus) .and. (r <= r_plus)) then
661  res = (1.0_f64 + eps*cos(k_mode*theta))
662  else
663  res = 0._f64
664  end if
665 
667 
668  function sll_f_beam_initializer_2d(x, vx, params) result(res)
669  sll_real64 :: res
670  sll_real64, intent(in) :: x
671  sll_real64, intent(in) :: vx
672 
673  sll_real64, dimension(:), intent(in) :: params
674  sll_real64 :: alpha
675  sll_real64 :: x_plus
676  sll_real64 :: x_minus
677 
678 !!$ if( .not. present(params) ) then
679 !!$ print *, '#sll_f_beam_initializer_2d, error: the params array must ', &
680 !!$ 'be passed. params(1) = alpha'
681 !!$ stop
682 !!$ end if
683  sll_assert(size(params) >= 1)
684  alpha = params(1)
685 
686  x_plus = (x + 1.2_f64)/0.3_f64
687  x_minus = (x - 1.2_f64)/0.3_f64
688  res = 4._f64/sqrt(2._f64*sll_p_pi*alpha)
689  res = res*(0.5_f64*erf(x_plus) - 0.5_f64*erf(x_minus))
690  res = res*exp(-vx**2/(2*alpha))
691 
692  end function sll_f_beam_initializer_2d
693 
702  function sll_f_hmf_initializer_2d(x, vx, params) result(res)
703 
704  sll_real64 :: res
705  sll_real64, intent(in) :: x
706  sll_real64, intent(in) :: vx
707 
708  sll_real64, dimension(:), intent(in) :: params
709  sll_real64 :: alpha, beta
710  sll_real64 :: m, eps
711 
712 !!$ if( .not. present(params) ) then
713 !!$ print *, '#sll_f_hmf_initializer_2d, error: the params array must ', &
714 !!$ 'be passed. params = [alpha, beta, m, epsilon]'
715 !!$ stop
716 !!$ end if
717  sll_assert(size(params) == 4)
718  alpha = params(1)
719  beta = params(2)
720  m = params(3)
721  eps = params(4)
722 
723  res = alpha
724  res = res*exp(-beta*((vx*vx)*0.5_f64 - m*cos(x)))
725  res = res*(1.0_f64 + eps*cos(x))
726 
727  end function sll_f_hmf_initializer_2d
728 
729  function sll_f_khp1_2d(x, y, params) result(res)
730  sll_real64 :: res
731  sll_real64, intent(in) :: x
732  sll_real64, intent(in) :: y
733 
734  sll_real64, dimension(:), intent(in) :: params
735  sll_real64 :: eps
736  sll_real64 :: k_mode_x
737  sll_real64 :: k_mode_y
738 
739 !!$ if( .not. present(params) ) then
740 !!$ print *, '#sll_f_khp1_2d, error: the params array must ', &
741 !!$ 'be passed.'
742 !!$ print *,'#params(1)= eps param(2)=k_mode'
743 !!$ stop
744 !!$ end if
745  sll_assert(size(params) >= 3)
746  eps = params(1)
747  k_mode_x = params(2)
748  k_mode_y = params(3)
749 
750  res = sin(k_mode_y*y) + eps*cos(k_mode_x*x)
751 
752  end function sll_f_khp1_2d
753 
754  function sll_f_dsg_2d(eta1, eta2, params) result(res)
755  sll_real64 :: res
756  sll_real64, intent(in) :: eta1
757  sll_real64, intent(in) :: eta2
758  sll_real64, dimension(:), intent(in) :: params
759 
760  sll_real64 :: eta1n
761  sll_real64 :: eta2n
762  sll_real64 :: eta1_min
763  sll_real64 :: eta2_min
764  sll_real64 :: eta1_max
765  sll_real64 :: eta2_max
766 !!$ if( .not. present(params) ) then
767 !!$ print *, '#sll_D_sharped_Geo_2d, error: the params array must ', &
768 !!$ 'be passed. params(1) = eta1_min, params(2) = eta2_min', &
769 !!$ 'be passed. params(3) = eta1_max, params(4) = eta2_max'
770 !!$ stop
771 !!$ end if
772  sll_assert(size(params) >= 4)
773  eta1_min = params(1)
774  eta2_min = params(2)
775  eta1_max = params(3)
776  eta2_max = params(4)
777  eta1n = (eta1 - eta1_min)/(eta1_max - eta1_min)
778  eta2n = (eta2 - eta2_min)/(eta2_max - eta2_min)
779  res = 4._f64*eta1n*(1._f64 - eta1n)*(1._f64 + 0.1_f64*sin(8.*sll_p_pi*eta2n))
780  end function sll_f_dsg_2d
781 
782  ! This is a simplistic initializer aimed at a 4d cartesian distribution
783  ! function, periodic in x and y, and compact-ish in vx and vy.
784  !
785  ! Basically:
786  !
787  ! f(x,y,vx,vy) = alpha*exp(-0.5*((x -xc )^2+(y - yc)^2)) +
788  ! beta* exp(-0.5*((vx-vxc)^2+(vy-vyc)^2))
789  !
790  !
791  ! It is meant to be used in the intervals:
792  ! x: [ 0,2*pi/kx]
793  ! y: [ 0,2*pi/ky]
794  ! vx: [-6,6]
795  ! vy: [-6,6]
796 
797  ! convention for the params array:
798  ! params(1) = eta1_min
799  ! params(2) = eta1_max
800  ! params(3) = eta2_min
801  ! params(4) = eta2_max
802  ! params(5) = epsilon
803 
804  function sll_gaussian_initializer_4d(x, y, vx, vy, params)
805  sll_real64 :: sll_gaussian_initializer_4d
806  sll_real64, intent(in) :: x
807  sll_real64, intent(in) :: y
808  sll_real64, intent(in) :: vx
809  sll_real64, intent(in) :: vy
810 
811  sll_real64, dimension(:), intent(in) :: params
812  sll_real64 :: xc
813  sll_real64 :: yc
814  sll_real64 :: vxc
815  sll_real64 :: vyc
816  sll_real64 :: alpha
817  sll_real64 :: beta
818 
819 !!$ if( .not. present(params) ) then
820 !!$ print *, 'sll_gaussian_initializer_4d, error: the params array must ', &
821 !!$ 'be passed: ', &
822 !!$ 'params(1) = xc, params(2) = yc, params(3) = vxc, params(4) = vyc',&
823 !!$ 'params(5) = alpha, params(6) = beta'
824 !!$ stop
825 !!$ end if
826 
827  xc = params(1)
828  yc = params(2)
829  vxc = params(3)
830  vyc = params(4)
831  alpha = params(5)
832  beta = params(6)
833 
834  sll_gaussian_initializer_4d = alpha*exp(-0.5_f64*((x - xc)**2 + (y - yc)**2)) + &
835  beta*exp(-0.5_f64*((vx - vxc)**2 + (vy - vyc)**2))
836 
837  end function sll_gaussian_initializer_4d
838 
839  ! -------------------------------------------------------------------------
840  !
841  ! Landau damping 4d initialization function
842  !
843  ! -------------------------------------------------------------------------
844  !
845  ! The params array is declared optional to conform with the expected
846  ! function signature of the initializer subroutines, but in the particular
847  ! case of the landau initializer, the params array must be passed.
848 
849  function sll_f_landau_initializer_4d(x, y, vx, vy, params)
850  sll_real64 :: sll_f_landau_initializer_4d
851  sll_real64, intent(in) :: x
852  sll_real64, intent(in) :: y
853  sll_real64, intent(in) :: vx
854  sll_real64, intent(in) :: vy
855 
856  sll_real64, dimension(:), intent(in) :: params
857  sll_real64 :: eta1_min
858  sll_real64 :: eta1_max
859  sll_real64 :: eta2_min
860  sll_real64 :: eta2_max
861 
862  sll_real64 :: eps
863  sll_real64 :: kx
864  sll_real64 :: factor1
865 
866 !!$ if( .not. present(params) ) then
867 !!$ print *, 'sll_f_landau_initializer_4d, error: the params array must ', &
868 !!$ 'be passed. params(1) = eta1_min, params(2) = eta1_max, ', &
869 !!$ 'params(3) = eta2_min, params(4) = eta2_max, params(5) = epsilon.'
870 !!$ print *,'does not depend on y',y
871 !!$ stop
872 !!$ end if
873 
874  sll_assert(size(params) >= 5)
875 
876  eta1_min = params(1)
877  eta1_max = params(2)
878  eta2_min = params(3)
879  eta2_max = params(4)
880  eps = params(5)
881  kx = 2.*sll_p_pi/(eta1_max - eta1_min)
882 
883  !Normalization
884  !sagemath command
885  !sage : var('u v epsilon a b c d x y')
886  !sage : f(a,b,c,d,epsilon) =integral(integral(integral(integral((1+epsilon*cos(2*pi/(b-a)*x))*exp(-(u*u+v*v)/2),u,-oo,oo),v,-oo,oo),x,a,b),y,c,d)
887 
888 !!$ factor1 = 1./( (eta2_min - eta2_max) &
889 !!$ *(((eta1_min - eta1_max)* &
890 !!$ sin(2*sll_p_pi*eta1_min/(eta1_min - eta1_max)) &
891 !!$ - (eta1_min - eta1_max)* &
892 !!$ sin(2*sll_p_pi*eta1_max/(eta1_min - eta1_max)))*eps &
893 !!$ + 2*sll_p_pi*eta1_min - 2*sll_p_pi*eta1_max))
894  factor1 = 1.0_f64/(2.0_f64*sll_p_pi)
895 !!$ sll_f_landau_initializer_4d = factor1 * &
896 !!$ (1.0_f64/((eta2_max-eta2_min)*(eta1_max-eta1_min))+eps*cos(kx*x))*exp(-0.5_f64*(vx**2+vy**2))
897  sll_f_landau_initializer_4d = factor1* &
898  (1.0_f64 + eps*cos(kx*x))*exp(-0.5_f64*(vx**2 + vy**2))
899  end function sll_f_landau_initializer_4d
900 
901  function sll_f_landau_mode_initializer_cos_sum_4d(x, y, vx, vy, params) result(res)
902  sll_real64 :: res
903  sll_real64, intent(in) :: x
904  sll_real64, intent(in) :: y
905  sll_real64, intent(in) :: vx
906  sll_real64, intent(in) :: vy
907  sll_real64, dimension(:), intent(in) :: params
908  sll_real64 :: eps
909  sll_real64 :: kx
910  sll_real64 :: ky
911  sll_real64 :: ellx
912  sll_real64 :: elly
913  sll_real64 :: eps_ell
914  sll_real64 :: factor1
915 
916 !!$ if( .not. present(params) ) then
917 !!$ print *, 'sll_f_landau_initializer_4d, error: the params array must ', &
918 !!$ 'be passed. params(1) = kx, params(2) = ky, ', &
919 !!$ 'params(3) = eps.'
920 !!$ stop
921 !!$ end if
922 
923  sll_assert(size(params) >= 3)
924 
925  kx = params(1)
926  ky = params(2)
927  eps = params(3)
928 
929  !factor1 = eps*cos(kx*x)*cos(ky*y)
930  factor1 = eps*cos(kx*x + ky*y)
931  if (size(params) >= 6) then
932  ellx = params(4)
933  elly = params(5)
934  eps_ell = params(6)
935  !factor1 = factor1+eps_ell*cos(ellx*x)*cos(elly*y)
936  factor1 = factor1 + eps_ell*cos(ellx*x + elly*y)
937  end if
938  factor1 = 1._f64 + factor1
939  res = (1.0_f64/(2.0*sll_p_pi))*factor1*exp(-0.5_f64*(vx**2 + vy**2))
940 
941  !print *,'k=',kx,ky,eps
942  !print *,'ell=',ellx,elly,eps_ell
943  !print *,'size(params)=',size(params)
944  !stop
945 
947 
948  function sll_f_landau_mode_initializer_4d(x, y, vx, vy, params) result(res)
949  sll_real64 :: res
950  sll_real64, intent(in) :: x
951  sll_real64, intent(in) :: y
952  sll_real64, intent(in) :: vx
953  sll_real64, intent(in) :: vy
954  sll_real64, dimension(:), intent(in) :: params
955  sll_real64 :: eps
956  sll_real64 :: kx
957  sll_real64 :: ky
958  sll_real64 :: ellx
959  sll_real64 :: elly
960  sll_real64 :: eps_ell
961  sll_real64 :: factor1
962 
963 !!$ if( .not. present(params) ) then
964 !!$ print *, 'sll_f_landau_initializer_4d, error: the params array must ', &
965 !!$ 'be passed. params(1) = kx, params(2) = ky, ', &
966 !!$ 'params(3) = eps.'
967 !!$ stop
968 !!$ end if
969 
970  sll_assert(size(params) >= 3)
971 
972  kx = params(1)
973  ky = params(2)
974  eps = params(3)
975 
976  factor1 = eps*cos(kx*x)*cos(ky*y)
977  !factor1 = eps*cos(kx*x+ky*y)
978  if (size(params) >= 6) then
979  ellx = params(4)
980  elly = params(5)
981  eps_ell = params(6)
982  factor1 = factor1 + eps_ell*cos(ellx*x)*cos(elly*y)
983  !factor1 = factor1+eps_ell*cos(ellx*x+elly*y)
984  end if
985  factor1 = 1.0_f64 + factor1
986  res = (1.0_f64/(2.0_f64*sll_p_pi))*factor1*exp(-0.5_f64*(vx**2 + vy**2))
987 
988  !print *,'k=',kx,ky,eps
989  !print *,'ell=',ellx,elly,eps_ell
990  !print *,'size(params)=',size(params)
991  !stop
992 
994 
995  ! -------------------------------------------------------------------------
996  !
997  ! Bump-on-tail 4d initialization function
998  !
999  ! -------------------------------------------------------------------------
1000  !
1001  !
1002 
1003  function sll_f_bump_on_tail_initializer_4d(x, y, vx, vy, params)
1004  sll_real64 :: sll_f_bump_on_tail_initializer_4d
1005  sll_real64, intent(in) :: x
1006  sll_real64, intent(in) :: y
1007  sll_real64, intent(in) :: vx
1008  sll_real64, intent(in) :: vy
1009  sll_real64, dimension(:), intent(in) :: params
1010 
1011  sll_real64 :: kx
1012  sll_real64 :: ky
1013  sll_real64 :: eps
1014  sll_real64 :: sigmax1
1015  sll_real64 :: sigmax2
1016  sll_real64 :: sigmay
1017  sll_real64 :: delta
1018  sll_real64 :: vx2
1019  sll_real64 :: factor
1020 
1021  sll_assert(size(params) >= 8)
1022 
1023  kx = params(1)
1024  ky = params(2)
1025  eps = params(3)
1026  sigmax1 = params(4)
1027  sigmax2 = params(5)
1028  sigmay = params(6)
1029  delta = params(7)
1030  vx2 = params(8)
1031 
1032  factor = 1.0_f64/(2.0_f64*sll_p_pi*sigmay)
1033 
1035  (1.0_f64 + eps*(cos(kx*x) + cos(ky*y)))*exp(-0.5_f64*(vy/sigmay)**2)* &
1036  ((1 - delta)/sigmax1*exp(-0.5_f64*(vx/sigmax1)**2) + &
1037  delta/sigmax2*exp(-0.5_f64*((vx - vx2)/sigmax2)**2))
1038 
1040 
1041  function sll_f_test_x_transport_initializer_v1v2x1x2(vx, vy, x, y, params)
1043  sll_real64, intent(in) :: x
1044  sll_real64, intent(in) :: y
1045  sll_real64, intent(in) :: vx
1046  sll_real64, intent(in) :: vy
1047  sll_real64 :: t
1048 
1049  sll_real64, dimension(:), intent(in) :: params
1050  sll_real64 :: eta1_min
1051  sll_real64 :: eta1_max
1052  sll_real64 :: kx
1053 
1054 !!$ if( .not. present(params) ) then
1055 !!$ print *, ' sll_test_x_transport_initializer, error: the params array', &
1056 !!$ 'must be passed. params(1) = epsilon, params(2)=kx, params(3) = ky.'
1057 !!$ print *,'does not depend on y,vy',y,vy
1058 !!$ stop
1059 !!$ end if
1060 
1061  eta1_min = params(1)
1062  eta1_max = params(2)
1063  t = params(11)
1064  kx = 2.0_f64*sll_p_pi/(eta1_max - eta1_min)
1065 
1066  !sll_f_test_x_transport_initializer_v1v2x1x2 =sin(kx*(x-t))
1067  sll_f_test_x_transport_initializer_v1v2x1x2 = sin(kx*(x - vx*t))
1068  !sll_f_test_x_transport_initializer_v1v2x1x2 = exp(-4*x**2)
1069 
1071 
1072  function sll_f_test_y_transport_initializer_v1v2x1x2(vx, vy, x, y, params)
1074  sll_real64, intent(in) :: x
1075  sll_real64, intent(in) :: y
1076  sll_real64, intent(in) :: vx
1077  sll_real64, intent(in) :: vy
1078  sll_real64 :: t
1079 
1080  sll_real64, dimension(:), intent(in) :: params
1081  sll_real64 :: eta2_min
1082  sll_real64 :: eta2_max
1083  sll_real64 :: kx
1084 
1085  eta2_min = params(3)
1086  eta2_max = params(4)
1087  t = params(11)
1088  kx = 2.0_f64*sll_p_pi/(eta2_max - eta2_min)
1089 !!$ if( .not. present(params) ) then
1090 !!$ print *, ' sll_test_y_transport_initializer, error: the params array', &
1091 !!$ 'must be passed. params(1) = epsilon, params(2)=kx, params(3) = ky.'
1092 !!$ print *,'does not depend on x vx',x,vx
1093 !!$ stop
1094 !!$ end if
1095 
1096  sll_f_test_y_transport_initializer_v1v2x1x2 = sin(kx*(y - vy*t))
1097  !sll_f_test_y_transport_initializer_v1v2x1x2 =exp(-4*y**2)
1098  !sll_f_test_x_transport_initializer_v1v2x1x2 = 2_f64
1099 
1101 
1102  function sll_f_test_vx_transport_initializer_v1v2x1x2(vx, vy, x, y, params)
1104  sll_real64, intent(in) :: x
1105  sll_real64, intent(in) :: y
1106  sll_real64, intent(in) :: vx
1107  sll_real64, intent(in) :: vy
1108  sll_real64 :: t
1109 
1110  sll_real64, dimension(:), intent(in) :: params
1111  sll_real64 :: eta1_min
1112  sll_real64 :: eta1_max
1113  sll_real64 :: kx, v, hh
1114 !!$ if( .not. present(params) ) then
1115 !!$ print *, ' sll_test_vx_transport_initializer, error: the params array', &
1116 !!$ ' mustbe passed. params(1)=epsilon,params(2)=kx, params(3) = ky.'
1117 !!$ print *,'does not depend on x,y,vy',x,y,vy
1118 !!$ stop
1119 !!$ end if
1120 
1121  eta1_min = params(1)
1122  eta1_max = params(2)
1123  t = params(11)
1124  kx = 2.*sll_p_pi/(eta1_max - eta1_min)
1125 
1126  !sll_f_test_vx_transport_initializer_v1v2x1x2 =exp(-4*(vx-t)**2)
1127  v = vx - t
1128  hh = 1.0_f64
1129  if ((v .gt. 1) .or. (v .lt. -1)) hh = 0.0_f64
1130  sll_f_test_vx_transport_initializer_v1v2x1x2 = (1 + (-3 + (3 - v**2)*v**2)*v**2)*hh
1131  !write(*,*) 'tini=',t
1132 
1133 !!$ sll_landau_initializer_v1v2x1x2 = 1
1134 !!$ if (x < 0) sll_landau_initializer_v1v2x1x2 = 0
1135 
1137  function sll_f_test_vy_transport_initializer_v1v2x1x2(vx, vy, x, y, params)
1139  sll_real64, intent(in) :: x
1140  sll_real64, intent(in) :: y
1141  sll_real64, intent(in) :: vx
1142  sll_real64, intent(in) :: vy
1143  sll_real64 :: t
1144 
1145  sll_real64, dimension(:), intent(in) :: params
1146  !sll_real64 :: eta1_min
1147  !sll_real64 :: eta1_max
1148  !sll_real64 :: eta2_min
1149  !sll_real64 :: eta2_max
1150 
1151  !sll_real64 :: eps
1152  !sll_real64 :: kx
1153  !sll_real64 :: factor1
1154  sll_real64 :: v, hh
1155  t = params(11)
1156 
1157 !!$ if( .not. present(params) ) then
1158 !!$ print *, ' sll_test_vy_transport_initializer, error: the params array', &
1159 !!$ 'must be passed. params(1) = epsilon, params(2)=kx, params(3) = ky.'
1160 !!$ print *, 'does not depend on x,y,vx',x,y,vx
1161 !!$ stop
1162 !!$ end if
1163  v = vy - t
1164  hh = 1.0_f64
1165  if ((v .gt. 1) .or. (v .lt. -1)) hh = 0.0_f64
1166  sll_f_test_vy_transport_initializer_v1v2x1x2 = (1 + (-3 + (3 - v**2)*v**2)*v**2)*hh
1167  !sll_f_test_vy_transport_initializer_v1v2x1x2 =exp(-4*vy**2)
1168  !sll_f_test_vy_transport_initializer_v1v2x1x2 = 2_f64
1169 
1171 
1172  function sll_f_test_xvx_transport_initializer_v1v2x1x2(vx, vy, x, y, params)
1174  sll_real64, intent(in) :: x
1175  sll_real64, intent(in) :: y
1176  sll_real64, intent(in) :: vx
1177  sll_real64, intent(in) :: vy
1178  sll_real64 :: t
1179 
1180  sll_real64, dimension(:), intent(in) :: params
1181  sll_real64 :: eta1_min
1182  sll_real64 :: eta1_max
1183  sll_real64 :: kx, v, hh, xx
1184 !!$ if( .not. present(params) ) then
1185 !!$ print *, ' sll_test_xvx_transport_initializer, error: the params array', &
1186 !!$ ' mustbe passed. params(1)=epsilon,params(2)=kx, params(3) = ky.'
1187 !!$ print *, 'does not depend on y and vy',y,vy
1188 !!$ stop
1189 !!$ end if
1190 
1191  eta1_min = params(1)
1192  eta1_max = params(2)
1193  t = params(11)
1194  kx = 2.*sll_p_pi/(eta1_max - eta1_min)
1195 
1196  !sll_f_test_vx_transport_initializer_v1v2x1x2 =exp(-4*(vx-t)**2)
1197  v = vx - t
1198  xx = x - t*vx + t*t/2
1199  hh = 1.0_f64
1200  if ((v .gt. 1) .or. (v .lt. -1)) hh = 0.0_f64
1201  sll_f_test_xvx_transport_initializer_v1v2x1x2 = (1 + (-3 + (3 - v**2)*v**2)*v**2)*hh*sin(kx*xx)
1202 
1204 
1205  function sll_f_test_yvy_transport_initializer_v1v2x1x2(vx, vy, x, y, params)
1207  sll_real64, intent(in) :: x
1208  sll_real64, intent(in) :: y
1209  sll_real64, intent(in) :: vx
1210  sll_real64, intent(in) :: vy
1211  sll_real64 :: t
1212 
1213  sll_real64, dimension(:), intent(in) :: params
1214  sll_real64 :: eta2_min
1215  sll_real64 :: eta2_max
1216  sll_real64 :: ky, v, hh, yy
1217 !!$ if( .not. present(params) ) then
1218 !!$ print *, ' sll_test_yvy_transport_initializer, error: the params array', &
1219 !!$ ' mustbe passed. params(1)=epsilon,params(2)=kx, params(3) = ky.'
1220 !!$ print *,'does not depend on x and vx',x,vx
1221 !!$ stop
1222 !!$ end if
1223 
1224  eta2_min = params(3)
1225  eta2_max = params(4)
1226  t = params(11)
1227  ky = 2.*sll_p_pi/(eta2_max - eta2_min)
1228 
1229  !sll_f_test_vx_transport_initializer_v1v2x1x2 =exp(-4*(vx-t)**2)
1230  v = vy - t
1231  yy = y - t*vy + t*t/2
1232  hh = 1.0_f64
1233  if ((v .gt. 1) .or. (v .lt. -1)) hh = 0.0_f64
1234  sll_f_test_yvy_transport_initializer_v1v2x1x2 = (1 + (-3 + (3 - v**2)*v**2)*v**2)*hh*sin(ky*yy)
1235 
1237 
1238 !!$function sll_test_transport_2d_initializer_v1v2x1x2( vx, vy, x, y, params )
1239 !!$ sll_real64 :: sll_test_transport_2d_initializer_v1v2x1x2
1240 !!$ sll_real64, intent(in) :: x
1241 !!$ sll_real64, intent(in) :: y
1242 !!$ sll_real64, intent(in) :: vx
1243 !!$ sll_real64, intent(in) :: vy
1244 !!$ sll_real64 :: t
1245 !!$
1246 !!$ sll_real64, dimension(:), intent(in) :: params
1247 !!$ sll_real64 :: eta1_min
1248 !!$ sll_real64 :: eta1_max
1249 !!$ sll_real64 :: kx,v,hh,xx
1250 !!$ if( .not. present(params) ) then
1251 !!$ print *, ' sll_test_xvx_transport_initializer, error: the params array', &
1252 !!$ ' mustbe passed. params(1)=epsilon,params(2)=kx, params(3) = ky.'
1253 !!$ stop
1254 !!$ end if
1255 !!$
1256 !!$ eta1_min = params(1)
1257 !!$ eta1_max = params(2)
1258 !!$ eta2_min = params(3)
1259 !!$ eta2_max = params(4)
1260 !!$ t=params(11)
1261 !!$ kx = 2. * sll_p_pi / (eta1_max - eta1_min)
1262 !!$ ky = 2. * sll_p_pi / (eta2_max - eta2_min)
1263 !!$
1264 !!$ !sll_f_test_vx_transport_initializer_v1v2x1x2 =exp(-4*(vx-t)**2)
1265 !!$ vvx=vx-t
1266 !!$ xx=x-t*vx+t*t/2
1267 !!$ vvy=vx-t
1268 !!$ yy=x-t*vy+t*t/2
1269 !!$ hh=1
1270 !!$ if ((v.gt.1).or.(v.lt.-1)) hh=0
1271 !!$ sll_test_transport_2d_initializer_v1v2x1x2=(1+(-3+(3-v**2)*v**2)*v**2)*hh*sin(kx*(xx-v*t))
1272 !!$
1273 !!$ end function sll_test_transport_2d_initializer_v1v2x1x2
1274 
1275  function sll_f_landau_1d_xvx_initializer_v1v2x1x2(vx, vy, x, y, params)
1277  sll_real64, intent(in) :: x
1278  sll_real64, intent(in) :: y
1279  sll_real64, intent(in) :: vx
1280  sll_real64, intent(in) :: vy
1281  !sll_real64 :: t
1282 
1283  sll_real64, dimension(:), intent(in) :: params
1284  sll_real64 :: eta1_min
1285  sll_real64 :: eta1_max
1286  sll_real64 :: eta2_min
1287  sll_real64 :: eta2_max
1288 
1289  sll_real64 :: eps
1290  sll_real64 :: kx
1291  sll_real64 :: factor1
1292 
1293 !!$ if( .not. present(params) ) then
1294 !!$ print *, 'sll_landau_1d_initializer_v1v2x1x2, error: the params array', &
1295 !!$ 'must be passed params(1)= epsilon, params(2) = kx, params(3) = ky.'
1296 !!$ print *,'does not depend on y and vy',y,vy
1297 !!$ stop
1298 !!$ end if
1299 
1300  eta1_min = params(1)
1301  eta1_max = params(2)
1302  eta2_min = params(3)
1303  eta2_max = params(4)
1304 
1305  eps = params(5)
1306  !kx = 2. * sll_p_pi / (eta1_max - eta1_min)
1307  kx = 0.2_f64
1308  factor1 = 1.0_f64/sqrt((2.0_f64*sll_p_pi))
1309 
1311  (1.0_f64 + eps*cos(kx*x))*exp(-0.5_f64*(vx**2))
1313 
1314  function sll_f_twostream_1d_xvx_initializer_v1v2x1x2(vx, vy, x, y, params)
1316  sll_real64, intent(in) :: x
1317  sll_real64, intent(in) :: y
1318  sll_real64, intent(in) :: vx
1319  sll_real64, intent(in) :: vy
1320  sll_real64 :: v0
1321 
1322  sll_real64, dimension(:), intent(in) :: params
1323  sll_real64 :: eta1_min
1324  sll_real64 :: eta1_max
1325  sll_real64 :: eta2_min
1326  sll_real64 :: eta2_max
1327 
1328  sll_real64 :: eps
1329  sll_real64 :: kx
1330  sll_real64 :: factor1
1331 #ifdef DEBUG
1332  sll_real64 :: dummy
1333  dummy = x + y + vx + vy
1334 #endif
1335 
1336 !!$ if( .not. present(params) ) then
1337 !!$ print *, 'sll_twostream_1d_initializer_v1v2x1x2, error: the params array', &
1338 !!$ 'must be passed params(1)= epsilon, params(2) = kx, params(3) = ky.'
1339 !!$ stop
1340 !!$ end if
1341 
1342  eta1_min = params(1)
1343  eta1_max = params(2)
1344  eta2_min = params(3)
1345  eta2_max = params(4)
1346 
1347  eps = params(5)
1348  v0 = 3.0_f64
1349  !kx = 2. * sll_p_pi / (eta1_max - eta1_min)
1350  kx = 0.2_f64
1351  factor1 = 1.0_f64/sqrt((2.0*sll_p_pi))
1352 
1354  (1.0_f64 + eps*cos(kx*x))*(exp(-0.5_f64*((vx - v0)**2)) + &
1355  exp(-0.5_f64*((vx + v0)**2)))
1357 
1358  function sll_f_galaxy_1d_xvx_initializer_v1v2x1x2(vx, vy, x, y, params)
1360  sll_real64, intent(in) :: x
1361  sll_real64, intent(in) :: y
1362  sll_real64, intent(in) :: vx
1363  sll_real64, intent(in) :: vy
1364  !sll_real64 :: t
1365 
1366  sll_real64, dimension(:), intent(in) :: params
1367  sll_real64 :: eta1_min
1368  sll_real64 :: eta1_max
1369  sll_real64 :: eta2_min
1370  sll_real64 :: eta2_max
1371 
1372  sll_real64 :: eps
1373  sll_real64 :: kx
1374  sll_real64 :: factor1
1375 
1376 !!$ if( .not. present(params) ) then
1377 !!$ print *, 'sll_landau_1d_initializer_v1v2x1x2, error: the params array', &
1378 !!$ 'must be passed params(1)= epsilon, params(2) = kx, params(3) = ky.'
1379 !!$ print *,'does not depend on y and vy',y,vy
1380 !!$ stop
1381 !!$ end if
1382 
1383  eta1_min = params(1)
1384  eta1_max = params(2)
1385  eta2_min = params(3)
1386  eta2_max = params(4)
1387 
1388  eps = params(5)
1389  !kx = 2. * sll_p_pi / (eta1_max - eta1_min)
1390  kx = 0.2_f64
1391  factor1 = 1.0_f64/sqrt((2.0*sll_p_pi))
1393  if ((x .lt. 1.0_f64) .and. (x .gt. -1.0_f64)) then
1394  sll_f_galaxy_1d_xvx_initializer_v1v2x1x2 = factor1*exp(-0.5_f64*(vx**2))
1395  end if
1397 
1398  function sll_f_galaxy_2d_initializer_v1v2x1x2(vx, vy, x, y, params)
1400  sll_real64, intent(in) :: x
1401  sll_real64, intent(in) :: y
1402  sll_real64, intent(in) :: vx
1403  sll_real64, intent(in) :: vy
1404  sll_real64 :: v0x
1405  sll_real64 :: v0y
1406  !sll_real64 :: t
1407 
1408  sll_real64, dimension(:), intent(in) :: params
1409  sll_real64 :: eta1_min
1410  sll_real64 :: eta1_max
1411  sll_real64 :: eta2_min
1412  sll_real64 :: eta2_max
1413  sll_real64 :: a1_xmin, a1_xmax, a1_ymin, a1_ymax, x1mil
1414  sll_real64 :: a2_xmin, a2_xmax, a2_ymin, a2_ymax, x2mil
1415  sll_real64 :: eps
1416  sll_real64 :: kx
1417  sll_real64 :: factor1
1418 
1419 !!$ if( .not. present(params) ) then
1420 !!$ print *, 'sll_landau_1d_initializer_v1v2x1x2, error: the params array', &
1421 !!$ 'must be passed params(1)= epsilon, params(2) = kx, params(3) = ky.'
1422 !!$ print *,'does not depend on y and vy',y,vy
1423 !!$ stop
1424 !!$ end if
1425  !lmin=0.0_f64
1426  eta1_min = params(1)
1427  eta1_max = params(2)
1428  eta2_min = params(3)
1429  eta2_max = params(4)
1430  !amas 1
1431  a1_xmin = -2.0_f64
1432  a1_xmax = 2.0_f64
1433  x1mil = 0.0_f64
1434  a1_ymin = -a1_xmax
1435  a1_ymax = -a1_xmin
1436  !amas 2
1437  a2_xmin = -6.0_f64
1438  a2_xmax = -2.0_f64
1439  x2mil = -4.0_f64
1440  a2_ymin = -a2_xmax
1441  a2_ymax = -a2_xmin
1442 
1443  eps = params(5)
1444  !kx = 2. * sll_p_pi / (eta1_max - eta1_min)
1445  kx = 0.2_f64
1446  factor1 = 1.0_f64/sqrt((2.0*sll_p_pi))**2
1448  !un bloc de particles
1449 !!$ if ((x.le.1.0_f64).and.(x.ge.-1.0_f64).and.(y.le.1.0_f64).and.(y.ge.-1.0_f64)) then
1450 !!$ sll_f_galaxy_2d_initializer_v1v2x1x2 = factor1*exp(-0.5_f64*(vx**2+vy**2))
1451 !!$ end if
1452  !2 blocs de particles
1453  !amas 1
1454  if ((x .le. a1_xmax) .and. (x .ge. a1_xmin) .and. (y .le. a1_ymax) .and. (y .ge. a1_ymin)) then
1455  v0x = 0.0_f64
1456  v0y = 0.0_f64
1457  sll_f_galaxy_2d_initializer_v1v2x1x2 = factor1*exp(-0.5_f64*((vx-v0x)**2+(vy-v0y)**2))*exp(-0.5_f64*((x-x1mil)**2+(y+x1mil)**2)*16)
1458  end if
1459  !amas 2
1460  if ((x .le. a2_xmax) .and. (x .ge. a2_xmin) .and. (y .le. a2_ymax) .and. (y .ge. a2_ymin)) then
1461  v0x = 0.0_f64 ! 1.0_f64 !0.3109793990 !0.2433894805
1462  v0y = -0.0_f64 !.5
1463  sll_f_galaxy_2d_initializer_v1v2x1x2 =factor1*exp(-0.5_f64*((vx-v0x)**2+(vy-v0y)**2))*exp(-0.5_f64*((x-x2mil)**2+(y+x2mil)**2)*16)
1464  end if
1465 !!$ if ((x.le.lmax).and.(x.ge.lmin).and.(y.le.-lmin).and.(y.ge.-lmax)) then
1466 !!$ v0x=-1.0
1467 !!$ v0y=0
1468 !!$ sll_f_galaxy_2d_initializer_v1v2x1x2 = factor1*exp(-0.5_f64*((vx-v0x)**2+(vy-v0y)**2))*exp(-((x-lmil)**2+(y+lmil)**2))
1469 !!$ end if
1470 !!$ if ((y.le.lmax).and.(y.ge.lmin).and.(x.le.-lmin).and.(x.ge.-lmax)) then
1471 !!$ v0x=1.0
1472 !!$ v0y=0
1473 !!$ sll_f_galaxy_2d_initializer_v1v2x1x2 = factor1*exp(-0.5_f64*((vx-v0x)**2+(vy-v0y)**2))*exp(-((x+lmil)**2+(y-lmil)**2))
1474 !!$ end if
1475  ! end if
1476 !!$ if ((x.le.lmax).and.(x.ge.lmin).and.(y.le.-lmin).and.(y.ge.-lmax)) then
1477 !!$ v0x=-1.0
1478 !!$ v0y=0
1479 !!$ sll_f_galaxy_2d_initializer_v1v2x1x2 = factor1*exp(-0.5_f64*((vx-v0x)**2+(vy-v0y)**2))*exp(-((x-lmil)**2+(y+lmil)**2))
1480 !!$ end if
1481 !!$ if ((y.le.lmax).and.(y.ge.lmin).and.(x.le.-lmin).and.(x.ge.-lmax)) then
1482 !!$ v0x=1.0
1483 !!$ v0y=0
1484 !!$ sll_f_galaxy_2d_initializer_v1v2x1x2 = factor1*exp(-0.5_f64*((vx-v0x)**2+(vy-v0y)**2))*exp((x+lmil)**2+(y-lmil)**2)
1485 !!$ end if
1486 !!$
1487 !!$ if ((x.le.3.0_f64).and.(x.ge.1.5_f64).and.(y.le.-1.5_f64).and.(y.ge.-3.0_f64)) then
1488 !!$ v0x=-1.0_f64
1489 !!$ v0y=0.0
1490 !!$ sll_f_galaxy_2d_initializer_v1v2x1x2 = factor1*exp(-0.5_f64*((vx-v0x)**2+(vy-v0y)**2))
1491 !!$ end if
1492 !!$ if ((y.le.3.0_f64).and.(y.ge.1.5_f64).and.(x.le.-1.5_f64).and.(x.ge.-3.0_f64)) then
1493 !!$ v0x=1.0_f64
1494 !!$ v0y=-0.0
1495 !!$ sll_f_galaxy_2d_initializer_v1v2x1x2 = factor1*exp(-0.5_f64*((vx-v0x)**2+(vy-v0y)**2))
1496 !!$ end if
1497 
1498 !!$ if ((x.le.2.5_f64).and.(x.ge.0.5_f64).and.(y.le.-0.5_f64).and.(y.ge.-2.5_f64)) then
1499 !!$ sll_f_galaxy_2d_initializer_v1v2x1x2 = factor1*exp(-0.5_f64*(vx**2+vy**2))
1500 !!$ end if
1501 !!$ if ((y.le.2.5_f64).and.(y.ge.0.5_f64).and.(x.le.-0.5_f64).and.(x.ge.-2.5_f64)) then
1502 !!$ sll_f_galaxy_2d_initializer_v1v2x1x2 = factor1*exp(-0.5_f64*(vx**2+vy**2))
1503 !!$ end if
1505 
1506  function sll_f_landau_1d_yvy_initializer_v1v2x1x2(vx, vy, x, y, params)
1508  sll_real64, intent(in) :: x
1509  sll_real64, intent(in) :: y
1510  sll_real64, intent(in) :: vx
1511  sll_real64, intent(in) :: vy
1512  !sll_real64 :: t
1513 
1514  sll_real64, dimension(:), intent(in) :: params
1515  sll_real64 :: eta1_min
1516  sll_real64 :: eta1_max
1517  sll_real64 :: eta2_min
1518  sll_real64 :: eta2_max
1519 
1520  sll_real64 :: eps
1521  sll_real64 :: ky
1522  sll_real64 :: factor1
1523 
1524 !!$ if( .not. present(params) ) then
1525 !!$ print *, 'sll_landau_1d_initializer_v1v2x1x2, error: the params array', &
1526 !!$ 'must be passed params(1)= epsilon, params(2) = kx, params(3) = ky.'
1527 !!$ print *,'does not depend on vx and x',vx,x
1528 !!$ stop
1529 !!$ end if
1530 
1531  eta1_min = params(1)
1532  eta1_max = params(2)
1533  eta2_min = params(3)
1534  eta2_max = params(4)
1535 
1536  eps = params(5)
1537  ky = 2.*sll_p_pi/(eta2_max - eta2_min)
1538  factor1 = 1.0_f64/sqrt((2.0*sll_p_pi))
1539 
1541  (1.0_f64 + eps*cos(ky*y))*exp(-0.5_f64*(vy**2))
1543 
1544  function sll_f_landau_2d_initializer_v1v2x1x2(vx, vy, x, y, params)
1546  sll_real64, intent(in) :: x
1547  sll_real64, intent(in) :: y
1548  sll_real64, intent(in) :: vx
1549  sll_real64, intent(in) :: vy
1550 
1551  sll_real64, dimension(:), intent(in) :: params
1552  sll_real64 :: eta1_min
1553  sll_real64 :: eta1_max
1554  sll_real64 :: eta2_min
1555  sll_real64 :: eta2_max
1556 
1557  sll_real64 :: eps
1558  sll_real64 :: kx
1559  sll_real64 :: ky
1560  sll_real64 :: factor1
1561 
1562 !!$ if( .not. present(params) ) then
1563 !!$ print *, 'sll_f_landau_initializer_4d, error: the params array must ', &
1564 !!$ 'be passed. params(1) = epsilon, params(2) = kx, params(3) = ky.'
1565 !!$ stop
1566 !!$ end if
1567 
1568  eta1_min = params(1)
1569  eta1_max = params(2)
1570  eta2_min = params(3)
1571  eta2_max = params(4)
1572 
1573  eps = params(5)
1574  kx = 2.*sll_p_pi/(eta1_max - eta1_min)
1575  ky = kx
1576  factor1 = 1.0_f64/(2.0*sll_p_pi)
1578  (1.0_f64 + eps*cos(kx*x)*cos(ky*y))*exp(-0.5_f64*(vx**2 + vy**2))
1579 
1581 
1582  ! this function is a 1D landau initializer used for debugging
1583  ! 4D drift kinetic simulations in variables x1,x2,x3 ,v1
1584  ! the function is constant with respect to x2 and x3
1585 
1586  function sll_landau_initializer_dk_test_4d(v1, x1, x2, x3, params)
1587  sll_real64 :: sll_landau_initializer_dk_test_4d
1588  sll_real64, intent(in) :: x1
1589  sll_real64, intent(in) :: x2
1590  sll_real64, intent(in) :: x3
1591  sll_real64, intent(in) :: v1
1592  sll_real64, dimension(:), intent(in) :: params
1593 
1594  sll_real64 :: epsilon
1595  sll_real64 :: kx
1596  sll_real64 :: factor1
1597 
1598 !!$ if( .not. present(params) ) then
1599 !!$ print *, 'sll_landau_initializer_dk_test_4d, error: the params array must ', &
1600 !!$ 'be passed. params(1) = epsilon, params(2) = kx'
1601 !!$ print *,'does not depend on x2,x3',x2,x3
1602 !!$ stop
1603 !!$ end if
1604 
1605  epsilon = params(1)
1606  kx = params(2)
1607  factor1 = 0.5_f64/sll_p_pi
1608 
1609  !write(*,*) 'x1 v1',x1,v1
1610 
1612  (1.0_f64 + epsilon*cos(kx*x1))*exp(-0.5_f64*(v1**2))
1614 
1615  !---------------------------------------------------------------------------
1616  !
1617  ! Periodic Maxwellian
1618  !
1619  ! 4D distribution in [0,1]X[0,1][-6,6]X[-6,6] with the property of being
1620  ! periodic in the spatial directions (x1,x2) and sll_m_gaussian in velocity space.
1621  !
1622  ! f(x,y,vx,vy) = sin(kx*x)*sin(ky*y) +
1623  ! beta* exp(-0.5*((vx-vxc)^2+(vy-vyc)^2))
1624  !
1625  !
1626  ! It is meant to be used in the intervals:
1627  ! x: [ 0,2*pi/kx]
1628  ! y: [ 0,2*pi/ky]
1629  ! vx: [-6,6]
1630  ! vy: [-6,6]
1631 
1632  ! convention for the params array:
1633  ! params(1) = eta1_min
1634  ! params(2) = eta1_max
1635  ! params(3) = eta2_min
1636  ! params(4) = eta2_max
1637  ! params(5) = epsilon
1638  !
1639  !---------------------------------------------------------------------------
1640  function sll_f_periodic_gaussian_initializer_4d(x, y, vx, vy, params) &
1641  result(val)
1642 
1643  sll_real64 :: val !sll_gaussian_initializer_4d
1644  sll_real64, intent(in) :: x
1645  sll_real64, intent(in) :: y
1646  sll_real64, intent(in) :: vx
1647  sll_real64, intent(in) :: vy
1648 
1649  sll_real64, dimension(:), intent(in) :: params
1650  sll_real64 :: xc
1651  sll_real64 :: yc
1652  sll_real64 :: vxc
1653  sll_real64 :: vyc
1654  sll_real64 :: alpha
1655  sll_real64 :: beta
1656 
1657 !!$ if( .not. present(params) ) then
1658 !!$ print *, 'sll_gaussian_initializer_4d, error: the params array must ', &
1659 !!$ 'be passed: ', &
1660 !!$ 'params(1) = xc, params(2) = yc, params(3) = vxc, params(4) = vyc',&
1661 !!$ 'params(5) = alpha, params(6) = beta'
1662 !!$ stop
1663 !!$ end if
1664 
1665  xc = params(1)
1666  yc = params(2)
1667  vxc = params(3)
1668  vyc = params(4)
1669  alpha = params(5)
1670  beta = params(6)
1671 
1672  val = alpha*exp(-0.5_f64*((x - xc)**2 + (y - yc)**2)) + &
1673  beta*exp(-0.5_f64*((vx - vxc)**2 + (vy - vyc)**2))
1675 
1676  !---------------------------------------------------------------------------
1677  !
1678  ! Periodic-Periodic initializer
1679  !
1680  ! 4D distribution in [0,2*pi/kx]X[0,2*pi/ky][-6,6]X[-6,6] with the property of being
1681  ! periodic in the spatial directions (x1,x2) and sll_m_gaussian in velocity space.
1682  !
1683  ! f(x,y,vx,vy) = (1 + alpha * cos(kx*x)*cos(ky*y) )
1684  ! * exp(-0.5*((vx-vxc)^2+(vy-vyc)^2))/ 2*pi
1685  !
1686  ! This function is described in the article of Crouseilles and al. 2009
1687  ! ' A parallel Vlasov solver based on local cubic spline interpolation on patches'
1688  !
1689  ! It is meant to be used in the intervals:
1690  ! x: [ 0,2*pi/kx]
1691  ! y: [ 0,2*pi/ky]
1692  ! vx: [-6,6]
1693  ! vy: [-6,6]
1694 
1695  ! convention for the params array:
1696  ! params(1) = eta1_min
1697  ! params(2) = eta1_max
1698  ! params(3) = eta2_min
1699  ! params(4) = eta2_max
1700  ! params(5) = vxc
1701  ! params(6) = vyc
1702  ! params(7) = alpha
1703  ! params(8) = beta
1704  !---------------------------------------------------------------------------
1705 
1706  function sll_periodic_periodic_gaussian2009_initializer_4d(x, y, vx, vy, params) &
1707  result(val)
1708 
1709  sll_real64 :: val !sll_gaussian_initializer_4d
1710  sll_real64, intent(in) :: x
1711  sll_real64, intent(in) :: y
1712  sll_real64, intent(in) :: vx
1713  sll_real64, intent(in) :: vy
1714 
1715  sll_real64, dimension(:), intent(in) :: params
1716  sll_real64 :: eta1_min, eta1_max
1717  sll_real64 :: eta2_min, eta2_max
1718  sll_real64 :: vxc
1719  sll_real64 :: vyc
1720  sll_real64 :: alpha
1721  sll_real64 :: beta
1722  sll_real64 :: kx, ky
1723 
1724 !!$ if( .not. present(params) ) then
1725 !!$ print *, 'sll_periodic_periodic_gaussian2009_initializer_4d, error: the params array must ', &
1726 !!$ 'be passed: ', &
1727 !!$ 'params(1) = eta1_min, params(2) = eta1_max, params(3) = eta2_min, params(4) = eta2_max',&
1728 !!$ 'params(5) = vxc, params(6) = vyx, params(7) = alpha, params(8) = beta'
1729 !!$ stop
1730 !!$ end if
1731 
1732  eta1_min = params(1)
1733  eta1_max = params(2)
1734  eta2_min = params(3)
1735  eta2_max = params(4)
1736  vxc = params(5)
1737  vyc = params(6)
1738  alpha = params(7)
1739  beta = params(8)
1740  kx = 2.*sll_p_pi/(eta1_max - eta1_min)
1741  ky = 2.*sll_p_pi/(eta2_max - eta2_min)
1742 
1743  val = beta*(1.0_f64 + alpha*cos(kx*x)*cos(ky*y)) &
1744  *exp(-0.5*((vx - vxc)**2 + (vy - vyc)**2)) &
1745  /(2*sll_p_pi)
1746 
1748 
1749  !---------------------------------------------------------------------------
1750  !
1751  ! Periodic-Periodic initializer another
1752  !
1753  ! 4D distribution in [0,2*pi/kx]X[0,2*pi/ky][-6,6]X[-6,6] with the property of being
1754  ! periodic in the spatial directions (x1,x2) and sll_m_gaussian in velocity space.
1755  !
1756  ! f(x,y,vx,vy) = (1 + alpha * (cos(kx*x) + cos(ky*y)) )
1757  ! * exp(-0.5*((vx-vxc)^2+(vy-vyc)^2))/ (2*sll_p_pi)
1758  !
1759  ! This function is described in the article of Filbet and Sonnendrucker 2002
1760  ! 'Comparison of Eulerian Vlasov solvers'
1761  !
1762  ! It is meant to be used in the intervals:
1763  ! x: [ 0,2*pi/kx]
1764  ! y: [ 0,2*pi/ky]
1765  ! vx: [-6,6]
1766  ! vy: [-6,6]
1767 
1768  ! convention for the params array:
1769  ! params(1) = eta1_min
1770  ! params(2) = eta1_max
1771  ! params(3) = eta2_min
1772  ! params(4) = eta2_max
1773  ! params(5) = vxc
1774  ! params(6) = vyc
1775  ! params(7) = alpha
1776  ! params(8) = beta
1777  !---------------------------------------------------------------------------
1778 
1779  function sll_periodic_periodic_gaussian2002_initializer_4d(x, y, vx, vy, params) &
1780  result(val)
1781 
1782  sll_real64 :: val !sll_gaussian_initializer_4d
1783  sll_real64, intent(in) :: x
1784  sll_real64, intent(in) :: y
1785  sll_real64, intent(in) :: vx
1786  sll_real64, intent(in) :: vy
1787 
1788  sll_real64, dimension(:), intent(in) :: params
1789  sll_real64 :: eta1_min, eta1_max
1790  sll_real64 :: eta2_min, eta2_max
1791  sll_real64 :: vxc
1792  sll_real64 :: vyc
1793  sll_real64 :: alpha
1794  sll_real64 :: beta
1795  sll_real64 :: kx, ky
1796 
1797 !!$ if( .not. present(params) ) then
1798 !!$ print *, 'sll_periodic_periodic_gaussian2002_initializer_4d, error: the params array must ', &
1799 !!$ 'be passed: ', &
1800 !!$ 'params(1) = eta1_min, params(2) = eta1_max, params(3) = eta2_min, params(4) = eta2_max',&
1801 !!$ 'params(5) = vxc, params(6) = vyx, params(7) = alpha, params(8) = beta'
1802 !!$ stop
1803 !!$ end if
1804 
1805  eta1_min = params(1)
1806  eta1_max = params(2)
1807  eta2_min = params(3)
1808  eta2_max = params(4)
1809  vxc = params(5)
1810  vyc = params(6)
1811  alpha = params(7)
1812  beta = params(8)
1813  kx = 2.*sll_p_pi/(eta1_max - eta1_min)
1814  ky = 2.*sll_p_pi/(eta2_max - eta2_min)
1815 
1816  val = beta*(1.0_f64 + alpha*(cos(kx*x) + cos(ky*y))) &
1817  *exp(-0.5*((vx - vxc)**2 + (vy - vyc)**2)) &
1818  /(2*sll_p_pi)
1819 
1821 
1822  !---------------------------------------------------------------------------
1823  !
1824  ! Gaussian beam 4d initializer
1825  !
1826  ! convention for the params array:
1827  ! params(1) = vth
1828  ! params(2) = xth
1829  ! params(3) = vxc
1830  ! params(4) = vyc
1831  ! params(5) = xc
1832  ! params(6) = yc
1833  ! params(7) = n0
1834  ! params(8) = radius
1835  !---------------------------------------------------------------------------
1836 
1837  function sll_f_gaussian_beam_initializer_4d(x, y, vx, vy, params) &
1838  result(val)
1839 
1840  sll_real64 :: val
1841  sll_real64, intent(in) :: x
1842  sll_real64, intent(in) :: y
1843  sll_real64, intent(in) :: vx
1844  sll_real64, intent(in) :: vy
1845 
1846  sll_real64, dimension(:), intent(in) :: params
1847  sll_real64 :: vxc
1848  sll_real64 :: vyc
1849  sll_real64 :: xc, yc, radius
1850  sll_real64 :: vt, xt, n0
1851 
1852 !!$ if( .not. present(params) ) then
1853 !!$ print *, 'sll_gaussian_initializer_4d, error: the params array must ', &
1854 !!$ 'be passed: ', &
1855 !!$ 'params(1) = vt, params(2) = xt, params(3) = sigma_x, params(4) = sigma_v',&
1856 !!$ ' params(5) = vxc, params(6) = vyc, params(7) = xc, params(8) = yc, params(9) = n0'
1857 !!$ stop
1858 !!$ end if
1859 
1860  vt = params(1)
1861  xt = params(2)
1862  vxc = params(3)
1863  vyc = params(4)
1864  xc = params(5)
1865  yc = params(6)
1866  n0 = params(7)
1867  radius = params(8)
1868 
1869  val = n0*exp(-0.5*(radius**2*(x - xc)**2 + radius**2*(y - yc)**2)/(xt*xt)) &
1870  /(2*sll_p_pi*xt**2) &
1871  *exp(-0.5*((vx - vxc)**2 + (vy - vyc)**2)/(vt*vt))/(2*sll_p_pi*vt**2)
1872 
1874 
1876  function sll_f_langmuir_cos_initializer_2d(x, vx, params)
1877  sll_real64 :: sll_f_langmuir_cos_initializer_2d
1878  sll_real64, intent(in) :: x
1879  sll_real64, intent(in) :: vx
1880 
1881  sll_real64, dimension(:), intent(in) :: params
1882  sll_real64 :: eps
1883  sll_real64 :: kx
1884  sll_real64 :: factor1
1885  sll_real64 :: sum
1886  sll_int32 :: ns
1887  sll_real64 :: vb2
1888  sll_real64 :: vb1
1889  sll_real64 :: dvb
1890  sll_real64 :: vj
1891  sll_real64 :: vtb
1892  sll_real64 :: db
1893  sll_real64 :: ve
1894  sll_int32 :: j
1895  sll_real64 :: sigma
1896 
1897 !!$ if( .not. present(params) ) then
1898 !!$ print *, 'langmuir_initializer_2d, error: the params array must ', &
1899 !!$ 'be passed. params(1) = epsilon, params(2) = kx', &
1900 !!$ 'params(3) = ns, params(4) = vb2, params(5) = vb1', &
1901 !!$ ' params(6) = vtb, params(7) = db', &
1902 !!$ 'params(8) = ve, params(9) = sigma.'
1903 !!$ stop
1904 !!$ end if
1905  sll_assert(size(params) >= 9)
1906  eps = params(1)
1907  kx = params(2)
1908  ns = int(params(3), i32)
1909  vb2 = params(4)
1910  vb1 = params(5)
1911  vtb = params(6)
1912  db = params(7)
1913  ve = params(8)
1914  sigma = params(9)
1915 
1916  sum = 0.0_f64
1917  do j = 0, ns - 1
1918  dvb = (vb2 - vb1)/(ns - 1)
1919  vj = vb2 - j*dvb
1920  sum = sum + exp(-(vx - vj)**2/(2.0_f64*vtb**2*sigma**2))
1921  end do
1922 
1923  factor1 = 1.0_f64/(sigma*sqrt(2.0_f64*sll_p_pi))
1924  !langmuir initializer with cosine function
1925  sll_f_langmuir_cos_initializer_2d = factor1*(1.0_f64 + eps*cos(kx*x)) &
1926  *((1.0_f64 - db)*exp(-(vx - ve)**2/(2.0_f64*sigma**2)) + db*sum/(ns*vtb))
1927 
1929 
1933  sll_real64, intent(in) :: x
1934  sll_real64, intent(in) :: vx
1935 
1936  sll_real64, dimension(:), intent(in) :: params
1937  sll_real64 :: eps
1938  sll_real64 :: kx
1939  sll_real64 :: factor1
1940  sll_real64 :: sum
1941  sll_int32 :: ns
1942  sll_real64 :: vb2
1943  sll_real64 :: vb1
1944  sll_real64 :: dvb
1945  sll_real64 :: vj
1946  sll_real64 :: vtb
1947  sll_real64 :: db
1948  sll_real64 :: ve
1949  sll_int32 :: j
1950  sll_real64 :: sigma
1951 
1952 !!$ if( .not. present(params) ) then
1953 !!$ print *, 'langmuir_initializer_2d, error: the params array must ', &
1954 !!$ 'be passed. params(1) = epsilon, params(2) = kx', &
1955 !!$ 'params(3) = ns, params(4) = vb2, params(5) = vb1', &
1956 !!$ ' params(6) = vtb, params(7) = db', &
1957 !!$ 'params(8) = ve, params(9) = sigma.'
1958 !!$ stop
1959 !!$ end if
1960  sll_assert(size(params) >= 9)
1961  eps = params(1)
1962  kx = params(2)
1963  ns = int(params(3), i32)
1964  vb2 = params(4)
1965  vb1 = params(5)
1966  vtb = params(6)
1967  db = params(7)
1968  ve = params(8)
1969  sigma = params(9)
1970 
1971  sum = 0.0_f64
1972  do j = 0, ns - 1
1973  dvb = (vb2 - vb1)/(ns - 1)
1974  vj = vb2 - j*dvb
1975  sum = sum + exp(-(vx - vj)**2/(2.0_f64*vtb**2*sigma**2))
1976  end do
1977 
1978  factor1 = 1.0_f64/(sigma*sqrt(2.0_f64*sll_p_pi))
1979 
1980  ! langmuir initializer with gaussian_deviate
1982  *((1.0_f64 - db)*exp(-(vx - ve)**2/(2.0_f64*sigma**2)) + db*sum/(ns*vtb))
1983 
1985 
1989  sll_real64, intent(in) :: x
1990  sll_real64, intent(in) :: vx
1991 
1992  sll_real64, dimension(:), intent(in) :: params
1993  sll_real64 :: eps
1994  sll_real64 :: kx
1995  sll_real64 :: factor1
1996  sll_real64 :: sum
1997  sll_int32 :: ns
1998  sll_real64 :: vb2
1999  sll_real64 :: vb1
2000  sll_real64 :: dvb
2001  sll_real64 :: vj
2002  sll_real64 :: vtb
2003  sll_real64 :: db
2004  sll_real64 :: ve
2005  sll_int32 :: j
2006  sll_real64 :: sigma
2007  sll_real64 :: pert
2008 
2009 !!$ if( .not. present(params) ) then
2010 !!$ print *, 'langmuir_initializer_2d_random, error: the params array must ', &
2011 !!$ 'be passed. params(1) = epsilon, params(2) = kx', &
2012 !!$ 'params(3) = ns, params(4) = vb2, params(5) = vb1', &
2013 !!$ ' params(6) = vtb, params(7) = db', &
2014 !!$ 'params(8) = ve, params(9) = sigma, params(10) = perturbation.'
2015 !!$ stop
2016 !!$ end if
2017  sll_assert(size(params) >= 10)
2018  eps = params(1)
2019  kx = params(2)
2020  ns = int(params(3), i32)
2021  vb2 = params(4)
2022  vb1 = params(5)
2023  vtb = params(6)
2024  db = params(7)
2025  ve = params(8)
2026  sigma = params(9)
2027  pert = params(10)
2028 
2029  sum = 0.0_f64
2030  do j = 0, ns - 1
2031  dvb = (vb2 - vb1)/(ns - 1)
2032  vj = vb2 - j*dvb
2033  sum = sum + exp(-(vx - vj)**2/(2.0_f64*vtb**2*sigma**2))
2034  end do
2035 
2036  factor1 = 1.0_f64/(sigma*sqrt(2.0_f64*sll_p_pi))
2037 
2038  ! langmuir initializer with given perturbation
2039  sll_f_langmuir_parameter_pert_initializer_2d = factor1*(1.0_f64 + eps*pert) &
2040  *((1.0_f64 - db)*exp(-(vx - ve)**2/(2.0_f64*sigma**2)) + db*sum/(ns*vtb))
2041 
2043 
real(kind=f64) function, public sll_f_sdf_a1_exact_charac_2d(t, t0, x0_1, x0_2, params)
real(kind=f64) function, public sll_f_test_y_transport_initializer_v1v2x1x2(vx, vy, x, y, params)
real(kind=f64) function, public sll_f_landau_mode_initializer_cos_sum_4d(x, y, vx, vy, params)
real(kind=f64) function, public sll_f_test_vy_transport_initializer_v1v2x1x2(vx, vy, x, y, params)
real(kind=f64) function, public sll_f_sdf_phi_initializer_2d(x_1, x_2, params)
real(kind=f64) function, public sll_f_gaussian_beam_initializer_4d(x, y, vx, vy, params)
real(kind=f64) function, public sll_f_diocotron_initializer_2d(r, theta, params)
real(kind=f64) function, public sll_f_twostream_1d_xvx_initializer_v1v2x1x2(vx, vy, x, y, params)
real(kind=f64) function, public sll_f_gaussian_initializer_2d(x_1, x_2, params)
real(kind=f64) function, public sll_f_dsg_2d(eta1, eta2, params)
real(kind=f64) function, public sll_f_landau_initializer_2d(x, vx, params)
real(kind=f64) function sll_landau_initializer_dk_test_4d(v1, x1, x2, x3, params)
real(kind=f64) function, public sll_f_cos_bell_initializer_2d(x_1, x_2, params)
real(kind=f64) function, public sll_f_langmuir_parameter_pert_initializer_2d(x, vx, params)
Initializer for Langmuir function with perturbation given as parameter.
real(kind=f64) function, public sll_f_galaxy_1d_xvx_initializer_v1v2x1x2(vx, vy, x, y, params)
real(kind=f64) function, public sll_f_hmf_initializer_2d(x, vx, params)
Function to intialize distribution function for the Vlasov-HMF model.
real(kind=f64) function sll_periodic_periodic_gaussian2002_initializer_4d(x, y, vx, vy, params)
real(kind=f64) function, public sll_f_landau_2d_initializer_v1v2x1x2(vx, vy, x, y, params)
real(kind=f64) function, public sll_f_cos_sin_initializer_2d(x_1, x_2, params)
real(kind=f64) function, public sll_f_langmuir_gaussxv_initializer_2d(x, vx, params)
Initializer for Langmuir function with Gaussian deviate perturbation.
real(kind=f64) function, public sll_f_rotation_a1_initializer_2d(x_1, x_2, params)
real(kind=f64) function, public sll_f_two_stream_instability_initializer_2d(x, vx, params)
real(kind=f64) function, public sll_f_cos_bell0_initializer_2d(x_1, x_2, params)
real(kind=f64) function, public sll_f_bump_on_tail_initializer_2d(x, vx, params)
real(kind=f64) function, public sll_f_translation_a2_exact_charac_2d(t, t0, x0_1, x0_2, params)
real(kind=f64) function, public sll_f_test_vx_transport_initializer_v1v2x1x2(vx, vy, x, y, params)
real(kind=f64) function, public sll_f_periodic_gaussian_initializer_4d(x, y, vx, vy, params)
real(kind=f64) function, public sll_f_rotation_a2_exact_charac_2d(t, t0, x0_1, x0_2, params)
real(kind=f64) function, public sll_f_galaxy_2d_initializer_v1v2x1x2(vx, vy, x, y, params)
real(kind=f64) function, public sll_f_sdf_a2_exact_charac_2d(t, t0, x0_1, x0_2, params)
real(kind=f64) function, public sll_f_translation_a1_exact_charac_2d(t, t0, x0_1, x0_2, params)
real(kind=f64) function, public sll_f_landau_1d_xvx_initializer_v1v2x1x2(vx, vy, x, y, params)
real(kind=f64) function, public sll_f_sdf_a1_initializer_2d(x_1, x_2, params)
real(kind=f64) function, public sll_f_diocotron_initializer_2d2(x, y, params)
real(kind=f64) function, public sll_f_test_yvy_transport_initializer_v1v2x1x2(vx, vy, x, y, params)
real(kind=f64) function, public sll_f_constant_time_initializer_1d(t, params)
real(kind=f64) function, public sll_f_sdf_a2_initializer_2d(x_1, x_2, params)
real(kind=f64) function, public sll_f_test_xvx_transport_initializer_v1v2x1x2(vx, vy, x, y, params)
real(kind=f64) function, public sll_f_beam_initializer_2d(x, vx, params)
real(kind=f64) function, public sll_f_one_initializer_2d(x_1, x_2, params)
real(kind=f64) function, public sll_f_landau_1d_yvy_initializer_v1v2x1x2(vx, vy, x, y, params)
real(kind=f64) function, public sll_f_landau_mode_initializer_4d(x, y, vx, vy, params)
real(kind=f64) function, public sll_f_khp1_2d(x, y, params)
real(kind=f64) function, public sll_f_rotation_a2_initializer_2d(x_1, x_2, params)
real(kind=f64) function, public sll_f_landau_initializer_4d(x, y, vx, vy, params)
real(kind=f64) function, public sll_f_rotation_phi_initializer_2d(x_1, x_2, params)
real(kind=f64) function, public sll_f_test_x_transport_initializer_v1v2x1x2(vx, vy, x, y, params)
real(kind=f64) function, public sll_f_langmuir_cos_initializer_2d(x, vx, params)
Initializer for Langmuir function with cosine perturbation.
real(kind=f64) function, public sll_f_bump_on_tail_initializer_4d(x, y, vx, vy, params)
real(kind=f64) function, public sll_f_translation_phi_initializer_2d(x_1, x_2, params)
real(kind=f64) function, public sll_f_sdf_time_initializer_1d(t, params)
real(kind=f64) function sll_periodic_periodic_gaussian2009_initializer_4d(x, y, vx, vy, params)
real(kind=f64) function, public sll_f_rotation_a1_exact_charac_2d(t, t0, x0_1, x0_2, params)
real(kind=f64) function, public sll_f_translation_a2_initializer_2d(x_1, x_2, params)
real(kind=f64) function sll_gaussian_initializer_4d(x, y, vx, vy, params)
real(kind=f64) function, public sll_f_translation_a1_initializer_2d(x_1, x_2, params)
Fortran module where set some physical and mathematical constants.
real(kind=f64), parameter, public sll_p_pi
sll_m_gaussian random generator
real(kind=f64) function, public sll_f_gaussian_deviate()
Returns a value of a random variable in ONE dimension following the Gaussian probability density with...
Module to select the kind parameter.
    Report Typos and Errors