UCEDefs.h
1 #ifndef BIOGEARS_CDM_UTILS_UNITCONVERSION_UCEDefs_H
2 #define BIOGEARS_CDM_UTILS_UNITCONVERSION_UCEDefs_H
3 
4 namespace biogears {
5 // Prefix format:
6 // PREFIX <name> <symbol> <conversion-factor>
7 // [note that symbol is single char only]
8 //
9 // Quantity formats:
10 // 1) QUANTITY FUNDAMENTAL <name> [20LOG]
11 // 2) QUANTITY DERIVED <name> [20LOG] <expansion>
12 // <expansion> is a string representation of a complex unit. Juxtaposed symbols must be whitespace-separated.
13 // Symbols must already be defined
14 // Note that each quantity definition implicitly defines an anonymous, "base unit" for that type.
15 // The base unit refers to any subsequently-defined unit that has a conversion-factor of 1.0. For fundamental
16 // types, this is also the unit's bigness. For derived types, the bigness of any unit is its conversion
17 // factor times the bigness of the derived type's expansion. The unit conversion engine does not require
18 // the existence of a named unit whose conversion factor is 1.0, though for fundamental types, there is
19 // really no reason for there not to be one.
20 // [20LOG] is an optional flag that indicates that this quantity should obey the "20 Log Rule",
21 // for decibels, as explained in http://en.wikipedia.org/wiki/Decibel
22 //
23 // Unit formats
24 // 1) UNIT <quantity-name> <name> <symbol> <conversion-factor> <expansion> {ALLPREFIXES/NOPREFIXES} [<bias>]
25 // 2) UNIT <quantity-name> <name> <symbol> <conversion-factor> <expansion> {GOODPREFIXES/BADPREFIXES} <prefix-char-seq> [<bias>]
26 // [bias] is at the end because it is optional and seldom used (e.g. temperature)
27 // <prefix-char-seq> is a sequence of prefix characters that are either allowed or forbidden
28 // <quantity-name> is the name of the previously-defined quantity type to which this unit applies.
29 // <expansion> is a complex unit with respect to which the current unit's conversion factor and bias are defined, or "*"
30 // if wrt the base unit. A note on biases: Whereas conversion factors are
31 // relative, and the choice of base unit is largely arbitrary as far as conversion factors are concerned,
32 // the same is not true with biases. In order for quantity type conversions to be done properly
33 // (e.g. Temperature to Energy and vice versa), the base unit must be an absolute scale (e.g.
34 // (Kelvin or Rankine). Selecting Celsius as the base unit, and specifying biases relative to
35 // it, may work for simple conversions from one temperature to another, but will not yield
36 // correct results when converting between quantity types. This restriction does not
37 // preclude defining such a unit's bias and conversion factor in terms of some other
38 // non-base unit, so long as the definition chain ends with a unit of absolute scale. Note that
39 // the specified bias value is the value of the current unit when the target unit has the
40 // value zero.
41 //
42 // Quantity type mapping format:
43 // TYPEMAP <to-quantity> <from-quantity> <from-exponent> <mapping-unit>
44 // TYPEMAP allows the conversion between disparate quantity types. Such conversions are almost
45 // always context dependent. For example, one can convert frequency to energy in the context of
46 // electromagnetic radiation by multiplying the frequency (raised to the first power) by Planck's
47 // constant (raised to the first power).
48 // <to-quantity> is the name of the quantity being converted to (e.g. Energy)
49 // <from-quantity> is the name of the quantity type being converted from (e.g. Frequency).
50 // <from-exponent> is the power that the original value needs to be raised to. (In the case of E = h nu,
51 // this power is 1.0, but some conversions might involve an inverse relationship, in which
52 // case the power might be -1.0.)
53 // <mapping-unit> is an arbitrary compound unit string representing
54 // the physical constant or constants, such as "c", or "h", or "c^2", or "c h".
55 // Note that there is no need to define an inverse typemap in the other direction. This is computed automatically.
56 
57 // A note on decibels
58 // Compled units may be preceded with "dB " to signify values in decibels relative to the unit which follows.
59 // E.g., you can use a unit like "dB mW", or "dB V/m".
60 
61 constexpr const char * UCEDEFS_TEXT = R"UCEDEFS(
62 PREFIX yotta Y 1.0e24
63 PREFIX zetta Z 1.0e21
64 PREFIX exa E 1.0e18
65 PREFIX peta P 1.0e15
66 PREFIX tera T 1.0e12
67 PREFIX giga G 1.0e9
68 PREFIX mega M 1.0e6
69 PREFIX kilo k 1.0e3
70 PREFIX hecto h 1.0e2
71 PREFIX deci d 1.0e-1
72 PREFIX centi c 1.0e-2
73 PREFIX milli m 1.0e-3
74 PREFIX micro u 1.0e-6
75 PREFIX nano n 1.0e-9
76 PREFIX pico p 1.0e-12
77 PREFIX femto f 1.0e-15
78 PREFIX atto a 1.0e-18
79 PREFIX zepto z 1.0e-21
80 PREFIX yocto y 1.0e-24
81 
82 QUANTITY FUNDAMENTAL Time
83 UNIT Time second s 1.0 * GoodPrefixes munpfazy
84 UNIT Time minute min 60.0 s NoPrefixes
85 UNIT Time hour hr 60.0 min NoPrefixes
86 UNIT Time day day 24.0 hr NoPrefixes
87 UNIT Time year yr 365.242199 day NoPrefixes
88 UNIT Time fortnight fortnight 14 day NoPrefixes
89 
90 QUANTITY FUNDAMENTAL Distance
91 UNIT Distance meter m 1.0 * BadPrefixes MGTPEZY
92 UNIT Distance inch in 2.54 cm NoPrefixes
93 UNIT Distance mil mil 0.001 in NoPrefixes
94 UNIT Distance foot ft 12 in GoodPrefixes k
95 UNIT Distance yard yd 3 ft NoPrefixes
96 UNIT Distance mile mi 5280 ft NoPrefixes
97 UNIT Distance nautical-mile nmi 1852 m NoPrefixes
98 UNIT Distance cubit cubit 18 in NoPrefixes
99 UNIT Distance furlong furlong 0.125 mi NoPrefixes
100 UNIT Distance chain chain 22 yd NoPrefixes
101 UNIT Distance rod rod 16.5 ft NoPrefixes
102 UNIT Distance fathom fathom 6 ft NoPrefixes
103 
104 QUANTITY FUNDAMENTAL Osmole
105 UNIT Osmole osmole Osm 1.0 * GoodPrefixes m
106 
107 QUANTITY DERIVED PlaneAngle m/m
108 UNIT PlaneAngle pi pi 3.1415926535897932384626433832795 * NoPrefixes
109 UNIT PlaneAngle degpercyc degpercyc 360.0 * NoPrefixes
110 UNIT PlaneAngle degfac degfac 60.0 * NoPrefixes
111 UNIT PlaneAngle radian rad 0.5 1/pi GoodPrefixes cmu
112 UNIT PlaneAngle degree deg 1.0 1/degpercyc NoPrefixes
113 UNIT PlaneAngle minute-arc minarc 1.0 deg/degfac NoPrefixes
114 UNIT PlaneAngle second-arc secarc 1.0 minarc/degfac NoPrefixes
115 
116 QUANTITY DERIVED Frequency 1/s
117 UNIT Frequency hertz Hz 1.0 * GoodPrefixes kMGT
118 
119 QUANTITY FUNDAMENTAL AmountOfSubstance
120 UNIT AmountOfSubstance mole mol 1.0 * AllPrefixes
121 
122 QUANTITY DERIVED InverseAmount 1/mol
123 UNIT InverseAmount AvogadrosConstant Na 6.02214179E23 * NoPrefixes
124 
125 UNIT AmountOfSubstance count ct 1.0 Na^-1 NoPrefixes
126 UNIT AmountOfSubstance dozen doz 12 ct NoPrefixes
127 
128 QUANTITY FUNDAMENTAL Mass
129 UNIT Mass gram g 1.0 * AllPrefixes
130 UNIT Mass UnifiedAMU u 1.0 g/mol Na NoPrefixes
131 UNIT Mass dalton Da 1.0 u GoodPrefixes k
132 UNIT Mass AMU amu 1.0 u NoPrefixes
133 UNIT Mass ounce oz 28.349523125 g NoPrefixes
134 UNIT Mass pound lb 16 oz NoPrefixes
135 UNIT Mass stone stone 14 lb NoPrefixes
136 UNIT Mass ton ton 2000.0 lb NoPrefixes
137 
138 QUANTITY FUNDAMENTAL 20LOG Current
139 UNIT Current ampere A 1.0 * AllPrefixes
140 
141 QUANTITY FUNDAMENTAL LuminousIntensity
142 UNIT LuminousIntensity candela cd 1.0 * AllPrefixes
143 
144 QUANTITY FUNDAMENTAL Temperature
145 UNIT Temperature DegreesRankine degR 1.0 * AllPrefixes 0.0
146 UNIT Temperature Kelvin K 1.8 degR AllPrefixes 0.0
147 UNIT Temperature DegreesCelsius degC 1.0 K AllPrefixes -273.15
148 UNIT Temperature DegreesFahrenheit degF 0.5555555555555 degC NoPrefixes 32.0
149 
150 QUANTITY DERIVED Area m^2
151 UNIT Area acre acre 4046.85642 * NoPrefixes
152 UNIT Area are are 100 * NoPrefixes
153 UNIT Area decare decare 10 are NoPrefixes
154 UNIT Area barn b 100 fm^2 NoPrefixes
155 
156 QUANTITY DERIVED Volume m^3
157 UNIT Volume liter l 0.001 * GoodPrefixes mu
158 UNIT Volume Liter L 1.0 l GoodPrefixes mud
159 UNIT Volume gallon gal 3.7854118 l NoPrefixes
160 UNIT Volume quart qt 0.25 gal NoPrefixes
161 UNIT Volume pint pt 0.5 qt NoPrefixes
162 UNIT Volume cubic-centimeter cc 1.0 cm^3 NoPrefixes
163 UNIT Volume cubic-foot cf 1.0 ft^3 NoPrefixes
164 UNIT Volume peck peck 2 gal NoPrefixes
165 UNIT Volume bushel bushel 4 peck NoPrefixes
166 UNIT Volume hogshead hhd 63 gal NoPrefixes
167 UNIT Volume barrel brl 31.5 gal NoPrefixes
168 
169 QUANTITY DERIVED Force kg m/s^2
170 UNIT Force newton N 1.0 * AllPRefixes
171 UNIT Force dyne dyn 1.0e-5 N AllPrefixes
172 UNIT Force pound-force lbf 4.44822162 N NoPrefixes
173 
174 QUANTITY DERIVED Energy N m
175 UNIT Energy joule J 1.0 * BadPRefixes c
176 UNIT Energy erg erg 1.0e-7 J AllPrefixes
177 UNIT Energy calorie cal 4.184 J AllPrefixes
178 UNIT Energy Calorie Cal 1.0 kcal AllPrefixes
179 UNIT Energy tonne-of-TNT t 1.0 Gcal GoodPrefixes umkMG
180 UNIT Energy BritishThermalUnit BTU 1055.05585 J NoPrefixes
181 
182 QUANTITY DERIVED Power J/s
183 Unit Power watt W 1.0 * AllPrefixes
184 Unit Power horsepower hp 745.699872 W GoodPRefixes k
185 
186 QUANTITY DERIVED 20LOG Speed m/s
187 UNIT Speed lightspeed c 2.99792458e+8 * NoPrefixes
188 UNIT Speed speedoflight lt 1.0 c NoPrefixes
189 UNIT Speed milesperhour mph 1.0 mi/hr NoPrefixes
190 UNIT Speed knots kn 1.0 nmi/hr NoPrefixes
191 
192 QUANTITY DERIVED Acceleration m/s^2
193 UNIT Acceleration gravity grav 9.8 * NoPrefixes
194 
195 QUANTITY DERIVED Pressure N/m^2
196 UNIT Pressure pascal Pa 1.0 * AllPrefixes
197 UNIT Pressure bar bar 1.0e+5 Pa AllPrefixes
198 UNIT Pressure torr Torr 133.322368 Pa AllPrefixes
199 UNIT Pressure atmosphere atm 760 Torr AllPrefixes
200 UNIT Pressure psi psi 1.0 lbf/in^2 NoPrefixes
201 UNIT Pressure mmHg mmHg 1.0 Torr NoPrefixes
202 UNIT Pressure cmH2O cmH2O 98.0665 Pa NoPrefixes
203 
204 QUANTITY DERIVED 20LOG ElectricCharge A s
205 UNIT ElectricCharge coulomb C 1.0 * AllPrefixes
206 UNIT ElectricCharge elementary-charge e 1.60217646E-19 C NoPrefixes
207 
208 QUANTITY DERIVED 20LOG ElectricPotential W/A
209 UNIT ElectricPotential volt V 1.0 * AllPrefixes
210 
211 UNIT Energy electron-volt eV 1.0 e V AllPrefixes
212 
213 QUANTITY DERIVED Capacitance C/V
214 UNIT Capacitance farad F 1.0 * AllPrefixes
215 
216 QUANTITY DERIVED Resistance V/A
217 UNIT Resistance ohm ohm 1.0 * AllPrefixes
218 UNIT Resistance Z0 Z0 120 pi ohm NoPrefixes
219 
220 QUANTITY DERIVED ThermalResistanceArea m^2 L/W
221 UNIT ThermalResistanceArea rsi rsi 1.0 * NoPrefixes
222 UNIT ThermalResistanceArea clo clo 0.155 rsi NoPrefixes
223 UNIT ThermalResistanceArea rValue rValue 0.1761101838 rsi NoPrefixes
224 UNIT ThermalResistanceArea tog tog 0.1 rsi NoPrefixes
225 
226 QUANTITY DERIVED Conductance A/V
227 UNIT Conductance siemens S 1.0 * AllPrefixes
228 
229 QUANTITY DERIVED 20LOG MagneticFlux V s
230 UNIT MagneticFlux weber Wb 1.0 * AllPrefixes
231 
232 QUANTITY DERIVED 20LOG MagneticFluxDensity Wb/m^2
233 UNIT MagneticFluxDensity tesla T 1.0 * AllPrefixes
234 UNIT MagneticFluxDensity gauss G 0.0001 T AllPrefixes
235 
236 QUANTITY DERIVED Inductance Wb/A
237 UNIT Inductance henry H 1.0 * AllPrefixes
238 
239 QUANTITY DERIVED SolidAngle m^2/m^2
240 UNIT SolidAngle steradian sr .25 1/pi GoodPrefixes cmun
241 
242 QUANTITY DERIVED LuminousFlux cd sr
243 UNIT LuminousFlux lumen lm 1.0 * AllPrefixes
244 
245 QUANTITY DERIVED Illuminance lm/m^2
246 UNIT Illuminance lux lx 1.0 * AllPrefixes
247 UNIT Illuminance footcandle fc 1.0 lm/ft^2 AllPrefixes
248 
249 QUANTITY DERIVED Luminance cd/m^2
250 UNIT Luminance nit nit 1.0 * AllPrefixes
251 UNIT Luminance stilb sb 1.0 cd/cm^2 AllPrefixes
252 UNIT Luminance lambert Lb 1.0 sb/pi AllPrefixes
253 UNIT Luminance footlambert fL 1.0 cd/pi ft^2 AllPrefixes
254 
255 QUANTITY DERIVED ActivityRadionuclide 1/s
256 UNIT ActivityRadionuclide becquerel Bq 1.0 * AllPrefixes
257 
258 QUANTITY DERIVED Radiation-Dose J/kg
259 UNIT Radiation-Dose gray Gy 1.0 * AllPrefixes
260 UNIT Radiation-Dose rad rd 0.01 Gy NoPrefixes
261 
262 QUANTITY DERIVED Action J s
263 UNIT Action planck's-constant h 6.6260689633E-34 * NoPrefixes
264 QUANTITY DERIVED AngularAction h/pi
265 UNIT AngularAction dirac's-constant hbar 1.0 * NoPrefixes
266 
267 QUANTITY DERIVED MolesOfMass mol g
268 
269 QUANTITY DERIVED 20LOG ElectricFieldStrength V/m
270 QUANTITY DERIVED PowerDensity W/cm^2
271 
272 QUANTITY DERIVED BoltzmannQuantity J/K
273 UNIT BoltzmannQuantity BoltzmannConstant kB 1.3806503E-23 * NoPrefixes
274 
275 TYPEMAP Energy Mass 1 c^2
276 TYPEMAP Energy Frequency 1 h
277 TYPEMAP Distance Frequency -1 c
278 TYPEMAP Energy Distance -1 h c
279 TYPEMAP Mass MolesOfMass 1 Na
280 TYPEMAP PowerDensity ElectricFieldStrength 2 1/Z0
281 TYPEMAP Energy Temperature 1 kB
282 
283 )UCEDEFS";
284 
285 }
286 #endif //BIOGEARS_CDM_UTILS_UNITCONVERSION_UCEDefs_H
constexpr const char * UCEDEFS_TEXT
Definition: UCEDefs.h:61
Definition: SEElectricalCircuit.h:18