aboutsummaryrefslogtreecommitdiff
path: root/Source/Particles/Collision/BinaryCollision/Coulomb/ComputeTemperature.H
diff options
context:
space:
mode:
authorGravatar Neïl Zaim <49716072+NeilZaim@users.noreply.github.com> 2022-01-04 20:43:17 +0100
committerGravatar GitHub <noreply@github.com> 2022-01-04 19:43:17 +0000
commit344f091b7103d0b04d5b6e4b781cf734ff69feb0 (patch)
treefb6131ada0aa323bd9713488dd799301a215cdd1 /Source/Particles/Collision/BinaryCollision/Coulomb/ComputeTemperature.H
parentf08f12835397b9cc05aa4a18fe2f22803501e08d (diff)
downloadWarpX-344f091b7103d0b04d5b6e4b781cf734ff69feb0.tar.gz
WarpX-344f091b7103d0b04d5b6e4b781cf734ff69feb0.tar.zst
WarpX-344f091b7103d0b04d5b6e4b781cf734ff69feb0.zip
Add Coulomb collision and nuclear fusion subfolders (#2389)
Diffstat (limited to 'Source/Particles/Collision/BinaryCollision/Coulomb/ComputeTemperature.H')
-rw-r--r--Source/Particles/Collision/BinaryCollision/Coulomb/ComputeTemperature.H47
1 files changed, 47 insertions, 0 deletions
diff --git a/Source/Particles/Collision/BinaryCollision/Coulomb/ComputeTemperature.H b/Source/Particles/Collision/BinaryCollision/Coulomb/ComputeTemperature.H
new file mode 100644
index 000000000..50e1f4a4b
--- /dev/null
+++ b/Source/Particles/Collision/BinaryCollision/Coulomb/ComputeTemperature.H
@@ -0,0 +1,47 @@
+/* Copyright 2019-2020 Andrew Myers, Yinjian Zhao
+ *
+ * This file is part of WarpX.
+ *
+ * License: BSD-3-Clause-LBNL
+ */
+#ifndef WARPX_PARTICLES_COLLISION_COMPUTE_TEMPERATURE_H_
+#define WARPX_PARTICLES_COLLISION_COMPUTE_TEMPERATURE_H_
+
+#include "Utils/WarpXConst.H"
+
+
+template <typename T_index, typename T_R>
+AMREX_GPU_HOST_DEVICE
+T_R ComputeTemperature (
+ T_index const Is, T_index const Ie, T_index const *I,
+ T_R const *ux, T_R const *uy, T_R const *uz, T_R const m )
+{
+
+ T_R constexpr inv_c2 = T_R(1.0) / ( PhysConst::c * PhysConst::c );
+
+ int N = Ie - Is;
+ if ( N == 0 ) { return T_R(0.0); }
+
+ T_R vx = T_R(0.0); T_R vy = T_R(0.0);
+ T_R vz = T_R(0.0); T_R vs = T_R(0.0);
+ T_R gm = T_R(0.0); T_R us = T_R(0.0);
+
+ for (int i = Is; i < static_cast<int>(Ie); ++i)
+ {
+ us = ( ux[ I[i] ] * ux[ I[i] ] +
+ uy[ I[i] ] * uy[ I[i] ] +
+ uz[ I[i] ] * uz[ I[i] ] );
+ gm = std::sqrt( T_R(1.0) + us*inv_c2 );
+ vx += ux[ I[i] ] / gm;
+ vy += uy[ I[i] ] / gm;
+ vz += uz[ I[i] ] / gm;
+ vs += us / gm / gm;
+ }
+
+ vx = vx / N; vy = vy / N;
+ vz = vz / N; vs = vs / N;
+
+ return m/T_R(3.0)*(vs-(vx*vx+vy*vy+vz*vz));
+}
+
+#endif // WARPX_PARTICLES_COLLISION_COMPUTE_TEMPERATURE_H_