1 #ifndef BASIC_PHYSICS_HPP
2 #define BASIC_PHYSICS_HPP
14 KOKKOS_INLINE_FUNCTION
double maxwellian_dist(
double den,
double temp,
double energy){
15 const double EXP_LIM = 64.0;
16 return den/(temp*sqrt(temp))*exp(-min(EXP_LIM,energy/temp));
27 KOKKOS_INLINE_FUNCTION
double exp_ad(
double x){
28 #ifdef USE_LINEAR_ADIABATIC_RESPONSE
29 constexpr
bool use_linear =
true;
31 constexpr
bool use_linear =
false;
34 #ifdef LINEAR_ADIABATIC_RESPONSE_BD
35 constexpr
double lim=LINEAR_ADIABATIC_RESPONSE_BD;
37 constexpr
double lim=0.7;
39 if constexpr(use_linear){
40 double tmp = exp(-abs(x)+lim)*(1-lim);
41 double tmp2 = (x<-lim ? tmp : 1.0+x);
42 return (x>lim ? 2.0-tmp : tmp2);
49 KOKKOS_INLINE_FUNCTION
double gyro_radius(
double B,
double mu,
double c2_2m){
50 return sqrt(mu/(B*c2_2m));
59 return sqrt((temp_ev*
EV_2_J)/mass);
69 return v*sqrt(mass/(temp_ev*
EV_2_J));
80 KOKKOS_INLINE_FUNCTION
double normalized_v_para(
double c_m,
double mass,
double B,
double temp_ev,
double rho){
81 return c_m*rho*B*sqrt(mass/(temp_ev*
EV_2_J));
91 return sqrt(mu*2.0*B/(temp_ev*
EV_2_J));
95 KOKKOS_INLINE_FUNCTION
void rho_mu_to_en_pitch(
double B,
double c_m,
double c2_2m,
double mass,
double rho,
double mu,
double& en,
double& pitch){
96 en = mu*B + c2_2m*(rho*rho*B*B);
97 double v_para = c_m*rho*B;
98 double v_perp2 = 2.0*mu*B/mass;
99 pitch=v_para/sqrt(v_para*v_para + v_perp2);
103 KOKKOS_INLINE_FUNCTION
void en_pitch_to_rho_mu(
double B,
double c_m,
double mass,
double en,
double pitch,
double& rho,
double& mu){
104 rho = pitch*sqrt(2.0*en/mass)/(B*c_m);
105 mu = max(0.0,(1.0-pitch*pitch)*en/B);
KOKKOS_INLINE_FUNCTION double normalized_v_para(double c_m, double mass, double B, double temp_ev, double rho)
Definition: basic_physics.hpp:80
constexpr double EV_2_J
Conversion rate ev to J.
Definition: constants.hpp:5
KOKKOS_INLINE_FUNCTION double thermal_velocity(double mass, double temp_ev)
Definition: basic_physics.hpp:58
KOKKOS_INLINE_FUNCTION void en_pitch_to_rho_mu(double B, double c_m, double mass, double en, double pitch, double &rho, double &mu)
Definition: basic_physics.hpp:103
KOKKOS_INLINE_FUNCTION double maxwellian_dist(double den, double temp, double energy)
Definition: basic_physics.hpp:14
KOKKOS_INLINE_FUNCTION double kinetic_energy(double mass, double v)
Definition: basic_physics.hpp:8
KOKKOS_INLINE_FUNCTION void rho_mu_to_en_pitch(double B, double c_m, double c2_2m, double mass, double rho, double mu, double &en, double &pitch)
Definition: basic_physics.hpp:95
KOKKOS_INLINE_FUNCTION double normalize_to_vth(double mass, double temp_ev, double v)
Definition: basic_physics.hpp:68
KOKKOS_INLINE_FUNCTION double normalized_sqrt_mu(double B, double temp_ev, double mu)
Definition: basic_physics.hpp:90
KOKKOS_INLINE_FUNCTION double exp_ad(double x)
Definition: basic_physics.hpp:27