"""Constants module."""

import math as _math
from . import base_units as _u


# temporary auxiliary derived units
_volt = (_u.kilogram * _u.meter**2) / (_u.ampere * _u.second**2)
_coulomb = _u.second * _u.ampere
_joule = _u.kilogram * _u.meter**2 / _u.second**2
_pascal = _u.kilogram / (_u.meter * _u.second**2)


# physical constants
# ==================

light_speed = 299792458 * (_u.meter/_u.second)  # [m/s] - definition

vacuum_permeability = 4*_math.pi*1e-7 * \
    (_volt * _u.second / _u.ampere / _u.meter)  # [T·m/A] - definition

# 2014-06-11 - http://physics.nist.gov/cgi-bin/cuu/Value?e
elementary_charge = 1.602176565e-19 * _coulomb

# 2014-06-11 - http://physics.nist.gov/cgi-bin/cuu/Value?me
electron_mass = 9.10938291e-31 * _u.kilogram

# 2015-06-12 - http://physics.nist.gov/cgi-bin/cuu/Value?r
gas_constant = 8.3144621 * (_joule / _u.mole / _u.kelvin)

# 2015-06-12 - http://physics.nist.gov/cgi-bin/cuu/Value?na
avogadro_constant = 6.02214129e23 * (1 / _u.mole)

# 2015-06-12 - http://physics.nist.gov/cgi-bin/cuu/Value?k
boltzmann_constant = gas_constant/avogadro_constant

# [Kg̣*m^2/s^2] - derived
electron_rest_energy = electron_mass * _math.pow(light_speed, 2)

# [V·s/(A.m)]  - derived
vacuum_permitticity = 1.0/(vacuum_permeability * _math.pow(light_speed, 2))

# [T·m^2/(A·s)] - derived
vacuum_impedance = vacuum_permeability * light_speed

# [m] - derived
electron_radius = _math.pow(elementary_charge, 2) / \
    (4*_math.pi*vacuum_permitticity*electron_rest_energy)

_joule_2_eV = _joule / elementary_charge

# 2014-07-22 - http://physics.nist.gov/cgi-bin/cuu/Value?hbar
reduced_planck_constant = 1.054571726e-34 * _joule * _u.second

# [m]/[GeV]^3 - derived
rad_cgamma = 4*_math.pi*electron_radius / \
    _math.pow(electron_rest_energy/elementary_charge/1.0e9, 3) / 3

# [m] - derived
Cq = (55.0/(32*_math.sqrt(3.0))) * (reduced_planck_constant) * \
    light_speed / electron_rest_energy

# [m^2/(s·GeV^3)] - derived
Ca = electron_radius*light_speed / \
    (3*_math.pow(electron_rest_energy*_joule_2_eV/1.0e9, 3))

@@ -351,16 +351,32 @@
 ======%0A%0A
+# --- exact --%0A%0A
 light_sp
@@ -417,204 +417,179 @@
 ond)
-  # %5Bm/s%5D - definition%0A%0Avacuum_permeability = 4*_math.pi*1e-7 * %5C%0A    (_volt * _u.second
+%0A%0Agas_constant = 8.314462618 * (_joule
  / _u.
-amper
+mol
 e / _u.
-meter)  # %5BT%C2%B7m/A%5D - definition%0A%0A# 2014-06-11 - http://physics.nist.gov/cgi-bin/cuu/Value?e
+kelvin)%0A%0Aboltzmann_constant = 1.380649e-23 * (_joule / _u.kelvin)%0A%0Aavogadro_constant = 6.02214076e23 * (1 / _u.mole)%0A
 %0Aele
@@ -617,11 +617,11 @@
 2176
-565
+634
 e-19
@@ -637,27 +637,112 @@
 mb%0A%0A
+reduced_planck_constant = 1.054571817e-34 * _joule * _u.second%0A%0A# --- measured ---%0A%0A
 # 20
+2
 1
-4
 -0
-6-11
+4-15
  - http
+s
 ://p
@@ -777,16 +777,41 @@
 Value?me
+%7Csearch_for=electron+mass
 %0Aelectro
@@ -830,11 +830,13 @@
 0938
-291
+37015
 e-31
@@ -851,39 +851,40 @@
 logram%0A%0A# 20
+2
 1
-5
 -0
-6-12
+4-15
  - http
+s
 ://physics.n
@@ -913,290 +913,151 @@
 lue?
-r%0Agas_constant = 8.3144621 * (_joule / _u.mole / _u.kelvin)%0A%0A# 2015-06-12 - http://physics.nist.gov/cgi-bin/cuu/Value?na%0Aavogadro_constant = 6.02214129e23 * (1
+mu0%7Csearch_for=vacuum+permeability%0Avacuum_permeability = 1.25663706212e-6 * %5C%0A    (_volt * _u.second / _u.ampere
  / _u.m
-ole
+eter
 )%0A%0A# 
-2015-06-12 - http://physics.nist.gov/cgi-bin/cuu/Value?k%0Aboltzmann_constant = gas_constant/avogadro_constant
+--- derived ---
 %0A%0A# 
@@ -1503,134 +1503,8 @@
 ge%0A%0A
-# 2014-07-22 - http://physics.nist.gov/cgi-bin/cuu/Value?hbar%0Areduced_planck_constant = 1.054571726e-34 * _joule * _u.second%0A%0A
 # %5Bm

Update physical constants (lol)