54#ifndef CONSTANTS_IN_ARTS_H
55#define CONSTANTS_IN_ARTS_H
66constexpr auto pow2(T x)
noexcept ->
decltype(x * x) {
72constexpr auto pow3(T x)
noexcept ->
decltype(
pow2(x) * x) {
114 3.141592653589793238462643383279502884197169399375105820974944592307816406286;
117static constexpr Numeric inv_pi =
118 0.3183098861837906715377675267450287240689192914809128974953346881177935952685;
121static constexpr Numeric two_pi =
122 6.283185307179586476925286766559005768394338798750211641949889184615632812572;
125static constexpr Numeric inv_two_pi =
126 0.1591549430918953357688837633725143620344596457404564487476673440588967976342;
129static constexpr Numeric sqrt_pi =
130 1.772453850905516027298167483341145182797549456122387128213807789852911284591;
133static constexpr Numeric inv_sqrt_pi =
134 0.5641895835477562869480794515607725858440506293289988568440857217106424684415;
137static constexpr Numeric euler =
138 2.718281828459045235360287471352662497757247093699959574966967627724076630354;
141static constexpr Numeric inv_euler =
142 0.3678794411714423215955237701614608674458111310317678345078368016974614957448;
145static constexpr Numeric log10_euler =
146 0.4342944819032518276511289189166050822943970058036665661144537831658646492089;
149static constexpr Numeric ln_10 =
150 2.302585092994045684017991454684364207601101488628772976033327900967572609677;
153static constexpr Numeric sqrt_2 =
154 1.414213562373095048801688724209698078569671875376948073176679737990732478462;
157static constexpr Numeric inv_sqrt_2 =
158 0.7071067811865475244008443621048490392848359376884740365883398689953662392311;
162 0.6931471805599453094172321214581765680755001343602552541206800094933936219697;
165static constexpr Numeric inv_ln_2 =
166 1.442695040888963407359924681001892137426645954152985934135449406931109219181;
169static constexpr Numeric sqrt_ln_2 =
170 0.8325546111576977563531646448952010476305888522644407291668291172340794351973;
173static constexpr Numeric inv_sqrt_ln_2 =
174 1.201122408786449794857803286095221722566764028068699423868879896733837175546;
180static constexpr Numeric Delta_nu_Cs = 9192631770;
186static constexpr Numeric speed_of_light = 299792458;
189static constexpr Numeric c = speed_of_light;
195static constexpr Numeric planck_constant = 6.62607015e-34;
198static constexpr Numeric h = planck_constant;
201static constexpr Numeric reduced_planck_constant = h * inv_two_pi;
204static constexpr Numeric h_bar = reduced_planck_constant;
210static constexpr Numeric elementary_charge = 1.602176634e-19;
213static constexpr Numeric e = elementary_charge;
219static constexpr Numeric boltzmann_constant = 1.380649e-23;
222static constexpr Numeric k = boltzmann_constant;
228static constexpr Numeric avogadro_constant = 6.02214076e23;
231static constexpr Numeric NA = avogadro_constant;
237static constexpr Numeric K_cd = 683;
244static constexpr Numeric fine_structure_constant = 7.2973525693e-3;
247static constexpr Numeric alpha = fine_structure_constant;
254static constexpr Numeric rydberg_constant = 10973731.568160;
257static constexpr Numeric R_inf = rydberg_constant;
260static constexpr Numeric magnetic_constant = 2 * h * alpha / (
c *
pow2(e));
263static constexpr Numeric mu_0 = magnetic_constant;
266static constexpr Numeric vacuum_permittivity =
pow2(e) / (2 * h *
c * alpha);
269static constexpr Numeric epsilon_0 = vacuum_permittivity;
272static constexpr Numeric electron_mass = 2 * h * R_inf / (
c *
pow2(alpha));
275static constexpr Numeric m_e = electron_mass;
282static constexpr Numeric unified_atomic_mass_unit = 1.66053906660e-27;
285static constexpr Numeric m_u = unified_atomic_mass_unit;
292static constexpr Numeric mass_ratio_electrons_per_proton = 1'836.152'673'43;
295static constexpr Numeric proton_mass =
296 electron_mass * mass_ratio_electrons_per_proton;
303static constexpr Numeric mass_ratio_electrons_per_neutron = 1'838.683'661'73;
306static constexpr Numeric neutron_mass =
307 electron_mass * mass_ratio_electrons_per_neutron;
310static constexpr Numeric bohr_magneton = e * h_bar / (2 * m_e);
313static constexpr Numeric ideal_gas_constant = k * NA;
316static constexpr Numeric R = ideal_gas_constant;
319static constexpr Numeric doppler_broadening_const_squared = 2'000 * R /
pow2(c);
322static constexpr Numeric one_degree_in_radians = pi / 180;
331constexpr auto deg2rad(T x)
noexcept ->
decltype(x * one_degree_in_radians) {
332 return x * one_degree_in_radians;
337constexpr auto rad2deg(T x)
noexcept ->
decltype(x / one_degree_in_radians) {
338 return x / one_degree_in_radians;
378template <
class T1,
class T2>
380 return rad2deg(std::atan2(y, x));
385constexpr auto kaycm2freq(T x)
noexcept ->
decltype(x * (100 *
c)) {
386 return x * (100 *
c);
391constexpr auto freq2kaycm(T x)
noexcept ->
decltype(x / (100 *
c)) {
392 return x / (100 *
c);
411 return x * inv_two_pi;
434constexpr auto hz2ghz(T x)
noexcept ->
decltype(x * 1e-9) {
440constexpr auto ghz2hz(T x)
noexcept ->
decltype(x * 1e9) {
446constexpr auto atm2pa(T x)
noexcept ->
decltype(x * 101'325.0) {
447 return x * 101'325.0;
452constexpr auto pa2atm(T x)
noexcept ->
decltype(x / 101'325.0) {
453 return x / 101'325.0;
458constexpr auto bar2pa(T x)
noexcept ->
decltype(x * 1e5) {
464constexpr auto pa2bar(T x)
noexcept ->
decltype(x * 1e-5) {
471 return x *
atm2pa(1.0 / 760.0);
477 return x /
atm2pa(1.0 / 760.0);
483 ->
decltype(x *
pa2torr(1e6)) {
535constexpr auto hz2joule(T x)
noexcept ->
decltype(x * h) {
553constexpr auto joule2hz(T x)
noexcept ->
decltype(x / h) {
579 TimeStep,
char, hour, hours, h, minute, minutes,
min, second, seconds, s)
582ENUMCLASS(LineShapeCoeff,
char, X0, X1, X2, X3)
588ENUMCLASS(BasicCatParamJacobian,
char, LineStrength, LineCenter)
600ENUMCLASS(LblSpeedup,
char, None, QuadraticIndependent, LinearIndependent)
602ENUMCLASS(SortingOption,
char, ByFrequency, ByEinstein)
std::chrono::duration< Numeric > TimeStep
A duration of time, 1 full tick should be 1 second.
NUMERIC Numeric
The type to use for all floating point numbers.
Namespace containing several constants, physical and mathematical.
constexpr auto pow2(T x) noexcept -> decltype(x *x)
power of two
constexpr auto pow3(T x) noexcept -> decltype(pow2(x) *x)
power of three
constexpr auto pow4(T x) noexcept -> decltype(pow2(pow2(x)))
power of four
Namespace containing several practical unit conversions, physical and mathematical.
constexpr auto hz2joule(T x) noexcept -> decltype(x *h)
Conversion from MHz to Joule.
auto acosd(T x) noexcept -> decltype(rad2deg(std::acos(x)))
Returns rad2deg of the arc-cosine of the input.
constexpr auto torr2pa(T x) noexcept -> decltype(x *atm2pa(1.0/760.0))
Conversion from Torr to Pa.
constexpr auto freq2angcm(T x) noexcept -> decltype(x/kaycm2freq(inv_two_pi))
Conversion from Hz to Angular wavenumber.
auto atand(T x) noexcept -> decltype(rad2deg(std::atan(x)))
Returns rad2deg of the arc-tangent of the input.
constexpr auto atm2pa(T x) noexcept -> decltype(x *101 '325.0)
Conversion from Atm to Pa.
constexpr auto kaycm_per_atm2hz_per_pa(T x) noexcept -> decltype(x *kaycm2freq(pa2atm(1)))
Conversion from cm-1 per atmosphere to Hz per Pascal.
constexpr auto mhz_per_torr2hz_per_pa(T x) noexcept -> decltype(x *pa2torr(1e6))
Conversion from MHz/Torr to Hz/Pa.
constexpr auto freq2wavelen(T x) noexcept -> decltype(c/x)
Conversion from Hz to wavelength.
constexpr auto kelvin2celsius(T x) noexcept -> decltype(x - 273.15)
Conversion from K to C.
constexpr auto ghz2hz(T x) noexcept -> decltype(x *1e9)
Conversion from Hz to wavelength.
constexpr auto kaycm_per_cmsquared2hz_per_msquared(T x) noexcept -> decltype(x *kaycm2freq(1e-4))
Conversion from cm-1 per molecule per cm^2 to Hz per molecule per m^2.
constexpr auto kaycm2freq(T x) noexcept -> decltype(x *(100 *c))
Conversion from Kayser wavenumber to Hz.
constexpr auto pa2bar(T x) noexcept -> decltype(x *1e-5)
Conversion from Pa to bar.
constexpr auto kaycm2joule(T x) noexcept -> decltype(x *kaycm2freq(h))
Conversion from cm-1 to Joule.
auto sind(T x) noexcept -> decltype(std::sin(deg2rad(x)))
Returns the sine of the deg2rad of the input.
constexpr auto meter2angstrom(T x) noexcept -> decltype(x *1e10)
Conversion from meter to Å
constexpr auto pa2atm(T x) noexcept -> decltype(x/101 '325.0)
Conversion from Pa to Atm.
constexpr auto angstrom2meter(T x) noexcept -> decltype(x *1e-10)
Conversion from Å to meter.
auto tand(T x) noexcept -> decltype(std::tan(deg2rad(x)))
Returns the tangent of the deg2rad of the input.
constexpr auto bar2pa(T x) noexcept -> decltype(x *1e5)
Conversion from bar to Pa.
auto cosd(T x) noexcept -> decltype(std::cos(deg2rad(x)))
Returns the cosine of the deg2rad of the input.
constexpr auto angfreq2freq(T x) noexcept -> decltype(x *inv_two_pi)
Conversion from Angular Hz to Hz.
constexpr auto joule2hz(T x) noexcept -> decltype(x/h)
Conversion from Hz to Joule.
constexpr auto hz_per_msquared2kaycm_per_cmsquared(T x) noexcept -> decltype(x *freq2kaycm(1e4))
Conversion from Hz per molecule per m^2 to cm-1 per molecule per cm^2.
constexpr auto deg2rad(T x) noexcept -> decltype(x *one_degree_in_radians)
Converts degrees to radians.
constexpr auto freq2kaycm(T x) noexcept -> decltype(x/(100 *c))
Conversion from Hz to Kayser wavenumber.
constexpr auto mhz2joule(T x) noexcept -> decltype(hz2joule(x) *1e6)
Conversion from MHz to Joule.
constexpr auto joule2kaycm(T x) noexcept -> decltype(x/kaycm2freq(h))
Conversion from Joule to cm-1.
constexpr auto rad2deg(T x) noexcept -> decltype(x/one_degree_in_radians)
Converts radians to degrees.
constexpr auto kelvin2joule(T x) noexcept -> decltype(x *k)
Conversion from Kelvin to Joule.
constexpr auto celsius2kelvin(T x) noexcept -> decltype(x+273.15)
Conversion from C to K.
constexpr auto wavelen2freq(T x) noexcept -> decltype(c/x)
Conversion from wavelength to Hz.
constexpr auto hz_per_pa2kaycm_per_atm(T x) noexcept -> decltype(x *freq2kaycm(atm2pa(1)))
Conversion from Hz per Pascal to cm-1 per atmosphere.
constexpr auto hz2ghz(T x) noexcept -> decltype(x *1e-9)
Conversion from wavelength to Hz.
auto atan2d(T1 y, T2 x) noexcept -> decltype(rad2deg(std::atan2(y, x)))
Returns rad2deg of the arc-tangent of inputs #T1/#T2
constexpr auto freq2angfreq(T x) noexcept -> decltype(x *two_pi)
Conversion from Hz to Angular Hz.
constexpr auto angcm2freq(T x) noexcept -> decltype(kaycm2freq(inv_two_pi))
Conversion from Angular wavenumber to Hz.
constexpr auto pa2torr(T x) noexcept -> decltype(x/atm2pa(1.0/760.0))
Conversion from Pa to Torr.
auto asind(T x) noexcept -> decltype(rad2deg(std::asin(x)))
Returns rad2deg of the arc-sine of the input.
ENUMCLASS(TimeStep, char, hour, hours, h, minute, minutes, min, second, seconds, s) ENUMCLASS(HitranType
Keep time options available to switch over them.