10#ifndef IMPACTX_ELEMENTS_MIXIN_SPIN_TRANSPORT_H
11#define IMPACTX_ELEMENTS_MIXIN_SPIN_TRANSPORT_H
46 template<
typename T_Real=amrex::ParticleReal>
61 T_Real
const angle =
sqrt(lambdax*lambdax + lambday*lambday + lambdaz*lambdaz);
64 T_Real
const w0 = cos_half_angle;
65 T_Real
const c_sin_half = -sin_half_angle / angle;
67 auto const non_zero_angle = angle!=0_prt;
76 T_Real w1 = non_zero_angle ? lambdax * c_sin_half : 0_prt;
77 T_Real w2 = non_zero_angle ? lambday * c_sin_half : 0_prt;
78 T_Real w3 = non_zero_angle ? lambdaz * c_sin_half : 0_prt;
82 T_Real
const sxout = (1_prt-2_prt*(w2*w2+w3*w3))*sx + 2_prt*(w1*w2+w0*w3)*sy + 2_prt*(w1*w3-w0*w2)*sz;
83 T_Real
const syout = 2_prt*(w1*w2-w0*w3)*sx + (1_prt-2_prt*(w1*w1+w3*w3))*sy + 2_prt*(w0*w1+w2*w3)*sz;
84 T_Real
const szout = 2_prt*(w0*w2+w1*w3)*sx + 2_prt*(w2*w3-w0*w1)*sy + (1_prt-2_prt*(w1*w1+w2*w2))*sz;
119 template<
typename T_Real=amrex::ParticleReal>
144 T_Real
const beta_gamma =
sqrt(gamma*gamma - 1_prt);
145 T_Real
const beta_gamma_z = uz * beta_gamma;
146 T_Real
const leading_factor = -(1_prt + h * x) / beta_gamma_z;
147 T_Real
const udotB = ux*Bx + uy*By + uz*Bz;
148 T_Real
const ucrossE_x = uy*Ez - uz*Ey;
149 T_Real
const ucrossE_y = uz*Ex - ux*Ez;
150 T_Real
const ucrossE_z = ux*Ey - uy*Ex;
151 T_Real
const c1 = (1_prt + gyro_anomaly*gamma);
152 T_Real
const c2 = gyro_anomaly * (gamma - 1_prt) * udotB;
153 T_Real
const c3 = (gyro_anomaly + 1_prt / (1_prt + gamma)) * beta_gamma;
154 Omegax = leading_factor * (c1 * Bx - c2 * ux - c3 * ucrossE_x);
155 Omegay = leading_factor * (c1 * By - c2 * uy - c3 * ucrossE_y) + h;
156 Omegaz = leading_factor * (c1 * Bz - c2 * uz - c3 * ucrossE_z);
#define AMREX_FORCE_INLINE
#define AMREX_GPU_HOST_DEVICE
amrex_particle_real ParticleReal
__host__ __device__ std::pair< double, double > sincos(double x)
__host__ __device__ detail::where_expression< T > where(bool const mask, T &value)
__host__ __device__ GpuComplex< T > sqrt(const GpuComplex< T > &a_z) noexcept
Definition alignment.H:25
Definition spintransport.H:36
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void tbmt_precession_vector(T_Real const &AMREX_RESTRICT x, T_Real const &AMREX_RESTRICT ux, T_Real const &AMREX_RESTRICT uy, T_Real const &AMREX_RESTRICT uz, T_Real const &AMREX_RESTRICT gamma, amrex::ParticleReal const &AMREX_RESTRICT h, amrex::ParticleReal const &AMREX_RESTRICT gyro_anomaly, T_Real const &AMREX_RESTRICT Bx, T_Real const &AMREX_RESTRICT By, T_Real const &AMREX_RESTRICT Bz, T_Real const &AMREX_RESTRICT Ex, T_Real const &AMREX_RESTRICT Ey, T_Real const &AMREX_RESTRICT Ez, T_Real &AMREX_RESTRICT Omegax, T_Real &AMREX_RESTRICT Omegay, T_Real &AMREX_RESTRICT Omegaz) const
Definition spintransport.H:121
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void rotate_spin(T_Real const &AMREX_RESTRICT lambdax, T_Real const &AMREX_RESTRICT lambday, T_Real const &AMREX_RESTRICT lambdaz, T_Real &AMREX_RESTRICT sx, T_Real &AMREX_RESTRICT sy, T_Real &AMREX_RESTRICT sz) const
Definition spintransport.H:48