Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
Classes | Namespaces | Macros | Variables
Constants.hpp File Reference
#include "ConversionConstants.hpp"
#include "Names.hpp"
#include "UnitSystem.hpp"
#include "details/utils.hpp"
#include <stdexcept>
+ Include dependency graph for Constants.hpp:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  shamunits::Constants< T >
 Physical constants. More...
 
struct  shamunits::Constants< T >::Si
 Physical constant in SI units. More...
 

Namespaces

namespace  shamunits
 namespace containing the units library
 

Macros

#define addconstant(name)
 Macro to add a constant to the shamunits::Constants class For example one can add a new constant by adding the following statement inside shamunits::Constants.
 
#define Uget(unitname, mult_pow)   units.template get<None, units::unitname, (mult_pow) * power>()
 Utility macro to get the value of a unit in the current unit system with its power.
 
#define Cget(constant_name, mult_pow)    details::pow_constexpr_fast_inv<(mult_pow) * power>(constant_name, 1 / constant_name)
 Utility macro to get the value of a constant in the current unit system with its power.
 
#define UNITS_CONSTANTS
 X macro to list all constants conversion & bindings.
 
#define X(name, conv)    addconstant(name) { return Cget(Si::name, 1) * conv; }
 Define the constant conversions functions.
 

Variables

template<class T >
constexpr T shamunits::pi = 3.141592653589793116
 Value of pi Usage : auto pi = shamunits::pi<T>;
 
template<class T >
constexpr T shamunits::fine_structure = 0.0072973525693
 Fine structure constant.
 
template<class T >
constexpr T shamunits::proton_electron_ratio = 1836.1526734311
 Mass ration between the proton and electron.
 
template<class T >
constexpr T shamunits::electron_proton_ratio = 1 / proton_electron_ratio<T>
 Mass ration between the electron and proton.
 

Detailed Description

Author
David Fang (david.nosp@m..fan.nosp@m.g@ikm.nosp@m.ail..nosp@m.com)
Timothée David–Cléris (tim.s.nosp@m.hamr.nosp@m.ock@p.nosp@m.roto.nosp@m.n.me)
Yona Lapeyre (yona..nosp@m.lape.nosp@m.yre@e.nosp@m.ns-l.nosp@m.yon.f.nosp@m.r)

Definition in file Constants.hpp.

Macro Definition Documentation

◆ addconstant

#define addconstant (   name)
Value:
template<int power = 1> \
inline constexpr T name()

Macro to add a constant to the shamunits::Constants class For example one can add a new constant by adding the following statement inside shamunits::Constants.

addconstant(delta_nu_cs) { return Cget(Si::delta_nu_cs,1) * Uget(Hertz, 1); }
#define addconstant(name)
Macro to add a constant to the shamunits::Constants class For example one can add a new constant by a...
Definition Constants.hpp:32
#define Uget(unitname, mult_pow)
Utility macro to get the value of a unit in the current unit system with its power.
Definition Constants.hpp:37
#define Cget(constant_name, mult_pow)
Utility macro to get the value of a constant in the current unit system with its power.
Definition Constants.hpp:40

Definition at line 32 of file Constants.hpp.

◆ Cget

#define Cget (   constant_name,
  mult_pow 
)     details::pow_constexpr_fast_inv<(mult_pow) * power>(constant_name, 1 / constant_name)

Utility macro to get the value of a constant in the current unit system with its power.

Definition at line 40 of file Constants.hpp.

◆ Uget

#define Uget (   unitname,
  mult_pow 
)    units.template get<None, units::unitname, (mult_pow) * power>()

Utility macro to get the value of a unit in the current unit system with its power.

Definition at line 37 of file Constants.hpp.

◆ UNITS_CONSTANTS

#define UNITS_CONSTANTS

X macro to list all constants conversion & bindings.

Definition at line 44 of file Constants.hpp.

◆ X

#define X (   name,
  conv 
)     addconstant(name) { return Cget(Si::name, 1) * conv; }

Define the constant conversions functions.

Definition at line 173 of file Constants.hpp.