Exemplo n.º 1
0
 def test_u_dt_vs_point_source(self):
     """test that in the stationary reference frame, for large enough 
     distances, the energy density of the DT tends to the one of a point like 
     source approximating it"""
     # point source with the same luminosity as the DT
     ps_dt = PointSourceBehindJet(dt_test.xi_dt * dt_test.L_disk, dt_test.epsilon_dt)
     # r >> R_dt
     r = np.logspace(21, 24, 10) * u.cm
     assert u.allclose(
         dt_test.u(r), ps_dt.u(r), atol=0 * u.Unit("erg cm-3"), rtol=1e-2
     )
Exemplo n.º 2
0
 def test_u_blr_vs_point_source(self):
     """test that for large enough distances the energy density of the 
     BLR tends to the one of a point like source approximating it"""
     # point source with the same luminosity as the BLR
     ps_blr = PointSourceBehindJet(BLR.xi_line * BLR.L_disk,
                                   BLR.epsilon_line)
     # r >> R_line
     r = np.logspace(19, 23, 10) * u.cm
     assert u.allclose(BLR.u(r),
                       ps_blr.u(r),
                       atol=0 * u.Unit("erg cm-3"),
                       rtol=1e-2)
Exemplo n.º 3
0
 def test_u_dt_vs_point_source_comoving(self):
     """test that in the reference frame comoving with the Blob, for large 
     enough distances, the energy density of the DT tends to the one of 
     a point like source approximating it"""
     # point source with the same luminosity as the DT
     ps_dt = PointSourceBehindJet(DT.xi_dt * DT.L_disk, DT.epsilon_dt)
     # r >> R_line
     r = np.logspace(21, 24, 10) * u.cm
     assert u.allclose(
         DT.u(r, PWL_BLOB),
         ps_dt.u(r, PWL_BLOB),
         atol=0 * u.Unit("erg cm-3"),
         rtol=1e-1,
     )
Exemplo n.º 4
0
 def test_ec_dt_vs_point_source(self):
     """check if in the limit of large distances the EC on the DT tends to
     the one of a point-like source approximating it"""
     r = 1e22 * u.cm
     # point like source approximating the dt
     ps_dt = PointSourceBehindJet(dt_test.xi_dt * dt_test.L_disk,
                                  dt_test.epsilon_dt)
     # external Compton
     ec_dt = ExternalCompton(bpwl_blob_test, dt_test, r)
     ec_ps_dt = ExternalCompton(bpwl_blob_test, ps_dt, r)
     # seds
     nu = np.logspace(15, 28) * u.Hz
     sed_ec_dt = ec_dt.sed_flux(nu)
     sed_ec_ps_dt = ec_ps_dt.sed_flux(nu)
     make_comparison_plot(
         nu,
         sed_ec_ps_dt,
         sed_ec_dt,
         "point source approximating the DT",
         "ring Dust Torus",
         "External Compton on Ring Dust Torus, " +
         r"$r = 10^{22}\,{\rm cm} \gg R_{\rm dt}$",
         f"{figures_dir}/ec/dt/comparison_point_source.png",
         "sed",
     )
     # requires a 20% deviation from the two SED points
     assert check_deviation(nu, sed_ec_dt, sed_ec_ps_dt, 0.2)
Exemplo n.º 5
0
 def test_ec_blr_vs_point_source(self):
     """check if in the limit of large distances the EC on the BLR tends to
     the one of a point-like source approximating it"""
     r = 1e22 * u.cm
     # point like source approximating the blr
     ps_blr = PointSourceBehindJet(blr_test.xi_line * blr_test.L_disk,
                                   blr_test.epsilon_line)
     # external Compton
     ec_blr = ExternalCompton(bpwl_blob_test, blr_test, r)
     ec_ps_blr = ExternalCompton(bpwl_blob_test, ps_blr, r)
     # seds
     nu = np.logspace(15, 30) * u.Hz
     sed_ec_blr = ec_blr.sed_flux(nu)
     sed_ec_ps_blr = ec_ps_blr.sed_flux(nu)
     # sed comparison plot
     make_comparison_plot(
         nu,
         sed_ec_ps_blr,
         sed_ec_blr,
         "point source approximating the BLR",
         "spherical shell BLR",
         "External Compton on Spherical Shell BLR, " +
         r"$r = 10^{22}\,{\rm cm} \gg R_{\rm line}$",
         f"{figures_dir}/ec/blr/comparison_point_source.png",
         "sed",
     )
     # requires a 20% deviation from the two SED points
     assert check_deviation(nu, sed_ec_ps_blr, sed_ec_blr, 0.2)
Exemplo n.º 6
0
 def test_abs_dt_vs_point_source(self):
     """check if in the limit of large distances the gamma-gamma optical depth 
     on the DT tends to the one of a point-like source approximating it"""
     # dust torus
     L_disk = 2e46 * u.Unit("erg s-1")
     T_dt = 1e3 * u.K
     csi_dt = 0.1
     dt = RingDustTorus(L_disk, csi_dt, T_dt)
     r = 1e22 * u.cm
     # point like source approximating the dt
     ps_dt = PointSourceBehindJet(dt.xi_dt * L_disk, dt.epsilon_dt)
     # absorption
     z = 0.859
     theta_s = np.deg2rad(10)
     abs_dt = Absorption(dt, r, z, mu_s=np.cos(theta_s))
     abs_ps_dt = Absorption(ps_dt, r, z, mu_s=np.cos(theta_s))
     # taus
     E = np.logspace(2, 6) * u.GeV
     nu = E.to("Hz", equivalencies=u.spectral())
     tau_dt = abs_dt.tau(nu)
     tau_ps_dt = abs_ps_dt.tau(nu)
     make_comparison_plot(
         nu,
         tau_ps_dt,
         tau_dt,
         "point source approximating the DT",
         "ring dust torus",
         "Absorption on Ring Dust Torus, " +
         r"$r = 10^{22}\,{\rm cm} \gg R_{\rm dt},\,\theta_s=10^{\circ}$",
         f"{figures_dir}/dt/tau_dt_point_source_comparison.png",
         "tau",
     )
     # requires a 10% deviation from the two SED points
     assert check_deviation(nu, tau_dt, tau_ps_dt, 0.1)
Exemplo n.º 7
0
 def test_abs_blr_vs_point_source(self):
     """check if in the limit of large distances the gamma-gamma optical depth 
     on the BLR tends to the one of a point-like source approximating it"""
     # broad line region
     L_disk = 2e46 * u.Unit("erg s-1")
     xi_line = 0.024
     R_line = 1e17 * u.cm
     blr = SphericalShellBLR(L_disk, xi_line, "Lyalpha", R_line)
     r = 1e20 * u.cm
     # point like source approximating the blr
     ps_blr = PointSourceBehindJet(blr.xi_line * L_disk, blr.epsilon_line)
     # absorption, consider a small viewing angle for this case
     z = 0.859
     theta_s = np.deg2rad(10)
     abs_blr = Absorption(blr, r, z, mu_s=np.cos(theta_s))
     abs_ps_blr = Absorption(ps_blr, r, z, mu_s=np.cos(theta_s))
     # taus
     E = np.logspace(2, 6) * u.GeV
     nu = E.to("Hz", equivalencies=u.spectral())
     tau_blr = abs_blr.tau(nu)
     tau_ps_blr = abs_ps_blr.tau(nu)
     # sed comparison plot
     make_comparison_plot(
         nu,
         tau_ps_blr,
         tau_blr,
         "point source approximating the BLR",
         "spherical shell BLR",
         "Absorption on Spherical Shell BLR, " +
         r"$r = 10^{20}\,{\rm cm} \gg R({\rm Ly\alpha}),\,\theta_s=10^{\circ}$",
         f"{figures_dir}/blr/tau_blr_point_source_comparison.png",
         "tau",
     )
     # requires a 10% deviation from the two SED points
     assert check_deviation(nu, tau_blr, tau_ps_blr, 0.1)
Exemplo n.º 8
0
 def test_ec_dt_vs_point_source(self):
     """check if in the limit of large distances the EC on the DT tends to
     the one of a point-like source approximating it"""
     # dust torus
     L_disk = 2 * 1e46 * u.Unit("erg s-1")
     T_dt = 1e3 * u.K
     csi_dt = 0.1
     dt = RingDustTorus(L_disk, csi_dt, T_dt)
     # point like source approximating the dt
     ps_dt = PointSourceBehindJet(dt.xi_dt * L_disk, dt.epsilon_dt)
     # external Compton
     ec_dt = ExternalCompton(BPL_BLOB, dt, r=1e22 * u.cm)
     ec_ps_dt = ExternalCompton(BPL_BLOB, ps_dt, r=1e22 * u.cm)
     # seds
     nu = np.logspace(15, 28) * u.Hz
     ec_dt_sed = ec_dt.sed_flux(nu)
     ec_ps_dt_sed = ec_ps_dt.sed_flux(nu)
     # requires a 20% deviation from the two SED points
     assert u.allclose(
         ec_dt_sed, ec_ps_dt_sed, atol=0 * u.Unit("erg cm-2 s-1"), rtol=0.2
     )
Exemplo n.º 9
0
 def test_ec_blr_vs_point_source(self):
     """check if in the limit of large distances the EC on the BLR tends to
     the one of a point-like source approximating it"""
     # broad line region
     L_disk = 2 * 1e46 * u.Unit("erg s-1")
     xi_line = 0.024
     R_line = 1e17 * u.cm
     blr = SphericalShellBLR(L_disk, xi_line, "Lyalpha", R_line)
     # point like source approximating the blr
     ps_blr = PointSourceBehindJet(blr.xi_line * L_disk, blr.epsilon_line)
     # external Compton
     ec_blr = ExternalCompton(BPL_BLOB, blr, r=1e22 * u.cm)
     ec_ps_blr = ExternalCompton(BPL_BLOB, ps_blr, r=1e22 * u.cm)
     # seds
     nu = np.logspace(15, 28) * u.Hz
     ec_blr_sed = ec_blr.sed_flux(nu)
     ec_ps_blr_sed = ec_ps_blr.sed_flux(nu)
     # requires a 20% deviation from the two SED points
     assert u.allclose(
         ec_blr_sed, ec_ps_blr_sed, atol=0 * u.Unit("erg cm-2 s-1"), rtol=0.2
     )
Exemplo n.º 10
0
    _integrand = np.power(_gamma, -2) * _N_e * _kernel
    integral_gamma = integrate(_integrand, gamma, axis=0)
    prefactor_num = (3 * sigma_T * target.L_0 * np.power(epsilon_s, 2) *
                     np.power(blob.delta_D, 3))
    prefactor_denom = (np.power(2, 7) * np.power(np.pi, 2) *
                       np.power(blob.d_L, 2) * np.power(r, 2) *
                       np.power(target.epsilon_0, 2))
    sed = prefactor_num / prefactor_denom * integral_gamma
    return sed.to("erg cm-2 s-1")


# target and distance
r = 1e16 * u.cm
L_0 = 2e46 * u.Unit("erg s-1")
epsilon_0 = 1e-3
ps = PointSourceBehindJet(L_0, epsilon_0)

nu = np.logspace(20, 30) * u.Hz

# increase the size of the gamma grid
blob.set_gamma_size(500)
sed_trapz = sed_flux_point_source(nu, blob, ps, r, np.trapz)
sed_trapz_loglog = sed_flux_point_source(nu, blob, ps, r, trapz_loglog)
plt.loglog(nu, sed_trapz, marker="o", label="np.trapz")
plt.loglog(nu,
           sed_trapz_loglog,
           ls="--",
           marker=".",
           label="naima trapz_loglog")
plt.legend()
plt.show()
Exemplo n.º 11
0
        "gamma_min": 1e2,
        "gamma_max": 1e5
    },
}
R_B = 1e16 * u.cm
B = 1 * u.G
Z = Distance(1e27, unit=u.cm).z
DELTA_D = 10
GAMMA = 10
PWL_BLOB = Blob(R_B, Z, DELTA_D, GAMMA, B, SPECTRUM_NORM, PWL_DICT)

# global CMB at z = 1
CMB_Z_1 = CMB(z=1)

# global PointSourceBehindJet
PS = PointSourceBehindJet(1e46 * u.Unit("erg s-1"), 1e-5)

# global disk
M_BH = 1.2 * 1e9 * M_sun
L_DISK = 1.512 * 1e46 * u.Unit("erg s-1")
ETA = 1 / 12
R_G = 1.77 * 1e14 * u.cm
R_IN_G_UNITS = 6
R_OUT_G_UNITS = 200
R_IN = R_IN_G_UNITS * R_G
R_OUT = R_OUT_G_UNITS * R_G
DISK = SSDisk(M_BH, L_DISK, ETA, R_IN, R_OUT)
# useful for checks
L_EDD = 15.12 * 1e46 * u.Unit("erg s-1")
M_DOT = 2.019 * 1e26 * u.Unit("g s-1")
Exemplo n.º 12
0
Gamma = 40
blob = Blob(R_b, z, delta_D, Gamma, B, spectrum_norm, spectrum_dict)
blob.set_gamma_size(500)

L_disk = 2 * 1e46 * u.Unit("erg s-1")
# dust torus
T_dt = 1e3 * u.K
csi_dt = 0.1
dt = RingDustTorus(L_disk, csi_dt, T_dt)
# blr
xi_line = 0.024
R_line = 1e17 * u.cm
blr = SphericalShellBLR(L_disk, xi_line, "Lyalpha", R_line)

# point source behind the jet approximating the DT
ps_dt = PointSourceBehindJet(dt.xi_dt * L_disk, dt.epsilon_dt)
# point source behind the jet approximating the BLR
ps_blr = PointSourceBehindJet(blr.xi_line * L_disk, blr.epsilon_line)

ec_dt = ExternalCompton(blob, dt, r=1e22 * u.cm)
ec_blr = ExternalCompton(blob, blr, r=1e22 * u.cm)
ec_ps_dt = ExternalCompton(blob, ps_dt, r=1e22 * u.cm)
ec_ps_blr = ExternalCompton(blob, ps_blr, r=1e22 * u.cm)

# seds
nu = np.logspace(15, 30) * u.Hz

sed_blr = ec_blr.sed_flux(nu)
sed_ps_blr = ec_ps_blr.sed_flux(nu)
sed_dt = ec_dt.sed_flux(nu)
sed_ps_dt = ec_ps_dt.sed_flux(nu)