Physical Quantities  v1.0.0
C++ library of physical quantities, physical models, and units of measure for scientific computing. https://github.com/acodcha/phq
Energy.hpp
Go to the documentation of this file.
1 // Copyright © 2020-2024 Alexandre Coderre-Chabot
2 //
3 // This file is part of Physical Quantities (PhQ), a C++ library of physical quantities, physical
4 // models, and units of measure for scientific computing.
5 //
6 // Physical Quantities is hosted at:
7 // https://github.com/acodcha/phq
8 //
9 // Physical Quantities is licensed under the MIT License:
10 // https://mit-license.org
11 //
12 // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
13 // associated documentation files (the "Software"), to deal in the Software without restriction,
14 // including without limitation the rights to use, copy, modify, merge, publish, distribute,
15 // sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
16 // furnished to do so, subject to the following conditions:
17 // - The above copyright notice and this permission notice shall be included in all copies or
18 // substantial portions of the Software.
19 // - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
20 // BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
22 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM
23 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 
25 #ifndef PHQ_UNIT_ENERGY_HPP
26 #define PHQ_UNIT_ENERGY_HPP
27 
28 #include <cstddef>
29 #include <cstdint>
30 #include <functional>
31 #include <map>
32 #include <ostream>
33 #include <string_view>
34 #include <unordered_map>
35 
36 #include "../Base.hpp"
37 #include "../Dimension/ElectricCurrent.hpp"
38 #include "../Dimension/Length.hpp"
39 #include "../Dimension/LuminousIntensity.hpp"
40 #include "../Dimension/Mass.hpp"
41 #include "../Dimension/SubstanceAmount.hpp"
42 #include "../Dimension/Temperature.hpp"
43 #include "../Dimension/Time.hpp"
44 #include "../Dimensions.hpp"
45 #include "../Unit.hpp"
46 #include "../UnitSystem.hpp"
47 
48 namespace PhQ {
49 
50 namespace Unit {
51 
52 /// \brief Energy units.
53 enum class Energy : int8_t {
54  /// \brief Joule (J) energy unit.
55  Joule,
56 
57  /// \brief Millijoule (mJ) energy unit.
58  Millijoule,
59 
60  /// \brief Microjoule (μJ) energy unit.
61  Microjoule,
62 
63  /// \brief Nanojoule (nJ) energy unit.
64  Nanojoule,
65 
66  /// \brief Kilojoule (kJ) energy unit.
67  Kilojoule,
68 
69  /// \brief Megajoule (MJ) energy unit.
70  Megajoule,
71 
72  /// \brief Gigajoule (GJ) energy unit.
73  Gigajoule,
74 
75  /// \brief Watt-minute (W·min) energy unit.
76  WattMinute,
77 
78  /// \brief Watt-hour (W·hr) energy unit.
79  WattHour,
80 
81  /// \brief Kilowatt-minute (kW·min) energy unit.
83 
84  /// \brief Kilowatt-hour (kW·hr) energy unit.
86 
87  /// \brief Megawatt-minute (MW·min) energy unit.
89 
90  /// \brief Megawatt-hour (MW·hr) energy unit.
92 
93  /// \brief Gigawatt-minute (GW·min) energy unit.
95 
96  /// \brief Gigawatt-hour (GW·hr) energy unit.
98 
99  /// \brief Foot-pound (ft·lbf) energy unit.
100  FootPound,
101 
102  /// \brief Inch-pound (in·lbf) energy unit.
103  InchPound,
104 
105  /// \brief Calorie (cal) energy unit.
106  Calorie,
107 
108  /// \brief Millicalorie (mcal) energy unit.
109  Millicalorie,
110 
111  /// \brief Microcalorie (μcal) energy unit.
112  Microcalorie,
113 
114  /// \brief Nanocalorie (ncal) energy unit.
115  Nanocalorie,
116 
117  /// \brief Kilocalorie (kcal) energy unit.
118  Kilocalorie,
119 
120  /// \brief Megacalorie (Mcal) energy unit.
121  Megacalorie,
122 
123  /// \brief Gigacalorie (Gcal) energy unit.
124  Gigacalorie,
125 
126  /// \brief Electronvolt (eV) energy unit.
127  Electronvolt,
128 
129  /// \brief Millielectronvolt (meV) energy unit.
131 
132  /// \brief Microelectronvolt (μeV) energy unit.
134 
135  /// \brief Nanoelectronvolt (neV) energy unit.
137 
138  /// \brief Kiloelectronvolt (keV) energy unit.
140 
141  /// \brief Megaelectronvolt (MeV) energy unit.
143 
144  /// \brief Gigaelectronvolt (GeV) energy unit.
146 
147  /// \brief British thermal unit (BTU) energy unit.
149 };
150 
151 } // namespace Unit
152 
153 /// \brief Standard energy unit: joule (J).
154 template <>
155 inline constexpr const Unit::Energy Standard<Unit::Energy>{Unit::Energy::Joule};
156 
157 /// \brief Physical dimension set of energy units.
158 template <>
159 inline constexpr const Dimensions RelatedDimensions<Unit::Energy>{
160  Dimensions{Dimension::Time{-2}, Dimension::Length{2}, Dimension::Mass{1},
162  Dimension::SubstanceAmount{0}, Dimension::LuminousIntensity{0}}
163 };
164 
165 inline std::ostream& operator<<(std::ostream& stream, const Unit::Energy unit) {
166  stream << Abbreviation(unit);
167  return stream;
168 }
169 
170 namespace Internal {
171 
172 template <>
173 inline const std::map<UnitSystem, Unit::Energy> ConsistentUnits<Unit::Energy>{
178 };
179 
180 template <>
181 inline const std::map<Unit::Energy, UnitSystem> RelatedUnitSystems<Unit::Energy>{
186 };
187 
188 // clang-format off
189 
190 template <>
191 inline const std::map<Unit::Energy, std::string_view> Abbreviations<Unit::Energy>{
192  {Unit::Energy::Joule, "J" },
193  {Unit::Energy::Millijoule, "mJ" },
194  {Unit::Energy::Microjoule, "μJ" },
195  {Unit::Energy::Nanojoule, "nJ" },
196  {Unit::Energy::Kilojoule, "kJ" },
197  {Unit::Energy::Megajoule, "MJ" },
198  {Unit::Energy::Gigajoule, "GJ" },
199  {Unit::Energy::WattMinute, "W·min" },
200  {Unit::Energy::WattHour, "W·hr" },
201  {Unit::Energy::KilowattMinute, "kW·min"},
202  {Unit::Energy::KilowattHour, "kW·hr" },
203  {Unit::Energy::MegawattMinute, "MW·min"},
204  {Unit::Energy::MegawattHour, "MW·hr" },
205  {Unit::Energy::GigawattMinute, "GW·min"},
206  {Unit::Energy::GigawattHour, "GW·hr" },
207  {Unit::Energy::FootPound, "ft·lbf"},
208  {Unit::Energy::InchPound, "in·lbf"},
209  {Unit::Energy::Calorie, "cal" },
210  {Unit::Energy::Millicalorie, "mcal" },
211  {Unit::Energy::Microcalorie, "μcal" },
212  {Unit::Energy::Nanocalorie, "ncal" },
213  {Unit::Energy::Kilocalorie, "kcal" },
214  {Unit::Energy::Megacalorie, "Mcal" },
215  {Unit::Energy::Gigacalorie, "Gcal" },
224 };
225 
226 template <>
227 inline const std::unordered_map<std::string_view, Unit::Energy> Spellings<Unit::Energy>{
228  {"J", Unit::Energy::Joule },
229  {"N·m", Unit::Energy::Joule },
230  {"N*m", Unit::Energy::Joule },
231  {"kg·m^2/s^2", Unit::Energy::Joule },
232  {"kg*m^2/s^2", Unit::Energy::Joule },
233  {"kg·m2/s2", Unit::Energy::Joule },
234  {"kg*m2/s2", Unit::Energy::Joule },
235  {"W·s", Unit::Energy::Joule },
236  {"W*s", Unit::Energy::Joule },
237  {"mJ", Unit::Energy::Millijoule },
238  {"μJ", Unit::Energy::Microjoule },
239  {"uJ", Unit::Energy::Microjoule },
240  {"nJ", Unit::Energy::Nanojoule },
241  {"μN·mm", Unit::Energy::Nanojoule },
242  {"μN*mm", Unit::Energy::Nanojoule },
243  {"uN·mm", Unit::Energy::Nanojoule },
244  {"uN*mm", Unit::Energy::Nanojoule },
245  {"g·mm^2/s^2", Unit::Energy::Nanojoule },
246  {"g*mm^2/s^2", Unit::Energy::Nanojoule },
247  {"g·mm2/s2", Unit::Energy::Nanojoule },
248  {"g*mm2/s2", Unit::Energy::Nanojoule },
249  {"kJ", Unit::Energy::Kilojoule },
250  {"MJ", Unit::Energy::Megajoule },
251  {"GJ", Unit::Energy::Gigajoule },
252  {"W·min", Unit::Energy::WattMinute },
253  {"W*min", Unit::Energy::WattMinute },
254  {"W·hr", Unit::Energy::WattHour },
255  {"W*hr", Unit::Energy::WattHour },
256  {"kW·min", Unit::Energy::KilowattMinute },
257  {"kW*min", Unit::Energy::KilowattMinute },
258  {"kW·hr", Unit::Energy::KilowattHour },
259  {"kW*hr", Unit::Energy::KilowattHour },
260  {"MW·min", Unit::Energy::MegawattMinute },
261  {"MW*min", Unit::Energy::MegawattMinute },
262  {"MW·hr", Unit::Energy::MegawattHour },
263  {"MW*hr", Unit::Energy::MegawattHour },
264  {"GW·min", Unit::Energy::GigawattMinute },
265  {"GW*min", Unit::Energy::GigawattMinute },
266  {"GW·hr", Unit::Energy::GigawattHour },
267  {"GW*hr", Unit::Energy::GigawattHour },
268  {"ft·lbf", Unit::Energy::FootPound },
269  {"ft*lbf", Unit::Energy::FootPound },
270  {"ft·lb", Unit::Energy::FootPound },
271  {"ft*lb", Unit::Energy::FootPound },
272  {"in·lbf", Unit::Energy::InchPound },
273  {"in*lbf", Unit::Energy::InchPound },
274  {"in·lb", Unit::Energy::InchPound },
275  {"in*lb", Unit::Energy::InchPound },
276  {"cal", Unit::Energy::Calorie },
277  {"mcal", Unit::Energy::Millicalorie },
278  {"μcal", Unit::Energy::Microcalorie },
279  {"ucal", Unit::Energy::Microcalorie },
280  {"ncal", Unit::Energy::Nanocalorie },
281  {"kcal", Unit::Energy::Kilocalorie },
282  {"Cal", Unit::Energy::Kilocalorie },
283  {"Mcal", Unit::Energy::Megacalorie },
284  {"Gcal", Unit::Energy::Gigacalorie },
295 };
296 
297 // clang-format on
298 
299 template <>
300 template <typename NumericType>
301 inline constexpr void Conversion<Unit::Energy, Unit::Energy::Joule>::FromStandard(
302  NumericType& /*value*/) noexcept {}
303 
304 template <>
305 template <typename NumericType>
306 inline constexpr void Conversion<Unit::Energy, Unit::Energy::Joule>::ToStandard(
307  NumericType& /*value*/) noexcept {}
308 
309 template <>
310 template <typename NumericType>
311 inline constexpr void Conversion<Unit::Energy, Unit::Energy::Millijoule>::FromStandard(
312  NumericType& value) noexcept {
313  value *= static_cast<NumericType>(1000.0L);
314 }
315 
316 template <>
317 template <typename NumericType>
318 inline constexpr void Conversion<Unit::Energy, Unit::Energy::Millijoule>::ToStandard(
319  NumericType& value) noexcept {
320  value *= static_cast<NumericType>(0.001L);
321 }
322 
323 template <>
324 template <typename NumericType>
325 inline constexpr void Conversion<Unit::Energy, Unit::Energy::Microjoule>::FromStandard(
326  NumericType& value) noexcept {
327  value *= static_cast<NumericType>(1000000.0L);
328 }
329 
330 template <>
331 template <typename NumericType>
332 inline constexpr void Conversion<Unit::Energy, Unit::Energy::Microjoule>::ToStandard(
333  NumericType& value) noexcept {
334  value *= static_cast<NumericType>(0.000001L);
335 }
336 
337 template <>
338 template <typename NumericType>
339 inline constexpr void Conversion<Unit::Energy, Unit::Energy::Nanojoule>::FromStandard(
340  NumericType& value) noexcept {
341  value *= static_cast<NumericType>(1000000000.0L);
342 }
343 
344 template <>
345 template <typename NumericType>
346 inline constexpr void Conversion<Unit::Energy, Unit::Energy::Nanojoule>::ToStandard(
347  NumericType& value) noexcept {
348  value *= static_cast<NumericType>(0.000000001L);
349 }
350 
351 template <>
352 template <typename NumericType>
353 inline constexpr void Conversion<Unit::Energy, Unit::Energy::Kilojoule>::FromStandard(
354  NumericType& value) noexcept {
355  value *= static_cast<NumericType>(0.001L);
356 }
357 
358 template <>
359 template <typename NumericType>
360 inline constexpr void Conversion<Unit::Energy, Unit::Energy::Kilojoule>::ToStandard(
361  NumericType& value) noexcept {
362  value *= static_cast<NumericType>(1000.0L);
363 }
364 
365 template <>
366 template <typename NumericType>
367 inline constexpr void Conversion<Unit::Energy, Unit::Energy::Megajoule>::FromStandard(
368  NumericType& value) noexcept {
369  value *= static_cast<NumericType>(0.000001L);
370 }
371 
372 template <>
373 template <typename NumericType>
374 inline constexpr void Conversion<Unit::Energy, Unit::Energy::Megajoule>::ToStandard(
375  NumericType& value) noexcept {
376  value *= static_cast<NumericType>(1000000.0L);
377 }
378 
379 template <>
380 template <typename NumericType>
381 inline constexpr void Conversion<Unit::Energy, Unit::Energy::Gigajoule>::FromStandard(
382  NumericType& value) noexcept {
383  value *= static_cast<NumericType>(0.000000001L);
384 }
385 
386 template <>
387 template <typename NumericType>
388 inline constexpr void Conversion<Unit::Energy, Unit::Energy::Gigajoule>::ToStandard(
389  NumericType& value) noexcept {
390  value *= static_cast<NumericType>(1000000000.0L);
391 }
392 
393 template <>
394 template <typename NumericType>
395 inline constexpr void Conversion<Unit::Energy, Unit::Energy::WattMinute>::FromStandard(
396  NumericType& value) noexcept {
397  value /= static_cast<NumericType>(60.0L);
398 }
399 
400 template <>
401 template <typename NumericType>
402 inline constexpr void Conversion<Unit::Energy, Unit::Energy::WattMinute>::ToStandard(
403  NumericType& value) noexcept {
404  value *= static_cast<NumericType>(60.0L);
405 }
406 
407 template <>
408 template <typename NumericType>
409 inline constexpr void Conversion<Unit::Energy, Unit::Energy::WattHour>::FromStandard(
410  NumericType& value) noexcept {
411  value /= static_cast<NumericType>(3600.0L);
412 }
413 
414 template <>
415 template <typename NumericType>
416 inline constexpr void Conversion<Unit::Energy, Unit::Energy::WattHour>::ToStandard(
417  NumericType& value) noexcept {
418  value *= static_cast<NumericType>(3600.0L);
419 }
420 
421 template <>
422 template <typename NumericType>
423 inline constexpr void Conversion<Unit::Energy, Unit::Energy::KilowattMinute>::FromStandard(
424  NumericType& value) noexcept {
425  value /= static_cast<NumericType>(60000.0L);
426 }
427 
428 template <>
429 template <typename NumericType>
430 inline constexpr void Conversion<Unit::Energy, Unit::Energy::KilowattMinute>::ToStandard(
431  NumericType& value) noexcept {
432  value *= static_cast<NumericType>(60000.0L);
433 }
434 
435 template <>
436 template <typename NumericType>
437 inline constexpr void Conversion<Unit::Energy, Unit::Energy::KilowattHour>::FromStandard(
438  NumericType& value) noexcept {
439  value /= static_cast<NumericType>(3600000.0L);
440 }
441 
442 template <>
443 template <typename NumericType>
444 inline constexpr void Conversion<Unit::Energy, Unit::Energy::KilowattHour>::ToStandard(
445  NumericType& value) noexcept {
446  value *= static_cast<NumericType>(3600000.0L);
447 }
448 
449 template <>
450 template <typename NumericType>
451 inline constexpr void Conversion<Unit::Energy, Unit::Energy::MegawattMinute>::FromStandard(
452  NumericType& value) noexcept {
453  value /= static_cast<NumericType>(60000000.0L);
454 }
455 
456 template <>
457 template <typename NumericType>
458 inline constexpr void Conversion<Unit::Energy, Unit::Energy::MegawattMinute>::ToStandard(
459  NumericType& value) noexcept {
460  value *= static_cast<NumericType>(60000000.0L);
461 }
462 
463 template <>
464 template <typename NumericType>
465 inline constexpr void Conversion<Unit::Energy, Unit::Energy::MegawattHour>::FromStandard(
466  NumericType& value) noexcept {
467  value /= static_cast<NumericType>(3600000000.0L);
468 }
469 
470 template <>
471 template <typename NumericType>
472 inline constexpr void Conversion<Unit::Energy, Unit::Energy::MegawattHour>::ToStandard(
473  NumericType& value) noexcept {
474  value *= static_cast<NumericType>(3600000000.0L);
475 }
476 
477 template <>
478 template <typename NumericType>
479 inline constexpr void Conversion<Unit::Energy, Unit::Energy::GigawattMinute>::FromStandard(
480  NumericType& value) noexcept {
481  value /= static_cast<NumericType>(60000000000.0L);
482 }
483 
484 template <>
485 template <typename NumericType>
486 inline constexpr void Conversion<Unit::Energy, Unit::Energy::GigawattMinute>::ToStandard(
487  NumericType& value) noexcept {
488  value *= static_cast<NumericType>(60000000000.0L);
489 }
490 
491 template <>
492 template <typename NumericType>
493 inline constexpr void Conversion<Unit::Energy, Unit::Energy::GigawattHour>::FromStandard(
494  NumericType& value) noexcept {
495  value /= static_cast<NumericType>(3600000000000.0L);
496 }
497 
498 template <>
499 template <typename NumericType>
500 inline constexpr void Conversion<Unit::Energy, Unit::Energy::GigawattHour>::ToStandard(
501  NumericType& value) noexcept {
502  value *= static_cast<NumericType>(3600000000000.0L);
503 }
504 
505 template <>
506 template <typename NumericType>
507 inline constexpr void Conversion<Unit::Energy, Unit::Energy::FootPound>::FromStandard(
508  NumericType& value) noexcept {
509  value /= (static_cast<NumericType>(0.3048L) * static_cast<NumericType>(0.45359237L)
510  * static_cast<NumericType>(9.80665L));
511 }
512 
513 template <>
514 template <typename NumericType>
515 inline constexpr void Conversion<Unit::Energy, Unit::Energy::FootPound>::ToStandard(
516  NumericType& value) noexcept {
517  value *= static_cast<NumericType>(0.3048L) * static_cast<NumericType>(0.45359237L)
518  * static_cast<NumericType>(9.80665L);
519 }
520 
521 template <>
522 template <typename NumericType>
523 inline constexpr void Conversion<Unit::Energy, Unit::Energy::InchPound>::FromStandard(
524  NumericType& value) noexcept {
525  value /= (static_cast<NumericType>(0.0254L) * static_cast<NumericType>(0.45359237L)
526  * static_cast<NumericType>(9.80665L));
527 }
528 
529 template <>
530 template <typename NumericType>
531 inline constexpr void Conversion<Unit::Energy, Unit::Energy::InchPound>::ToStandard(
532  NumericType& value) noexcept {
533  value *= static_cast<NumericType>(0.0254L) * static_cast<NumericType>(0.45359237L)
534  * static_cast<NumericType>(9.80665L);
535 }
536 
537 template <>
538 template <typename NumericType>
539 inline constexpr void Conversion<Unit::Energy, Unit::Energy::Calorie>::FromStandard(
540  NumericType& value) noexcept {
541  value /= static_cast<NumericType>(4.184L);
542 }
543 
544 template <>
545 template <typename NumericType>
546 inline constexpr void Conversion<Unit::Energy, Unit::Energy::Calorie>::ToStandard(
547  NumericType& value) noexcept {
548  value *= static_cast<NumericType>(4.184L);
549 }
550 
551 template <>
552 template <typename NumericType>
553 inline constexpr void Conversion<Unit::Energy, Unit::Energy::Millicalorie>::FromStandard(
554  NumericType& value) noexcept {
555  value /= static_cast<NumericType>(0.004184L);
556 }
557 
558 template <>
559 template <typename NumericType>
560 inline constexpr void Conversion<Unit::Energy, Unit::Energy::Millicalorie>::ToStandard(
561  NumericType& value) noexcept {
562  value *= static_cast<NumericType>(0.004184L);
563 }
564 
565 template <>
566 template <typename NumericType>
567 inline constexpr void Conversion<Unit::Energy, Unit::Energy::Microcalorie>::FromStandard(
568  NumericType& value) noexcept {
569  value /= static_cast<NumericType>(0.000004184L);
570 }
571 
572 template <>
573 template <typename NumericType>
574 inline constexpr void Conversion<Unit::Energy, Unit::Energy::Microcalorie>::ToStandard(
575  NumericType& value) noexcept {
576  value *= static_cast<NumericType>(0.000004184L);
577 }
578 
579 template <>
580 template <typename NumericType>
581 inline constexpr void Conversion<Unit::Energy, Unit::Energy::Nanocalorie>::FromStandard(
582  NumericType& value) noexcept {
583  value /= static_cast<NumericType>(0.000000004184L);
584 }
585 
586 template <>
587 template <typename NumericType>
588 inline constexpr void Conversion<Unit::Energy, Unit::Energy::Nanocalorie>::ToStandard(
589  NumericType& value) noexcept {
590  value *= static_cast<NumericType>(0.000000004184L);
591 }
592 
593 template <>
594 template <typename NumericType>
595 inline constexpr void Conversion<Unit::Energy, Unit::Energy::Kilocalorie>::FromStandard(
596  NumericType& value) noexcept {
597  value /= static_cast<NumericType>(4184.0L);
598 }
599 
600 template <>
601 template <typename NumericType>
602 inline constexpr void Conversion<Unit::Energy, Unit::Energy::Kilocalorie>::ToStandard(
603  NumericType& value) noexcept {
604  value *= static_cast<NumericType>(4184.0L);
605 }
606 
607 template <>
608 template <typename NumericType>
609 inline constexpr void Conversion<Unit::Energy, Unit::Energy::Megacalorie>::FromStandard(
610  NumericType& value) noexcept {
611  value /= static_cast<NumericType>(4184000.0L);
612 }
613 
614 template <>
615 template <typename NumericType>
616 inline constexpr void Conversion<Unit::Energy, Unit::Energy::Megacalorie>::ToStandard(
617  NumericType& value) noexcept {
618  value *= static_cast<NumericType>(4184000.0L);
619 }
620 
621 template <>
622 template <typename NumericType>
623 inline constexpr void Conversion<Unit::Energy, Unit::Energy::Gigacalorie>::FromStandard(
624  NumericType& value) noexcept {
625  value /= static_cast<NumericType>(4184000000.0L);
626 }
627 
628 template <>
629 template <typename NumericType>
630 inline constexpr void Conversion<Unit::Energy, Unit::Energy::Gigacalorie>::ToStandard(
631  NumericType& value) noexcept {
632  value *= static_cast<NumericType>(4184000000.0L);
633 }
634 
635 template <>
636 template <typename NumericType>
637 inline constexpr void Conversion<Unit::Energy, Unit::Energy::Electronvolt>::FromStandard(
638  NumericType& value) noexcept {
639  value /= static_cast<NumericType>(1.602176634e-19L);
640 }
641 
642 template <>
643 template <typename NumericType>
644 inline constexpr void Conversion<Unit::Energy, Unit::Energy::Electronvolt>::ToStandard(
645  NumericType& value) noexcept {
646  value *= static_cast<NumericType>(1.602176634e-19L);
647 }
648 
649 template <>
650 template <typename NumericType>
651 inline constexpr void Conversion<Unit::Energy, Unit::Energy::Millielectronvolt>::FromStandard(
652  NumericType& value) noexcept {
653  value /= static_cast<NumericType>(1.602176634e-22L);
654 }
655 
656 template <>
657 template <typename NumericType>
658 inline constexpr void Conversion<Unit::Energy, Unit::Energy::Millielectronvolt>::ToStandard(
659  NumericType& value) noexcept {
660  value *= static_cast<NumericType>(1.602176634e-22L);
661 }
662 
663 template <>
664 template <typename NumericType>
665 inline constexpr void Conversion<Unit::Energy, Unit::Energy::Microelectronvolt>::FromStandard(
666  NumericType& value) noexcept {
667  value /= static_cast<NumericType>(1.602176634e-25L);
668 }
669 
670 template <>
671 template <typename NumericType>
672 inline constexpr void Conversion<Unit::Energy, Unit::Energy::Microelectronvolt>::ToStandard(
673  NumericType& value) noexcept {
674  value *= static_cast<NumericType>(1.602176634e-25L);
675 }
676 
677 template <>
678 template <typename NumericType>
679 inline constexpr void Conversion<Unit::Energy, Unit::Energy::Nanoelectronvolt>::FromStandard(
680  NumericType& value) noexcept {
681  value /= static_cast<NumericType>(1.602176634e-28L);
682 }
683 
684 template <>
685 template <typename NumericType>
686 inline constexpr void Conversion<Unit::Energy, Unit::Energy::Nanoelectronvolt>::ToStandard(
687  NumericType& value) noexcept {
688  value *= static_cast<NumericType>(1.602176634e-28L);
689 }
690 
691 template <>
692 template <typename NumericType>
693 inline constexpr void Conversion<Unit::Energy, Unit::Energy::Kiloelectronvolt>::FromStandard(
694  NumericType& value) noexcept {
695  value /= static_cast<NumericType>(1.602176634e-16L);
696 }
697 
698 template <>
699 template <typename NumericType>
700 inline constexpr void Conversion<Unit::Energy, Unit::Energy::Kiloelectronvolt>::ToStandard(
701  NumericType& value) noexcept {
702  value *= static_cast<NumericType>(1.602176634e-16L);
703 }
704 
705 template <>
706 template <typename NumericType>
707 inline constexpr void Conversion<Unit::Energy, Unit::Energy::Megaelectronvolt>::FromStandard(
708  NumericType& value) noexcept {
709  value /= static_cast<NumericType>(1.602176634e-13L);
710 }
711 
712 template <>
713 template <typename NumericType>
714 inline constexpr void Conversion<Unit::Energy, Unit::Energy::Megaelectronvolt>::ToStandard(
715  NumericType& value) noexcept {
716  value *= static_cast<NumericType>(1.602176634e-13L);
717 }
718 
719 template <>
720 template <typename NumericType>
721 inline constexpr void Conversion<Unit::Energy, Unit::Energy::Gigaelectronvolt>::FromStandard(
722  NumericType& value) noexcept {
723  value /= static_cast<NumericType>(1.602176634e-10L);
724 }
725 
726 template <>
727 template <typename NumericType>
728 inline constexpr void Conversion<Unit::Energy, Unit::Energy::Gigaelectronvolt>::ToStandard(
729  NumericType& value) noexcept {
730  value *= static_cast<NumericType>(1.602176634e-10L);
731 }
732 
733 template <>
734 template <typename NumericType>
735 inline constexpr void Conversion<Unit::Energy, Unit::Energy::BritishThermalUnit>::FromStandard(
736  NumericType& value) noexcept {
737  value *= static_cast<NumericType>(1.8L)
738  / (static_cast<NumericType>(4.1868L) * static_cast<NumericType>(453.59237L));
739 }
740 
741 template <>
742 template <typename NumericType>
743 inline constexpr void Conversion<Unit::Energy, Unit::Energy::BritishThermalUnit>::ToStandard(
744  NumericType& value) noexcept {
745  value *= static_cast<NumericType>(4.1868L) * static_cast<NumericType>(453.59237L)
746  / static_cast<NumericType>(1.8L);
747 }
748 
749 template <typename NumericType>
750 inline const std::map<Unit::Energy,
751  std::function<void(NumericType* values, const std::size_t size)>>
752  MapOfConversionsFromStandard<Unit::Energy, NumericType>{
754  Conversions<Unit::Energy, Unit::Energy::Joule>::FromStandard<NumericType> },
756  Conversions<Unit::Energy, Unit::Energy::Millijoule>::FromStandard<NumericType> },
758  Conversions<Unit::Energy, Unit::Energy::Microjoule>::FromStandard<NumericType> },
760  Conversions<Unit::Energy, Unit::Energy::Nanojoule>::FromStandard<NumericType> },
762  Conversions<Unit::Energy, Unit::Energy::Kilojoule>::FromStandard<NumericType> },
764  Conversions<Unit::Energy, Unit::Energy::Megajoule>::FromStandard<NumericType> },
766  Conversions<Unit::Energy, Unit::Energy::Gigajoule>::FromStandard<NumericType> },
768  Conversions<Unit::Energy, Unit::Energy::WattMinute>::FromStandard<NumericType> },
770  Conversions<Unit::Energy, Unit::Energy::WattHour>::FromStandard<NumericType> },
772  Conversions<Unit::Energy, Unit::Energy::KilowattMinute>::FromStandard<NumericType> },
774  Conversions<Unit::Energy, Unit::Energy::KilowattHour>::FromStandard<NumericType> },
776  Conversions<Unit::Energy, Unit::Energy::MegawattMinute>::FromStandard<NumericType> },
778  Conversions<Unit::Energy, Unit::Energy::MegawattHour>::FromStandard<NumericType> },
780  Conversions<Unit::Energy, Unit::Energy::GigawattMinute>::FromStandard<NumericType> },
782  Conversions<Unit::Energy, Unit::Energy::GigawattHour>::FromStandard<NumericType> },
784  Conversions<Unit::Energy, Unit::Energy::FootPound>::FromStandard<NumericType> },
786  Conversions<Unit::Energy, Unit::Energy::InchPound>::FromStandard<NumericType> },
788  Conversions<Unit::Energy, Unit::Energy::Calorie>::FromStandard<NumericType> },
790  Conversions<Unit::Energy, Unit::Energy::Millicalorie>::FromStandard<NumericType> },
792  Conversions<Unit::Energy, Unit::Energy::Microcalorie>::FromStandard<NumericType> },
794  Conversions<Unit::Energy, Unit::Energy::Nanocalorie>::FromStandard<NumericType> },
796  Conversions<Unit::Energy, Unit::Energy::Kilocalorie>::FromStandard<NumericType> },
798  Conversions<Unit::Energy, Unit::Energy::Megacalorie>::FromStandard<NumericType> },
800  Conversions<Unit::Energy, Unit::Energy::Gigacalorie>::FromStandard<NumericType> },
802  Conversions<Unit::Energy, Unit::Energy::Electronvolt>::FromStandard<NumericType> },
804  Conversions<Unit::Energy, Unit::Energy::Millielectronvolt>::FromStandard<NumericType> },
806  Conversions<Unit::Energy, Unit::Energy::Microelectronvolt>::FromStandard<NumericType> },
808  Conversions<Unit::Energy, Unit::Energy::Nanoelectronvolt>::FromStandard<NumericType> },
810  Conversions<Unit::Energy, Unit::Energy::Kiloelectronvolt>::FromStandard<NumericType> },
812  Conversions<Unit::Energy, Unit::Energy::Megaelectronvolt>::FromStandard<NumericType> },
814  Conversions<Unit::Energy, Unit::Energy::Gigaelectronvolt>::FromStandard<NumericType> },
816  Conversions<Unit::Energy, Unit::Energy::BritishThermalUnit>::FromStandard<NumericType>},
817 };
818 
819 template <typename NumericType>
820 inline const std::map<Unit::Energy,
821  std::function<void(NumericType* const values, const std::size_t size)>>
822  MapOfConversionsToStandard<Unit::Energy, NumericType>{
824  Conversions<Unit::Energy, Unit::Energy::Joule>::ToStandard<NumericType> },
826  Conversions<Unit::Energy, Unit::Energy::Millijoule>::ToStandard<NumericType> },
828  Conversions<Unit::Energy, Unit::Energy::Microjoule>::ToStandard<NumericType> },
830  Conversions<Unit::Energy, Unit::Energy::Nanojoule>::ToStandard<NumericType> },
832  Conversions<Unit::Energy, Unit::Energy::Kilojoule>::ToStandard<NumericType> },
834  Conversions<Unit::Energy, Unit::Energy::Megajoule>::ToStandard<NumericType> },
836  Conversions<Unit::Energy, Unit::Energy::Gigajoule>::ToStandard<NumericType> },
838  Conversions<Unit::Energy, Unit::Energy::WattMinute>::ToStandard<NumericType> },
840  Conversions<Unit::Energy, Unit::Energy::WattHour>::ToStandard<NumericType> },
842  Conversions<Unit::Energy, Unit::Energy::KilowattMinute>::ToStandard<NumericType> },
844  Conversions<Unit::Energy, Unit::Energy::KilowattHour>::ToStandard<NumericType> },
846  Conversions<Unit::Energy, Unit::Energy::MegawattMinute>::ToStandard<NumericType> },
848  Conversions<Unit::Energy, Unit::Energy::MegawattHour>::ToStandard<NumericType> },
850  Conversions<Unit::Energy, Unit::Energy::GigawattMinute>::ToStandard<NumericType> },
852  Conversions<Unit::Energy, Unit::Energy::GigawattHour>::ToStandard<NumericType> },
854  Conversions<Unit::Energy, Unit::Energy::FootPound>::ToStandard<NumericType> },
856  Conversions<Unit::Energy, Unit::Energy::InchPound>::ToStandard<NumericType> },
858  Conversions<Unit::Energy, Unit::Energy::Calorie>::ToStandard<NumericType> },
860  Conversions<Unit::Energy, Unit::Energy::Millicalorie>::ToStandard<NumericType> },
862  Conversions<Unit::Energy, Unit::Energy::Microcalorie>::ToStandard<NumericType> },
864  Conversions<Unit::Energy, Unit::Energy::Nanocalorie>::ToStandard<NumericType> },
866  Conversions<Unit::Energy, Unit::Energy::Kilocalorie>::ToStandard<NumericType> },
868  Conversions<Unit::Energy, Unit::Energy::Megacalorie>::ToStandard<NumericType> },
870  Conversions<Unit::Energy, Unit::Energy::Gigacalorie>::ToStandard<NumericType> },
872  Conversions<Unit::Energy, Unit::Energy::Electronvolt>::ToStandard<NumericType> },
874  Conversions<Unit::Energy, Unit::Energy::Millielectronvolt>::ToStandard<NumericType> },
876  Conversions<Unit::Energy, Unit::Energy::Microelectronvolt>::ToStandard<NumericType> },
878  Conversions<Unit::Energy, Unit::Energy::Nanoelectronvolt>::ToStandard<NumericType> },
880  Conversions<Unit::Energy, Unit::Energy::Kiloelectronvolt>::ToStandard<NumericType> },
882  Conversions<Unit::Energy, Unit::Energy::Megaelectronvolt>::ToStandard<NumericType> },
884  Conversions<Unit::Energy, Unit::Energy::Gigaelectronvolt>::ToStandard<NumericType> },
886  Conversions<Unit::Energy, Unit::Energy::BritishThermalUnit>::ToStandard<NumericType>},
887 };
888 
889 } // namespace Internal
890 
891 } // namespace PhQ
892 
893 #endif // PHQ_UNIT_ENERGY_HPP
ElectricCurrent
Electric current units.
Mass
Mass units.
Definition: Mass.hpp:53
Length
Length units.
Definition: Length.hpp:53
Energy
Energy units.
Definition: Energy.hpp:53
@ Gigaelectronvolt
Gigaelectronvolt (GeV) energy unit.
@ Nanojoule
Nanojoule (nJ) energy unit.
@ InchPound
Inch-pound (in·lbf) energy unit.
@ Gigajoule
Gigajoule (GJ) energy unit.
@ MegawattMinute
Megawatt-minute (MW·min) energy unit.
@ BritishThermalUnit
British thermal unit (BTU) energy unit.
@ Nanocalorie
Nanocalorie (ncal) energy unit.
@ Joule
Joule (J) energy unit.
@ Microcalorie
Microcalorie (μcal) energy unit.
@ FootPound
Foot-pound (ft·lbf) energy unit.
@ Calorie
Calorie (cal) energy unit.
@ WattHour
Watt-hour (W·hr) energy unit.
@ Nanoelectronvolt
Nanoelectronvolt (neV) energy unit.
@ KilowattHour
Kilowatt-hour (kW·hr) energy unit.
@ Microjoule
Microjoule (μJ) energy unit.
@ KilowattMinute
Kilowatt-minute (kW·min) energy unit.
@ Millicalorie
Millicalorie (mcal) energy unit.
@ GigawattHour
Gigawatt-hour (GW·hr) energy unit.
@ GigawattMinute
Gigawatt-minute (GW·min) energy unit.
@ Megaelectronvolt
Megaelectronvolt (MeV) energy unit.
@ MegawattHour
Megawatt-hour (MW·hr) energy unit.
@ WattMinute
Watt-minute (W·min) energy unit.
@ Millielectronvolt
Millielectronvolt (meV) energy unit.
@ Microelectronvolt
Microelectronvolt (μeV) energy unit.
@ Gigacalorie
Gigacalorie (Gcal) energy unit.
@ Kiloelectronvolt
Kiloelectronvolt (keV) energy unit.
@ Megacalorie
Megacalorie (Mcal) energy unit.
@ Millijoule
Millijoule (mJ) energy unit.
@ Kilojoule
Kilojoule (kJ) energy unit.
@ Megajoule
Megajoule (MJ) energy unit.
@ Electronvolt
Electronvolt (eV) energy unit.
@ Kilocalorie
Kilocalorie (kcal) energy unit.
SubstanceAmount
Amount of substance units.
Temperature
Temperature units. Not to be confused with temperature difference units. For example,...
Definition: Temperature.hpp:55
Time
Time units.
Definition: Time.hpp:53
Namespace that encompasses all of the Physical Quantities library's content.
@ FootPoundSecondRankine
Foot-pound-second-rankine (ft·lbf·s·°R) system.
@ MillimetreGramSecondKelvin
Millimetre-gram-second-kelvin (mm·g·s·K) system.
@ MetreKilogramSecondKelvin
Metre-kilogram-second-kelvin (m·kg·s·K) system.
@ InchPoundSecondRankine
Inch-pound-second-rankine (in·lbf·s·°R) system.
std::string_view Abbreviation(const Enumeration enumeration)
Returns the abbreviation of a given enumeration value. For example, PhQ::Abbreviation(PhQ::Unit::Time...
Definition: Base.hpp:89
std::ostream & operator<<(std::ostream &stream, const Acceleration< NumericType > &acceleration)