Skip to content

Commit

Permalink
Added a safety check for covering fractions exceeding unity (#813)
Browse files Browse the repository at this point in the history
  • Loading branch information
WillJRoper authored Jan 29, 2025
2 parents bc235be + b0dbd91 commit 8fb1192
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/synthesizer/emission_models/agn/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"""

from synthesizer import exceptions
from synthesizer.emission_models.base_model import BlackHoleEmissionModel


Expand Down Expand Up @@ -287,6 +288,12 @@ def __init__(
**kwargs
"""
# Ensure the sum of covering fractions is less than 1
if covering_fraction_nlr + covering_fraction_blr > 1:
raise exceptions.InconsistentArguments(
"The sum of the covering fractions must be less than 1."
)

# Create the child models
nlr = NLRTransmittedEmission(
grid=nlr_grid,
Expand Down Expand Up @@ -345,6 +352,12 @@ def __init__(
fraction of the BLR). Default is 0.1.
**kwargs
"""
# Ensure the sum of covering fractions is less than 1
if covering_fraction_nlr + covering_fraction_blr > 1:
raise exceptions.InconsistentArguments(
"The sum of the covering fractions must be less than 1."
)

BlackHoleEmissionModel.__init__(
self,
grid=grid,
Expand Down Expand Up @@ -494,6 +507,12 @@ def __init__(
**kwargs
"""
# Ensure the sum of covering fractions is less than 1
if covering_fraction_nlr + covering_fraction_blr > 1:
raise exceptions.InconsistentArguments(
"The sum of the covering fractions must be less than 1."
)

# Create the child models
disc = DiscEmission(
nlr_grid=nlr_grid,
Expand Down
7 changes: 7 additions & 0 deletions src/synthesizer/emission_models/agn/unified_agn.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import numpy as np
from unyt import deg

from synthesizer import exceptions
from synthesizer.emission_models.base_model import BlackHoleEmissionModel
from synthesizer.sed import Sed

Expand Down Expand Up @@ -157,6 +158,12 @@ def __init__(
**kwargs: Any additional keyword arguments to pass to the
BlackHoleEmissionModel.
"""
# Ensure the sum of covering fractions is less than 1
if covering_fraction_nlr + covering_fraction_blr > 1:
raise exceptions.InconsistentArguments(
"The sum of the covering fractions must be less than 1."
)

# Get the incident istropic disc emission model
self.disc_incident_isotropic = self._make_disc_incident_isotropic(
nlr_grid,
Expand Down

0 comments on commit 8fb1192

Please sign in to comment.