From 5512d8db6d12f7c0ef12a794cf48bdd117eb30f1 Mon Sep 17 00:00:00 2001 From: dominic-chang Date: Tue, 11 Feb 2025 09:27:19 -0500 Subject: [PATCH] Bump version to 0.4.0 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 --- Project.toml | 2 +- examples/level-set-example.jl | 15 ++++++++------- examples/mino-time-example.jl | 2 +- examples/neural-net-example.jl | 5 +---- examples/raytracing-mesh-example.jl | 9 +++++++-- src/schemes/RayTrace.jl | 5 +++++ 6 files changed, 23 insertions(+), 15 deletions(-) diff --git a/Project.toml b/Project.toml index 0c0aaf3..0c09797 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Krang" uuid = "54806c32-d51a-438d-8447-e0041be2fbfb" authors = ["Dominic and contributors"] -version = "0.3.1" +version = "0.4.0" [deps] DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" diff --git a/examples/level-set-example.jl b/examples/level-set-example.jl index ab3ee9a..c305e1c 100644 --- a/examples/level-set-example.jl +++ b/examples/level-set-example.jl @@ -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 @@ -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 @@ -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, diff --git a/examples/mino-time-example.jl b/examples/mino-time-example.jl index 126010b..66f6e6c 100644 --- a/examples/mino-time-example.jl +++ b/examples/mino-time-example.jl @@ -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 = diff --git a/examples/neural-net-example.jl b/examples/neural-net-example.jl index e55668f..61680d0 100644 --- a/examples/neural-net-example.jl +++ b/examples/neural-net-example.jl @@ -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], diff --git a/examples/raytracing-mesh-example.jl b/examples/raytracing-mesh-example.jl index 5df1451..162d941 100644 --- a/examples/raytracing-mesh-example.jl +++ b/examples/raytracing-mesh-example.jl @@ -29,7 +29,7 @@ bunny_mesh = translate( 0.0, ), 2.0, - 7.0, + 10.0, -10.0, ); @@ -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) diff --git a/src/schemes/RayTrace.jl b/src/schemes/RayTrace.jl index 0b16fb7..093e0a3 100644 --- a/src/schemes/RayTrace.jl +++ b/src/schemes/RayTrace.jl @@ -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