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

Add cycles per second to units #420

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

BrandonConder
Copy link
Contributor

Cycles per second is a really powerful unit to include. In theory the definition of "Hertz" as a unit is the same as cycles per second, but in practice it is sometimes not.

In my field (electronics) cycles per second can simplify most of my calculations:

  • 1 cycle = 2π radians

For example, calculating impedance of an inductor, cycles per second avoids an arbitrary factor of 2π in my equations.

With Hertz:

using Unitful: nH, Ω, MHz
L = 200nH  # Inductance
f = 10MHz  # Frequency
ω = 2π*f  # Angular frequency
Z = uconvert(Ω, im*ω*L)

ω is 62.8e6/s which is required for calculations but illegible to humans

With cycles per second:

using Unitful: nH, Ω, Mcps
L = 200nH  # Inductance
ω = 10Mcps  # Angular frequency
Z = uconvert(Ω, im*ω*L)

ω is 10e6 cyc/s, which is legible to humans and converts to the correct value in Ohms


So why not make the unit of Hertz equal to cycles per second?

In electromagnetics (and probably other domains) there's a problem: it's standard to use wavelength (units: meters) instead of angular wavelength (units: meters/cycle).
As an example, CB radio operates around the 11 meter band, which corresponds to a frequency around 25 MHz. The conversion from wavelength to frequency requires frequency to be in units of "per second":

julia> using Unitful: m, c0, MHz, Mcps

julia> λ = 11m;  # CB radio wavelength

julia> @show ω = uconvert(Mcps, c0/λ);  # Not conventional
ω = uconvert(Mcps, c0 / λ) = 4.33758650839722 Mcps

julia> @show f = uconvert(MHz, c0/λ);  # Conventional units
f = uconvert(MHz, c0 / λ) = 27.253859818181816 MHz

Similarly you may want to consider creating the "Revolution" unit for the RPM and RPS units:

@unit rev     "rev"     Revolution       2π*rad                  false

@codecov-io
Copy link

Codecov Report

Merging #420 (a91cb3f) into master (9126cc5) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #420   +/-   ##
=======================================
  Coverage   83.41%   83.41%           
=======================================
  Files          15       15           
  Lines        1284     1284           
=======================================
  Hits         1071     1071           
  Misses        213      213           
Impacted Files Coverage Δ
src/pkgdefaults.jl 30.00% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9126cc5...a91cb3f. Read the comment docs.

@sostock
Copy link
Collaborator

sostock commented Feb 1, 2021

Note that there is already the unit Hz2π which is equal to cps.

@giordano
Copy link
Collaborator

giordano commented Feb 1, 2021

And "cycle" is already in UnitfulAngles.jl as "turn"

@sostock sostock added the new units adding new units/dimensions/constants to this package label Dec 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new units adding new units/dimensions/constants to this package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants