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

Draft: prelude with dimensionful angles #167

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open

Conversation

sharkdp
Copy link
Owner

@sharkdp sharkdp commented Sep 21, 2023

see #91

This PR makes changes to Numbats prelude to treat angles as dimensionful quantities. Angle becomes a new base dimension. And radian is the base unit in that dimension. This follows the paper Angles in the SI: a detailed proposal for solving the problem by Quincey.

Immediate advantages of this approach:

  • When using a unit like J, cal, eV etc., we don't see [Energy or Torque] anymore. We just see [Energy].
  • lumen -> candela conversion is not possible anymore (1 lumen does not equal 1 candela (1 lm -> cd returns 1 cd) insect#225)
    But 400 cd * (5°)^2 -> lm is still possible, as it should. Completely wrong expressions like 400 cd / (5°)^2 -> lm do not type-check anymore.
  • When typing lumen, it doesn't show [LuminousIntensity or LuminousFlux], but just LuminousFlux. Similarly, candela only shows LuminousIntensity.
  • An expression like 40°/s is detected as AngularFrequency, not as Frequency.
  • RPM works as it should:
    >>> 60 rpm -> rev/s
    
        = 1 rev/s    [AngularFrequency]
    
    >>> 60 rpm -> deg/s
    
        = 360 °/s    [AngularFrequency]
    
  • You can not accidentally pass an angle to ASin, ACos, ATan, …
  • Similarly, you can not do meaningless things like log(30°).
  • You directly see the result of ASin, … as an angle in rad
  • When typing in angles like 30°, they don't just "decay" to scalars (this is one of Numbats simplification procedures… which is not ideal in the case when angles are dimensionless).

Obvious disadvantages:

  • Users can not use "textbook" formulas if they are not "complete". They need to insert factors of θC/theta_C/rad when needed.
  • Users need to use Sin(…) for angles and sin(…) for scalars.
  • There is not just ℏ: AngularMomentum, there is also ȟ: Action.
  • Some constants have "unexpected" units. This is particularly evident for the bohr radius, which now has a unit of m/rad and dimensions of Length / Angle.
  • To get a feeling for the type of changes to expect, check out the diff.

Try this online at: https://numbat.dev/angles/

@archisman-panigrahi
Copy link
Contributor

archisman-panigrahi commented Sep 29, 2023

Will there be an option to turn this off? The idea of angles being dimensionless still did not get into mainstream physics. Having different dimensions for Torque and Energy (or Bohr radius and length) may give rise to a lot of confusions.

In my opinion (but I am saying this with my physicist hat on) it is best if this feature is turned off by default, but can be turned on by calling something like use unit::dimensionful_angles. One possible method to do this may be to have a different prelude for dimensionful angles, which will overwrite all the definitions of units related to dimensionless_angles when it is called.

@sharkdp
Copy link
Owner Author

sharkdp commented Sep 29, 2023

Will there be an option to turn this off?

This is just a proof of concept / draft. It will not be merged as-is. And no, we will most probably not enable this by default. What I'm planning to have is something like #55, which would allow us to have one single prelude, where certain aspects could be controlled by the user (via a config file). So users could potentially opt in to this by setting dimensionful_angles = true in their config file.

@sharkdp
Copy link
Owner Author

sharkdp commented Sep 29, 2023

The idea of angles being dimensionless still did not get into mainstream physics. Having different dimensions for Torque and Energy (or Bohr radius and length) may give rise to a lot of confusions.

I do agree. But note that the current situation also leads to lots of confusion. Just look at the tickets linked in #91 (comment)

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

Successfully merging this pull request may close these issues.

2 participants