WarpX
ComputeTemperature.H
Go to the documentation of this file.
1 /* Copyright 2019-2020 Andrew Myers, Yinjian Zhao
2  *
3  * This file is part of WarpX.
4  *
5  * License: BSD-3-Clause-LBNL
6  */
7 #ifndef WARPX_PARTICLES_COLLISION_COMPUTE_TEMPERATURE_H_
8 #define WARPX_PARTICLES_COLLISION_COMPUTE_TEMPERATURE_H_
9 
10 #include "Utils/WarpXConst.H"
11 
12 
13 template <typename T_index, typename T_R>
16  T_index const Is, T_index const Ie, T_index const * AMREX_RESTRICT I,
17  T_R const * AMREX_RESTRICT w,
18  T_R const * AMREX_RESTRICT ux, T_R const * AMREX_RESTRICT uy, T_R const * AMREX_RESTRICT uz,
19  T_R const m )
20 {
21 
22  T_R constexpr inv_c2 = T_R(1.0) / ( PhysConst::c * PhysConst::c );
23 
24  const int N = Ie - Is;
25  if ( N == 0 ) { return T_R(0.0); }
26 
27  T_R vx = T_R(0.0); T_R vy = T_R(0.0);
28  T_R vz = T_R(0.0); T_R vs = T_R(0.0);
29  T_R gm = T_R(0.0); T_R us = T_R(0.0);
30  T_R wtot = T_R(0.0);
31 
32  for (int i = Is; i < static_cast<int>(Ie); ++i)
33  {
34  us = ( ux[ I[i] ] * ux[ I[i] ] +
35  uy[ I[i] ] * uy[ I[i] ] +
36  uz[ I[i] ] * uz[ I[i] ] );
37  gm = std::sqrt( T_R(1.0) + us*inv_c2 );
38  wtot += w[ I[i] ];
39  vx += w[ I[i] ] * ux[ I[i] ] / gm;
40  vy += w[ I[i] ] * uy[ I[i] ] / gm;
41  vz += w[ I[i] ] * uz[ I[i] ] / gm;
42  vs += w[ I[i] ] * us / gm / gm;
43  }
44 
45  vx = vx / wtot; vy = vy / wtot;
46  vz = vz / wtot; vs = vs / wtot;
47 
48  return m/T_R(3.0)*(vs-(vx*vx+vy*vy+vz*vz));
49 }
50 
51 #endif // WARPX_PARTICLES_COLLISION_COMPUTE_TEMPERATURE_H_
#define AMREX_GPU_HOST_DEVICE
AMREX_GPU_HOST_DEVICE T_R ComputeTemperature(T_index const Is, T_index const Ie, T_index const *AMREX_RESTRICT I, T_R const *AMREX_RESTRICT w, T_R const *AMREX_RESTRICT ux, T_R const *AMREX_RESTRICT uy, T_R const *AMREX_RESTRICT uz, T_R const m)
Definition: ComputeTemperature.H:15
static constexpr auto c
vacuum speed of light [m/s]
Definition: constant.H:44
i
Definition: check_interp_points_and_weights.py:174
tuple w
Definition: yt3d_mpi.py:46