JuliaPhysics / JuliaPhysics/Unitful.jl

Physicist conversions

Open
#37 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
675
Forks
124
Avg merge
3h 38m
Merged PRs (30d)
1

Description

On master, you can now easily implement conversion between dimensions by multiplying by appropriate fundamental constants (e.g. energy = planck constant \* frequency). Currently this is on a case-by-case basis, and is opt-in to avoid confusion:

```
julia> using Unitful

julia> import Unitful: uconvert, EnergyUnit, Frequency

julia> uconvert(e::EnergyUnit, f::Frequency) = uconvert(e, u"h"*f)
uconvert (generic function with 4 methods)

julia> 1u"GHz" |> u"eV"
4.135667662340165e-6 eV
```

It'd be cool if we could come up with a mechanism to implement this logic automatically given a set of fundamental constants, although this sort of thing would always need to be opt-in. Perhaps we could define a generalized `uconvert` called `dconvert` that attempts to convert quantities between dimensions using a set of fundamental constants when possible. The `h` vs `ħ` distinction would be super annoying.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.