32#define addconstant(name) \
33 template<int power = 1> \
34 inline constexpr T name()
37#define Uget(unitname, mult_pow) units.template get<None, units::unitname, (mult_pow) * power>()
40#define Cget(constant_name, mult_pow) \
41 details::pow_constexpr_fast_inv<(mult_pow) * power>(constant_name, 1 / constant_name)
44#define UNITS_CONSTANTS \
46 X(delta_nu_cs , Uget(Hertz, 1)) \
47 X(c , Uget(m, 1) * Uget(s, -1)) \
48 X(h , Uget(Joule, 1) * Uget(s, -1)) \
49 X(e , Uget(Coulomb, 1)) \
50 X(k , Uget(Joule, 1) * Uget(Kelvin, -1)) \
51 X(Na , Uget(mole, -1)) \
52 X(Kcd , Uget(lm, 1) * Uget(Watt, -1)) \
54 X(second , Uget(s, 1)) \
55 X(minute , Uget(s, 1)) \
56 X(hour , Uget(s, 1)) \
58 X(year , Uget(s, 1)) \
61 X(astronomical_unit , Uget(m, 1)) \
62 X(light_year , Uget(m, 1)) \
63 X(parsec , Uget(m, 1)) \
64 X(solar_radius , Uget(m, 1)) \
65 X(earth_radius , Uget(m, 1)) \
66 X(planck_length , Uget(m, 1)) \
68 X(proton_mass , Uget(kg, 1)) \
69 X(electron_mass , Uget(kg, 1)) \
70 X(earth_mass , Uget(kg, 1)) \
71 X(jupiter_mass , Uget(kg, 1)) \
72 X(sol_mass , Uget(kg, 1)) \
73 X(planck_mass , Uget(kg, 1)) \
74 X(dalton , Uget(kg, 1)) \
76 X(guiness_density, Uget(kg, 1) * Uget(m, -1)) \
78 X(G , Uget(N, 1) * Uget(m, 2) * Uget(kg, -2)) \
79 X(hbar , Uget(Joule, 1) * Uget(s, -1)) \
80 X(mu_0 , Uget(N, 1) * Uget(A, -2)) \
81 X(Z_0 , Uget(Ohm, 1)) \
82 X(epsilon_0 , Uget(F, 1) * Uget(m, -1)) \
83 X(ke , Uget(N, 1) * Uget(m, 2) * Uget(Coulomb, -2)) \
84 X(kb , Uget(J, 1) * Uget(K, -1)) \
85 X(sigma , Uget(W, 1) * Uget(m, -2) * Uget(K, -4))
94 constexpr T
pi = 3.141592653589793116;
122 static constexpr T
c = 299792458;
123 static constexpr T
h = 6.62607015e-34;
124 static constexpr T
e = 1.602176634e-19;
125 static constexpr T
k = 1.380649e-23;
126 static constexpr T
Na = 6.02214076e23;
127 static constexpr T
Kcd = 683;
130 static constexpr T
G = 6.6743015e-11;
131 static constexpr T
hbar =
h / (2 * pi<T>);
132 static constexpr T
mu_0 = 1.2566370621219e-6;
136 static constexpr T
kb = 1.380649e-23;
139 static constexpr T
sigma = 5.670374419e-8;
141 static constexpr T second = 1;
161 static constexpr T dalton = 1.66053906892e-27;
173#define X(name, conv) \
174 addconstant(name) { return Cget(Si::name, 1) * conv; }
#define UNITS_CONSTANTS
X macro to list all constants conversion & bindings.
namespace containing the units library
constexpr T electron_proton_ratio
Mass ration between the electron and proton.
constexpr T pi
Value of pi Usage : auto pi = shamunits::pi<T>;
constexpr T fine_structure
Fine structure constant.
constexpr T proton_electron_ratio
Mass ration between the proton and electron.
Physical constant in SI units.
static constexpr T Na
get Na in the si unit system (mol-1 )
static constexpr T planck_length
get the value of a planck_length in the distance unit of the si unit system (m)
static constexpr T k
get k in the si unit system (J.K-1 )
static constexpr T hour
get the value of a hour in the time unit of the si unit system (s)
static constexpr T electron_mass
get the value of a electron_mass in the mass unit of the si unit system (kg)
static constexpr T parsec
get the value of a parsec in the distance unit of the si unit system (m)
static constexpr T c
get c in the si unit system (m.s-1)
static constexpr T Z_0
get the value of Z_0 in the si unit system (Ohm)
static constexpr T kb
get the value of kb in the si unit system (J.K-1)
static constexpr T mu_0
get the value of mu_0 in the si unit system (N.A-2)
static constexpr T ke
get the value of ke in the si unit system (N.m2.C-2)
static constexpr T earth_mass
get the value of a earth_mass in the mass unit of the si unit system (kg)
static constexpr T light_year
get the value of a light_year in the distance unit of the si unit system (m)
static constexpr T solar_radius
get the value of a solar radius in the distance unit of the si unit system (m)
static constexpr T delta_nu_cs
get delta_nu_cs in the si unit system (s-1)
static constexpr T au
get the value of an au in the distance unit of the si unit system (m)
static constexpr T planck_mass
get the value of a planck_mass in the mass unit of the si unit system (kg)
static constexpr T sigma
Stephan Boltzmann constant (W.m-2.K-4)
static constexpr T epsilon_0
get the value of epsilon_0 in the si unit system (F.m-1)
static constexpr T hbar
get the value of hbar in the si unit system (J.s-1)
static constexpr T Kcd
get Kcd in the si unit system (lm.W-1)
static constexpr T proton_mass
get the value of a proton_mass in the mass unit of the si unit system (kg)
static constexpr T G
get the value of G in the si unit system (N.m2.kg-2)
static constexpr T h
get h in the si unit system (J.s-1)
static constexpr T year
get the value of a year in the time unit of the si unit system (s)
static constexpr T sol_mass
get the value of a sol_mass in the mass unit of the si unit system (kg)
static constexpr T jupiter_mass
get the value of a jupiter_mass in the mass unit of the si unit system (kg)
static constexpr T guiness_density
get the value of a guiness_density in the density of the si unit system (kg.m-3)
static constexpr T astronomical_unit
get the value of an astronomical_unit in the distance unit of the si unit system (m)
static constexpr T earth_radius
get the value of one earth equatorial radius in the distance unit of the si unit system (m)
static constexpr T day
get the value of a day in the time unit of the si unit system (s)
static constexpr T e
get e in the si unit system (C)
Constants(const UnitSystem< T > units)
Construct the shamunits::Constants class with a unit system.
const UnitSystem< T > units
Current unit system of the constants.
static constexpr T pc_to_m
conversion factor from parsecs to meters
static constexpr T dy_to_s
conversion factor from days to seconds
static constexpr T hr_to_s
conversion factor from hours to seconds
static constexpr T ly_to_m
conversion factor from light years to meters
static constexpr T yr_to_s
conversion factor from years to seconds
static constexpr T rsol_to_m
conversion factor from solar radii to meters
static constexpr T gcm3_to_guiness_density
static constexpr T rearth_to_m
conversion factor from earth equatorial radii to meters
static constexpr T au_to_m
conversion factor from au to meters
static constexpr T mn_to_s
conversion factor from minutes to seconds