Skip to content

Physical constants #26

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

Closed
MilesCranmer opened this issue Jun 15, 2023 · 6 comments
Closed

Physical constants #26

MilesCranmer opened this issue Jun 15, 2023 · 6 comments

Comments

@MilesCranmer
Copy link
Member

MilesCranmer commented Jun 15, 2023

We could have a submodule that delivers common physical constants. Already I am finding myself having to type out the speed of light by hand; it would be useful if it were just built-in.

This could work as follows:

using DynamicQuantities
import DynamicQuantities: Units as U, Constants as C

Then, C would let you access constants, and U the units. This is similar to how astropy does it, to avoid mixing namespaces.

e.g., the energy of a 500nm photon

wavelength = 500*U.nm
energy = C.c*C.h/wavelength

This Constants namespace could also be exposed within the @u_str macro, so you could also write this as

energy = (1/500) * u"C.c*C.h/nm"

I'd be interested to know if @odow or @ChrisRackauckas have any thoughts or ideas in this direction.

@odow
Copy link
Contributor

odow commented Jun 15, 2023

That seems very reasonable to me.

@j-fu
Copy link
Contributor

j-fu commented Jun 15, 2023

Hi, how does this square with the physical constants defined in Unitful
or those in
https://github.com/JuliaPhysics/PhysicalConstants.jl?

Codes using these constants from different sources should be guaranteed to work together.
I think it might make sense to check this in CI...

@MilesCranmer
Copy link
Member Author

Could you be more specific, I don't understand your question. PhysicalConstants.jl uses Unitful.jl unfortunately, so we cannot use it directly. The constants in PhysicalConstants.jl are taken from the same source as in #27 - from CODATA 2018. By CI do you mean to check the constants are equal?

@j-fu
Copy link
Contributor

j-fu commented Jun 15, 2023

By CI do you mean to check the constants are equal?

Right. If you think it makes sense the PR would be on me...

@MilesCranmer
Copy link
Member Author

I understand, that sounds good to me! Thanks.

@MilesCranmer
Copy link
Member Author

Closed with #32

MilesCranmer added a commit that referenced this issue Jul 9, 2023
[Diff since v0.5.0](v0.5.0...v0.6.0)

**Closed issues:**
- Physical constants (#26)

**Merged pull requests:**
- Create (1) physical constants, and (2) symbolic dimensions object (#32) (@MilesCranmer)
MilesCranmer added a commit that referenced this issue Jul 10, 2023
[Diff since v0.5.0](v0.5.0...v0.6.0)

**Closed issues:**
- Physical constants (#26)

**Merged pull requests:**
- Create (1) physical constants, and (2) symbolic dimensions object (#32) (@MilesCranmer)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants