diff options
author | 2021-10-04 21:31:53 +0200 | |
---|---|---|
committer | 2021-10-04 12:31:53 -0700 | |
commit | d0cc41acec8fbba8d66fabd3351751adf00903d7 (patch) | |
tree | a81179ac9fa9df10a5f3eee4c62eee2812a5b2f2 /Source/Particles/Collision/BinaryCollision/ComputeTemperature.H | |
parent | f32fca03f725afa92ee380884d86e116e265aee1 (diff) | |
download | WarpX-d0cc41acec8fbba8d66fabd3351751adf00903d7.tar.gz WarpX-d0cc41acec8fbba8d66fabd3351751adf00903d7.tar.zst WarpX-d0cc41acec8fbba8d66fabd3351751adf00903d7.zip |
Add structure for proton-boron fusion module (#2217)
* Add structure for proton-boron fusion module
* Fix clang compile error
* Generalize structure for other nuclear fusion types
* Workaround: try to use std::vectors to fix clang compile error
* Simplify workaround for clang
* Rebase on 2245 and add empty particle creation functor
* Apply suggestions from code review
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Add couple of consts and runtime assert
* Add another const
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
Diffstat (limited to 'Source/Particles/Collision/BinaryCollision/ComputeTemperature.H')
-rw-r--r-- | Source/Particles/Collision/BinaryCollision/ComputeTemperature.H | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/Source/Particles/Collision/BinaryCollision/ComputeTemperature.H b/Source/Particles/Collision/BinaryCollision/ComputeTemperature.H new file mode 100644 index 000000000..50e1f4a4b --- /dev/null +++ b/Source/Particles/Collision/BinaryCollision/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_ |