SyDEVS  v0.6.6
Multiscale Simulation and Systems Modeling Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sydevs::units< g, m, s, A, K, mol, cd > Struct Template Reference

A template which represents Standard International (SI) units inclusing the base units such as grams, meters, and seconds, and derived units such as meters-per-second-squared. More...

#include <units.h>

Public Types

enum  {
  g_ = g, m_ = m, s_ = s, A_ = A,
  K_ = K, mol_ = mol, cd_ = cd
}
 

Public Member Functions

constexpr units ()=default
 Constructs a unit object. More...
 
template<int64 g_, int64 m_, int64 s_, int64 A_, int64 K_, int64 mol_, int64 cd_>
constexpr units< g+g_, m+m_, s+s_,
A+A_, K+K_, mol+mol_, cd+cd_
operator* (units< g_, m_, s_, A_, K_, mol_, cd_ > rhs) const
 Combines two units into one as if the unit on the left were multiplied by that on the right. More...
 
template<int64 g_, int64 m_, int64 s_, int64 A_, int64 K_, int64 mol_, int64 cd_>
constexpr units< g-g_, m-m_, s-s_,
A-A_, K-K_, mol-mol_, cd-cd_
operator/ (units< g_, m_, s_, A_, K_, mol_, cd_ > rhs) const
 Combines two units into one as if the unit on the left were divided by that on the right. More...
 

Detailed Description

template<int64 g, int64 m, int64 s, int64 A, int64 K, int64 mol, int64 cd>
struct sydevs::units< g, m, s, A, K, mol, cd >

A template which represents Standard International (SI) units inclusing the base units such as grams, meters, and seconds, and derived units such as meters-per-second-squared.

The units type can be used to specify an SI unit at compile time as a combination of the 7 base units: grams (g), meters (m), seconds (s), Amperes (A), Kelvin (L), mols (mol), and candelas (cd).

A type alias is defined for dimensionless quantities.

There is also a type alias for each of the base units:

grams // Unit of mass
meters // Unit of distance
seconds // Unit of duration
amperes // Unit of electric current
kelvins // Unit of thermodynamic temperature
moles // Unit of amount of substance
candelas // Unit of luminous intensity

For each base unit, the associated value is defined as a constant.

_g // grams()
_m // meters()
_s // seconds()
_A // amperes()
_K // kelvins()
_mol // moles()
_cd // candelas()

There are two ways to expressed SI derived units. The first is using the template constructor, where each template parameter is the exponent of the corresponding base unit.

units<0, 1, -1, 0, 0, 0, 0> // meters/second (speed)
units<0, 1, -2, 0, 0, 0, 0> // meters/second^2 (acceleration)
units<0, 0, 1, 1, 0, 0, 0> // second*Ampere or coulomb (electric charge)
units<0, -2, 0, 0, 0, 0, 1> // candelas/meter^2 or lux (illuminance)

The second approach employs the base unit values in conjunction with multiplication and division operators and decltype.

decltype(_m/_s) // meters/second (speed)
decltype(_m/_s/_s) // meters/second^2 (acceleration)
decltype(_s*_A) // second*Ampere or coulomb (electric charge)
decltype (_cd/_m/_m) // candelas/meter^2 or lux (illuminance)

It is important to note that the units class treats grams, not kilograms, as the base unit for mass. This affects derived quantities such as Newtons.

decltype(_g*_m/_s/_s) // grams*meters/second^2 or milliNewtons (force)

Member Enumeration Documentation

template<int64 g, int64 m, int64 s, int64 A, int64 K, int64 mol, int64 cd>
anonymous enum
Enumerator
g_ 

Grams exponent.

m_ 

Meters exponent.

s_ 

Seconds exponent.

A_ 

Amperes exponent.

K_ 

Kelvins exponent.

mol_ 

Moles exponent.

cd_ 

Candelas exponent.

Constructor & Destructor Documentation

template<int64 g, int64 m, int64 s, int64 A, int64 K, int64 mol, int64 cd>
constexpr sydevs::units< g, m, s, A, K, mol, cd >::units ( )
default

Constructs a unit object.

Member Function Documentation

template<int64 g, int64 m, int64 s, int64 A, int64 K, int64 mol, int64 cd>
template<int64 g_, int64 m_, int64 s_, int64 A_, int64 K_, int64 mol_, int64 cd_>
constexpr units<g + g_, m + m_, s + s_, A + A_, K + K_, mol + mol_, cd + cd_> sydevs::units< g, m, s, A, K, mol, cd >::operator* ( units< g_, m_, s_, A_, K_, mol_, cd_ rhs) const
inline

Combines two units into one as if the unit on the left were multiplied by that on the right.

template<int64 g, int64 m, int64 s, int64 A, int64 K, int64 mol, int64 cd>
template<int64 g_, int64 m_, int64 s_, int64 A_, int64 K_, int64 mol_, int64 cd_>
constexpr units<g - g_, m - m_, s - s_, A - A_, K - K_, mol - mol_, cd - cd_> sydevs::units< g, m, s, A, K, mol, cd >::operator/ ( units< g_, m_, s_, A_, K_, mol_, cd_ rhs) const
inline

Combines two units into one as if the unit on the left were divided by that on the right.


The documentation for this struct was generated from the following file: