-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
all modules now get physical constants from this instead of scipy directly. Co-authored-by: Eric T. Johnson <yut23@users.noreply.github.com>
- Loading branch information
Showing
10 changed files
with
90 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
"""Fundamental constants in CGS (unless otherwise noted)""" | ||
|
||
__all__ = ["constants"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import scipy.constants as physical_constants | ||
|
||
# atomic unit mass in g | ||
m_u = physical_constants.value("unified atomic mass unit") * physical_constants.kilo | ||
m_u_MeV = physical_constants.value("atomic mass constant energy equivalent in MeV") | ||
m_p = physical_constants.value("proton mass") * physical_constants.kilo | ||
m_p_MeV = physical_constants.value("proton mass energy equivalent in MeV") | ||
m_n = physical_constants.value("neutron mass") * physical_constants.kilo | ||
m_n_MeV = physical_constants.value("neutron mass energy equivalent in MeV") | ||
m_e = physical_constants.value("electron mass") * physical_constants.kilo | ||
m_e_MeV = physical_constants.value("electron mass energy equivalent in MeV") | ||
|
||
N_A = physical_constants.value("Avogadro constant") | ||
|
||
k = physical_constants.value("Boltzmann constant") / physical_constants.erg | ||
k_MeV = physical_constants.value("Boltzmann constant in eV/K") / physical_constants.mega | ||
|
||
h = physical_constants.value("Planck constant") / physical_constants.erg | ||
hbar = physical_constants.value("reduced Planck constant") / physical_constants.erg | ||
|
||
q_e = physical_constants.value("elementary charge") * (physical_constants.c * 100) / 10 # C to statC (esu) | ||
c_light = physical_constants.value("speed of light in vacuum") / physical_constants.centi | ||
|
||
erg2MeV = physical_constants.erg / (physical_constants.eV * physical_constants.mega) | ||
MeV2erg = (physical_constants.eV * physical_constants.mega) / physical_constants.erg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import math | ||
|
||
from pytest import approx | ||
|
||
from pynucastro.constants import constants | ||
|
||
|
||
class TestConstants: | ||
def test_constants(self): | ||
|
||
assert constants.m_u == approx(1.66054e-24, abs=0, rel=1.e-6) | ||
assert constants.m_u_MeV == approx(constants.m_u * constants.c_light**2 * constants.erg2MeV, abs=0, rel=1.e-6) | ||
assert constants.m_p == approx(1.67262192e-24, abs=0, rel=1.e-6) | ||
assert constants.m_p_MeV == approx(constants.m_p * constants.c_light**2 * constants.erg2MeV, abs=0, rel=1.e-6) | ||
assert constants.m_n == approx(1.674927498e-24, abs=0, rel=1.e-6) | ||
assert constants.m_n_MeV == approx(constants.m_n * constants.c_light**2 * constants.erg2MeV, abs=0, rel=1.e-6) | ||
assert constants.m_e == approx(9.1093837e-28, abs=0, rel=1.e-6) | ||
assert constants.m_e_MeV == approx(constants.m_e * constants.c_light**2 * constants.erg2MeV) | ||
|
||
assert constants.N_A == approx(6.02214e23) | ||
|
||
assert constants.k == approx(1.38064e-16, abs=0, rel=1.e-5) | ||
assert constants.k_MeV == approx(constants.k * constants.erg2MeV, abs=0, rel=1.e-5) | ||
|
||
assert constants.h == approx(6.62607e-27, abs=0, rel=1.e-6) | ||
assert constants.hbar == approx(6.62607e-27 / 2 / math.pi, abs=0, rel=1.e-6) | ||
|
||
assert constants.q_e == approx(4.803e-10, abs=0, rel=1.e-4) | ||
assert constants.c_light == approx(2.997924e10) | ||
|
||
assert constants.erg2MeV == approx(1.0 / 1.60218e-6, abs=0, rel=1.e-4) | ||
assert constants.MeV2erg == approx(1.60218e-6, abs=0, rel=1.e-4) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.