File indexing completed on 2025-09-16 08:52:28
0001
0002
0003
0004
0005
0006
0007
0008 #pragma once
0009
0010 #include "corecel/Config.hh"
0011
0012 #include "corecel/Types.hh"
0013 #include "corecel/math/Constant.hh"
0014
0015 namespace celeritas
0016 {
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054 namespace units
0055 {
0056
0057
0058 #define CELER_ICRT inline constexpr Constant
0059
0060 #if CELERITAS_UNITS == CELERITAS_UNITS_CGS
0061
0062
0063 CELER_ICRT centimeter{1};
0064 CELER_ICRT gram{1};
0065 CELER_ICRT second{1};
0066 CELER_ICRT gauss{1};
0067 CELER_ICRT kelvin{1};
0068
0069
0070
0071
0072 CELER_ICRT meter = 100 * centimeter;
0073 CELER_ICRT kilogram = 1000 * gram;
0074 CELER_ICRT tesla = 10000 * gauss;
0075
0076
0077
0078
0079 CELER_ICRT newton = kilogram * meter / (second * second);
0080 CELER_ICRT joule = newton * meter;
0081 CELER_ICRT coulomb = kilogram / (tesla * second);
0082 CELER_ICRT ampere = coulomb / second;
0083 CELER_ICRT volt = joule / coulomb;
0084 CELER_ICRT farad = coulomb / volt;
0085
0086
0087
0088
0089 CELER_ICRT millimeter = Constant{0.1} * centimeter;
0090 CELER_ICRT nanosecond = Constant{1e-9} * second;
0091
0092
0093 #elif CELERITAS_UNITS == CELERITAS_UNITS_SI
0094
0095
0096 CELER_ICRT second{1};
0097 CELER_ICRT meter{1};
0098 CELER_ICRT kilogram{1};
0099 CELER_ICRT kelvin{1};
0100 CELER_ICRT coulomb{1};
0101
0102
0103
0104
0105 CELER_ICRT newton = kilogram * meter / (second * second);
0106 CELER_ICRT joule = newton * meter;
0107 CELER_ICRT volt = joule / coulomb;
0108 CELER_ICRT tesla = volt * second / (meter * meter);
0109 CELER_ICRT ampere = coulomb / second;
0110 CELER_ICRT farad = coulomb / volt;
0111
0112
0113
0114
0115 CELER_ICRT gauss = Constant{1e-4} * tesla;
0116 CELER_ICRT centimeter = Constant{1e-2} * meter;
0117 CELER_ICRT gram = Constant{1e-3} * kilogram;
0118
0119
0120
0121
0122 CELER_ICRT millimeter = Constant{1e-3} * meter;
0123 CELER_ICRT nanosecond = Constant{1e-9} * second;
0124
0125
0126 #elif CELERITAS_UNITS == CELERITAS_UNITS_CLHEP
0127
0128
0129
0130 CELER_ICRT millimeter{1};
0131 CELER_ICRT megaelectronvolt{1};
0132 CELER_ICRT nanosecond{1};
0133 CELER_ICRT e_electron{1};
0134 CELER_ICRT kelvin{1};
0135
0136
0137
0138 CELER_ICRT coulomb = e_electron / Constant{1.602176634e-19};
0139 CELER_ICRT volt = Constant{1e-6} * (megaelectronvolt / e_electron);
0140 CELER_ICRT joule = coulomb * volt;
0141
0142 CELER_ICRT second = Constant{1e9} * nanosecond;
0143 CELER_ICRT meter = 1000 * millimeter;
0144
0145 CELER_ICRT ampere = coulomb / second;
0146 CELER_ICRT farad = coulomb / volt;
0147 CELER_ICRT kilogram = joule * (second / meter) * (second / meter);
0148 CELER_ICRT tesla = volt * second / (meter * meter);
0149 CELER_ICRT newton = joule / meter;
0150
0151
0152
0153 CELER_ICRT centimeter = 10 * millimeter;
0154 CELER_ICRT gram = Constant{1e-3} * kilogram;
0155 CELER_ICRT gauss = Constant{1e-4} * tesla;
0156
0157
0158 #endif
0159
0160
0161
0162 CELER_ICRT micrometer = Constant{1e-4} * centimeter;
0163 CELER_ICRT nanometer = Constant{1e-7} * centimeter;
0164 CELER_ICRT femtometer = Constant{1e-13} * centimeter;
0165 CELER_ICRT barn = Constant{1e-24} * centimeter * centimeter;
0166
0167
0168 #undef CELER_ICRT
0169
0170
0171 }
0172 }