Good progress made

This commit is contained in:
Louis Burke 2024-09-23 19:57:32 -04:00
parent 8394c83e40
commit e1660d42de
4 changed files with 94 additions and 16 deletions

5
README.md Normal file
View file

@ -0,0 +1,5 @@
To play around with IIPAU, run `julia --project=.` and start with:
using Revise
using Unitful
using IIPAU

View file

@ -23,10 +23,12 @@ export item
export @b6_str export @b6_str
export yocte, zepte, atte, femte, pice, nane, micre, mille, cente, dice export yocte, zepte, atte, femte, pice, nane, micre, mille, cente, dice
export yotte, zette, exe, pete, tere, gige, mege, kile, hecte, dece export yotte, zette, exe, pete, tere, gige, mege, kile, hecte, dece
export to₆
export wave_number export wave_number
export pace, tick, egg, jolt, brr, °c export span, tick, egg, spark, lotta, alotta, brr
export ball, touch, jolt
function __init__() function __init__()
Unitful.register(IIPAU) Unitful.register(IIPAU)
@ -36,29 +38,32 @@ end
span = 1@unit "" Span (Unitful.c / Natural.HHz) false # ~21cm span = 1@unit "" Span (Unitful.c / Natural.HHz) false # ~21cm
tick = 1@unit t "t" Tick (b6"2e15" / Natural.HHz) false # ~0.51s (1/tick is ~118 bpm) tick = 1@unit t "t" Tick (b6"2e15" / Natural.HHz) false # ~0.51s (1/tick is ~118 bpm)
egg = 1@unit e "e" Egg (-b6"4e44" * Natural.ΔEₕ * tick^2 / span^2) false # ~136g egg = 1@unit e "e" Egg (-b6"4e44" * Natural.ΔEₕ * tick^2 / span^2) false # ~136g
spark = 1@unit ş "ş" Spark (b6"1e34" * Unitful.q) false # ~0.02C
lotta = 1@unit ļ "ļ" Lotta (1u"mol" * egg / u"g") false # ~135mol lotta = 1@unit ļ "ļ" Lotta (1u"mol" * egg / u"g") false # ~135mol
alotta = (lotta |> item).val alotta = (lotta |> item).val # ~81 septillion (81e24)
brr = 1@unit "" Brr (Natural.ΔEₕ / Natural.hexit) false # ~0.04K
# Unit of charge at b6"1e34" * Unitful.q is about 0.02C @affineunit °c "°c" (Int(b6"-100000") * brr) # ~23°C -> 0°c, human's can't really survive past about -2000₆°c (too hot)
# u"ṡ^2*e" / (b6"1e34" * Unitful.q) / u"t^2" is about 1.1V
# (b6"1e34" * Unitful.q) / u"t" is about 0.04A
#
# A good target voltage is hydrogen fuel cell ideal voltage of 1.229V
# A good target amperage could be near-life-threatening 0.8A
#
# Alternatively fix the coulomb constant?
# That is below:
touch = 1@unit "" Touch (egg * span / tick ^2) false # ~0.1N (10grams of weight)
jolt = 1@unit j "j" Jolt (b6"1e10" * (span / tick) / sqrt(Natural.kₑ / touch)) false # ~0.067A
# Derived Units # Derived Units
ball = 1@unit "" Ball ((π/6)*span^3) false # ~5L (sphere of diameter 1ṡ) ball = 1@unit "" Ball ((π/6)*span^3) false # ~5L (sphere of diameter 1ṡ)
touch = 1@unit "" Touch (egg * span / tick ^2) false # ~0.1N (10grams of weight)
jolt = 1@unit j "j" Jolt (spark / tick) false # ~0.04A
cell = 1@unit ċ "ċ" Cell (span * touch / spark) false # ~1.1V (just shy of zinc/copper electrode)
# TODO: resistance is at about 26.6Ω
# Convenience Units
instant = 1@unit i "i" Instant (b6"3e-2" * tick) false # ~5ms (300₆ instants to a tick)
pause = 1@unit "" Pause (b6"300" * tick) false # ~55 seconds
wait = 1@unit "" Wait (b6"300" * pause) false # ~100 minutes
# Useful references
resistance_of_wire(ρ, L, d) = ρ * L / (π * (d/2)^2)
# Note: 1 kile span of 1 mille span diameter silver wire has a resistance of about 210Ω
#egg = 1@unit e "e" Egg (b6"1e53" * (Unitful.mp + Unitful.me)) false # ~80g #egg = 1@unit e "e" Egg (b6"1e53" * (Unitful.mp + Unitful.me)) false # ~80g
#=
pace = 1@unit p "p" Pace (lₛ * b6"1e114") false # ~86cm # 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) # 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 # 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) # 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)
@ -81,6 +86,8 @@ nosh = 1@unit n "n" Nosh (b6"1e11" * pace * touch) false # ~20.5 kcal
Speed of light: c 3e14₆p/t Speed of light: c 3e14₆p/t
===============================================================================# ===============================================================================#
=#
#= #=
export stride, skip, bed, gulp export stride, skip, bed, gulp
export moment, instant, wait export moment, instant, wait

View file

@ -16,6 +16,8 @@ a₀= Unitful.ħ / (Unitful.me * Unitful.c * α) # bohr radius
ΔEₕ = 2 * gₑ * α^4 * gₚ * Unitful.me^2 * Unitful.c^2 / (3 * Unitful.mp) # hydrogen hyperfine transition energy ΔEₕ = 2 * gₑ * α^4 * gₚ * Unitful.me^2 * Unitful.c^2 / (3 * Unitful.mp) # hydrogen hyperfine transition energy
HHz = -ΔEₕ / Unitful.h # Hydrogen hyperfine transition frequency HHz = -ΔEₕ / Unitful.h # Hydrogen hyperfine transition frequency
bit = Unitful.k * log(2) bit = Unitful.k * log(2)
hexit = Unitful.k * log(6)
natit = Unitful.k * log(1/α)
# Natural Units # Natural Units
@unit lₛ "lₛ" StoneyLength (sqrt(Unitful.G * kₑ * Unitful.q^2 / Unitful.c^4) |> Unitful.upreferred) false @unit lₛ "lₛ" StoneyLength (sqrt(Unitful.G * kₑ * Unitful.q^2 / Unitful.c^4) |> Unitful.upreferred) false

View file

@ -54,4 +54,68 @@ exe = b6"1e40" # E |
zette = b6"1e44" # Z | zette = b6"1e44" # Z |
yotte = b6"1e52" # Y | yotte = b6"1e52" # Y |
#=
def longdiv(numerator,denominator):
digits = []
remainders = [0]
n = numerator
while n not in remainders: # until repeated remainder or no remainder
remainders.append(n) # add remainder to collection
digits.append(n//denominator) # add integer division to result
n = n%denominator * 10 # remainder*10 for next iteration
# Result
result = list(map(str,digits)) # convert digits to strings
result = ''.join(result) # combine list to string
if not n:
result = result[:1]+'.'+result[1:] # Insert . into string
else:
recurring = remainders.index(n)-1 # first recurring digit
# Insert '.' and then surround recurring part in brackets:
result = result[:1]+'.'+result[1:recurring]+'['+result[recurring:]+']'
return result;
print(longdiv(31,8)) # 3.875
print(longdiv(2,13)) # 0.[153846]
print(longdiv(13,14)) # 0.9[285714]
=#
"Converts x to an exact seximal number. Repeated digits are shown in brackets."
function to₆(x :: Rational{BigInt})
if x < 0
return "-" * to₆(-x)
end
if x > 1
intpart = floor(x)
return string(intpart.num, base=6) * to₆(x - intpart)
end
digits = []
remainders = [BigInt(0)]
remset = Set{BigInt}()
n = x.num
d = x.den
while !(n in remset)
append!(remainders, n)
push!(remset, n)
append!(digits, floor(n // d).num)
n = (n % d) * 6
end
if n == 0
return "." * prod(map(string, digits[2:end]))
end
recur = findfirst(==(n), remainders) - 1
return "." * prod(map(string, digits[2:recur - 1])) * "(" * prod(map(string, digits[recur:end])) * ")"
end
to₆(x) = to₆(Rational{BigInt}(x))
# TODO: custom base6 version of @prefixed_unit_symbol
end # module Seximal end # module Seximal