Comments (6)
I've opened a PR for Unitful.jl
defining AbstractQuantity
: PainterQubits/Unitful.jl#204 If it gets merged, I've already a branch for this package to achieve these cool features:
julia> using PhysicalConstants.CODATA2014
julia> 2c
5.99584916e8 m s^-1
julia> sqrt((h/2pi) * G / c^3) # Planck length, the units are just metres
1.6162283730808862e-35 J^1/2 s kg^-1/2
julia> α
Fine-structure constant (α)
Value = 0.0072973525664
Standard uncertainty = 1.7e-12
Relative standard uncertainty = 2.3e-10
Reference = CODATA 2014
julia> α/2
0.0036486762832
julia> typeof(α/2)
Float64
😃
However this needs improvement as it currently works only with Float64
values of the constants.
from physicalconstants.jl.
I totally agree that the objects exported by this Module should be immediatelly useable in mathematical operations. I do not think that an explicit conversion should first be done, as this typically means that it is faster to copy paste the wikipedia value :D
I won't comment on how this should be done internally however. I don't have enough experience with coding this package or Uniful....
from physicalconstants.jl.
First of all, I'm glad someone takes another hit on this topic. There was a Package with the same name in the past: https://github.com/DataWookie/PhysicalConstants.jl and another that extracts the Data directly from CODATA: https://github.com/kofron/CODATA.jl, but both are unmaintained today.
I forked the old PhysicalConstants and gave it a global switch, so you can change from Value with Dimension to Values without dimension by calling something like switch_units()
, don't know if it is of any use for your implementation thogh.
Regarding the abstract type in Unitful.jl
you could play with it on your own fork and make a PR if it works out.
from physicalconstants.jl.
@Datseris regarding how this package works internally, it defines a new Constant
type, which is very similar to Base.Irrational
in spirit (and also in code): each constant is a singleton (empty struct
) for which various methods are defined.
The most useful feature of this approach is that you get arbitrary precision values for the physical constants (just like the Base.Irrational
mathematical constants), even if you change the precision of BigFloat
.
You know, apart from some constants that are defined to be exact (without uncertainty), all physical constants are currently measured with precision much lower than that of double precision floating-point numbers. Thus, it may look an overkill to use arbitrary precision for calculations involving physical constants, but I think that Julia should be ready for the era of high-precision measurements 😄
@BeastyBlacksmith thanks for pointing those packages out. Probably I came across them long time ago and didn't like how they worked. Indeed, I've been thinking about this package for a while now. I don't think I like the idea of having a constant without units, the choice of the reference units would be then arbitrary. However, the user is free to strip the units with ustrip(float(c))
(or, even better, with ustrip(c)
if I define an appropriate method for ustrip
)
from physicalconstants.jl.
+1 for AbstractQuantity
from physicalconstants.jl.
I've opened an issue at Unitful.jl
: PainterQubits/Unitful.jl#186
from physicalconstants.jl.
Related Issues (11)
- Export all constants? HOT 27
- Unexpected error in runtime: StackOverflowError() HOT 8
- Faster compile times with UnitSystems.jl HOT 2
- how to extract the numerical part from a physical constant HOT 1
- TagBot trigger issue HOT 2
- Unable to install on fresh julia 1.6/1.7 installs HOT 5
- Version tag HOT 6
- Add all constants of CODATA2014 HOT 8
- Add CODATA2018 HOT 5
- Fine structure constant is not usable HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from physicalconstants.jl.