Skip to content

Commit

Permalink
Update docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
dominic-chang committed Oct 9, 2024
1 parent 1449071 commit 055cd8a
Show file tree
Hide file tree
Showing 11 changed files with 453 additions and 41 deletions.
1 change: 1 addition & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ makedocs(;
],
"api.md",
],
checkdocs=:none
)

deploydocs(;
Expand Down
30 changes: 27 additions & 3 deletions docs/src/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,27 +48,50 @@ Krang.αboundary
Krang.βboundary
```

### Polarization Functions
### Local Frame transformations
```@docs
Krang.p_bl_d
Krang.jac_bl_u_zamo_d
Krang.jac_zamo_u_bl_d
Krang.jac_bl_d_zamo_u
Krang.jac_zamo_d_bl_u
Krang.jac_fluid_u_zamo_d
```

### Polarization
```@docs
Krang.screen_polarization
Krang.penrose_walker
Krang.synchrotronIntensity
Krang.synchrotronPolarization
```

### Raytracing API Related Functions
### Meshes, Geometries and Materials
```@docs
Krang.Mesh
Krang.MeshGeometry
Krang.ElectronSynchrotronPowerLawIntensity
Krang.ElectronSynchrotronPowerLawPolarization
Krang.UnionGeometry
```

### Pixel Related Functions
```@docs
Krang.absGθo_Gθhat
Krang.I1_inf_m_I0_terms
Krang.radial_inf_integrals_m_I0_terms
Krang.inclination
Krang.metric
Krang.absGto_Gthat
Krang.screen_coordinate
Krang.Ip_inf_m_I0_terms
Krang.I2_inf_m_I0_terms
Krang.roots
Krang.Im_inf_m_I0_terms
Krang.absGϕo_Gϕhat
Krang.I0_inf
```

### Misc
```@docs
Krang._isreal2
Expand Down Expand Up @@ -101,4 +124,5 @@ Krang.Ir_s
Krang.AbstractGeometry
Krang.radial_inf_integrals_case2
Krang.It_inf
```
```

22 changes: 11 additions & 11 deletions examples/coordinate-example.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# This example shows how to access coordinate information from the raytracing process.
# You will likely need to do this when making custom physics `materials`.
# We will raytrace a sequence of cones in the region around a Kerr black hole as seen by an observer stationed at infinity.
# We will show the emission coordinates of the n=0 (direct) and n=1 (indirect) photons as they are emitted from the
# source, at a fixed inclination angle from the black hole's spin axis.
# We will show the emission coordinates of the n=0 (direct) and n=1 (indirect) photons that are emitted from the
# source, at a fixed inclination angles with respect to the black hole's spin axis.
#
# First, let's import Krang and CairoMakie for plotting.
using Krang
Expand All @@ -24,18 +24,18 @@ curr_theme = Theme(
)
set_theme!(merge!(curr_theme, theme_latexfonts()))

metric = Krang.Kerr(0.99);
θo = 45 * π / 180;
sze = 400;
rmin = Krang.horizon(metric)
rmax = 10.0;
ρmax = 15.0;

#
# We will use a 0.99 spin Kerr black hole viewed by an asmyptptic observer at an inclination angle of θo=π/4.
# We will use a 0.99 spin Kerr black hole viewed by an asymptotic observer at an inclination angle of θo=π/4.
# A region spanned by radii between the horizon and 20M at varying inclinations will be raytraced onto the 20Mx20M
# screen of the observer.


metric = Krang.Kerr(0.99); # Kerr metric with a spin of 0.99
θo = 45 * π / 180; # inclination angle of the observer. θo ∈ (0, π)
sze = 400; # resolution of the screen is sze x sze
rmin = Krang.horizon(metric); # minimum radius to be raytraced
rmax = 10.0; # maximum radius to be raytraced
ρmax = 15.0; # horizontal and vertical limits of the screen

# Create Figure
fig = Figure(resolution=(700, 700));
axes_list = [
Expand Down
2 changes: 1 addition & 1 deletion examples/raytracing-mesh-example.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ using FileIO
metric = Krang.Kerr(0.99) # Kerr metric with a spin of 0.99
θo = 90/180*π # Inclination angle of the observer
ρmax = 12.0 # Horizontal and Vertical extent of the screen
sze = 400 # Resolution of the screen is sze x sze
sze = 100 # Resolution of the screen is sze x sze

camera = Krang.SlowLightIntensityCamera(metric, θo, -ρmax, ρmax, -ρmax, ρmax, sze)

Expand Down
62 changes: 60 additions & 2 deletions src/cameras/IntensityCamera.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,25 @@ struct IntensityPixel{T} <: AbstractPixel{T}
θo::T
η::T
λ::T
@doc """
IntensityPixel(met::Kerr{T}, α::T, β::T, θo::T) where {T}
Construct an `IntensityPixel` object with the given Kerr metric, screen coordinates, and inclination.
# Arguments
- `met::Kerr{T}`: The Kerr metric.
- `α::T`: The Bardeen α value (screen coordinate).
- `β::T`: The Bardeen β value (screen coordinate).
- `θo::T`: The inclination angle.
# Returns
- An `IntensityPixel` object initialized with the given parameters.
# Details
This function calculates the η and λ values using the provided Kerr metric and screen coordinates.
It then computes the radial roots and adjusts them if necessary.
Finally, it initializes an `IntensityPixel` object with the calculated values and the provided parameters.
"""
function IntensityPixel(met::Kerr{T}, α::T, β::T, θo::T) where {T}
tempη = Krang.η(met, α, β, θo)
tempλ = Krang.λ(met, α, θo)
Expand All @@ -40,7 +59,7 @@ end
"""
$TYPEDEF
Screen made of Intensity Pixels.
Screen made of `IntensityPixel`s.
"""
struct IntensityScreen{T, A <:AbstractMatrix} <: AbstractScreen
"Minimum and Maximum Bardeen α values"
Expand All @@ -58,6 +77,26 @@ struct IntensityScreen{T, A <:AbstractMatrix} <: AbstractScreen
β = βmin + (βmax - βmin) * (T(J)-1) / (res-1)
screen[I, J] = IntensityPixel(met, α, β, θo)
end

@doc """
IntensityScreen(met::Kerr{T}, αmin::T, αmax::T, βmin::T, βmax::T, θo::T, res::Int; A=Matrix) where {T}
Creates an intensity screen for the given Kerr metric.
This camera caches information for fast light computations.
# Arguments
- `met::Kerr{T}`: The Kerr metric.
- `αmin::T`: Minimum value of α.
- `αmax::T`: Maximum value of α.
- `βmin::T`: Minimum value of β.
- `βmax::T`: Maximum value of β.
- `θo::T`: Observer's inclination angle. θo ∈ (0, π).
- `res::Int`: Resolution of the screen.
- `A=Matrix`: Optional argument to specify the type of matrix to use. A GPUMatrix can be used for GPU computations.
# Returns
- `IntensityScreen{T, A}`: An intensity screen object.
"""
function IntensityScreen(met::Kerr{T}, αmin::T, αmax::T, βmin::T, βmax::T, θo::T, res; A=Matrix) where {T}
screen = A(Matrix{IntensityPixel{T}}(undef, res, res))

Expand All @@ -72,7 +111,7 @@ end
"""
$TYPEDEF
Observer sitting at radial infinity.
Camera that caches fast light raytracing information for an observer sitting at radial infinity.
The frame of this observer is alligned with the Boyer-Lindquist frame.
"""
struct IntensityCamera{T, A} <: AbstractCamera
Expand All @@ -81,6 +120,25 @@ struct IntensityCamera{T, A} <: AbstractCamera
screen::IntensityScreen{T, A}
"Observer screen_coordinate"
screen_coordinate::NTuple{2, T}

@doc """
IntensityCamera(met::Kerr{T}, θo, αmin, αmax, βmin, βmax, res::Int; A=Matrix) where {T}
Constructor for an Intensity Camera.
# Arguments
- `met::Kerr{T}`: The Kerr metric.
- `θo`: Observer's inclination angle. θo ∈ (0, π).
- `αmin`: Minimum value of α.
- `αmax`: Maximum value of α.
- `βmin`: Minimum value of β.
- `βmax`: Maximum value of β.
- `res::Int`: Resolution of the screen.
- `A=Matrix`: Optional argument to specify the type of matrix to use. A GPUMatrix can be used for GPU computations.
# Returns
- `IntensityCamera{T, A}`: An intensity camera object.
"""
function IntensityCamera(met::Kerr{T}, θo, αmin, αmax, βmin, βmax, res::Int; A=Matrix) where {T}
new{T, A}(met, IntensityScreen(met, αmin, αmax, βmin, βmax, θo, res; A=A), (T(Inf), θo))
end
Expand Down
60 changes: 58 additions & 2 deletions src/cameras/SlowLightIntensityCamera.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,26 @@ struct SlowLightIntensityPixel{T} <: AbstractPixel{T}
θo::T
η::T
λ::T
@doc """
SlowLightIntensityPixel(met::Kerr{T}, α::T, β::T, θo::T) where {T}
Construct a `SlowLightIntensityPixel` object with the given Kerr metric, screen coordinates, and inclination.
# Arguments
- `met::Kerr{T}`: The Kerr metric.
- `α::T`: The Bardeen α value (screen coordinate).
- `β::T`: The Bardeen β value (screen coordinate).
- `θo::T`: The inclination angle.
# Returns
- A `SlowLightIntensityPixel` object initialized with the given parameters.
# Details
This function calculates the η and λ values using the provided Kerr metric and screen coordinates.
It then computes the radial roots and adjusts them if necessary.
It also calculates the radial and angular antiderivatives.
Finally, it initializes a `SlowLightIntensityPixel` object with the calculated values and the provided parameters.
"""
function SlowLightIntensityPixel(met::Kerr{T}, α::T, β::T, θo) where {T}
tempη = Krang.η(met, α, β, θo)
tempλ = Krang.λ(met, α, θo)
Expand Down Expand Up @@ -59,7 +79,7 @@ end
"""
$TYPEDEF
Screen made of Intensity Pixels.
Screen made of `SlowLightIntensityPixel`s.
"""
struct SlowLightIntensityScreen{T, A <:AbstractMatrix} <: AbstractScreen
"Minimum and Maximum Bardeen α values"
Expand All @@ -77,6 +97,24 @@ struct SlowLightIntensityScreen{T, A <:AbstractMatrix} <: AbstractScreen
β = βmin + (βmax - βmin) * (T(J)-1) / (res-1)
screen[I, J] = SlowLightIntensityPixel(met, α, β, θo)
end
@doc """
SlowLightIntensityScreen(met::Kerr{T}, αmin, αmax, βmin, βmax, θo, res; A=Matrix) where {T}
Construct a `SlowLightIntensityScreen` object.
# Arguments
- `met::Kerr{T}`: The Kerr metric object.
- `αmin`: Minimum Bardeen α value.
- `αmax`: Maximum Bardeen α value.
- `βmin`: Minimum Bardeen β value.
- `βmax`: Maximum Bardeen β value.
- `θo`: Observer's inclination angle. θo ∈ (0, π).
- `res`: Resolution of the screen (number of pixels along one dimension).
- `A=Matrix`: Data type that stores screen pixel information (default is `Matrix`). A GPUMatrix can be used for GPU computations.
# Returns
A `SlowLightIntensityScreen` object.
"""
function SlowLightIntensityScreen(met::Kerr{T}, αmin, αmax, βmin, βmax, θo, res; A=Matrix) where {T}
screen = A(Matrix{SlowLightIntensityPixel{T}}(undef, res, res))

Expand All @@ -91,7 +129,7 @@ end
"""
$TYPEDEF
Observer sitting at radial infinity.
Camera that caches slow light raytracing information for an observer sitting at radial infinity.
The frame of this observer is alligned with the Boyer-Lindquist frame.
"""
struct SlowLightIntensityCamera{T, A} <: AbstractCamera
Expand All @@ -100,6 +138,24 @@ struct SlowLightIntensityCamera{T, A} <: AbstractCamera
screen::SlowLightIntensityScreen{T, A}
"Observer screen_coordinate"
screen_coordinate::NTuple{2, T}
@doc """
SlowLightIntensityCamera(met::Kerr{T}, θo, αmin, αmax, βmin, βmax, res; A=Matrix) where {T}
Constructs a `SlowLightIntensityCamera` object.
# Arguments
- `met::Kerr{T}`: The Kerr metric.
- `θo`: The Observer's inclination angle. θo ∈ (0, π).
- `αmin`: Minimum α coordinate on the screen.
- `αmax`: Maximum α coordinate on the screen.
- `βmin`: Minimum β coordinate on the screen.
- `βmax`: Maximum β coordinate on the screen.
- `res`: Resolution of the screen (number of pixels along one dimension).
- `A`: Data type that stores screen pixel information (default is `Matrix`). A GPUMatrix can be used for GPU computations.
# Returns
- A `SlowLightIntensityCamera` object.
"""
function SlowLightIntensityCamera(met::Kerr{T}, θo, αmin, αmax, βmin, βmax, res; A=Matrix) where {T}
screen = SlowLightIntensityScreen(met, αmin, αmax, βmin, βmax, θo, res; A)
new{T,typeof(screen.pixels)}(met, screen, (T(Inf), θo))
Expand Down
Loading

0 comments on commit 055cd8a

Please sign in to comment.