Physical constants, unit conversion. More...
Go to the source code of this file.
Namespaces | |
| namespace | forcefields |
| namespace | forcefields::unit_system |
| Physical constants and unit conversion. | |
Macros | |
| #define | FORCEFIELDS_UNIT_SYSTEM_SI_MKSA 0 |
| Systeme international. | |
| #define | FORCEFIELDS_UNIT_SYSTEM_METRE_KILOGRAMME_PER_MOL_SECOND_AMPERE_PER_MOL 1 |
| System based on Metre, kg/mol, second, Ampere/mol. | |
| #define | FORCEFIELDS_UNIT_SYSTEM_ANGSTROM_KILOGRAMME_PER_MOL_FEMTOSECOND_AMPERE_PER_MOL 2 |
| System based on angstrom, kg/mol, femtosecond, Ampere/mol. | |
| #define | FORCEFIELDS_UNIT_SYSTEM_ANGSTROM_GRAMME_PER_MOL_FEMTOSECOND_ECHARGE 3 |
| Angstrom, gramme/mol, femtosecond, e (proton charge). | |
| #define | FORCEFIELDS_UNIT_SYSTEM_ELECTRONVOLT_ANGSTROM_FEMTOSECOND_ECHARGE 4 |
| Electron volt, angstrom, femtosecond, e (proton charge). | |
| #define | FORCEFIELDS_UNIT_SYSTEM_KILOCALORY_PER_MOL_ANGSTROM_FEMTOSECOND_ECHARGE 5 |
| Kilo calory per mole, angstrom, femtosecond, e (proton charge). | |
| #define | FORCEFIELDS_UNIT_SYSTEM_HPP FORCEFIELDS_UNIT_SYSTEM_ELECTRONVOLT_ANGSTROM_FEMTOSECOND_ECHARGE |
| Default system of units. | |
Physical constants, unit conversion.
This file contains constants to convert between different units and also to choose a default system of units. There are two types of constants, those in lowercase letters and those in capital letters. Constants in lowercase letters are universal constants usually expressed in the international sytem of unit (SI). The contents of these constants do not depend on the default system of unit chosen. The content of constants is capital letters depends on the default system. Those latter are further devided into two subgroups: unit name constants and converters.
The default system of units is selected at compilation by setting the macro FORCEFIELDS_UNIT_SYSTEM_HPP .
The content of the constants called unit name constants and converters depends on the system chosen.
The default system like the SI is based on the four dimensions distance, mass, time, electric current. All other units are extracted from the four units chosen for these four dimensions. For example if the default system is SI, the unit of energy will be Joule because \( 1\ J = 1\ m^2\ kg\ s^{-2} \) . As well the unit of pressure will be Pascal ( \( 1\ Pa=1\ m^{-1}\ kg\ s^{-2} \) ). Quantities of same dimensions are always expressed with the same units. For instance the temperature has the dimension of the energy, therefore is default unit is the unit of the energy (Joule if SI is the default system).
A unit constant is a constant string of characters named after a quantity (e.g. ENERGY, PRESSURE, etc). It contains the name of the default unit used for that quantity (e.g. kJ , eV , etc for an energy). These constants can be used to display a quantity in the default system of unit. For example, let us assume that kJ/mol is the default unit for the energy. We wish to display the content of a variable energy which contains an energy expressed in the default system of unit. We shall write the following code:
A converter is a double constant which has the name of a unit (e.g. PASCAL, KELVIN, ANGSTROM...). The constant contains the value of one quantity of the unit espressed in the default system of unit. Here is an example on how to use the converters. Let us assume that the default system of unit uses the meter as length unit. We wish to display the content of a variable x which contains a distance in meter, but we want to display it in Angstrom. To make the conversion we need to divide the quantity by one Angstrom:
\[ \frac{x\ meter}{1\ Angstrom}=\frac{x\ meter}{10^{-10}\ meter}=x \time 10^{-10} \]
We shall add to the code the following line which will display the quantity in Angstrom.
Reversively, we may also wish to input a value into x. We shall write for example:
Definition in file units.hpp.
| #define FORCEFIELDS_UNIT_SYSTEM_ANGSTROM_GRAMME_PER_MOL_FEMTOSECOND_ECHARGE 3 |
| #define FORCEFIELDS_UNIT_SYSTEM_ANGSTROM_KILOGRAMME_PER_MOL_FEMTOSECOND_AMPERE_PER_MOL 2 |
| #define FORCEFIELDS_UNIT_SYSTEM_ELECTRONVOLT_ANGSTROM_FEMTOSECOND_ECHARGE 4 |
| #define FORCEFIELDS_UNIT_SYSTEM_HPP FORCEFIELDS_UNIT_SYSTEM_ELECTRONVOLT_ANGSTROM_FEMTOSECOND_ECHARGE |
| #define FORCEFIELDS_UNIT_SYSTEM_KILOCALORY_PER_MOL_ANGSTROM_FEMTOSECOND_ECHARGE 5 |
| #define FORCEFIELDS_UNIT_SYSTEM_METRE_KILOGRAMME_PER_MOL_SECOND_AMPERE_PER_MOL 1 |