195 lines
6.8 KiB
Julia
195 lines
6.8 KiB
Julia
# Useful information:
|
|
#
|
|
# https://en.wikipedia.org/wiki/List_of_physical_quantities
|
|
# https://www.themeasureofthings.com/
|
|
#
|
|
# "free" Unitful units: efijno r v xzDEIOQUXZ |
|
|
# "used" Unitful units: e i p t w |
|
|
module IIPAU
|
|
|
|
import Unitful
|
|
using Unitful: @unit, @affineunit, @u_str
|
|
export item
|
|
export @b6_str
|
|
export yocte, zepte, atte, femte, pice, nane, micre, mille, cente, dice
|
|
export yotte, zette, exe, pete, tere, gige, mege, kile, hecte, dece
|
|
|
|
export pace, tick, egg
|
|
|
|
|
|
function __init__()
|
|
Unitful.register(IIPAU)
|
|
end
|
|
#Unitful.register(IIPAU)
|
|
|
|
# Additional Constants
|
|
kₑ = 8987551792u"N*m^2/C^2"
|
|
mₑ = 9.109e-31u"kg"
|
|
mᵤ = 1.6605390666e-27u"kg"
|
|
mₙ = 1.674927498e-27u"kg"
|
|
kb = 1.380649e-23u"J/K"
|
|
ϵ₀ = 8.854e-12u"F/m"
|
|
|
|
# Natural Units
|
|
@unit lₛ "lₛ" StoneyLength (sqrt(Unitful.G * kₑ * Unitful.q^2 / Unitful.c^4) |> Unitful.upreferred) false
|
|
@unit mₛ "mₛ" StoneyMass (sqrt(kₑ * Unitful.q^2 / Unitful.G) |> Unitful.upreferred) false
|
|
@unit tₛ "tₛ" StoneyTime (sqrt(Unitful.G * kₑ * Unitful.q^2 / Unitful.c^6) |> Unitful.upreferred) false
|
|
|
|
@unit lₚ "lₚ" PlanckLength sqrt(Unitful.ħ * Unitful.G / Unitful.c^3) false
|
|
@unit mₚ "mₚ" PlanckMass sqrt(Unitful.ħ * Unitful.c / Unitful.G) false
|
|
@unit tₚ "tₚ" PlanckTime sqrt(Unitful.ħ * Unitful.G / Unitful.c^5) false
|
|
@unit Tₚ "Tₚ" PlanckTemperature sqrt(Unitful.ħ * Unitful.c ^ 5 / (Unitful.G * Unitful.k ^ 2)) false
|
|
@unit qₚ "qₚ" Planckcharge sqrt(4π * Unitful.ϵ0 * Unitful.ħ * Unitful.c) false
|
|
@unit Qₚ "Qₚ" PlanckCharge sqrt(Unitful.ϵ0 * Unitful.ħ * Unitful.c) false
|
|
item = @unit count "count" Count (1 / Unitful.Na) false
|
|
|
|
# Senary prefixes
|
|
function base6(number::AbstractString)
|
|
if occursin('e', number)
|
|
(digits, exponent) = split(number, 'e')
|
|
else
|
|
(digits, exponent) = (number, "0")
|
|
end
|
|
|
|
if occursin('.', digits)
|
|
value = parse(BigFloat, digits, base=6)
|
|
else
|
|
value = parse(BigInt, digits, base=6)
|
|
end
|
|
|
|
expval = parse(Int, exponent, base=6)
|
|
|
|
if expval < 0
|
|
return 1 // (value * BigInt(6) ^ (-expval))
|
|
else
|
|
return value * BigInt(6) ^ expval
|
|
end
|
|
end
|
|
|
|
macro b6_str(digits)
|
|
value = base6(digits)
|
|
|
|
return :( $value )
|
|
end
|
|
|
|
yocte = b6"1e-52" # y |
|
|
zepte = b6"1e-44" # z |
|
|
atte = b6"1e-40" # a |
|
|
femte = b6"1e-32" # f |
|
|
pice = b6"1e-24" # p |
|
|
nane = b6"1e-20" # n |
|
|
micre = b6"1e-12" # μ |
|
|
mille = b6"1e-4" # m |
|
|
cente = b6"1e-2" # c |
|
|
dice = b6"1e-1" # d |
|
|
dece = b6"1e1" # de |
|
|
hecte = b6"1e2" # h |
|
|
kile = b6"1e4" # k |
|
|
mege = b6"1e12" # M |
|
|
gige = b6"1e20" # G |
|
|
tere = b6"1e24" # T |
|
|
pete = b6"1e32" # P |
|
|
exe = b6"1e40" # E |
|
|
zette = b6"1e44" # Z |
|
|
yotte = b6"1e52" # Y |
|
|
|
|
# TODO: consider scaling instants up, using moment for the base unit at a more
|
|
# human timescale
|
|
|
|
# Base Units
|
|
pace = 1@unit p "p" Pace (lₛ * b6"1e114") false # ~86cm
|
|
tick = 1@unit t "t" Tick (tₛ * b6"3e132") false # ~0.52s = 300₆ instants (1/tick ~115bpm)
|
|
egg = 1@unit e "e" Egg (mₛ * b6"1e14") false # ~112g
|
|
jolt = 1@unit j "j" Jolt (b6"1e34" * Unitful.q / tick) false # ~40mA painful jolt (https://electronics.stackexchange.com/questions/19103/how-much-voltage-current-is-dangerous)
|
|
|
|
# Convenience Units
|
|
instant = 1@unit i "i" Instant (tₛ * b6"1e130") false # ~5ms (1000₆ instants is about a second)
|
|
# TODO: larger chunks of meaningful time (akin to minutes/hours)
|
|
# TODO: name ~0.5L which is a mille pace^3?
|
|
|
|
# Derived Units
|
|
walk = 1@unit w "w" Walk (1 * pace / tick) false # ~6km/h (pretty quick walk)
|
|
touch = 1@unit ṫ "ṫ" Touch (1 * egg * pace / tick ^ 2) false # ~0.36N (half what it takes to press a key on a keyboard)
|
|
|
|
#= Useful Constants ============================================================
|
|
Earth's gravitational constant: gₑ ≈ 3₆p/t²
|
|
Speed of light: c ≡ 3e14₆p/t
|
|
===============================================================================#
|
|
|
|
#=
|
|
export stride, skip, bed, gulp
|
|
export moment, instant, wait
|
|
export amble, shot
|
|
export ball
|
|
export brr
|
|
export press, bite, snack
|
|
export jolt
|
|
export lotta, alotta
|
|
|
|
# Lengths (root unit: skip)
|
|
skip = 1@unit sk "sk" Skip (lₚ * b6"1e112") false # ~28cm
|
|
stride = 1@unit st "st" Stride (dece * skip) false # ~1.7m
|
|
sprint = 1@unit sp "sp" Sprint (kile * skip) false # ~360m
|
|
# Note: a kile stride is about 1 nautical mile
|
|
|
|
# Areas (root unit: paper)
|
|
paper = 1@unit pa "pa" Paper (skip * skip) false # ~0.08m²
|
|
bed = 1@unit bd "bd" Bed (stride * stride) false # ~2.8m²
|
|
|
|
# Volumes (root unit: gulp)
|
|
gulp = 1@unit gu "gu" Gulp ((dice * IIPAU.skip) ^ 3) false # ~100 mL
|
|
|
|
# Durations (root unit: instant)
|
|
instant = 1@unit in "in" Instant (tₚ * b6"1e131") false # ~1/3s
|
|
moment = 1@unit mo "mo" Moment (dece * instant) false # ~2s
|
|
wait = 1@unit w "w" Wait (kile * moment) false # ~43.9 minutes
|
|
|
|
# Speed (root unit: amble)
|
|
amble = 1@unit amb "amb" Amble (skip / instant) false # ~3km/h
|
|
shot = 1@unit sh "sh" Shot (kile * amble) false # ~1km/s (bullet speed)
|
|
|
|
# Mass (root unit: ball)
|
|
ball = 1@unit bl "bl" Ball (mₚ * b6"1.0e13") false # ~200g (note: Float to fix Int64 overflow)
|
|
|
|
# Temperate (root unit: brr, base unit degree of comfort)
|
|
brr = 1@unit br "br" Brr (Tₚ * b6"1e-110") false # ~0.3K
|
|
@affineunit °c "°c" (Int(b6"4400") * brr) # ~13°C -> 0°c
|
|
# This sets up that 0 is uncomfortably cold, 100₆ is comfortable, and 200₆ is
|
|
# uncomfortably warm (13, 23.5, 34)°C respectively
|
|
|
|
# Force (root unit: press)
|
|
press = 1@unit pr "pr" Press (ball * skip / instant^2) false # ~0.5N (key press on keyboard)
|
|
|
|
# NOTE: 1bi / Mto = 1st, aka a bite is one megatouch stride (or a kileshove stride)
|
|
# NOTE: 1sn / Mpr = 1sk, aka a snack is one megepress skip
|
|
|
|
# Energy (root unit: snack)
|
|
snack = 1@unit sn "sn" Snack (b6"1.0e12" * press * skip) false # ~60cal
|
|
bite = 1@unit bi "bi" Bite (dice * snack) false # ~10cal
|
|
|
|
# Electricity, based on a common static shock
|
|
# ~0-2mJ / ~1-5KV = ~5e-8 to 5e-7C
|
|
|
|
# Charge (root unit: jolt)
|
|
jolt = 1@unit jo "jo" Jolt (b6"1e23" * Unitful.q) false # ~7.5e-8C (a moderate static shock of charge)
|
|
|
|
# TODO: Voltage and consider charge in lotta electron charges (q in Unitful
|
|
# [leads to about 2e7C, which is a lot, but might make cleaner 'volts'])
|
|
# or consider using resistivity or conductivity of something common?
|
|
temp = 1@unit tmp "tmp" Temp (jolt / moment) false
|
|
|
|
# "Count" (root unit: lotta [mole equivalent]) ~1.32e26
|
|
lotta = 1@unit lo "lo" Lotta (1u"mol" * 1u"bl" / 1u"g") false # ~220mol
|
|
alotta = (1u"lo" |> item).val # ~1.32e26
|
|
|
|
function prefer_iipau()
|
|
Unitful.preferunits(u"sk,mo,bl,br,lo,tmp"...)
|
|
end
|
|
|
|
function prefer_natural()
|
|
Unitful.preferunits(u"lₚ,mₚ,tₚ,Tₚ,qₚ,Qₚ,count"...)
|
|
end
|
|
=#
|
|
|
|
end # module IIPAU
|