Skip to content

Commit 7d9dd8e

Browse files
committed
Update docs
1 parent 7f890e7 commit 7d9dd8e

4 files changed

Lines changed: 179 additions & 31 deletions

File tree

109 KB
Loading

docs/source/bibliography.bib

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,17 @@ @ARTICLE{Luminet_1979
99
pages = {228-235},
1010
adsurl = {https://ui.adsabs.harvard.edu/abs/1979A&A....75..228L},
1111
adsnote = {Provided by the SAO/NASA Astrophysics Data System}
12-
}
12+
}
13+
14+
@ARTICLE{Page_1974,
15+
title = "Disk-accretion onto a black hole. Time-averaged structure of
16+
accretion disk",
17+
author = "Page, Don N and Thorne, Kip S",
18+
journal = "Astrophys. J.",
19+
publisher = "American Astronomical Society",
20+
volume = 191,
21+
pages = "499",
22+
month = jul,
23+
year = 1974,
24+
language = "en"
25+
}

luminet/black_hole.py

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,11 @@ def plot_isoradials(
270270
271271
Example::
272272
273-
>>> direct_irs = [6, 10, 15, 20]
274-
>>> ghost_irs = [6, 20, 50, 100] # ghost_r can go to infinity
275-
>>> ax = bh.plot_isoradials(direct_irs, ghost_irs, lw=1, colors='white')
273+
from luminet.black_hole import BlackHole
274+
275+
direct_irs = [6, 10, 15, 20]
276+
ghost_irs = [6, 20, 50, 100] # ghost_r can go to infinity
277+
ax = bh.plot_isoradials(direct_irs, ghost_irs, lw=1, colors='white')
276278
277279
.. image:: /../_static/_images/isoradials.png
278280
:align: center
@@ -319,8 +321,10 @@ def plot(self, **kwargs) -> Axes:
319321
320322
Example::
321323
322-
>>> bh = BlackHole()
323-
>>> bh.plot()
324+
from luminet.black_hole import BlackHole
325+
326+
bh = BlackHole()
327+
bh.plot()
324328
325329
.. image:: /../_static/_images/bh.png
326330
:align: center
@@ -345,10 +349,12 @@ def plot_isoredshifts(self, redshifts=None, order=0, ax=None, **kwargs) -> Axes:
345349
346350
Example::
347351
348-
>>> bh = BlackHole()
349-
>>> redshifts = [-.2, -.1, 0., .1, .2, .3, .4]
350-
>>> ax = bh.plot_isoredshifts(redshifts, c='white')
351-
>>> ax = bh.disk_apparent_inner_edge.plot(ax=ax, c='white')
352+
from luminet.black_hole import BlackHole
353+
354+
bh = BlackHole()
355+
redshifts = [-.2, -.1, 0., .1, .2, .3, .4]
356+
ax = bh.plot_isoredshifts(redshifts, c='white')
357+
ax = bh.disk_apparent_inner_edge.plot(ax=ax, c='white')
352358
353359
.. image:: /../_static/_images/isoredshifts.png
354360
:align: center
@@ -362,14 +368,17 @@ def plot_isoredshifts(self, redshifts=None, order=0, ax=None, **kwargs) -> Axes:
362368
ax = isoredshift.plot(ax, **kwargs)
363369
return ax
364370

365-
def plot_isofluxlines(self, mask_inner=True, normalize=True, order=0, ax=None, **kwargs) -> Axes:
371+
def plot_isofluxlines(self, mask_inner=True, mask_outer=True, normalize=True, order=0, ax=None, **kwargs) -> Axes:
366372
"""Plot lines of equal flux.
367373
368374
Args:
369375
normalize (bool): Whether to normalize the fluxlines by the maximum flux or not. Defaults to True.
370376
mask_inner (bool):
371377
Whether to place a mask over the apparent inner edge, where the direct image produces no flux.
372-
Useful to mitigate matplotlib tricontour artifacts.
378+
Useful to mitigate matplotlib tricontour artifacts. Default is ``True``
379+
mask_outer (bool):
380+
Whether to place a mask over the apparent outer edge, where we are not capturing photons from.
381+
Useful to mitigate matplotlib tricontour artifacts. Default is ``True``.
373382
order (int): The order of the image to plot siofluxlines for. Default is :math:`0`.
374383
ax (:class:`~matplotlib.axes.Axes`, optional): Axes object to plot on.
375384
Useful for when you want to plot multiple things one a single canvas.
@@ -383,9 +392,11 @@ def plot_isofluxlines(self, mask_inner=True, normalize=True, order=0, ax=None, *
383392
384393
Example::
385394
386-
>>> bh = BlackHole(incl=1.4, radial_resolution=200)
387-
>>> levels = np.logspace(-1.3, 0, 10)
388-
>>> ax = bh.plot_isofluxlines(colors='white', levels=levels, linewidths=1)
395+
from luminet.black_hole import BlackHole
396+
397+
bh = BlackHole(incl=1.4, radial_resolution=200)
398+
levels = [.05, .1, .15, .2, .25, .3, .6, .9, 1.2, 1.5, 1.8, 2.1]
399+
ax = bh.plot_isofluxlines(colors='white', levels=levels, linewidths=1)
389400
390401
.. image:: /../_static/_images/isofluxlines.png
391402
:align: center
@@ -426,6 +437,15 @@ def plot_isofluxlines(self, mask_inner=True, normalize=True, order=0, ax=None, *
426437
color='k',
427438
zorder=len(contour.levels) + 1
428439
)
440+
if mask_outer:
441+
max_r = ax.get_ylim()[-1]
442+
ax.fill_between(
443+
self.disk_apparent_outer_edge.angles,
444+
self.disk_apparent_outer_edge.impact_parameters,
445+
max_r,
446+
color='k',
447+
zorder=len(contour.levels) + 1
448+
)
429449
return ax
430450

431451
def sample_photons(self, n_points=1000) -> Tuple[pd.DataFrame]:

luminet/black_hole_math.py

Lines changed: 131 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ def calc_b_from_perigee(p: float, bh_mass: float) -> float:
4747
The fraction on the right hand side equals :math:`b^2`, not :math:`b`.
4848
You can verify this by filling in :math:`u_2` in Equation 3.
4949
Only this way do the limits :math:`P -> 3M` and :math:`P >> M` hold true,
50-
as well as the value for :math:`b_c`
50+
as well as the value for :math:`b_c`. The resulting images of the paper are correct though.
51+
5152
5253
Returns:
5354
float: Impact parameter :math:`b`
@@ -74,7 +75,8 @@ def calc_k(periastron: float, bh_mass: float) -> float:
7475
float: Modulus of the elliptic integral
7576
7677
Attention:
77-
Mind the typo in :cite:t:`Luminet_1979`. The numerator should be in brackets.
78+
Mind the typo in :cite:t:`Luminet_1979`. The numerator should be in brackets. The resulting images of the paper are correct though.
79+
7880
"""
7981
q = calc_q(periastron, bh_mass)
8082
if q is np.nan:
@@ -468,32 +470,73 @@ def ellipse(r, a, incl) -> float:
468470

469471

470472
def calc_Z1(bh_mass, a):
471-
"""Calculate :math:`Z1` for Kerr black holes.
473+
r"""Calculate :math:`Z1` for Kerr black holes.
474+
475+
The variable :math:`Z1` is used to calculate the innermost orbit for Kerr black holes.
476+
477+
.. math::
478+
479+
Z_1 \equiv 1 + \sqrt[3]{1-a_*^2}\left[ \sqrt[3]{1+a_*} + \sqrt[3]{1-a_*} \right]
480+
481+
Args:
482+
bh_mass (float): Mass of the black hole.
483+
a (float): Specific angular momentum of the black hole. Should always be between :math:`-1` and :math:`1`. :math:`a > 0` if the accretion disk orbits in the same direction as the hole rotates; :math:`a < 0` if it orbits in the opposite direction.
472484
473485
See also:
474486
:cite:t:`Page_1974` Equation 15l
487+
488+
See also:
489+
:meth:`calc_innermost_orbit` for the calculation of the innermost orbit of Kerr black holes.
475490
"""
476491
a_ = a/bh_mass
477492
return 1 + (1-a_**2)**(1/3)*((1+a_)**(1/3) + (1 - a_)**(1/3))
478493

494+
479495
def calc_Z2(bh_mass, a):
480-
"""Calculate :math:`Z2`
496+
r"""Calculate :math:`Z2` for Kerr black holes.
497+
498+
The variable :math:`Z2` is used to calculate the innermost orbit for Kerr black holes.
499+
500+
.. math::
501+
502+
Z_2 \equiv \sqrt{3a_*^2+Z_1^2}
503+
504+
Args:
505+
bh_mass (float): Mass of the black hole.
506+
a (float): Specific angular momentum of the black hole. Should always be between :math:`-1` and :math:`1`. :math:`a > 0` if the accretion disk orbits in the same direction as the hole rotates; :math:`a < 0` if it orbits in the opposite direction.
481507
482508
See also:
483509
:cite:t:`Page_1974` Equation 15m
510+
511+
See also:
512+
:meth:`calc_innermost_orbit` for the calculation of the innermost orbit of Kerr black holes.
484513
"""
485514
Z1 = calc_Z1(bh_mass, a)
486515
a_ = a/bh_mass
487516
return np.sqrt(3*a_**2 + Z1**2)
488517

489518

490-
def calc_innermost_orbit(bh_mass, a):
491-
"""Calculcate the innermost orbit :math:`r_{ms}` for a Kerr black hole.
519+
def calc_innermost_stable_orbit(bh_mass, a):
520+
r"""Calculcate the innermost stable orbit :math:`r_{ms}` for a Kerr black hole.
492521
493-
A larger angular momentum :math:`a` will yield innermost orbits closer to the black hole.
522+
A larger specific angular momentum :math:`a` will yield innermost orbits closer to the black hole.
523+
524+
.. math::
525+
526+
\begin{align*}
527+
r_{ms} &= Mx_0^2 \\
528+
x_0^2 &= 3 + Z_2 - sgn(a_*)\sqrt{(3-Z_1)(3+Z_1+2Z_2) }
529+
\end{align*}
530+
531+
Args:
532+
bh_mass (float): Mass of the black hole.
533+
a (float): Specific angular momentum of the black hole. Should always be between :math:`-1` and :math:`1`. :math:`a > 0` if the accretion disk orbits in the same direction as the hole rotates; :math:`a < 0` if it orbits in the opposite direction.
494534
495535
See also:
496536
:cite:t:`Page_1974`
537+
538+
See also:
539+
:meth:`calc_Z1` and :meth:`calc_Z2`.
497540
"""
498541
Z1 = calc_Z1(bh_mass, a)
499542
Z2 = calc_Z2(bh_mass, a)
@@ -502,18 +545,25 @@ def calc_innermost_orbit(bh_mass, a):
502545
3 + Z2 - np.sign(a_)*((3-Z1)*(3+Z1+2*Z2))**.5
503546
)
504547

548+
505549
def calc_x0(bh_mass, a):
506550
r"""Calculcate :math:`x_0` for Kerr black holes.
507551
508552
.. math::
509553
510-
x_0 = \sqrt{\frac{r_{ms}}/{M}}
554+
x_0 = \sqrt{\frac{r_{ms}}{M}}
511555
556+
Args:
557+
bh_mass (float): Mass of the black hole.
558+
a (float): Specific angular momentum of the black hole. Should always be between :math:`-1` and :math:`1`. :math:`a > 0` if the accretion disk orbits in the same direction as the hole rotates; :math:`a < 0` if it orbits in the opposite direction.
512559
513560
See also:
514561
:cite:t:`Page_1974` Equation 15k
562+
563+
See also:
564+
meth:`calc_innermost_orbit` for the calculation of :math:`r_{ms}`
515565
"""
516-
rms = calc_innermost_orbit(bh_mass, a)
566+
rms = calc_innermost_stable_orbit(bh_mass, a)
517567
return np.sqrt(rms/bh_mass)
518568

519569

@@ -526,7 +576,7 @@ def calc_f_kerr(bh_mass, a, r):
526576
527577
F_s(r) = \frac{\dot{M}_0}{4\pi}e^{-(\nu + \psi + \mu)}f
528578
529-
Here, :math:`nu`, :math:`psi` and :math:`mu` are metric coefficients (functions of r), including Kerr metric. :math:`\dot{M}_0` is the radius-independent, time-averaged rate at which mass flows inward. Defining the innermost stable orbit as :math:`r_{ms}`, :math:`x=\sqrt{r/M}`, :math:`x_0=\sqrt{r_{ms}/M}` and :math:`a^*=a/M`, the :math:`f`-function is defined as:
579+
Here, :math:`\nu`, :math:`\psi` and :math:`\mu` are metric coefficients (functions of :math:`r`) of the Kerr metric. :math:`\dot{M}_0` is the radius-independent, time-averaged rate at which mass flows inward. Defining the innermost stable orbit as :math:`r_{ms}`, :math:`x=\sqrt{r/M}=\sqrt{r^*}`, :math:`x_0=\sqrt{r_{ms}/M}` and :math:`a^*=a/M`, the :math:`f`-function is defined as:
530580
531581
.. math::
532582
@@ -537,6 +587,43 @@ def calc_f_kerr(bh_mass, a, r):
537587
&- \frac{3(x_3 - a^*)^2}{x_3(x_3-x_1)(x_3-x_2)}\ln\left(\frac{x-x_3}{x_0-x_3}\right) \Bigg]
538588
\end{align*}
539589
590+
, where
591+
592+
.. math::
593+
594+
\begin{align*}
595+
x_1 &= 2\cos(\frac{1}{3}\cos^{-1}(a_*) - \frac{\pi}{3}) \\
596+
x_2 &= 2\cos(\frac{1}{3}\cos^{-1}(a_*) + \frac{\pi}{3}) \\
597+
x_3 &= -2\cos(\frac{1}{3}\cos^{-1}(a_*)) \\
598+
\end{align*}
599+
600+
For a Swarzschild black hole, :math:`a=0` and these simplify to:
601+
602+
.. math::
603+
604+
\begin{align*}
605+
x_1 &= \sqrt{3} \\
606+
x_2 &= 0 \\
607+
x_3 &= - \sqrt{3} \\
608+
f &= \frac{3}{2M}\frac{1}{{r^{*}}^{1.5}(r^*-3)}\left[x - x_0 + \frac{\sqrt{3}}{2}\ln\left( \frac{(\sqrt{6} - \sqrt{3})(\sqrt{r^*}+\sqrt{3})}{(\sqrt{6} + \sqrt{3})(\sqrt{r^*} - \sqrt{3})} \right) \right]
609+
\end{align*}
610+
611+
Args:
612+
bh_mass (float): Mass of the black hole.
613+
a (float): Specific angular momentum of the black hole. Should always be between :math:`-1` and :math:`1`. :math:`a > 0` if the accretion disk orbits in the same direction as the hole rotates; :math:`a < 0` if it orbits in the opposite direction.
614+
r (float): Radius of the orbit
615+
616+
Attention:
617+
:cite:t:`Luminet_1979` has a mistake in Equation 15. The factor in fromt of the :math:`log` should be :math:`\sqrt{3}/2` instead of :math:`\sqrt{3}/3`. This can be verified by solving :cite:t:`Page_1974` Equation 15n. The resulting images of the paper are correct though.
618+
619+
See also:
620+
:cite:t:`Page_1974` for more information.
621+
622+
See also:
623+
:meth:`calc_flux_intrinsic_kerr` for the calculation of the intrinsic flux.
624+
625+
See also:
626+
:meth:`calc_innermost_stable_orbit` for the calculation of :math:`r_{ms}`
540627
"""
541628
a_ = a/bh_mass
542629
x = np.sqrt(r/bh_mass)
@@ -555,7 +642,35 @@ def calc_f_kerr(bh_mass, a, r):
555642

556643

557644
def calc_flux_intrinsic_kerr(bh_mass, a, r, acc):
558-
"""Calculate the intrinsic flux of the accretion disk of a Kerr black hole, in function of the accretion rate, specific angular momentum, and radius of emission."""
645+
r"""Calculate the intrinsic flux of the accretion disk of a Kerr black hole, in function of the accretion rate, specific angular momentum, and radius of emission.
646+
647+
The intrinsic flux is not redshift-corrected. Observed photons will have a flux that deviates from this by a factor of :math:`1/(1+z)^4`
648+
649+
The intrinsic flux in function of the radius is defined as:
650+
651+
.. math::
652+
653+
F_s(r) &= \frac{\dot{M_0}}{4\pi}e^{-(\nu+\psi+\mu)}f \\
654+
655+
where
656+
657+
.. math::
658+
659+
\begin{align*}
660+
e^{\nu+\psi+\mu} &= r \\
661+
f &= -\Omega_{,r}(E^{\dagger}-\Omega L^\dagger)^{-2}\int_{r_{ms}}^r(E^\dagger \ - \Omega L^\dagger)L^\dagger_{,r}dr
662+
\end{align*}
663+
664+
Args:
665+
bh_mass (float): Mass of the black hole.
666+
a (float): Specific angular momentum of the black hole. Should always be between :math:`-1` and :math:`1`. :math:`a > 0` if the accretion disk orbits in the same direction as the hole rotates; :math:`a < 0` if it orbits in the opposite direction.
667+
r (float): Radius of the orbit.
668+
acc (float): (initial) accretion rate of the black hole :math:`\dot{M}_0`
669+
670+
See also:
671+
:meth:`calc_f_kerr` for an algebraic expression of the :math:`f` function.
672+
673+
"""
559674
f = calc_f_kerr(bh_mass=bh_mass, a=a, r=r)
560675
exp_nupsimu = r
561676
return acc * f / exp_nupsimu / 4 / np.pi
@@ -564,14 +679,14 @@ def calc_flux_intrinsic_kerr(bh_mass, a, r, acc):
564679
def calc_flux_intrinsic_swarzschild(bh_mass, r, acc):
565680
r"""Calculate the intrinsic flux of a photon.
566681
567-
The intrinsic flux is not redshift-corrected. Observed photons will have a flux
568-
that deviates from this.
682+
The intrinsic flux is not redshift-corrected. Observed photons will have a flux that deviates from this by a factor of :math:`1/(1+z)^4`
569683
570684
.. math::
571685
572-
F_s = \frac{3 M \dot{M}}{8 \pi (r^* - 3) r^{5/2}} \left( \sqrt{r^*} - \sqrt{6} + \frac{1}{\sqrt{3}} \log \left( \frac{(\sqrt{r^*} + \sqrt{3})(\sqrt{6}-\sqrt{3})}{(\sqrt{6} + \sqrt{3})(\sqrt{r^*}-\sqrt{3})} \right) \right)
686+
F_s = \frac{3 M \dot{M}}{8 \pi (r^* - 3) {r^*}^{5/2}} \left( \sqrt{r^*} - \sqrt{6} + \frac{\sqrt{3}}{2} \log \left( \frac{(\sqrt{r^*} + \sqrt{3})(\sqrt{6}-\sqrt{3})}{(\sqrt{6} + \sqrt{3})(\sqrt{r^*}-\sqrt{3})} \right) \right)
573687
574688
where :math:`r^*=r/M`
689+
575690
Args:
576691
r (float): radius on the accretion disk (BH frame)
577692
acc (float): accretion rate
@@ -581,7 +696,7 @@ def calc_flux_intrinsic_swarzschild(bh_mass, r, acc):
581696
float: Intrinsic flux of the photon :math:`F_s`
582697
583698
Attention:
584-
:cite:t:`Luminet_1979` has a mistake in Equation 15. The factor in fromt of the :math:`log` should be :math:`\sqrt{3}/2` instead of :math:`sqrt{3}/3`. This can be verified (tediously) by solving :cite:t:`Page_1974` Equation 15n.
699+
:cite:t:`Luminet_1979` has a mistake in Equation 15. The factor in fromt of the :math:`log` should be :math:`\sqrt{3}/2` instead of :math:`\sqrt{3}/3`. This can be verified by solving :cite:t:`Page_1974` Equation 15n. The resulting images of the paper are correct though.
585700
"""
586701
r_ = r / bh_mass
587702
log_arg = (np.sqrt(r_) + np.sqrt(3)) * (np.sqrt(6) - np.sqrt(3)) / ((np.sqrt(r_) - np.sqrt(3)) * (np.sqrt(6) + np.sqrt(3)))
@@ -621,7 +736,7 @@ def calc_redshift_factor(radius, angle, incl, bh_mass, b):
621736
622737
Attention:
623738
:cite:t:`Luminet_1979` does not have the correct equation for the redshift factor.
624-
The correct formula is given above.
739+
The correct formula is given above. The resulting images of the paper are correct though.
625740
"""
626741
# gff = (radius * np.sin(incl) * np.sin(angle)) ** 2
627742
# gtt = - (1 - (2. * M) / radius)

0 commit comments

Comments
 (0)