Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Stephan-Boltzmann constant accuracy and add radiation constant #520

Merged
merged 7 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions unyt/_physical_ratios.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,15 @@
btu_per_therm = 1e5 * J_per_BTU
btu_per_quad = 1e15 * J_per_BTU
rydberg_unit_mks = planck_mks * speed_of_light_m_per_s * rydberg_constant_mks
stefan_boltzmann_W_per_sqm_per_K4 = (
2.0
* np.pi**5
* boltzmann_constant_J_per_K**4
/ (15.0 * speed_of_light_m_per_s**2 * planck_mks**3)
)
radiation_constant_J_per_m3_per_K4 = (
4.0 * stefan_boltzmann_W_per_sqm_per_K4 / speed_of_light_m_per_s
)
J_per_foe = 1.0e44

# Solar System masses
Expand Down
19 changes: 18 additions & 1 deletion unyt/_unit_lookup_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
planck_mks,
planck_temperature_K,
planck_time_s,
radiation_constant_J_per_m3_per_K4,
rydberg_constant_mks,
rydberg_unit_mks,
sec_per_day,
Expand All @@ -73,6 +74,7 @@
sec_per_year,
speed_of_light_m_per_s,
standard_gravity_m_per_s2,
stefan_boltzmann_W_per_sqm_per_K4,
temp_sun_kelvin,
uk_fl_oz_per_L,
us_fl_oz_per_L,
Expand Down Expand Up @@ -564,7 +566,22 @@
),
("h", (planck_mks, "J*s", ["planck_constant"])),
("hbar", (0.5 * planck_mks / np.pi, "J*s", ["reduced_planck_constant"])),
("σ", (5.670373e-8, "W/m**2/K**4", ["stefan_boltzmann_constant"])),
(
"σ",
(
stefan_boltzmann_W_per_sqm_per_K4,
"W/m**2/K**4",
["stefan_boltzmann_constant"],
),
),
(
"a",
(
radiation_constant_J_per_m3_per_K4,
"J/m**3/K**4",
["radiation_density_constant"],
),
),
("Tcmb", (2.726, "K", ["CMB_temperature"])),
(
"Msun",
Expand Down
4 changes: 2 additions & 2 deletions unyt/equivalencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,9 +473,9 @@ class EffectiveTemperatureEquivalence(Equivalence):
effective_temperature: flux <-> temperature
>>> from unyt import K, W, m
>>> (5000.*K).to_equivalent('W/m**2', 'effective_temperature')
unyt_quantity(35439831.25, 'W/m**2')
unyt_quantity(35439828.89119583, 'W/m**2')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure such a large change is warranted (unless it somehow counts as a bug fix), but why is this output changing at all ?

>>> (100.*W/m**2).to_equivalent('K', 'effective_temperature')
unyt_quantity(204.92601414, 'K')
unyt_quantity(204.92601755, 'K')
"""

type_name = "effective_temperature"
Expand Down