1 #ifndef BASIC_PHYSICS_HPP
2 #define BASIC_PHYSICS_HPP
15 KOKKOS_INLINE_FUNCTION
double maxwellian_dist(
double den,
double temp,
double energy){
16 return den/(temp*sqrt(temp))*exp(-min(
EXP_LIM,energy/temp));
24 return 1.0/sqrt(temp)*exp(-min(
EXP_LIM,energy/temp)) / (1.0-exp(-maxe));
32 return 1.0/temp*exp(-min(
EXP_LIM,energy/temp)) / (1.0-exp(-maxe));
43 KOKKOS_INLINE_FUNCTION
double exp_ad(
double x){
44 #ifdef USE_LINEAR_ADIABATIC_RESPONSE
45 constexpr
bool use_linear =
true;
47 constexpr
bool use_linear =
false;
50 #ifdef LINEAR_ADIABATIC_RESPONSE_BD
51 constexpr
double lim=LINEAR_ADIABATIC_RESPONSE_BD;
53 constexpr
double lim=0.7;
55 if constexpr(use_linear){
56 double tmp = exp(-abs(x)+lim)*(1-lim);
57 double tmp2 = (x<-lim ? tmp : 1.0+x);
58 return (x>lim ? 2.0-tmp : tmp2);
65 KOKKOS_INLINE_FUNCTION
double gyro_radius(
double B,
double mu,
double c2_2m){
66 return sqrt(mu/(B*c2_2m));
75 return sqrt((temp_ev*
EV_2_J)/mass);
85 return v*sqrt(mass/(temp_ev*
EV_2_J));
96 KOKKOS_INLINE_FUNCTION
double normalized_v_para(
double c_m,
double mass,
double B,
double temp_ev,
double rho){
97 return c_m*rho*B*sqrt(mass/(temp_ev*
EV_2_J));
107 return sqrt(mu*2.0*B/(temp_ev*
EV_2_J));
111 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){
112 en = mu*B + c2_2m*(rho*rho*B*B);
113 double v_para = c_m*rho*B;
114 double v_perp2 = 2.0*mu*B/mass;
115 pitch=v_para/sqrt(v_para*v_para + v_perp2);
119 KOKKOS_INLINE_FUNCTION
void en_pitch_to_rho_mu(
double B,
double c_m,
double mass,
double en,
double pitch,
double& rho,
double& mu){
120 rho = pitch*sqrt(2.0*en/mass)/(B*c_m);
121 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:96
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:74
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:119
KOKKOS_INLINE_FUNCTION double maxwellian_dist(double den, double temp, double energy)
Definition: basic_physics.hpp:15
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:111
KOKKOS_INLINE_FUNCTION double maxwellian_dist_1d_v(double temp, double energy, double maxe)
Definition: basic_physics.hpp:23
KOKKOS_INLINE_FUNCTION double normalize_to_vth(double mass, double temp_ev, double v)
Definition: basic_physics.hpp:84
KOKKOS_INLINE_FUNCTION double normalized_sqrt_mu(double B, double temp_ev, double mu)
Definition: basic_physics.hpp:106
KOKKOS_INLINE_FUNCTION double maxwellian_dist_2d_v(double temp, double energy, double maxe)
Definition: basic_physics.hpp:31
KOKKOS_INLINE_FUNCTION double exp_ad(double x)
Definition: basic_physics.hpp:43
const double EXP_LIM
Limit of exponents.
Definition: constants.hpp:14