#!pip install -I "phoebe>=2.4,<2.5"

"""
Explanation: Critical Radii: Detached Systems
Setup
Let's first make sure we have the latest version of PHOEBE 2.4 installed (uncomment this line if running in an online notebook session such as colab).
End of explanation
"""


import phoebe
from phoebe import u # units
import numpy as np
import matplotlib.pyplot as plt

logger = phoebe.logger()

b = phoebe.default_binary()

"""
Explanation: As always, let's do imports and initialize a logger and a new Bundle.
End of explanation
"""


b['requiv_max@component@primary']

b['requiv_max@constraint@primary']

"""
Explanation: Detached Systems
Detached systems are the default case for default_binary.  The requiv_max parameter is constrained to show the maximum value for requiv before the system will begin overflowing at periastron.
End of explanation
"""


print(b.filter(qualifier='requiv*', context='component'))

"""
Explanation: We can see that the default system is well within this critical value by printing all radii and critical radii.
End of explanation
"""


b['requiv@primary'] = 2.2

print(b.run_checks())

"""
Explanation: If we increase 'requiv' past the critical point, we'll receive a warning from the logger and would get an error if attempting to call b.run_compute().
End of explanation
"""


