Line data Source code
1 : /* 2 : * units.hpp 3 : * 4 : * Definition of different units 5 : * Created on: 30 Jun 2022 6 : * Author(s): Volkan Kumtepeli 7 : */ 8 : 9 : #pragma once 10 : 11 : #include "../settings/constants.hpp" 12 : #include <cstddef> 13 : 14 : namespace slide { 15 : 16 : // Current: 17 : constexpr inline auto operator""_kA(long double d) { return 1e3 * d; } //!< kiloAmperes 18 : constexpr inline auto operator""_A(long double d) { return d; } //!< Amperes 19 : constexpr inline auto operator""_mA(long double d) { return d * 1e-3; } //!< miliAmperes 20 : constexpr inline auto operator""_uA(long double d) { return d * 1e-6; } //!< microAmperes 21 : 22 : // Voltage: 23 : constexpr inline auto operator""_kV(long double d) { return 1e3 * d; } //!< kiloVolts 24 : constexpr inline auto operator""_V(long double d) { return d; } //!< Volts 25 : constexpr inline auto operator""_mV(long double d) { return d * 1e-3; } //!< miliVolts 26 : constexpr inline auto operator""_uV(long double d) { return d * 1e-6; } //!< microVolts 27 : 28 : 29 : // Temperature: 30 53 : constexpr inline double C_to_Kelvin(auto Celsius) { return static_cast<double>(PhyConst::Kelvin + Celsius); } // #TODO check if it better to have auto or double 31 122 : constexpr inline double K_to_Celsius(auto Kelvin) { return static_cast<double>(Kelvin - PhyConst::Kelvin); } 32 : 33 0 : constexpr inline double operator""_degC(long double d) { return C_to_Kelvin(d); } //!< degrees Celsius 34 : constexpr inline double operator""_K(long double d) { return static_cast<double>(d); } //!< Kelvins 35 : 36 53 : constexpr inline double operator""_degC(unsigned long long d) { return C_to_Kelvin(d); } //!< degrees Celsius 37 : constexpr inline double operator""_K(unsigned long long d) { return static_cast<double>(d); } //!< Kelvins 38 : 39 : 40 : } // namespace slide