24 #include "sll_assert.h"
25 #include "sll_memory.h"
26 #include "sll_working_precision.h"
27 #include "sll_particle_representation.h"
70 sll_real64,
intent(in) :: thermal_speed
71 sll_real64,
intent(in) :: alpha, k
73 sll_int32,
intent(in) :: num_particles
74 sll_int32,
dimension(:),
intent(in),
optional :: rand_seed
75 sll_int32,
optional :: rank, worldsize
78 sll_int32 :: ncx, ic_x, ic_y
79 sll_real64 :: x, y, vx, vy, z
80 sll_real64 :: xmin, ymin, rdx, rdy
82 sll_real32 :: off_x, off_y
83 sll_real64 :: tmp1, tmp2
84 sll_real64 :: yo, nu, fdx
86 if (
present(rand_seed))
then
87 call random_seed(put=rand_seed)
90 if (
present(worldsize))
then
91 weight = real((m2d%eta1_max - m2d%eta1_min)* &
92 (m2d%eta2_max - m2d%eta2_min), f32)/(real(worldsize, f32)*real(num_particles, f32))
94 weight = real((m2d%eta1_max - m2d%eta1_min)* &
95 (m2d%eta2_max - m2d%eta2_min), f32)/real(num_particles, f32)
99 rdx = 1._f64/m2d%delta_eta1
100 rdy = 1._f64/m2d%delta_eta2
106 do while (j <= num_particles)
107 call random_number(x)
108 x = (m2d%eta1_max - xmin)*x + xmin
109 call random_number(fdx)
110 fdx = (1._f64 + alpha)*fdx
112 call random_number(y)
113 y = (m2d%eta2_max - ymin)*y + ymin
114 call random_number(z)
115 nu = thermal_speed*sqrt(-2._f64*log(1.0_f64 - z))
116 call random_number(yo)
119 set_particle_values(p_group%p_list(j), x, y, vx, vy, weight, xmin, ymin, ncx, ic_x, ic_y, off_x, off_y, rdx, rdy, tmp1, tmp2)
125 sll_assert(
present(rank))
132 thermal_speed, alpha, k, &
136 rand_seed, rank, worldsize)
137 sll_real64,
intent(in) :: thermal_speed
138 sll_real64,
intent(in) :: alpha, k
140 sll_int32,
intent(in) :: num_particles
143 sll_int32 :: ncx, ic_x, ic_y
144 sll_real64 :: x, y, vx, vy
145 sll_real64 :: xmin, ymin, rdx, rdy
147 sll_real32 :: off_x, off_y
148 sll_real64 :: tmp1, tmp2
149 sll_int32,
dimension(:),
intent(in),
optional :: rand_seed
150 sll_int32,
optional :: rank, worldsize
151 sll_real64,
dimension(:),
allocatable :: pos_x, pos_y
153 sll_real64 :: nu, rtheta
155 if (
present(rand_seed))
then
156 call random_seed(put=rand_seed)
159 if (
present(worldsize))
then
160 weight = real((m2d%eta1_max - m2d%eta1_min)* &
161 (m2d%eta2_max - m2d%eta2_min), f32)/(real(worldsize, f32)*real(num_particles, f32))
163 weight = real((m2d%eta1_max - m2d%eta1_min)* &
164 (m2d%eta2_max - m2d%eta2_min), f32)/real(num_particles, f32)
168 sll_allocate(pos_x(1:num_particles), ierr)
169 sll_allocate(pos_y(1:num_particles), ierr)
171 rdx = 1._f64/m2d%delta_eta1
172 rdy = 1._f64/m2d%delta_eta2
179 do while (j <= num_particles + ll)
181 x = (m2d%eta1_max - xmin)*x + xmin
183 y = (1._f64 + alpha)*y
193 do j = 1, num_particles
194 nu = sqrt(-2._f64*log(1._f64 - (real(j, f64) - 0.5_f64)/real(num_particles, f64)))
198 vx = vx*thermal_speed
199 vy = vy*thermal_speed
200 set_particle_values(p_group%p_list(j),pos_x(j),pos_y(j),vx,vy,weight,xmin,ymin,ncx,ic_x,ic_y,off_x,off_y,rdx,rdy,tmp1,tmp2)
202 sll_deallocate_array(pos_x, ierr)
203 sll_deallocate_array(pos_y, ierr)
206 sll_assert(
present(rank))
219 sll_real64,
intent(in) :: thermal_speed
220 sll_real64,
intent(in) :: alpha, kx, ky
222 sll_int32,
intent(in) :: num_particles
223 sll_int32,
dimension(:),
intent(in),
optional :: rand_seed
224 sll_int32,
optional :: rank, worldsize
226 sll_int32 :: j, ncx, ic_x, ic_y
227 sll_real64 :: x, y, vx, vy, z
228 sll_real64 :: xmin, ymin, rdx, rdy
230 sll_real32 :: off_x, off_y
231 sll_real64 :: tmp1, tmp2
232 sll_real64 :: val(1:2)
234 if (
present(rand_seed))
then
235 call random_seed(put=rand_seed)
238 if (
present(worldsize))
then
239 weight = real((m2d%eta1_max - m2d%eta1_min)* &
240 (m2d%eta2_max - m2d%eta2_min), f32)/(real(worldsize, f32)*real(num_particles, f32))
242 weight = real((m2d%eta1_max - m2d%eta1_min)* &
243 (m2d%eta2_max - m2d%eta2_min), f32)/real(num_particles, f32)
246 rdx = 1._f64/m2d%delta_eta1
247 rdy = 1._f64/m2d%delta_eta2
253 do while (j <= num_particles)
254 call random_number(x)
255 x = (m2d%eta1_max - xmin)*x + xmin
256 call random_number(y)
257 y = (m2d%eta2_max - ymin)*y + ymin
258 call random_number(z)
259 z = (1._f64 + alpha)*z
262 vx = val(1)*thermal_speed
263 vy = val(2)*thermal_speed
264 set_particle_values(p_group%p_list(j), x, y, vx, vy, weight, xmin, ymin, ncx, ic_x, ic_y, off_x, off_y, rdx, rdy, tmp1, tmp2)
270 sll_assert(
present(rank))
275 sll_real64 :: alp, kx, x
281 sll_real64 :: alp, kx, x, ky, y
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.
subroutine, public sll_s_initial_hammersley_particles_4d(thermal_speed, alpha, k, m2d, num_particles, p_group, rand_seed, rank, worldsize)
Initialize particles in a 2d+2v phase space using pseudo-random generators. The Landau damping case w...
subroutine, public sll_s_initial_random_particles_4d(thermal_speed, alpha, k, m2d, num_particles, p_group, rand_seed, rank, worldsize)
Initialize particles in a 2d+2v phase space using random generators. The Landau damping case with a p...
subroutine sll_s_initial_random_particles_4d_landau2d(thermal_speed, alpha, kx, ky, m2d, num_particles, p_group, rand_seed, rank, worldsize)
The Landau damping case with a perturbation in BOTH directions of the physical space: (x,...
real(kind=f64) function sll_f_eval_landau1d(alp, kx, x)
real(kind=f64) function sll_f_eval_landau2d(alp, kx, x, ky, y)