def test_fraction(): """ Tests whether integrating all the fractions of UV times the local luminosity returns the global UV luminosity. """ distance = 1e26 for M in M_range: for mdot in mdot_range: print("%e %.2f" % (M, mdot)) bh = sed.SED(M=M, mdot=mdot, reprocessing=False) _, total_uv_flux, total_flux, _ = bh.compute_uv_fractions( distance, return_all=True, include_corona=True) uvf = total_uv_flux / total_flux testing.assert_approx_equal(uvf, bh.uv_fraction, significant=2)
def test_conservation_energy(): for M in M_range: for mdot in mdot_range: print("M = %e \t mdot = %.2f"%(M, mdot)) sed_test = sed.SED(M = M, mdot = mdot, reprocessing = True) distance = 1e20 bol_lumin = sed_test.bolometric_luminosity total_spectral_flux = sed_test.total_flux(distance) total_flux = integrate.trapz(x = sed_test.ENERGY_RANGE_KEV, y = total_spectral_flux) total_flux_erg = sed.convert_units(total_flux * u.keV, u.erg) total_lumin = total_flux_erg * 4 * np.pi * distance**2 print(total_lumin, bol_lumin) testing.assert_approx_equal(total_lumin, bol_lumin, significant = 1)
import pytest import qsosed.sed as sed from qsosed.sed import convert_units from qsosed import constants from scipy import integrate import numpy as np from numpy import testing from astropy import units as u sed_test = sed.SED(M=1e8, mdot=0.5, reprocessing=True) distance = 100 #Mpc distance_cm = convert_units(distance * u.Mpc, u.cm) def test_setup(): XSPEC_GAMMA_WARM = 2.5 XSPEC_KT_WARM = 0.2 XSPEC_ALBEDO = 0.3 XSPEC_LDISS_HOT = 2.0183853632627917e-2 # Ledd testing.assert_equal(sed_test.warm_electron_energy, XSPEC_KT_WARM) testing.assert_equal(sed_test.warm_photon_index, XSPEC_GAMMA_WARM) testing.assert_equal(sed_test.reflection_albedo, XSPEC_ALBEDO) testing.assert_approx_equal(sed_test.hard_xray_fraction, XSPEC_LDISS_HOT, significant=2)
def test_isco(): testing.assert_approx_equal(sed_test.isco, 6.) sed_test_2 = sed.SED(astar=0.998) testing.assert_approx_equal(sed_test_2.isco, 1.23, significant=2)
""" Tests involving the disk component. """ import qsosed.sed as sed from qsosed import constants from scipy import integrate import numpy as np from numpy import testing from astropy import units as u sed_test = sed.SED(M=1e8, mdot=0.5, reprocessing=False) def test_schwarzschild_radius(): testing.assert_approx_equal(2 * sed_test.Rg, 2.95337e13, significant=4) def test_efficiency(): testing.assert_approx_equal(sed_test.efficiency, 0.05719, significant=4) def test_isco(): testing.assert_approx_equal(sed_test.isco, 6.) sed_test_2 = sed.SED(astar=0.998) testing.assert_approx_equal(sed_test_2.isco, 1.23, significant=2) def test_gravity_radius(): XSPEC_GR = 1581.6308089974727 XSPEC_T_AT_GR = 4047.1865836535567 testing.assert_approx_equal(sed_test.gravity_radius, XSPEC_GR)