Skip to content

Commit

Permalink
Feat: Bumblebee metric (#93)
Browse files Browse the repository at this point in the history
* feat: bumblebee metric in slow rotation regime

* chore: bump version

* style: formatting

* test: bumblebee metric

* fix: reach under the hood for missing function

* fix: remove show
  • Loading branch information
fjebaker authored Mar 1, 2023
1 parent 3e3e0aa commit 9c891dc
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Gradus"
uuid = "c5b7b928-ea15-451c-ad6f-a331a0f3e4b7"
authors = ["fjebaker <[email protected]>"]
version = "0.2.10"
version = "0.2.11"

[deps]
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"
Expand Down
1 change: 1 addition & 0 deletions src/Gradus.jl
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ include("metrics/johannsen-psaltis-ad.jl")
include("metrics/morris-thorne-ad.jl")
include("metrics/kerr-refractive-ad.jl")
include("metrics/dilaton-axion-ad.jl")
include("metrics/bumblebee-ad.jl")

include("special-radii.jl")
include("redshift.jl")
Expand Down
52 changes: 52 additions & 0 deletions src/metrics/bumblebee-ad.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
module __BumblebeeAD
using ..StaticArrays
using ..MuladdMacro

@muladd @fastmath begin
Δ(r, M, l) = (r^2 - (2M * r)) / (l + 1)

function metric_components(M, a, l, rθ)
(r, θ) =
sinθ2 = sin(θ)^2
Δ₀ = Δ(r, M, l)

tt = -(1 - (2M / r))
rr = r^2 / Δ₀
θθ = r^2
ϕϕ = r^2 * sinθ2

= -2M * a * sinθ2 / r
@SVector [tt, rr, θθ, ϕϕ, tϕ]
end
end

end # module

struct BumblebeeMetric{T} <: AbstractAutoDiffStaticAxisSymmetricParams{T}
"Black hole mass."
M::T
"Black hole spin."
a::T
"LSB parameter."
l::T
function BumblebeeMetric(M::T, a, l) where {T}
if l <= -1.0
error("l must be >-1")
end
if abs(a) > 0.3
error(
"This metric is for the slow rotation approximation only, and requires |a| < 0.3.",
)
end
new{T}(T(M), T(a), T(l))
end
end
BumblebeeMetric(; M = 1.0, a = 0.0, l = 0.0) = BumblebeeMetric(M, a, l)

# implementation
metric_components(m::BumblebeeMetric{T}, rθ) where {T} =
__BumblebeeAD.metric_components(m.M, m.a, m.l, rθ)
inner_radius(m::BumblebeeMetric{T}) where {T} = m.M + (m.M^2 - m.a^2)


export BumblebeeMetric
4 changes: 2 additions & 2 deletions src/tracing/method-implementations/auto-diff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ but non-allocating.
function metric_jacobian(m::AbstractAutoDiffStaticAxisSymmetricParams, rθ)
f = x -> metric_components(m, x)
T = typeof(ForwardDiff.Tag(f, eltype(rθ)))
ydual = ForwardDiff.static_dual_eval(T, f, rθ)
ForwardDiff.value.(T, ydual), ForwardDiff.extract_jacobian(T, ydual, rθ)
ydual = ForwardDiff.ForwardDiffStaticArraysExt.static_dual_eval(T, f, rθ)
ForwardDiff.value.(T, ydual), ForwardDiff.ForwardDiffStaticArraysExt.extract_jacobian(T, ydual, rθ)
end

@inbounds function geodesic_eq(
Expand Down
3 changes: 2 additions & 1 deletion test/smoke-tests/rendergeodesics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ end
u = @SVector [0.0, 100.0, deg2rad(85), 0.0]

# last computed 21/01/2023: shrink resolution
expected = (8969.1564582409967, 8969.15634220181, 8977.502920124776, 413.4963434133726)
expected = (8969.1564582409967, 8969.15634220181, 8977.502920124776, 413.4963434133726, 8969.155411207657)
result = map((
KerrMetric(),
JohannsenMetric(),
KerrSpacetimeFirstOrder(),
MorrisThorneWormhole(),
BumblebeeMetric(),
)) do m
α, β, img = rendergeodesics(
m,
Expand Down
1 change: 1 addition & 0 deletions test/smoke-tests/tracegeodesics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ using StaticArrays
JohannsenMetric(),
KerrSpacetimeFirstOrder(),
MorrisThorneWormhole(),
BumblebeeMetric()
]
test_single(m, u, v)
test_many(m, u, v)
Expand Down

0 comments on commit 9c891dc

Please sign in to comment.