scambio.constant
Physical constants.
1r"""Physical constants.""" 2 3from scipy.constants import au, c, e, h, k, sigma 4 5 6class ConstantMeta(type): 7 r"""Metaclass of Constant.""" 8 9 def __repr__(cls) -> str: 10 r"""Represent Constant class.""" 11 return "\n".join( 12 [ 13 f"Physical constants:", 14 f"- au: {cls.au:.2e} cm", 15 f"- c: {cls.c:.2e} cm·s¯¹", 16 f"- h: {cls.h:.2e} eV·s", 17 f"- k: {cls.k:.2e} eV·K¯¹", 18 f"- q: {cls.q:.2e} mC", 19 f"- σ: {cls.sigma:.2e} mW·cm¯²·K¯⁴", 20 f"- f_Sun: {cls.fsun:.2e}", 21 f"- T_Sun: {cls.tsun:.2e} K", 22 f"- µ_Sun: {cls.usun:.2e} eV", 23 f"- P_Sun: {cls.psun:.2e} mW·cm¯²", 24 ] 25 ) 26 27 @property 28 def au(cls) -> float: 29 r"""Astronomical unit [$\mathrm{cm}$].""" 30 return 1e2 * au 31 32 @property 33 def c(cls) -> float: 34 r"""Speed of light in vacuum [$\mathrm{cm \, s^{-1}}$].""" 35 return 1e2 * c 36 37 @property 38 def h(cls) -> float: 39 r"""Plack's constant [$\mathrm{eV \, s}$].""" 40 return h / e 41 42 @property 43 def k(cls) -> float: 44 r"""Boltzmann's constant [$\mathrm{eV \, K^{-1}}$].""" 45 return k / e 46 47 @property 48 def q(cls) -> float: 49 r"""Elementary charge [$\mathrm{mC}$].""" 50 return 1e3 * e 51 52 @property 53 def sigma(cls) -> float: 54 r"""Stefan-Boltzmann's constant [$\mathrm{mW \, cm^{-2} \, K^{-4}}$].""" 55 return 1e-1 * sigma 56 57 @property 58 def fsun(cls) -> float: 59 r"""Sun-Earth sunlight attenuantion factor.""" 60 return (cls.rsun / cls.au) ** 2 61 62 @property 63 def rsun(cls) -> float: 64 r"""Sun radius [$\mathrm{cm}$].""" 65 return 6.957e10 66 67 @property 68 def tsun(cls) -> float: 69 r"""Sun temperature [$\mathrm{K}$].""" 70 return 6000.0 71 72 @property 73 def usun(cls) -> float: 74 r"""Sun chemical potential [$\mathrm{eV}$].""" 75 return 0.0 76 77 @property 78 def psun(cls) -> float: 79 r"""Sunlight power density [$\mathrm{mW \, cm^{-2}}$].""" 80 return cls.fsun * cls.sigma * cls.tsun**4 81 82 83class Constant(metaclass=ConstantMeta): 84 r"""Physical constants."""
class
ConstantMeta(builtins.type):
7class ConstantMeta(type): 8 r"""Metaclass of Constant.""" 9 10 def __repr__(cls) -> str: 11 r"""Represent Constant class.""" 12 return "\n".join( 13 [ 14 f"Physical constants:", 15 f"- au: {cls.au:.2e} cm", 16 f"- c: {cls.c:.2e} cm·s¯¹", 17 f"- h: {cls.h:.2e} eV·s", 18 f"- k: {cls.k:.2e} eV·K¯¹", 19 f"- q: {cls.q:.2e} mC", 20 f"- σ: {cls.sigma:.2e} mW·cm¯²·K¯⁴", 21 f"- f_Sun: {cls.fsun:.2e}", 22 f"- T_Sun: {cls.tsun:.2e} K", 23 f"- µ_Sun: {cls.usun:.2e} eV", 24 f"- P_Sun: {cls.psun:.2e} mW·cm¯²", 25 ] 26 ) 27 28 @property 29 def au(cls) -> float: 30 r"""Astronomical unit [$\mathrm{cm}$].""" 31 return 1e2 * au 32 33 @property 34 def c(cls) -> float: 35 r"""Speed of light in vacuum [$\mathrm{cm \, s^{-1}}$].""" 36 return 1e2 * c 37 38 @property 39 def h(cls) -> float: 40 r"""Plack's constant [$\mathrm{eV \, s}$].""" 41 return h / e 42 43 @property 44 def k(cls) -> float: 45 r"""Boltzmann's constant [$\mathrm{eV \, K^{-1}}$].""" 46 return k / e 47 48 @property 49 def q(cls) -> float: 50 r"""Elementary charge [$\mathrm{mC}$].""" 51 return 1e3 * e 52 53 @property 54 def sigma(cls) -> float: 55 r"""Stefan-Boltzmann's constant [$\mathrm{mW \, cm^{-2} \, K^{-4}}$].""" 56 return 1e-1 * sigma 57 58 @property 59 def fsun(cls) -> float: 60 r"""Sun-Earth sunlight attenuantion factor.""" 61 return (cls.rsun / cls.au) ** 2 62 63 @property 64 def rsun(cls) -> float: 65 r"""Sun radius [$\mathrm{cm}$].""" 66 return 6.957e10 67 68 @property 69 def tsun(cls) -> float: 70 r"""Sun temperature [$\mathrm{K}$].""" 71 return 6000.0 72 73 @property 74 def usun(cls) -> float: 75 r"""Sun chemical potential [$\mathrm{eV}$].""" 76 return 0.0 77 78 @property 79 def psun(cls) -> float: 80 r"""Sunlight power density [$\mathrm{mW \, cm^{-2}}$].""" 81 return cls.fsun * cls.sigma * cls.tsun**4
Metaclass of Constant.
au: float
28 @property 29 def au(cls) -> float: 30 r"""Astronomical unit [$\mathrm{cm}$].""" 31 return 1e2 * au
Astronomical unit [$\mathrm{cm}$].
c: float
33 @property 34 def c(cls) -> float: 35 r"""Speed of light in vacuum [$\mathrm{cm \, s^{-1}}$].""" 36 return 1e2 * c
Speed of light in vacuum [$\mathrm{cm \, s^{-1}}$].
h: float
38 @property 39 def h(cls) -> float: 40 r"""Plack's constant [$\mathrm{eV \, s}$].""" 41 return h / e
Plack's constant [$\mathrm{eV \, s}$].
k: float
43 @property 44 def k(cls) -> float: 45 r"""Boltzmann's constant [$\mathrm{eV \, K^{-1}}$].""" 46 return k / e
Boltzmann's constant [$\mathrm{eV \, K^{-1}}$].
sigma: float
53 @property 54 def sigma(cls) -> float: 55 r"""Stefan-Boltzmann's constant [$\mathrm{mW \, cm^{-2} \, K^{-4}}$].""" 56 return 1e-1 * sigma
Stefan-Boltzmann's constant [$\mathrm{mW \, cm^{-2} \, K^{-4}}$].
fsun: float
58 @property 59 def fsun(cls) -> float: 60 r"""Sun-Earth sunlight attenuantion factor.""" 61 return (cls.rsun / cls.au) ** 2
Sun-Earth sunlight attenuantion factor.
usun: float
73 @property 74 def usun(cls) -> float: 75 r"""Sun chemical potential [$\mathrm{eV}$].""" 76 return 0.0
Sun chemical potential [$\mathrm{eV}$].
psun: float
78 @property 79 def psun(cls) -> float: 80 r"""Sunlight power density [$\mathrm{mW \, cm^{-2}}$].""" 81 return cls.fsun * cls.sigma * cls.tsun**4
Sunlight power density [$\mathrm{mW \, cm^{-2}}$].
Inherited Members
- builtins.type
- type
- mro
class
Constant:
Physical constants.