rssn_advanced/
constant.rs

1#![allow(clippy::inline_always)]
2
3/// The date the library was built.
4
5pub const BUILD_DATE: &str =
6    env!("VERGEN_BUILD_DATE");
7
8/// The Git commit SHA the library was built from.
9
10pub const COMMIT_SHA: &str =
11    env!("VERGEN_GIT_SHA");
12
13/// The version of the Rust compiler used to build the library.
14
15pub const RUSTC_VERSION: &str =
16    env!("VERGEN_RUSTC_SEMVER");
17
18/// The target triple for which the library was built.
19
20pub const CARGO_TARGET_TRIPLE: &str =
21    env!("VERGEN_CARGO_TARGET_TRIPLE");
22
23/// Operating system and version information of the build environment.
24
25pub const SYSTEM_INFO: &str =
26    env!("VERGEN_SYSINFO_OS_VERSION");
27
28// --- Getter functions ---
29
30/// Returns the build date (e.g., "2023-10-24").
31///
32/// # Examples
33///
34/// ```
35/// 
36/// use rssn::constant::get_build_date;
37///
38/// let date = get_build_date();
39///
40/// assert!(!date.is_empty());
41/// ```
42#[must_use]
43#[inline(always)]
44
45pub const fn get_build_date()
46-> &'static str {
47
48    BUILD_DATE
49}
50
51/// Returns the Git short SHA for the current commit.
52///
53/// # Examples
54///
55/// ```
56/// 
57/// use rssn::constant::get_commit_sha;
58///
59/// let sha = get_commit_sha();
60///
61/// assert!(!sha.is_empty());
62/// ```
63#[must_use]
64#[inline(always)]
65
66pub const fn get_commit_sha()
67-> &'static str {
68
69    COMMIT_SHA
70}
71
72/// Returns the rustc semantic version (e.g., "1.70.0-nightly").
73///
74/// # Examples
75///
76/// ```
77/// 
78/// use rssn::constant::get_rustc_version;
79///
80/// let version = get_rustc_version();
81///
82/// assert!(!version.is_empty());
83/// ```
84#[must_use]
85#[inline(always)]
86
87pub const fn get_rustc_version()
88-> &'static str {
89
90    RUSTC_VERSION
91}
92
93/// Returns the Cargo target triple (e.g., "x86_64-unknown-linux-gnu").
94///
95/// # Examples
96///
97/// ```
98/// 
99/// use rssn::constant::get_cargo_target_triple;
100///
101/// let triple = get_cargo_target_triple();
102///
103/// assert!(!triple.is_empty());
104/// ```
105#[must_use]
106#[inline(always)]
107
108pub const fn get_cargo_target_triple()
109-> &'static str {
110
111    CARGO_TARGET_TRIPLE
112}
113
114/// Returns the system information string (e.g., "Linux Arch Linux").
115///
116/// # Examples
117///
118/// ```
119/// 
120/// use rssn::constant::get_system_info;
121///
122/// let sys_info = get_system_info();
123///
124/// assert!(!sys_info.is_empty());
125/// ```
126#[must_use]
127#[inline(always)]
128
129pub const fn get_system_info()
130-> &'static str {
131
132    SYSTEM_INFO
133}
134
135// --- Math & Physics Constants ---
136
137macro_rules! nist_const {
138    ($const_name:ident, $fn_name:ident, $value:expr_2021, $unit:expr_2021, $uncert:expr_2021, $desc:expr_2021) => {
139        #[doc = concat!($desc, "\n\n**Value:** ", stringify!($value), " ", $unit, "\n**Uncertainty:** ", $uncert)]
140        pub const $const_name: f64 = $value;
141
142        #[doc = concat!("Returns the ", $desc)]
143        #[must_use]
144        #[inline(always)]
145        pub const fn $fn_name() -> f64 {
146            $const_name
147        }
148    };
149}
150
151// --- Fundamental Constants ---
152
153nist_const!(
154    SPEED_OF_LIGHT,
155    get_speed_of_light,
156    299_792_458.0,
157    "m s⁻¹",
158    "exact",
159    "speed of light in vacuum"
160); // [cite: 16, 18, 19]
161
162nist_const!(
163    PLANCK_CONSTANT,
164    get_planck_constant,
165    6.626_070_15e-34,
166    "J Hz⁻¹",
167    "exact",
168    "Planck constant"
169); // [cite: 28, 30, 31]
170
171nist_const!(
172    ELEMENTARY_CHARGE,
173    get_elementary_charge,
174    1.602_176_634e-19,
175    "C",
176    "exact",
177    "elementary charge"
178); // [cite: 57, 59, 60]
179
180nist_const!(
181    BOLTZMANN_CONSTANT,
182    get_boltzmann_constant,
183    1.380_649e-23,
184    "J K⁻¹",
185    "exact",
186    "Boltzmann constant"
187); // [cite: 227, 229, 230]
188
189nist_const!(
190    AVOGADRO_CONSTANT,
191    get_avogadro_constant,
192    6.022_140_76e23,
193    "mol⁻¹",
194    "exact",
195    "Avogadro constant"
196); // [cite: 235, 237, 238]
197
198// --- Measured Constants (with uncertainty) ---
199
200nist_const!(
201    GRAVITATIONAL_CONSTANT,
202    get_gravitational_constant,
203    6.674_30e-11,
204    "m³ kg⁻¹ s⁻²",
205    "0.00015 x 10⁻¹¹",
206    "Newtonian constant of gravitation"
207); // [cite: 24, 26, 27]
208
209nist_const!(
210    ELECTRON_MASS,
211    get_electron_mass,
212    9.109_383_713_9e-31,
213    "kg",
214    "2.8e-40",
215    "electron mass"
216); // [cite: 147, 149, 150]
217
218nist_const!(
219    FINE_STRUCTURE_CONSTANT,
220    get_fine_structure_constant,
221    7.297_352_564_3e-3,
222    "dimensionless",
223    "0.000_000_001_1e-3",
224    "fine-structure constant"
225); // [cite: 121, 123]
226
227nist_const!(
228    RYDBERG_CONSTANT,
229    get_rydberg_constant,
230    10_973_731.568_157,
231    "m⁻¹",
232    "0.000_000_012",
233    "Rydberg constant"
234); // [cite: 134, 136, 137]
235
236nist_const!(
237    VACUUM_ELECTRIC_PERMITTIVITY,
238    get_vacuum_electric_permittivity,
239    8.854_187_818_8e-12,
240    "F m⁻¹",
241    "0.000_000_001_4e-12",
242    "vacuum electric permittivity"
243); // [cite: 74, 76]
244
245// --- Electromagnetic Constants ---
246
247nist_const!(
248    VACUUM_MAGNETIC_PERMEABILITY,
249    get_vacuum_magnetic_permeability,
250    1.256_637_061_27e-6,
251    "N A⁻²",
252    "0.000_000_000_20e-6",
253    "vacuum magnetic permeability"
254); // [cite: 65, 66, 67]
255
256nist_const!(
257    JOSEPHSON_CONSTANT,
258    get_josephson_constant,
259    483_597.848_4e9,
260    "Hz V⁻¹",
261    "exact (definition based)",
262    "Josephson constant (2e/h)"
263); // [cite: 82, 84, 85]
264
265nist_const!(
266    VON_KLITZING_CONSTANT,
267    get_von_klitzing_constant,
268    25_812.807_45,
269    "Ω",
270    "exact (definition based)",
271    "von Klitzing constant (h/e²)"
272); // [cite: 90, 92, 93]
273
274nist_const!(
275    MAGNETIC_FLUX_QUANTUM,
276    get_magnetic_flux_quantum,
277    2.067_833_848e-15,
278    "Wb",
279    "exact (definition based)",
280    "magnetic flux quantum (h/2e)"
281); // [cite: 96, 98, 100]
282
283// --- Atomic & Particle Masses ---
284
285nist_const!(
286    PROTON_MASS_KG,
287    get_proton_mass_kg,
288    1.672_621_925_95e-27,
289    "kg",
290    "0.000_000_000_52e-27",
291    "proton mass"
292); // [cite: 35, 36]
293
294nist_const!(
295    NEUTRON_MASS_U,
296    get_neutron_mass_u,
297    1.008_664_916_06,
298    "u",
299    "0.000_000_000_40",
300    "neutron mass in atomic mass units"
301); // [cite: 174, 182, 183]
302
303nist_const!(
304    ATOMIC_MASS_CONSTANT,
305    get_atomic_mass_constant,
306    1.660_539_068_92e-27,
307    "kg",
308    "0.000_000_000_52e-27",
309    "atomic mass constant (m_u)"
310); // [cite: 243, 244, 245]
311
312nist_const!(
313    PROTON_ELECTRON_MASS_RATIO,
314    get_proton_electron_mass_ratio,
315    1_836.152_673_426,
316    "dimensionless",
317    "0.000_000_032",
318    "proton-electron mass ratio"
319); // [cite: 54, 56]
320
321// --- Magnetic Moments & Factors ---
322
323nist_const!(
324    BOHR_MAGNETON,
325    get_bohr_magneton,
326    9.274_010_065_7e-24,
327    "J T⁻¹",
328    "0.000_000_002_9e-24",
329    "Bohr magneton"
330); // [cite: 101, 103, 107]
331
332nist_const!(
333    NUCLEAR_MAGNETON,
334    get_nuclear_magneton,
335    5.050_783_739_3e-27,
336    "J T⁻¹",
337    "0.000_000_001_6e-27",
338    "nuclear magneton"
339); // [cite: 114, 116, 117]
340
341nist_const!(
342    ELECTRON_G_FACTOR,
343    get_electron_g_factor,
344    -2.002_319_304_360_92,
345    "dimensionless",
346    "0.000_000_000_000_36",
347    "electron g-factor"
348); // [cite: 259, 265, 266]
349
350// --- Physico-Chemical Constants ---
351
352nist_const!(
353    MOLAR_GAS_CONSTANT,
354    get_molar_gas_constant,
355    8.314_462_618,
356    "J mol⁻¹ K⁻¹",
357    "exact (defined by R = Na * k)",
358    "molar gas constant"
359); // [cite: 261, 262, 263, 264]
360
361nist_const!(
362    FARADAY_CONSTANT,
363    get_faraday_constant,
364    96_485.332_12,
365    "C mol⁻¹",
366    "exact (defined by F = Na * e)",
367    "Faraday constant"
368); // [cite: 255, 256, 257, 258]
369
370nist_const!(
371    STEFAN_BOLTZMANN_CONSTANT,
372    get_stefan_boltzmann_constant,
373    5.670_374_419e-8,
374    "W m⁻² K⁻⁴",
375    "exact (calculated from k, h, c)",
376    "Stefan-Boltzmann constant"
377); // [cite: 312, 313, 317]
378
379// --- Additional Fundamental & Quantum Constants ---
380
381nist_const!(
382    REDUCED_PLANCK_CONSTANT,
383    get_reduced_planck_constant,
384    1.054_571_817e-34,
385    "J s",
386    "uncertainty in source",
387    "reduced Planck constant (h-bar)"
388); //
389
390nist_const!(
391    INVERSE_FINE_STRUCTURE_CONSTANT,
392    get_inverse_fine_structure_constant,
393    137.035_999_177,
394    "dimensionless",
395    "0.000_000_021",
396    "inverse fine-structure constant \
397     (1/α)"
398); //
399
400nist_const!(
401    BOHR_RADIUS,
402    get_bohr_radius,
403    5.291_772_105_44e-11,
404    "m",
405    "0.000_000_000_82e-11",
406    "Bohr radius (a₀)"
407); //
408
409nist_const!(
410    HARTREE_ENERGY,
411    get_hartree_energy,
412    4.359_744_722_206_0e-18,
413    "J",
414    "0.000_000_000_004_8e-18",
415    "Hartree energy (Eh)"
416); //
417
418// --- Particle Masses (Atomic Units) ---
419
420nist_const!(
421    ELECTRON_MASS_U,
422    get_electron_mass_u,
423    5.485_799_090_441e-4,
424    "u",
425    "0.000_000_000_097e-4",
426    "electron mass in atomic mass \
427     units"
428); //
429
430nist_const!(
431    PROTON_MASS_U,
432    get_proton_mass_u,
433    1.007_276_466_578_9,
434    "u",
435    "0.000_000_000_008_3",
436    "proton mass in atomic mass units"
437); //
438
439nist_const!(
440    DEUTERON_MASS_U,
441    get_deuteron_mass_u,
442    2.013_553_212_544,
443    "u",
444    "0.000_000_000_015",
445    "deuteron mass in atomic mass \
446     units"
447); //
448
449nist_const!(
450    ALPHA_PARTICLE_MASS_U,
451    get_alpha_particle_mass_u,
452    4.001_506_179_129,
453    "u",
454    "0.000_000_000_062",
455    "alpha particle mass in atomic \
456     mass units"
457); //
458
459// --- Electromagnetic Interaction ---
460
461nist_const!(
462    CLASSICAL_ELECTRON_RADIUS,
463    get_classical_electron_radius,
464    2.817_940_320_5e-15,
465    "m",
466    "0.000_000_001_3e-15",
467    "classical electron radius"
468); //
469
470nist_const!(
471    THOMSON_CROSS_SECTION,
472    get_thomson_cross_section,
473    6.652_458_705_1e-29,
474    "m²",
475    "0.000_000_006_2e-29",
476    "Thomson cross section"
477); //
478
479// --- Radiation Constants ---
480
481nist_const!(
482    WIEN_DISPLACEMENT_CONSTANT,
483    get_wien_displacement_constant,
484    2.897_771_955e-3,
485    "m K",
486    "exact (calculated)",
487    "Wien displacement law constant \
488     (b)"
489); //
490
491nist_const!(
492    FIRST_RADIATION_CONSTANT,
493    get_first_radiation_constant,
494    3.741_771_852e-16,
495    "W m²",
496    "exact (calculated)",
497    "first radiation constant (c₁)"
498); //
499
500nist_const!(
501    SECOND_RADIATION_CONSTANT,
502    get_second_radiation_constant,
503    1.438_776_877e-2,
504    "m K",
505    "exact (calculated)",
506    "second radiation constant (c₂)"
507); //
508
509// --- Muon Data ---
510nist_const!(
511    MUON_G_FACTOR,
512    get_muon_g_factor,
513    -2.002_331_841_23,
514    "dimensionless",
515    "0.000_000_000_82",
516    "muon g-factor"
517); // [cite: 20-23]
518
519nist_const!(
520    MUON_MASS_U,
521    get_muon_mass_u,
522    0.113_428_925_7,
523    "u",
524    "0.000_000_002_5",
525    "muon mass in atomic mass units"
526); // [cite: 272-273]
527
528nist_const!(
529    MUON_ELECTRON_MASS_RATIO,
530    get_muon_electron_mass_ratio,
531    206.768_282_7,
532    "dimensionless",
533    "0.000_004_6",
534    "muon-electron mass ratio"
535); // [cite: 278]
536
537// --- Magnetic Moments & Shielding ---
538nist_const!(
539    PROTON_MAGNETIC_MOMENT,
540    get_proton_magnetic_moment,
541    1.410_606_795_45e-26,
542    "J T⁻¹",
543    "0.000_000_000_60e-26",
544    "proton magnetic moment"
545); // [cite: 61-63]
546
547nist_const!(
548    NEUTRON_MAGNETIC_MOMENT,
549    get_neutron_magnetic_moment,
550    -9.662_365_3e-27,
551    "J T⁻¹",
552    "0.000_002_3e-27",
553    "neutron magnetic moment"
554); // [cite: 188-189]
555
556nist_const!(
557    PROTON_MAGNETIC_SHIELDING_CORRECTION, get_proton_magnetic_shielding_correction,
558    2.567_15e-5, "dimensionless", "0.000_41e-5",
559    "proton magnetic shielding correction (H2O sphere, 25°C)"
560); // [cite: 77-78, 81]
561
562nist_const!(
563    SHIELDED_PROTON_GYROMAGNETIC_RATIO, get_shielded_proton_gyromagnetic_ratio,
564    2.675_153_194e8, "s⁻¹ T⁻¹", "0.000_000_011e8",
565    "shielded proton gyromagnetic ratio (H2O, sphere, 25°C)"
566); // [cite: 104-106, 108]
567
568// --- Mass Ratios & Specific Quotients ---
569nist_const!(
570    NEUTRON_PROTON_MASS_RATIO,
571    get_neutron_proton_mass_ratio,
572    1.001_378_419_46,
573    "dimensionless",
574    "0.000_000_000_40",
575    "neutron-proton mass ratio"
576); // [cite: 186-187]
577
578nist_const!(
579    ELECTRON_MUON_MASS_RATIO,
580    get_electron_muon_mass_ratio,
581    4.836_331_70e-3,
582    "dimensionless",
583    "0.000_000_11e-3",
584    "electron-muon mass ratio"
585); // [cite: 158-160]
586
587nist_const!(
588    DEUTERON_PROTON_MASS_RATIO,
589    get_deuteron_proton_mass_ratio,
590    1.999_007_501_269_9,
591    "dimensionless",
592    "0.000_000_000_008_4",
593    "deuteron-proton mass ratio"
594); // [cite: 200-201]
595
596nist_const!(
597    ELECTRON_CHARGE_TO_MASS_QUOTIENT, get_electron_charge_to_mass_quotient,
598    -1.758_820_008_38e11, "C kg⁻¹", "0.000_000_000_55e11",
599    "electron charge to mass quotient"
600); // [cite: 163-164, 170-171]
601
602// --- Physicochemical Data ---
603nist_const!(
604    MOLAR_VOLUME_IDEAL_GAS,
605    get_molar_volume_ideal_gas,
606    22.413_969_54e-3,
607    "m³ mol⁻¹",
608    "exact (at 273.15 K, 101.325 kPa)",
609    "molar volume of ideal gas"
610); // [cite: 308-311]
611
612nist_const!(
613    MUON_MAGNETIC_MOMENT,
614    get_muon_magnetic_moment,
615    -4.490_448_30e-26,
616    "J T⁻¹",
617    "0.000_000_10e-26",
618    "muon magnetic moment"
619);