@@ -31,16 +31,12 @@ namespace user {
3131 }
3232
3333 Inline auto ex1 (const coord_t <D>& x_Ph) const -> real_t {
34- if (x_Ph[0 ] < xsurf + ds ){
34+ if (x_Ph[0 ] < xsurf ){
3535 return ZERO;
36- }else if (x_Ph[0 ] > xsurf + 1.33 * ds){
37- return -coeff * (x_Ph[0 ] - xsurf - ds * (ONE + 0.03 * math::log (1.01 ) - 0.33 * math::log (0.01 + math::exp (-11.0 / ds))));
38-
3936 }else {
40- return -coeff * (x_Ph[0 ] - xsurf - ds
37+ return -coeff * (x_Ph[0 ] - xsurf
4138 + 0.03 * ds * math::log (0.01 + math::exp ((xsurf + 1.0 * ds - x_Ph[0 ]) / 0.03 / ds))
42- - 0.03 * ds * math::log (0.01 + ONE));
43- // return -coeff * (x_Ph[0] - xsurf - ds);
39+ - 0.03 * ds * math::log (0.01 + math::exp (1.0 /0.03 )));
4440 }
4541 }
4642
@@ -109,14 +105,10 @@ namespace user {
109105 , ds { ds_ } {}
110106
111107 Inline auto operator ()(const coord_t <M::Dim>& x_Ph) const -> real_t {
112- if ( x_Ph[0 ] < xsurf or x_Ph[ 0 ] > 1.33 * ds + xsurf ){
108+ if ( x_Ph[0 ] < xsurf){
113109 return ZERO;
114110 }else {
115- if (x_Ph[0 ] < ds + xsurf){
116- return ONE;
117- }else {
118- return ONE - 0.01 / (0.01 + math::exp (-(x_Ph[0 ] - xsurf - 1.0 * ds) / 0.03 / ds));
119- }
111+ return ONE - 0.01 / (0.01 + math::exp (-(x_Ph[0 ] - xsurf - 1.0 * ds) / 0.03 / ds));
120112 }
121113 }
122114 }; // ExtraCharge
@@ -167,8 +159,11 @@ namespace user {
167159 MagnetosphericCurrent<D> ext_current;
168160
169161 const kernel::QED::cdfTable cdf;
170- random_number_pool_t random_pool (12345 );
171- const real_t e_min, gamma_emit, coeff, rho, N_max, dt;
162+ random_number_pool_t random_pool;
163+ const real_t e_min, gamma_emit, coeff, rho, dt, coeff1, coeff2;
164+ const size_t N_max;
165+
166+ const bool QED_on;
172167
173168
174169 inline PGen (const SimulationParams& p, const Metadomain<S, M>& m)
@@ -185,18 +180,18 @@ namespace user {
185180 , gamma_emit { p.template get <real_t >(" setup.gamma_emit" ) }
186181 , coeff { p.template get <real_t >(" setup.coeff" ) }
187182 , rho { p.template get <real_t >(" setup.rho" ) }
188- , N_max { p.template get <real_t >(" setup.N_max" ) }
183+ , N_max { static_cast < size_t >( p.template get <int >(" setup.N_max" ) ) }
189184 , coeff1 { coeff * 0.23 * constant::PI * b0 * constant::SQRT3 }
190185 , coeff2 { FOUR * TWO / THREE / b0 }
186+ , random_pool { 12345 }
191187 , xsurf([&m, this ]() {
192188 const auto min_buff = params.template get <unsigned short >(" algorithms.current_filters" ) + 2 ;
193189 const auto buffer_ncells = min_buff > 5 ? min_buff : 5 ;
194190 return m.mesh ().metric .template convert <1 , Crd::Cd, Crd::Ph>(static_cast <real_t >(buffer_ncells));
195191 }())
196- // , l_atm { ZERO }
197- // , init_flds(b0, TWO * FOUR * constant::PI * b0 * Omega * SQR(skindepth0) / larmor0, l_atm, ds)
198192 , init_flds(b0, larmor0 / SQR(skindepth0), xsurf, ds)
199193 , ext_current(j0)
194+ , QED_on { p.template get <bool >(" setup.QED" ) }
200195 {}
201196
202197 inline PGen () {}
@@ -230,7 +225,8 @@ namespace user {
230225 params,
231226 local_domain,
232227 injector,
233- ONE);
228+ ONE,
229+ true );
234230
235231 const auto extra_charge = ExtraCharge<S, M>(
236232 local_domain.mesh .metric ,
@@ -246,61 +242,64 @@ namespace user {
246242 params,
247243 local_domain,
248244 injector_extra_charge,
249- TWO);
245+ TWO,
246+ true );
250247 }
251248
252249 void CustomPostStep (std::size_t , long double time, Domain<S, M>& local_domain) {
253- kernel::QED::CurvatureEmission_kernel<D, C> curvature_emission1 (local_domain.species [0 ],
254- local_domain.species [2 ],
255- e_min,
256- gamma_emit,
257- coeff * dt / skindepth0,
258- rho,
259- N_max,
260- random_pool,
261- cdf);
262- Kokkos::parallel_for (" CurvatureEmission" ,
263- local_domain.species [0 ].rangeActiveParticles (),
264- curvature_emission1);
265- Kokkos::fence ();
266- auto n_injected = curvature_emission1.num_injected ();
267- local_domain.species [2 ].set_npart (local_domain.species [2 ].npart () + n_injected);
268- kernel::QED::CurvatureEmission_kernel<D, C> curvature_emission2 (local_domain.species [1 ],
269- local_domain.species [2 ],
270- e_min,
271- gamma_emit,
272- coeff * dt / skindepth0,
273- rho,
274- N_max,
275- random_pool,
276- cdf);
277- Kokkos::parallel_for (" CurvatureEmission" ,
278- local_domain.species [1 ].rangeActiveParticles (),
279- curvature_emission2);
280- Kokkos::fence ();
281- n_injected = curvature_emission2.num_injected ();
282- local_domain.species [2 ].set_npart (local_domain.species [2 ].npart () + n_injected);
283-
284- kernel::QED::PairCreation_kernel<D, C> pair_creation (local_domain.species [2 ],
285- local_domain.species [1 ],
286- local_domain.species [0 ]);
287-
288- Kokkos::fence ();
289-
290- n_injected = pair_creation.num_injected ();
291- local_domain.species [1 ].set_npart (local_domain.species [1 ].npart () + n_injected);
292- local_domain.species [0 ].set_npart (local_domain.species [0 ].npart () + n_injected);
293-
294- Kokkos::parallel_for (" PayloadUpdate" ,
295- local_domain.species [2 ].rangeActiveParticles (),
296- PayloadUpdate<D, C>(local_domain.species [2 ],
297- coeff1 / skindepth0,
298- coeff2,
299- dt,
300- rho,
301- 5 ));
250+ if (QED_on) {
251+ kernel::QED::CurvatureEmission_kernel<D, M::CoordType> curvature_emission1 (local_domain.species [0 ],
252+ local_domain.species [2 ],
253+ e_min,
254+ gamma_emit,
255+ coeff * dt / skindepth0,
256+ rho,
257+ N_max,
258+ random_pool,
259+ cdf);
260+ Kokkos::parallel_for (" CurvatureEmission" ,
261+ local_domain.species [0 ].rangeActiveParticles (),
262+ curvature_emission1);
263+ Kokkos::fence ();
264+ auto n_injected = curvature_emission1.num_injected ();
265+ local_domain.species [2 ].set_npart (local_domain.species [2 ].npart () + n_injected);
266+ kernel::QED::CurvatureEmission_kernel<D, M::CoordType> curvature_emission2 (local_domain.species [1 ],
267+ local_domain.species [2 ],
268+ e_min,
269+ gamma_emit,
270+ coeff * dt / skindepth0,
271+ rho,
272+ N_max,
273+ random_pool,
274+ cdf);
275+ Kokkos::parallel_for (" CurvatureEmission" ,
276+ local_domain.species [1 ].rangeActiveParticles (),
277+ curvature_emission2);
278+ Kokkos::fence ();
279+ n_injected = curvature_emission2.num_injected ();
280+ local_domain.species [2 ].set_npart (local_domain.species [2 ].npart () + n_injected);
281+
282+ kernel::QED::PairCreation_kernel<D, M::CoordType> pair_creation (local_domain.species [2 ],
283+ local_domain.species [1 ],
284+ local_domain.species [0 ]);
285+
286+ Kokkos::fence ();
287+
288+ n_injected = pair_creation.num_injected ();
289+ local_domain.species [1 ].set_npart (local_domain.species [1 ].npart () + n_injected);
290+ local_domain.species [0 ].set_npart (local_domain.species [0 ].npart () + n_injected);
291+
292+ Kokkos::parallel_for (" PayloadUpdate" ,
293+ local_domain.species [2 ].rangeActiveParticles (),
294+ kernel::QED::PayloadUpdate<D, M::CoordType>(local_domain.species [2 ],
295+ coeff1 / skindepth0,
296+ coeff2,
297+ dt,
298+ rho,
299+ 5 ));
302300
303301 }
302+ }
304303
305304
306305 }; // PGen
0 commit comments