From 832c0a965e834b0eaee090306ee4f75e575fc3b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignacio=20Fdez=2E=20Galv=C3=A1n?= Date: Wed, 21 Aug 2024 15:22:08 +0200 Subject: [PATCH 1/4] Update constants to CODATA 2022 --- pint/constants_en.txt | 18 ++++++++++-------- pint/default_en.txt | 2 +- pint/pint_convert.py | 26 +++++++++++++------------- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/pint/constants_en.txt b/pint/constants_en.txt index 9babc8fa2..9f2947735 100644 --- a/pint/constants_en.txt +++ b/pint/constants_en.txt @@ -46,20 +46,22 @@ wien_wavelength_displacement_law_constant = ℎ * c / (k * wien_x) wien_frequency_displacement_law_constant = wien_u * k / ℎ #### MEASURED CONSTANTS #### -# Recommended CODATA-2018 values +# Recommended CODATA-2022 values # To some extent, what is measured and what is derived is a bit arbitrary. # The choice of measured constants is based on convenience and on available uncertainty. # The uncertainty in the last significant digits is given in parentheses as a comment. +# The K_alpha values are either backtransformed from the corresponding x unit or +# from the the CODATA-2018 publication (doi:10.1103/RevModPhys.93.025010) newtonian_constant_of_gravitation = 6.67430e-11 m^3/(kg s^2) = _ = gravitational_constant # (15) -rydberg_constant = 1.0973731568160e7 * m^-1 = R_∞ = R_inf # (21) -electron_g_factor = -2.00231930436256 = g_e # (35) -atomic_mass_constant = 1.66053906660e-27 kg = m_u # (50) -electron_mass = 9.1093837015e-31 kg = m_e = atomic_unit_of_mass = a_u_mass # (28) -proton_mass = 1.67262192369e-27 kg = m_p # (51) -neutron_mass = 1.67492749804e-27 kg = m_n # (95) +rydberg_constant = 1.0973731568157e7 * m^-1 = R_∞ = R_inf # (12) +electron_g_factor = -2.00231930436092 = g_e # (36) +atomic_mass_constant = 1.66053906892e-27 kg = m_u # (52) +electron_mass = 9.1093837139e-31 kg = m_e = atomic_unit_of_mass = a_u_mass # (28) +proton_mass = 1.67262192595e-27 kg = m_p # (52) +neutron_mass = 1.67492750056e-27 kg = m_n # (85) lattice_spacing_of_Si = 1.920155716e-10 m = d_220 # (32) -K_alpha_Cu_d_220 = 0.80232719 # (22) +K_alpha_Cu_d_220 = 0.80232719 # (24) K_alpha_Mo_d_220 = 0.36940604 # (19) K_alpha_W_d_220 = 0.108852175 # (98) diff --git a/pint/default_en.txt b/pint/default_en.txt index 4250a48cb..8c30a349d 100644 --- a/pint/default_en.txt +++ b/pint/default_en.txt @@ -164,7 +164,7 @@ nautical_mile = 1852 * meter = nmi bohr = hbar / (alpha * m_e * c) = a_0 = a0 = bohr_radius = atomic_unit_of_length = a_u_length x_unit_Cu = K_alpha_Cu_d_220 * d_220 / 1537.4 = Xu_Cu x_unit_Mo = K_alpha_Mo_d_220 * d_220 / 707.831 = Xu_Mo -angstrom_star = K_alpha_W_d_220 * d_220 / 0.2090100 = Å_star +angstrom_star = K_alpha_W_d_220 * d_220 / 0.20901 = Å_star planck_length = (hbar * gravitational_constant / c ** 3) ** 0.5 # Mass diff --git a/pint/pint_convert.py b/pint/pint_convert.py index 0934588b8..0587f641a 100644 --- a/pint/pint_convert.py +++ b/pint/pint_convert.py @@ -91,23 +91,23 @@ def _set(key: str, value): # m_e: Electron mass # m_p: Proton mass # m_n: Neutron mass - R_i = (ureg._units["R_inf"].converter.scale, 0.0000000000021e7) - g_e = (ureg._units["g_e"].converter.scale, 0.00000000000035) - m_u = (ureg._units["m_u"].converter.scale, 0.00000000050e-27) + R_i = (ureg._units["R_inf"].converter.scale, 0.0000000000012e7) + g_e = (ureg._units["g_e"].converter.scale, 0.00000000000036) + m_u = (ureg._units["m_u"].converter.scale, 0.00000000052e-27) m_e = (ureg._units["m_e"].converter.scale, 0.00000000028e-30) - m_p = (ureg._units["m_p"].converter.scale, 0.00000000051e-27) - m_n = (ureg._units["m_n"].converter.scale, 0.00000000095e-27) + m_p = (ureg._units["m_p"].converter.scale, 0.00000000052e-27) + m_n = (ureg._units["m_n"].converter.scale, 0.00000000085e-27) if args.corr: # Correlation matrix between measured constants (to be completed below) - # R_i g_e m_u m_e m_p m_n + # R_i g_e m_u m_e m_p m_n corr = [ - [1.0, -0.00206, 0.00369, 0.00436, 0.00194, 0.00233], # R_i - [-0.00206, 1.0, 0.99029, 0.99490, 0.97560, 0.52445], # g_e - [0.00369, 0.99029, 1.0, 0.99536, 0.98516, 0.52959], # m_u - [0.00436, 0.99490, 0.99536, 1.0, 0.98058, 0.52714], # m_e - [0.00194, 0.97560, 0.98516, 0.98058, 1.0, 0.51521], # m_p - [0.00233, 0.52445, 0.52959, 0.52714, 0.51521, 1.0], - ] # m_n + [ 1.00000,-0.00122, 0.00438, 0.00225, 0.00455, 0.00277], # R_i + [-0.00122, 1.00000, 0.97398, 0.97555, 0.97404, 0.59702], # g_e + [ 0.00438, 0.97398, 1.00000, 0.99839, 0.99965, 0.61279], # m_u + [ 0.00225, 0.97555, 0.99839, 1.00000, 0.99845, 0.61199], # m_e + [ 0.00455, 0.97404, 0.99965, 0.99845, 1.00000, 0.61281], # m_p + [ 0.00277, 0.59702, 0.61279, 0.61199, 0.61281, 1.00000], # m_n + ] try: (R_i, g_e, m_u, m_e, m_p, m_n) = uncertainties.correlated_values_norm( [R_i, g_e, m_u, m_e, m_p, m_n], corr From 87c63f8b6aa8b1eefa8d7936891192feaa156c42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignacio=20Fdez=2E=20Galv=C3=A1n?= Date: Wed, 21 Aug 2024 15:38:09 +0200 Subject: [PATCH 2/4] Changelog and fixes --- CHANGES | 1 + pint/pint_convert.py | 16 +++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/CHANGES b/CHANGES index 9d7de4298..7cf9f721c 100644 --- a/CHANGES +++ b/CHANGES @@ -10,6 +10,7 @@ Pint Changelog - Support permille units and `‰` symbol (PR #2033, Issue #1963) - Switch from appdirs to platformdirs. - Fixes issues related to GenericPlainRegistry.__getattr__ type (PR #2038, Issues #1946 and #1804) +- Update constants to CODATA 2022 recommended values. 0.24.1 (2024-06-24) diff --git a/pint/pint_convert.py b/pint/pint_convert.py index 0587f641a..5d7fd9eac 100644 --- a/pint/pint_convert.py +++ b/pint/pint_convert.py @@ -98,16 +98,18 @@ def _set(key: str, value): m_p = (ureg._units["m_p"].converter.scale, 0.00000000052e-27) m_n = (ureg._units["m_n"].converter.scale, 0.00000000085e-27) if args.corr: + # fmt: off # Correlation matrix between measured constants (to be completed below) - # R_i g_e m_u m_e m_p m_n + # R_i g_e m_u m_e m_p m_n corr = [ - [ 1.00000,-0.00122, 0.00438, 0.00225, 0.00455, 0.00277], # R_i - [-0.00122, 1.00000, 0.97398, 0.97555, 0.97404, 0.59702], # g_e - [ 0.00438, 0.97398, 1.00000, 0.99839, 0.99965, 0.61279], # m_u - [ 0.00225, 0.97555, 0.99839, 1.00000, 0.99845, 0.61199], # m_e - [ 0.00455, 0.97404, 0.99965, 0.99845, 1.00000, 0.61281], # m_p - [ 0.00277, 0.59702, 0.61279, 0.61199, 0.61281, 1.00000], # m_n + [ 1.00000, -0.00122, 0.00438, 0.00225, 0.00455, 0.00277], # R_i + [-0.00122, 1.00000, 0.97398, 0.97555, 0.97404, 0.59702], # g_e + [ 0.00438, 0.97398, 1.00000, 0.99839, 0.99965, 0.61279], # m_u + [ 0.00225, 0.97555, 0.99839, 1.00000, 0.99845, 0.61199], # m_e + [ 0.00455, 0.97404, 0.99965, 0.99845, 1.00000, 0.61281], # m_p + [ 0.00277, 0.59702, 0.61279, 0.61199, 0.61281, 1.00000], # m_n ] + # fmt: on try: (R_i, g_e, m_u, m_e, m_p, m_n) = uncertainties.correlated_values_norm( [R_i, g_e, m_u, m_e, m_p, m_n], corr From 04beecf212fab4d276aceaf315d86133aa14d1a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignacio=20Fdez=2E=20Galv=C3=A1n?= Date: Thu, 22 Aug 2024 14:08:17 +0200 Subject: [PATCH 3/4] fix --- pint/constants_en.txt | 2 +- pint/pint_convert.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pint/constants_en.txt b/pint/constants_en.txt index 9f2947735..877876668 100644 --- a/pint/constants_en.txt +++ b/pint/constants_en.txt @@ -51,7 +51,7 @@ wien_frequency_displacement_law_constant = wien_u * k / ℎ # The choice of measured constants is based on convenience and on available uncertainty. # The uncertainty in the last significant digits is given in parentheses as a comment. # The K_alpha values are either backtransformed from the corresponding x unit or -# from the the CODATA-2018 publication (doi:10.1103/RevModPhys.93.025010) +# from the CODATA-2018 publication (doi:10.1103/RevModPhys.93.025010) newtonian_constant_of_gravitation = 6.67430e-11 m^3/(kg s^2) = _ = gravitational_constant # (15) rydberg_constant = 1.0973731568157e7 * m^-1 = R_∞ = R_inf # (12) diff --git a/pint/pint_convert.py b/pint/pint_convert.py index 5d7fd9eac..6e27b14fa 100644 --- a/pint/pint_convert.py +++ b/pint/pint_convert.py @@ -149,7 +149,7 @@ def _set(key: str, value): _set( "K_alpha_Cu_d_220", uncertainties.ufloat( - ureg._units["K_alpha_Cu_d_220"].converter.scale, 0.00000022 + ureg._units["K_alpha_Cu_d_220"].converter.scale, 0.00000024 ), ) From 736ee668e9752e4b13dcb9ff4ba3cf512ab14a3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignacio=20Fdez=2E=20Galv=C3=A1n?= Date: Thu, 22 Aug 2024 14:35:12 +0200 Subject: [PATCH 4/4] x units and angstrom star as constants Like most "measured constants", they're not measured directly, but derived from other measures. However, the list of CODATA values includes these (and their uncertainties and correlations), so it's better to treat them as other constants. --- pint/constants_en.txt | 9 ++---- pint/default_en.txt | 3 -- pint/pint_convert.py | 71 +++++++++++++++++++++---------------------- 3 files changed, 38 insertions(+), 45 deletions(-) diff --git a/pint/constants_en.txt b/pint/constants_en.txt index 877876668..2f6fcfb50 100644 --- a/pint/constants_en.txt +++ b/pint/constants_en.txt @@ -50,8 +50,6 @@ wien_frequency_displacement_law_constant = wien_u * k / ℎ # To some extent, what is measured and what is derived is a bit arbitrary. # The choice of measured constants is based on convenience and on available uncertainty. # The uncertainty in the last significant digits is given in parentheses as a comment. -# The K_alpha values are either backtransformed from the corresponding x unit or -# from the CODATA-2018 publication (doi:10.1103/RevModPhys.93.025010) newtonian_constant_of_gravitation = 6.67430e-11 m^3/(kg s^2) = _ = gravitational_constant # (15) rydberg_constant = 1.0973731568157e7 * m^-1 = R_∞ = R_inf # (12) @@ -60,10 +58,9 @@ atomic_mass_constant = 1.66053906892e-27 kg = m_u electron_mass = 9.1093837139e-31 kg = m_e = atomic_unit_of_mass = a_u_mass # (28) proton_mass = 1.67262192595e-27 kg = m_p # (52) neutron_mass = 1.67492750056e-27 kg = m_n # (85) -lattice_spacing_of_Si = 1.920155716e-10 m = d_220 # (32) -K_alpha_Cu_d_220 = 0.80232719 # (24) -K_alpha_Mo_d_220 = 0.36940604 # (19) -K_alpha_W_d_220 = 0.108852175 # (98) +x_unit_Cu = 1.00207697e-13 m = Xu_Cu # (28) +x_unit_Mo = 1.00209952e-13 m = Xu_Mo # (53) +angstrom_star = 1.00001495e-10 = Å_star # (90) #### DERIVED CONSTANTS #### diff --git a/pint/default_en.txt b/pint/default_en.txt index 8c30a349d..bbac09bed 100644 --- a/pint/default_en.txt +++ b/pint/default_en.txt @@ -162,9 +162,6 @@ astronomical_unit = 149597870700 * meter = au # since Aug 2012 parsec = 1 / tansec * astronomical_unit = pc nautical_mile = 1852 * meter = nmi bohr = hbar / (alpha * m_e * c) = a_0 = a0 = bohr_radius = atomic_unit_of_length = a_u_length -x_unit_Cu = K_alpha_Cu_d_220 * d_220 / 1537.4 = Xu_Cu -x_unit_Mo = K_alpha_Mo_d_220 * d_220 / 707.831 = Xu_Mo -angstrom_star = K_alpha_W_d_220 * d_220 / 0.20901 = Å_star planck_length = (hbar * gravitational_constant / c ** 3) ** 0.5 # Mass diff --git a/pint/pint_convert.py b/pint/pint_convert.py index 6e27b14fa..dd830718c 100644 --- a/pint/pint_convert.py +++ b/pint/pint_convert.py @@ -91,28 +91,47 @@ def _set(key: str, value): # m_e: Electron mass # m_p: Proton mass # m_n: Neutron mass + # x_Cu: Copper x unit + # x_Mo: Molybdenum x unit + # A_s: Angstrom star R_i = (ureg._units["R_inf"].converter.scale, 0.0000000000012e7) g_e = (ureg._units["g_e"].converter.scale, 0.00000000000036) m_u = (ureg._units["m_u"].converter.scale, 0.00000000052e-27) - m_e = (ureg._units["m_e"].converter.scale, 0.00000000028e-30) + m_e = (ureg._units["m_e"].converter.scale, 0.0000000028e-31) m_p = (ureg._units["m_p"].converter.scale, 0.00000000052e-27) m_n = (ureg._units["m_n"].converter.scale, 0.00000000085e-27) + x_Cu = (ureg._units["x_unit_Cu"].converter.scale, 0.00000028e-13) + x_Mo = (ureg._units["x_unit_Mo"].converter.scale, 0.00000053e-13) + A_s = (ureg._units["angstrom_star"].converter.scale, 0.00000090e-10) if args.corr: # fmt: off # Correlation matrix between measured constants (to be completed below) - # R_i g_e m_u m_e m_p m_n + # R_i g_e m_u m_e m_p m_n x_Cu x_Mo A_s corr = [ - [ 1.00000, -0.00122, 0.00438, 0.00225, 0.00455, 0.00277], # R_i - [-0.00122, 1.00000, 0.97398, 0.97555, 0.97404, 0.59702], # g_e - [ 0.00438, 0.97398, 1.00000, 0.99839, 0.99965, 0.61279], # m_u - [ 0.00225, 0.97555, 0.99839, 1.00000, 0.99845, 0.61199], # m_e - [ 0.00455, 0.97404, 0.99965, 0.99845, 1.00000, 0.61281], # m_p - [ 0.00277, 0.59702, 0.61279, 0.61199, 0.61281, 1.00000], # m_n + [ 1.00000, -0.00122, 0.00438, 0.00225, 0.00455, 0.00277, 0.00000, 0.00000, 0.00000], # R_i + [-0.00122, 1.00000, 0.97398, 0.97555, 0.97404, 0.59702, 0.00000, 0.00000, 0.00000], # g_e + [ 0.00438, 0.97398, 1.00000, 0.99839, 0.99965, 0.61279, 0.00000, 0.00000, 0.00000], # m_u + [ 0.00225, 0.97555, 0.99839, 1.00000, 0.99845, 0.61199, 0.00000, 0.00000, 0.00000], # m_e + [ 0.00455, 0.97404, 0.99965, 0.99845, 1.00000, 0.61281, 0.00000, 0.00000, 0.00000], # m_p + [ 0.00277, 0.59702, 0.61279, 0.61199, 0.61281, 1.00000,-0.00098,-0.00108,-0.00063], # m_n + [ 0.00000, 0.00000, 0.00000, 0.00000, 0.00000,-0.00098, 1.00000, 0.00067, 0.00039], # x_Cu + [ 0.00000, 0.00000, 0.00000, 0.00000, 0.00000,-0.00108, 0.00067, 1.00000, 0.00100], # x_Mo + [ 0.00000, 0.00000, 0.00000, 0.00000, 0.00000,-0.00063, 0.00039, 0.00100, 1.00000], # A_s ] # fmt: on try: - (R_i, g_e, m_u, m_e, m_p, m_n) = uncertainties.correlated_values_norm( - [R_i, g_e, m_u, m_e, m_p, m_n], corr + ( + R_i, + g_e, + m_u, + m_e, + m_p, + m_n, + x_Cu, + x_Mo, + A_s, + ) = uncertainties.correlated_values_norm( + [R_i, g_e, m_u, m_e, m_p, m_n, x_Cu, x_Mo, A_s], corr ) except AttributeError: raise Exception( @@ -125,6 +144,9 @@ def _set(key: str, value): m_e = uncertainties.ufloat(*m_e) m_p = uncertainties.ufloat(*m_p) m_n = uncertainties.ufloat(*m_n) + x_Cu = uncertainties.ufloat(*x_Cu) + x_Mo = uncertainties.ufloat(*x_Mo) + A_s = uncertainties.ufloat(*A_s) _set("R_inf", R_i) _set("g_e", g_e) @@ -132,6 +154,9 @@ def _set(key: str, value): _set("m_e", m_e) _set("m_p", m_p) _set("m_n", m_n) + _set("x_unit_Cu", x_Cu) + _set("x_unit_Mo", x_Mo) + _set("angstrom_star", A_s) # Measured constants with zero correlation _set( @@ -141,32 +166,6 @@ def _set(key: str, value): ), ) - _set( - "d_220", - uncertainties.ufloat(ureg._units["d_220"].converter.scale, 0.000000032e-10), - ) - - _set( - "K_alpha_Cu_d_220", - uncertainties.ufloat( - ureg._units["K_alpha_Cu_d_220"].converter.scale, 0.00000024 - ), - ) - - _set( - "K_alpha_Mo_d_220", - uncertainties.ufloat( - ureg._units["K_alpha_Mo_d_220"].converter.scale, 0.00000019 - ), - ) - - _set( - "K_alpha_W_d_220", - uncertainties.ufloat( - ureg._units["K_alpha_W_d_220"].converter.scale, 0.000000098 - ), - ) - ureg._root_units_cache = {} ureg._build_cache()