Skip to content

Physical constants #26

Closed
Closed
@MilesCranmer

Description

@MilesCranmer

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions