Skip to content

Commit

Permalink
Bump version to 0.4.0
Browse files Browse the repository at this point in the history
Update raytracing mesh example to push mesh outside of photon shell

Patch bug where phi blows up on the horizon. Added a warning to indicate that this is happening. A proper fix would require regularizing the integral
  • Loading branch information
dominic-chang committed Feb 11, 2025
1 parent d9cd69b commit 5512d8d
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Krang"
uuid = "54806c32-d51a-438d-8447-e0041be2fbfb"
authors = ["Dominic <[email protected]> and contributors"]
version = "0.3.1"
version = "0.4.0"

[deps]
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
Expand Down
15 changes: 8 additions & 7 deletions examples/level-set-example.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# # Raytracing a Level set geometry
# # Raytracing a Level Set geometry
# A level set geoemtry is defined by a constraint equations $f(x,y,z)=0$.
# We will ray trace an example parabaloid geometry in this example as a simple geometric jet model.
using Krang
Expand All @@ -19,15 +19,16 @@ struct Parabaloid{T} <: Krang.AbstractLevelSetGeometry{T}
rh::T
index::T
end
function (geometry::Parabaloid)(x,y,z)
r = sqrt(x^2+y^2+z^2)
return 1-(r/geometry.rh)^geometry.index*(1-z/r)
function (geometry::Parabaloid)(x, y, z)
r = sqrt(x^2 + y^2 + z^2)
return 1 - (r / geometry.rh)^geometry.index * (1 - z / r)
end

# The jet will be emit a constant intensity whose physics we define in the `XMaterial`.
# [!NOTE] We are ignoring relativistic effects in this example.
# > [!NOTE]
# > We are ignoring relativistic effects in this example.
struct XMaterial <: Krang.AbstractMaterial end
function (mat::XMaterial)(pix, intersection) where T
function (mat::XMaterial)(pix, intersection)
return 1.0
end

Expand All @@ -38,7 +39,7 @@ fig = GLMk.Figure();
ax = GLMk.Axis(fig[1, 1], aspect = 1)


intersections = raytrace(camera, Krang.Mesh(parabaloid, XMaterial()), res = 1_00)
intersections = raytrace(camera, Krang.Mesh(parabaloid, XMaterial()), res = 1_00);

# And plot the image with GLMakie,

Expand Down
2 changes: 1 addition & 1 deletion examples/mino-time-example.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ camera = Krang.SlowLightIntensityCamera(metric, θo, -ρmax, ρmax, -ρmax, ρma
# We will create a loop to plot the emission coordinates for each `τ` using the `emission_coordinates!` function.
# Let us now create a figure to plot the emission coordinates on.

fig = GLMk.Figure(resolution = (500, 600));
fig = GLMk.Figure(size = (500, 600));


recording =
Expand Down
5 changes: 1 addition & 4 deletions examples/neural-net-example.jl
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,7 @@ loss_function(pixels, target_img, ps_trained, st_trained)
using Printf

fig = Figure(size = (700, 300))
heatmap!(
Axis(fig[1, 1], aspect = 1, title = "Target Image"),
reshape(target_img, sze, sze),
)
heatmap!(Axis(fig[1, 1], aspect = 1, title = "Target Image"), reshape(target_img, sze, sze))
heatmap!(
Axis(
fig[1, 2],
Expand Down
9 changes: 7 additions & 2 deletions examples/raytracing-mesh-example.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ bunny_mesh = translate(
0.0,
),
2.0,
7.0,
10.0,
-10.0,
);

Expand Down Expand Up @@ -109,7 +109,12 @@ recording = GLMk.record(fig, "mesh.mp4", 1:sze*sze, framerate = 120) do i
end

cart_line = map(
x -> (x.rs * sin(x.θs) * cos(x.ϕs), x.rs * sin(x.θs) * sin(x.ϕs), x.rs * cos(x.θs)),
x -> Krang.boyer_lindquist_to_quasi_cartesian_kerr_schild_fast_light(
metric,
x.rs,
x.θs,
x.ϕs,
),
line,
)
GLMk.lines!(ax3, cart_line, color = :red)
Expand Down
5 changes: 5 additions & 0 deletions src/schemes/RayTrace.jl
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ function ϕ_kerr_schild(metric::Kerr{T}, rBL, ϕBL) where {T}

term1 = a / (2temp) * log(abs(num / den))
term2 = -atan(a / rBL)
ans = ϕBL - term1 - term2
if isinf(ans)
@warn "ϕ_kerr_schild is inf at rs=$rBL. This usually happens if the ray intersects the horizon."
return ϕBL - term2
end
return ϕBL - term1 - term2
end

Expand Down

0 comments on commit 5512d8d

Please sign in to comment.