-
Notifications
You must be signed in to change notification settings - Fork 0
/
Astro.lua
75 lines (67 loc) · 2.08 KB
/
Astro.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
local Math = require "Math"
local Astro = {
hubble = { -- Plack + ACTPol + SPTpol 2021 https://lambda.gsfc.nasa.gov/education/graphic_history/hubb_const.html
value = 68.7 * 1000, -- m/s/Mpc
uncertainty = 1.3 * 1000
},
}
setmetatable(Astro, {__index = Astro})
-- v = λf
---@param length number
---@param frequency number
---@return number velocity m/s
function Astro:waveVelocity(length, frequency)
local velocity = length * frequency
return velocity
end
-- λ = v/f
---@param velocity number
---@param frequency number
---@return number length m
function Astro:waveLength(velocity, frequency)
local length = velocity / frequency
return length
end
-- f = v/λ
---@param velocity number
---@param length number
---@return number frequency Hz
function Astro:waveFrequency(velocity, length)
local frequency = velocity / length
return frequency
end
-- z = v/c
-- v/c = Δλ / λ∘
-- Δλ = λ - λ∘
-- v = Δλ / λ∘ * c
---@param referenceWavelength number
---@param observedWavelegth number
---@return number velocity m/s
function Astro:dopplerRadialVelocity(referenceWavelength, observedWavelegth)
local deltaWavelegth = observedWavelegth - referenceWavelength
local velocity = Math.SPEED_OF_LIGHT * (deltaWavelegth / referenceWavelength)
return velocity
end
-- z = Δλ / λ∘
---@param referenceWavelength number
---@param observedWavelegth number
---@return number shift z
function Astro:dopplerShift(referenceWavelength, observedWavelegth)
local deltaWavelegth = observedWavelegth - referenceWavelength
local shift = deltaWavelegth / referenceWavelength
return shift
end
-- Vr = cz
-- cz = H0d
-- d = cz/H0
---@param redshift number
---@return number distance mpc
---@return number uncertain mpc
function Astro:dopplerDistance(redshift)
local relativeUncertain = self.hubble.uncertainty / self.hubble.value
local recessionVelocity = Math.SPEED_OF_LIGHT * redshift
local distance = recessionVelocity / self.hubble.value
local uncertain = distance * relativeUncertain
return distance, uncertain
end
return Astro