24 #include "sll_assert.h"
25 #include "sll_memory.h"
26 #include "sll_working_precision.h"
27 #include "sll_particle_representation.h"
60 sll_real64,
intent(in) :: thermal_speed
62 sll_real64,
intent(in) :: alpha
64 sll_real64,
intent(in) :: k
68 sll_int32,
intent(in) :: num_particles
70 sll_int32,
dimension(:),
intent(in),
optional :: rand_seed
72 sll_int32,
optional :: rank
74 sll_int32,
optional :: worldsize
79 sll_int32 :: ic_x, ic_y, ic_z
80 sll_int32 :: nc_x, nc_y
82 sll_real64 :: xmin, ymin, zmin, rdx, rdy, rdz
84 sll_real64 :: tmp_x, tmp_y, tmp_z
85 sll_real64 :: nu, fdx, phi, theta, rnd
88 volume = real((mesh%eta1_max - mesh%eta1_min)* &
89 (mesh%eta2_max - mesh%eta2_min)* &
90 (mesh%eta3_max - mesh%eta3_min), f32)
92 if (
present(rand_seed))
then
93 call random_seed(put=rand_seed)
96 if (
present(worldsize))
then
97 weight = volume/(real(worldsize, f32)*real(num_particles, f32))
99 weight = volume/real(num_particles, f32)
104 rdx = 1._f64/mesh%delta_eta1
105 rdy = 1._f64/mesh%delta_eta2
106 rdz = 1._f64/mesh%delta_eta3
110 nc_x = mesh%num_cells1
111 nc_y = mesh%num_cells2
114 do while (j <= num_particles)
115 call random_number(x)
116 x = (mesh%eta1_max - xmin)*x + xmin
117 call random_number(fdx)
118 fdx = (1._f64 + alpha)*fdx
120 call random_number(y)
121 y = (mesh%eta2_max - ymin)*y + ymin
122 call random_number(z)
123 z = (mesh%eta3_max - zmin)*z + zmin
124 call random_number(rnd)
125 nu = thermal_speed*sqrt(-2._f64*log(1.0_f64 - rnd))
126 call random_number(theta)
127 call random_number(phi)
128 p_group%p_list(j)%vx = nu*cos(theta*2.0_f64*
sll_p_pi)*cos(phi*2.0_f64*
sll_p_pi)
129 p_group%p_list(j)%vy = nu*sin(theta*2.0_f64*
sll_p_pi)*cos(phi*2.0_f64*
sll_p_pi)
130 p_group%p_list(j)%vz = nu*sin(phi*2.0_f64*
sll_p_pi)
131 tmp_x = (x - xmin)*rdx
132 tmp_y = (y - ymin)*rdy
133 tmp_z = (z - zmin)*rdz
137 p_group%p_list(j)%dx = real(tmp_x - real(ic_x, f64), f32)
138 p_group%p_list(j)%dy = real(tmp_y - real(ic_y, f64), f32)
139 p_group%p_list(j)%dz = real(tmp_z - real(ic_z, f64), f32)
140 p_group%p_list(j)%ic = 1 + ic_x + ic_y*nc_x + ic_z*(nc_x*nc_y)
146 sll_assert(
present(rank))
152 sll_real64 :: alp, kx, x
Cartesian mesh basic types.
Fortran module where set some physical and mathematical constants.
real(kind=f64), parameter, public sll_p_pi
sll_m_gaussian random generator
subroutine, public sll_s_gaussian_deviate_2d(res)
Returns a value of a random variable in TWO dimensions following the Gaussian probability density wit...
hamm pseudo-random generator
real(kind=f64) function, public sll_f_suite_hamm(n, b)
Initialization of particles in 2d+2v: the Landau damping case.
real(kind=f64) function sll_f_eval_landau1d(alp, kx, x)
subroutine, public sll_s_initial_random_particles_6d(thermal_speed, alpha, k, mesh, num_particles, p_group, rand_seed, rank, worldsize)
Initialize particles in a 3d+3v phase space using random generators.