TBTK
TBTK::UnitHandler Class Reference

#include <UnitHandler.h>

Public Types

enum  TemperatureUnit {
  kK, K, mK, uK,
  nK
}
 
enum  TimeUnit {
  s, ms, us, ns,
  ps, fs, as
}
 
enum  LengthUnit {
  m, mm, um, nm,
  pm, fm, am, Ao
}
 
enum  EnergyUnit {
  GeV, MeV, keV, eV,
  meV, ueV, J
}
 
enum  ChargeUnit {
  kC, C, mC, uC,
  nC, pC, fC, aC,
  Te, Ge, Me, ke,
  e
}
 
enum  CountUnit { pcs, mol }
 
enum  MassUnit {
  kg, g, mg, ug,
  ng, pg, fg, ag,
  u
}
 
enum  MagneticFieldUnit {
  MT, kT, T, mT,
  uT, nT, GG, MG,
  kG, G, mG, uG
}
 
enum  VoltageUnit {
  GV, MV, kV, V,
  mV, uV, nV
}
 

Static Public Member Functions

static double getHbarB ()
 
static double getHbarN ()
 
static double getK_BB ()
 
static double getK_BN ()
 
static double getEB ()
 
static double getEN ()
 
static double getCB ()
 
static double getCN ()
 
static double getN_AB ()
 
static double getN_AN ()
 
static double getM_eB ()
 
static double getM_eN ()
 
static double getM_pB ()
 
static double getM_pN ()
 
static double getMu_BB ()
 
static double getMu_BN ()
 
static double getMu_nB ()
 
static double getMu_nN ()
 
static double getMu_0B ()
 
static double getMu_0N ()
 
static double getEpsilon_0B ()
 
static double getEpsilon_0N ()
 
static void setTemperatureUnit (TemperatureUnit unit)
 
static void setTimeUnit (TimeUnit unit)
 
static void setLengthUnit (LengthUnit unit)
 
static void setEnergyUnit (EnergyUnit unit)
 
static void setChargeUnit (ChargeUnit unit)
 
static void setCountUnit (CountUnit unit)
 
static void setTemperatureScale (double scale)
 
static void setTimeScale (double scale)
 
static void setLengthScale (double scale)
 
static void setEnergyScale (double scale)
 
static void setChargeScale (double scale)
 
static void setCountScale (double scale)
 
static void setTemperatureScale (double scale, TemperatureUnit unit)
 
static void setTimeScale (double scale, TimeUnit unit)
 
static void setLengthScale (double scale, LengthUnit unit)
 
static void setEnergyScale (double scale, EnergyUnit unit)
 
static void setChargeScale (double scale, ChargeUnit unit)
 
static void setCountScale (double scale, CountUnit unit)
 
static void setTemperatureScale (std::string scale)
 
static void setTimeScale (std::string scale)
 
static void setLengthScale (std::string scale)
 
static void setEnergyScale (std::string scale)
 
static void setChargeScale (std::string scale)
 
static void setCountScale (std::string scale)
 
static void setScales (const std::vector< std::string > &scales)
 
static double convertTemperatureNtB (double temperature)
 
static double convertTimeNtB (double time)
 
static double convertLengthNtB (double length)
 
static double convertEnergyNtB (double energy)
 
static double convertChargeNtB (double charge)
 
static double convertCountNtB (double count)
 
static double convertTemperatureBtN (double temperature)
 
static double convertTimeBtN (double time)
 
static double convertLengthBtN (double length)
 
static double convertEnergyBtN (double energy)
 
static double convertChargeBtN (double charge)
 
static double convertCountBtN (double count)
 
static double convertMassDtB (double mass, MassUnit unit)
 
static double convertMassBtD (double mass, MassUnit unit)
 
static double convertMassDtN (double mass, MassUnit unit)
 
static double convertMassNtD (double mass, MassUnit unit)
 
static double convertMagneticFieldDtB (double field, MagneticFieldUnit unit)
 
static double convertMagneticFieldBtD (double field, MagneticFieldUnit unit)
 
static double convertMagneticFieldDtN (double field, MagneticFieldUnit unit)
 
static double convertMagneticFieldNtD (double field, MagneticFieldUnit unit)
 
static double convertVoltageDtB (double voltage, VoltageUnit unit)
 
static double convertVoltageBtD (double voltage, VoltageUnit unit)
 
static double convertVoltageDtN (double voltage, VoltageUnit unit)
 
static double convertVoltageNtD (double voltage, VoltageUnit unit)
 
static std::string getTemperatureUnitString ()
 
static std::string getTimeUnitString ()
 
static std::string getLengthUnitString ()
 
static std::string getEnergyUnitString ()
 
static std::string getChargeUnitString ()
 
static std::string getCountUnitString ()
 
static std::string getMassUnitString ()
 
static std::string getMagneticFieldUnitString ()
 
static std::string getVoltageUnitString ()
 
static std::string getHBARUnitString ()
 
static std::string getK_BUnitString ()
 
static std::string getEUnitString ()
 
static std::string getCUnitString ()
 
static std::string getN_AUnitString ()
 
static std::string getM_eUnitString ()
 
static std::string getM_pUnitString ()
 
static std::string getMu_BUnitString ()
 
static std::string getMu_nUnitString ()
 
static std::string getMu_0UnitString ()
 
static std::string getEpsilon_0UnitString ()
 

Detailed Description

!!! Note: Numerica values are picked from Wikipedia, and have not yet been checked agains an authoritative source. Some values that should be the same are even known to differ in some of the least significant digits. !!!

The UnitHandler handles conversion between the 'natural units' used in the calculations and standard 'base units'. The base quantities are Temperature, time, length, energy, charge, and count, and the default units are Kelvin (K), second (s), meter (m), electron Volt (eV), Coulomb (C), and pieces (pcs).

The current base units can be changed with setXXXUnit(), where \( XXX \in \{Temperature, Time, Length, Energy, Charge, Count\}\), and subsequent calls will take input paramaters and return output parameters in corresponding units.

The functions setXXXScale() can be used to specify the scale of the 'ruler' with which parameters in the calculation are meassured. This sets the scale which relates the natrual units to the base units. For example:

UnitHandler::setEnergyUnits(UnitHandler::EnergyUnit:meV); UnitHandler::setEnergyScale(1.47);

Here the energy base unit is first set to meV, and the scale subsequently set to 1.47meV. The natural unit 1.0, now corresponds to the base unit 1.47meV. An energy parameter with value 1.0 will therefore be interpreted as having the physical value 1.47meV whenever a multiplication with a physical constant is required to generate a unitless number.

Note that the order of the above calls are important. Setting the energy scale to 1.47 while the default energy unit eV is used and then changing to meV as units will result in the scale becoming 1.47eV = 1470meV.

In addition to base units and natural units, there are also derived units. These are used to convert to and from units not included among the base units, such as kg for mass. That a u unit is derived means that it can be expressed in terms of the already existing base units. For example: kg = eVs^2/m^2.

Member Enumeration Documentation

Charge units (base unit):
kC - kilocoulomb
C - Coulomb
mC - millicoulomb
uC - microcoulomb
nC - nanocoulomb
pC - picocoulomb
fC - femtocoulomb
aC - attocoulomb
Te - terrae
Ge - gigae
Me - megae
ke - kiloe
e - e (elementary charge)

Count unit (base unit): pcs - pieces mol - Mole

Energy units (base unit):
GeV - gigaelectron Volt
MeV - megaelectron Volt
keV - kiloelectron Volt
eV - electron Volt
meV - millielectron Volt
ueV - microelectron Volt
J - Joule

Length units (base unit):
m - meter
mm - millimeter
um - micrometer
nm - nanometer
pm - picometer
fm - femtometer
am - attometer
Ao - Angstrom

Magnetic unit (derived unit):
MT - megatesla
kT - kilotesla
T - Tesla
mT - millitesla
uT - microtesla
nT - nanotesla
GG - gigagauss
MG - megagauss
kG - kilogauss
G - Gauss
mG - milligauss
uG - microgauss

Mass units (derived unit):
kg - kilogram
g - gram
mg - milligram
ug - microgram
ng - nanogram
pg - picogram
fg - femtogram
ag - attogram
u - atomic mass

Temperature units (base unit):
kK - kilokelvin
K - Kelvin
mK - millikelvin
uK - microkelvin
nK - nanokelvin

Voltage unit (derived unit):
GV - kilovolt
MV - kilovolt
kV - kilovolt
V - volt
mV - millivolt uV - millivolt
nV - millivolt

Member Function Documentation

double TBTK::UnitHandler::convertChargeBtN ( double  charge)
inlinestatic

Convert charge from base units to natural units.

double TBTK::UnitHandler::convertChargeNtB ( double  charge)
inlinestatic

Convert charge from natural units to base units.

double TBTK::UnitHandler::convertCountBtN ( double  count)
inlinestatic

Convert count from base units to natural units.

double TBTK::UnitHandler::convertCountNtB ( double  count)
inlinestatic

Conver counting from natural units to base units.

double TBTK::UnitHandler::convertEnergyBtN ( double  energy)
inlinestatic

Convert energy from base units to natural units.

double TBTK::UnitHandler::convertEnergyNtB ( double  energy)
inlinestatic

Convert energy from natural units to base units

double TBTK::UnitHandler::convertLengthBtN ( double  length)
inlinestatic

Convert length from base units to natural units.

double TBTK::UnitHandler::convertLengthNtB ( double  length)
inlinestatic

Convert length from natural units to base units.

static double TBTK::UnitHandler::convertMagneticFieldBtD ( double  field,
MagneticFieldUnit  unit 
)
static

Convert magnetic field from base units to derived units.

static double TBTK::UnitHandler::convertMagneticFieldDtB ( double  field,
MagneticFieldUnit  unit 
)
static

Convert magnetic field from derived units to base units.

static double TBTK::UnitHandler::convertMagneticFieldDtN ( double  field,
MagneticFieldUnit  unit 
)
static

Convert magnetic field from derived units to natural units.

static double TBTK::UnitHandler::convertMagneticFieldNtD ( double  field,
MagneticFieldUnit  unit 
)
static

Convert magnetic field from natural units to derived units.

static double TBTK::UnitHandler::convertMassBtD ( double  mass,
MassUnit  unit 
)
static

Convert mass from base units to derived units.

static double TBTK::UnitHandler::convertMassDtB ( double  mass,
MassUnit  unit 
)
static

Convert mass from derived units to base units.

static double TBTK::UnitHandler::convertMassDtN ( double  mass,
MassUnit  unit 
)
static

Convert mass from derived units to natural units.

static double TBTK::UnitHandler::convertMassNtD ( double  mass,
MassUnit  unit 
)
static

Convert mass from natural units to derived units.

double TBTK::UnitHandler::convertTemperatureBtN ( double  temperature)
inlinestatic

Convert temperature from base units to natural units.

double TBTK::UnitHandler::convertTemperatureNtB ( double  temperature)
inlinestatic

Convert temperature from natural units to base units.

double TBTK::UnitHandler::convertTimeBtN ( double  time)
inlinestatic

Convert time from base units to natural units.

double TBTK::UnitHandler::convertTimeNtB ( double  time)
inlinestatic

Convert time to from natural units to base units.

static double TBTK::UnitHandler::convertVoltageBtD ( double  voltage,
VoltageUnit  unit 
)
static

Convert voltage from base units to derived units.

static double TBTK::UnitHandler::convertVoltageDtB ( double  voltage,
VoltageUnit  unit 
)
static

Convert voltage from derived units to base units.

static double TBTK::UnitHandler::convertVoltageDtN ( double  voltage,
VoltageUnit  unit 
)
static

Convert voltage from derived units to natural units.

static double TBTK::UnitHandler::convertVoltageNtD ( double  voltage,
VoltageUnit  unit 
)
static

Convert voltage from natural units to derived units.

double TBTK::UnitHandler::getCB ( )
inlinestatic

Get the speed of light in the curently set base units.

static std::string TBTK::UnitHandler::getChargeUnitString ( )
static

Get charge unit string

Returns
string representation of the currently set charge unit.
double TBTK::UnitHandler::getCN ( )
inlinestatic

Get the speed of light in the curently set natural units.

static std::string TBTK::UnitHandler::getCountUnitString ( )
static

Get count unit string

Returns
string representation of the current set count unit.
static std::string TBTK::UnitHandler::getCUnitString ( )
static

Get speed of light unit string.

Returns
string representation of the unit for the speed of light.
double TBTK::UnitHandler::getEB ( )
inlinestatic

Get the elementary charge in the currently set base units.

double TBTK::UnitHandler::getEN ( )
inlinestatic

Get the elementary charge in the currently set natural units.

static std::string TBTK::UnitHandler::getEnergyUnitString ( )
static

Get energy unit string

Returns
string representation of the currently set energy unit.
double TBTK::UnitHandler::getEpsilon_0B ( )
inlinestatic

Get the vacuum permittivity in the currently set base units.

double TBTK::UnitHandler::getEpsilon_0N ( )
inlinestatic

Get the vacuum permittivity in the currently set natural units.

static std::string TBTK::UnitHandler::getEpsilon_0UnitString ( )
static

Get vacuum permittivity unit string

Returns
string representation of the unit for the vacuum permittivity.
static std::string TBTK::UnitHandler::getEUnitString ( )
static

Get elementary charge unit string.

Returns
string representation of the unit for the elementary charge.
double TBTK::UnitHandler::getHbarB ( )
inlinestatic

Get the Planck constant in the currently set base units.

double TBTK::UnitHandler::getHbarN ( )
inlinestatic

Get the Planck constant in the currently set natural units.

static std::string TBTK::UnitHandler::getHBARUnitString ( )
static

Get Planck constant unit string

Returns
string representation of the unit for the Planck constant.
double TBTK::UnitHandler::getK_BB ( )
inlinestatic

Get the Boltzmann constant in the currently set base units.

double TBTK::UnitHandler::getK_BN ( )
inlinestatic

Get the Boltzmann constant in the currently set natural units.

static std::string TBTK::UnitHandler::getK_BUnitString ( )
static

Get Boltzmann constant unit string.

Returns
string representation of the unit for the Boltzmann constant.
static std::string TBTK::UnitHandler::getLengthUnitString ( )
static

Get length unit string

Returns
string representation of the currently set length unit.
double TBTK::UnitHandler::getM_eB ( )
inlinestatic

Get the electron mass in the currently set base units.

double TBTK::UnitHandler::getM_eN ( )
inlinestatic

Get the electron mass in the currently set natural units.

static std::string TBTK::UnitHandler::getM_eUnitString ( )
static

Get electron mass unit string.

Returns
string representation of the unit for the electron mass.
double TBTK::UnitHandler::getM_pB ( )
inlinestatic

Get the proton mass in the currently set base units.

double TBTK::UnitHandler::getM_pN ( )
inlinestatic

Get the proton mass in the currently set natural units.

static std::string TBTK::UnitHandler::getM_pUnitString ( )
static

Get proton mass unit string.

Returns
string representation of the unit for the proton mass.
static std::string TBTK::UnitHandler::getMagneticFieldUnitString ( )
static

Get mass unit string.

Returns
string representation of the derived magnetic field unit in terms of the currently set base units.
static std::string TBTK::UnitHandler::getMassUnitString ( )
static

Get mass unit string.

Returns
string representation of the derived mass unit in terms of the currently set base units.
double TBTK::UnitHandler::getMu_0B ( )
inlinestatic

Get the vacuum permeability in the currently set base units.

double TBTK::UnitHandler::getMu_0N ( )
inlinestatic

Get the vacuum permeability in the currently set natural units.

static std::string TBTK::UnitHandler::getMu_0UnitString ( )
static

Get vacuum permeability unit string.

Returns
string representation of the unit for the vacuum permeability.
double TBTK::UnitHandler::getMu_BB ( )
inlinestatic

Get the Bohr magneton in the currently set base units.

double TBTK::UnitHandler::getMu_BN ( )
inlinestatic

Get the Bohr magneton in the currently set natural units.

static std::string TBTK::UnitHandler::getMu_BUnitString ( )
static

Get Bohr magneton unit string.

Returns
string representation of the unit for the Bohr magneton.
double TBTK::UnitHandler::getMu_nB ( )
inlinestatic

Get the nuclear magneton in the currently set base units.

double TBTK::UnitHandler::getMu_nN ( )
inlinestatic

Get the nuclear magneton in the currently set natural units.

static std::string TBTK::UnitHandler::getMu_nUnitString ( )
static

Get nuclear magneton unit string.

Returns
string representation of the unit for the nuclear magneton.
double TBTK::UnitHandler::getN_AB ( )
inlinestatic

Get Avogadros number in the currently set base units.

double TBTK::UnitHandler::getN_AN ( )
inlinestatic

Get Avogadros number in the currently set natural units.

static std::string TBTK::UnitHandler::getN_AUnitString ( )
static

GetAvogadros number unit string.

Returns
string representation of the unit for Avogadros number.
static std::string TBTK::UnitHandler::getTemperatureUnitString ( )
static

Get temperature unit string

Returns
string representation of the currently set temperature unit.
static std::string TBTK::UnitHandler::getTimeUnitString ( )
static

Get time unit string

Returns
string representation of the currently set time unit.
static std::string TBTK::UnitHandler::getVoltageUnitString ( )
static

Get voltage unit string.

Returns
string representation of the derived voltage unit in terms of the currently set base units.
static void TBTK::UnitHandler::setChargeScale ( double  scale)
static

Set charge scale.

void TBTK::UnitHandler::setChargeScale ( double  scale,
ChargeUnit  unit 
)
inlinestatic

Set charge scale.

static void TBTK::UnitHandler::setChargeScale ( std::string  scale)
static

Set charge scale.

static void TBTK::UnitHandler::setChargeUnit ( ChargeUnit  unit)
static

Set charge unit.

static void TBTK::UnitHandler::setCountScale ( double  scale)
static

Set count unit.

void TBTK::UnitHandler::setCountScale ( double  scale,
CountUnit  unit 
)
inlinestatic

Set count scale.

static void TBTK::UnitHandler::setCountScale ( std::string  scale)
static

Set count scale.

static void TBTK::UnitHandler::setCountUnit ( CountUnit  unit)
static

Set counting unit.

static void TBTK::UnitHandler::setEnergyScale ( double  scale)
static

Set energy scale.

void TBTK::UnitHandler::setEnergyScale ( double  scale,
EnergyUnit  unit 
)
inlinestatic

Set energy scale.

static void TBTK::UnitHandler::setEnergyScale ( std::string  scale)
static

Set energy scale.

static void TBTK::UnitHandler::setEnergyUnit ( EnergyUnit  unit)
static

Set energy unit.

static void TBTK::UnitHandler::setLengthScale ( double  scale)
static

Set length scale.

void TBTK::UnitHandler::setLengthScale ( double  scale,
LengthUnit  unit 
)
inlinestatic

Set length scale.

static void TBTK::UnitHandler::setLengthScale ( std::string  scale)
static

Set length scale.

static void TBTK::UnitHandler::setLengthUnit ( LengthUnit  unit)
static

Set length unit.

void TBTK::UnitHandler::setScales ( const std::vector< std::string > &  scales)
inlinestatic

Set scales.

static void TBTK::UnitHandler::setTemperatureScale ( double  scale)
static

Set temperature scale.

void TBTK::UnitHandler::setTemperatureScale ( double  scale,
TemperatureUnit  unit 
)
inlinestatic

Set temperature scale.

static void TBTK::UnitHandler::setTemperatureScale ( std::string  scale)
static

Set temperature scale.

static void TBTK::UnitHandler::setTemperatureUnit ( TemperatureUnit  unit)
static

Set temperature unit.

static void TBTK::UnitHandler::setTimeScale ( double  scale)
static

Set time scale.

void TBTK::UnitHandler::setTimeScale ( double  scale,
TimeUnit  unit 
)
inlinestatic

Set time scale.

static void TBTK::UnitHandler::setTimeScale ( std::string  scale)
static

Set time scale.

static void TBTK::UnitHandler::setTimeUnit ( TimeUnit  unit)
static

Set time unit.


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