Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
Classes | Enumerations | Functions | Variables
shamunits Namespace Reference

namespace containing the units library More...

Classes

struct  Constants
 Physical constants. More...
 
struct  ConversionConstants
 
class  UnitSystem
 Defines a unit system. More...
 

Enumerations

enum  UnitPrefix {
  tera = 12 , T = 12 , giga = 9 , G = 9 ,
  mega = 6 , M = 6 , kilo = 3 , k = 3 ,
  hecto = 2 , hect = 2 , deca = 1 , dec = 1 ,
  None = 0 , _ = 0 , centi = -2 , c = -2 ,
  milli = -3 , m = -3 , micro = -6 , mu = -6 ,
  nano = -9 , n = -9 , pico = -12 , p = -12 ,
  femto = -15 , f = -15
}
 Enum of all prefixes. More...
 

Functions

template<class Tscal >
void to_json (nlohmann::json &j, const ::shamunits::UnitSystem< Tscal > &p)
 Converts a UnitSystem object to a JSON object.
 
template<class Tscal >
void from_json (const nlohmann::json &j, ::shamunits::UnitSystem< Tscal > &p)
 Deserializes a UnitSystem object from a JSON object.
 
template<class T , UnitPrefix p>
constexpr T get_prefix_val ()
 Get the value of a prefix.
 
const std::string get_unit_prefix_name (UnitPrefix p)
 Get the prefix name for a UnitPrefix enum value.
 
const UnitPrefix unit_prefix_from_name (std::string p)
 Get the UnitPrefix enum value from a prefix name as a string.
 

Variables

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

Detailed Description

namespace containing the units library

Enumeration Type Documentation

◆ UnitPrefix

Enum of all prefixes.

Definition at line 89 of file Names.hpp.

Function Documentation

◆ from_json()

template<class Tscal >
void shamunits::from_json ( const nlohmann::json &  j,
::shamunits::UnitSystem< Tscal > &  p 
)
inline

Deserializes a UnitSystem object from a JSON object.

Parameters
jThe JSON object to deserialize from.
pThe UnitSystem object to populate.

Definition at line 51 of file units_json.hpp.

◆ get_prefix_val()

template<class T , UnitPrefix p>
constexpr T shamunits::get_prefix_val ( )
inlineconstexpr

Get the value of a prefix.

Definition at line 100 of file Names.hpp.

◆ get_unit_prefix_name()

const std::string shamunits::get_unit_prefix_name ( UnitPrefix  p)
inline

Get the prefix name for a UnitPrefix enum value.

Definition at line 125 of file Names.hpp.

◆ to_json()

template<class Tscal >
void shamunits::to_json ( nlohmann::json &  j,
const ::shamunits::UnitSystem< Tscal > &  p 
)
inline

Converts a UnitSystem object to a JSON object.

Parameters
jThe JSON object to be populated.
pThe UnitSystem object to be converted.

Definition at line 33 of file units_json.hpp.

◆ unit_prefix_from_name()

const UnitPrefix shamunits::unit_prefix_from_name ( std::string  p)
inline

Get the UnitPrefix enum value from a prefix name as a string.

Definition at line 137 of file Names.hpp.

Variable Documentation

◆ electron_proton_ratio

template<class T >
constexpr T shamunits::electron_proton_ratio = 1 / proton_electron_ratio<T>
constexpr

Mass ration between the electron and proton.

Definition at line 106 of file Constants.hpp.

◆ fine_structure

template<class T >
constexpr T shamunits::fine_structure = 0.0072973525693
constexpr

Fine structure constant.

Definition at line 98 of file Constants.hpp.

◆ pi

template<class T >
constexpr T shamunits::pi = 3.141592653589793116
constexpr

Value of pi Usage : auto pi = shamunits::pi<T>;

Definition at line 94 of file Constants.hpp.

◆ proton_electron_ratio

template<class T >
constexpr T shamunits::proton_electron_ratio = 1836.1526734311
constexpr

Mass ration between the proton and electron.

Definition at line 102 of file Constants.hpp.