Celeritas  0.5.0-56+6b053cd
Classes | Functions
celeritas::units Namespace Reference

Units in Celeritas for macro-scale quantities. More...

Classes

struct  CLight
 Natural unit of speed. More...
 
struct  EElectron
 Natural unit of charge (positive electron) More...
 
struct  Mev
 Nucleus-scale energy. More...
 
struct  MevPerCsq
 Nucleus-scale mass. More...
 
struct  MevPerC
 Nucleus-scale momentum. More...
 
struct  Amu
 Atomic mass units [amu]. More...
 
struct  Barn
 Barn cross section [b]. More...
 
struct  Millibarn
 Millibarn cross section [mb]. More...
 
struct  Mol
 Amount of substance \(N_a\). More...
 
struct  Centimeter
 
struct  Gram
 
struct  Gauss
 
struct  InvCentimeterCubed
 Inverse cubic centimeter for number densities. More...
 
struct  MolPerCentimeterCubed
 Molar density. More...
 
struct  GramPerCentimeterCubed
 Mass density. More...
 
struct  Meter
 
struct  Kilogram
 
struct  Second
 
struct  Tesla
 
struct  Millimeter
 
struct  Nanosecond
 
struct  ClhepUnitMass
 Unit mass in CLHEP system. More...
 
struct  ClhepUnitBField
 Unit magnetic flux density in CLHEP system. More...
 
struct  Native
 Mark as being in the native/builtin unit system. More...
 
struct  LogMev
 Annotate a quantity represented the logarithm of (E/MeV) More...
 
struct  UnitSystemTraits
 Traits class for units. More...
 

Typedefs

Quantities for atomic scale/natural units
using ElementaryCharge = Quantity< EElectron >
 
using MevEnergy = Quantity< Mev >
 
using LogMevEnergy = Quantity< LogMev >
 
using MevMass = Quantity< MevPerCsq >
 
using MevMomentum = Quantity< MevPerC >
 
using MevMomentumSq = Quantity< UnitProduct< MevPerC, MevPerC > >
 
using LightSpeed = Quantity< CLight >
 
using AmuMass = Quantity< Amu >
 
Quantities for manual input and/or test harnesses
using BarnXs = Quantity< Barn >
 
using CmLength = Quantity< Centimeter >
 
using InvCmXs = Quantity< UnitInverse< Centimeter > >
 
using InvCcDensity = Quantity< InvCentimeterCubed >
 
using MolCcDensity = Quantity< MolPerCentimeterCubed >
 
using GramCcDensity = Quantity< GramPerCentimeterCubed >
 
using FieldTesla = Quantity< Tesla >
 
Type aliases for unit system traits
using CgsTraits = UnitSystemTraits< UnitSystem::cgs >
 
using SiTraits = UnitSystemTraits< UnitSystem::si >
 
using ClhepTraits = UnitSystemTraits< UnitSystem::clhep >
 
using NativeTraits = UnitSystemTraits< UnitSystem::native >
 

Functions

template<class F >
constexpr decltype(auto) visit_unit_system (F &&func, UnitSystem sys)
 Expand a macro to a switch statement over all possible unit system types. More...
 

Variables

Units with numerical value defined to be 1 for CGS
constexpr real_type centimeter = 1
 Length.
 
constexpr real_type gram = 1
 Mass.
 
constexpr real_type second = 1
 Time.
 
constexpr real_type gauss = 1
 Field strength.
 
constexpr real_type kelvin = 1
 Temperature.
 
Exact unit transformations to SI units
constexpr real_type meter = 100 * centimeter
 
constexpr real_type kilogram = 1000 * gram
 
constexpr real_type tesla = 10000 * gauss
 
Exact unit transformations using SI unit definitions
constexpr real_type newton = kilogram * meter / (second * second)
 
constexpr real_type joule = newton * meter
 
constexpr real_type coulomb = kilogram / (tesla * second)
 
constexpr real_type ampere = coulomb / second
 
constexpr real_type volt = joule / coulomb
 
constexpr real_type farad = coulomb / volt
 
CLHEP units
constexpr real_type millimeter = real_type(0.1) * centimeter
 
constexpr real_type nanosecond = real_type(1e-9) * second
 
Other common units
constexpr real_type micrometer = real_type(1e-4) * centimeter
 
constexpr real_type nanometer = real_type(1e-7) * centimeter
 
constexpr real_type femtometer = real_type(1e-13) * centimeter
 
constexpr real_type barn = real_type(1e-24) * centimeter * centimeter
 

Detailed Description

Units in Celeritas for macro-scale quantities.

Celeritas can be configured at build time to use different unit systems for better compatibility with external libraries and applications. The CELERITAS_UNITS CMake variable can be set to one of the following:

The following units have numerical values of 1 in the default Celeritas system (Gaussian CGS) and are often seen in unit tests:

Unless otherwise specified, this unit system is used for input and output numerical values. They are meant for macro-scale quantities coupling the different code components of Celeritas.

Note
This system of units should be fully consistent so that constants can be precisely defined. (E.g., you cannot define both MeV as 1 and Joule as 1.) To express quantities in another system of units, such as MeV and "natural" units, use the Quantity class.

See also:

Additionally:

Function Documentation

◆ visit_unit_system()

template<class F >
constexpr decltype(auto) celeritas::units::visit_unit_system ( F &&  func,
UnitSystem  sys 
)
constexpr

Expand a macro to a switch statement over all possible unit system types.

This helper function is meant for processing user input to convert values to the native unit system. It is not a CELER_FUNCTION because unit conversion should be done only during preprocessing on the CPU.