Contact Binary Hierarchy

Setup

Let's first make sure we have the latest version of PHOEBE 2.3 installed (uncomment this line if running in an online notebook session such as colab).


In [1]:
#!pip install -I "phoebe>=2.3,<2.4"

In [2]:
%matplotlib inline

In [3]:
import phoebe
from phoebe import u # units
import numpy as np
import matplotlib.pyplot as plt

logger = phoebe.logger()

Here we'll initialize a default binary, but ask for it to be created as a contact system.


In [4]:
b_cb = phoebe.default_binary(contact_binary=True)

We'll compare this to the default detached binary


In [5]:
b_detached = phoebe.default_binary()

Hierarchy

Let's first look at the hierarchy of the default detached binary, and then compare that to the hierarchy of the overcontact system


In [6]:
print(b_detached.hierarchy)


    orbit:binary
    
        star:primary
        star:secondary
    


In [7]:
print(b_cb.hierarchy)


    orbit:binary
    
        star:primary
        star:secondary
        envelope:contact_envelope
    

As you can see, the overcontact system has an additional "component" with method "envelope" and component label "contact_envelope".

Next let's look at the parameters in the envelope and star components. You can see that most of parameters in the envelope class are constrained, while the equivalent radius of the primary is unconstrained. The value of primary equivalent radius constrains the potential and fillout factor of the envelope, as well as the equivalent radius of the secondary.


In [8]:
print(b_cb.filter(component='contact_envelope', kind='envelope', context='component'))


ParameterSet: 5 parameters
   abun@contact_envelope@compo...: 0.0
C  fillout_factor@contact_enve...: 0.6417897080768679
C  pot@contact_envelope@component: 3.4013774072298766
C  pot_min@contact_envelope@co...: 3.2067962240861534
C  pot_max@contact_envelope@co...: 3.75

In [9]:
print(b_cb.filter(component='primary', kind='star', context='component'))


ParameterSet: 16 parameters
         requiv@primary@component: 1.5 solRad
C    requiv_max@primary@component: 1.6724563972838384 solRad
C    requiv_min@primary@component: 1.2725418568681297 solRad
           teff@primary@component: 6000.0 K
C          logg@primary@component: 4.0897361581316245
        syncpar@primary@component: 1.0
C        period@primary@component: 0.5 d
C          freq@primary@component: 12.56637 rad / d
      gravb_bol@primary@component: 0.32
   irrad_frac_refl_bol@primary...: 0.6
C  irrad_frac_lost_bol@primary...: 0.4
    ld_mode_bol@primary@component: lookup
    ld_func_bol@primary@component: logarithmic
   ld_coeffs_source_bol@primar...: auto
C          mass@primary@component: 1.0089067994531358 solMass
C           sma@primary@component: 1.675 solRad

In [10]:
b_cb['requiv@primary'] = 1.5

In [11]:
b_cb['pot@contact_envelope@component']


Out[11]:
<Parameter: pot=3.4013774072298766 | keys: description, value, quantity, default_unit, limits, visible_if, copy_for, readonly, advanced>

In [12]:
b_cb['fillout_factor@contact_envelope@component']


Out[12]:
<Parameter: fillout_factor=0.6417897080768679 | keys: description, value, quantity, default_unit, limits, visible_if, copy_for, readonly, advanced>

In [13]:
b_cb['requiv@secondary@component']


Out[13]:
<Parameter: requiv=1.4999999999999074 solRad | keys: description, value, quantity, default_unit, limits, visible_if, copy_for, readonly, advanced>

Now, of course, if we didn't originally know we wanted a contact binary and built the default detached system, we could still turn it into an contact binary just by changing the hierarchy.


In [14]:
b_detached.add_component('envelope', component='contact_envelope')


Out[14]:
<ParameterSet: 5 parameters | qualifiers: pot, fillout_factor, abun, pot_min, pot_max>

In [15]:
hier = phoebe.hierarchy.binaryorbit(b_detached['binary'], b_detached['primary'], b_detached['secondary'], b_detached['contact_envelope'])
print(hier)


orbit:binary(star:primary, star:secondary, envelope:contact_envelope)

In [16]:
b_detached.filter(context='constraint',constraint_func='pitch',component='primary')


Out[16]:
<ParameterSet: 1 parameters>

In [17]:
b_detached.set_hierarchy(hier)


Mon, 25 May 2020 13:03 BUNDLE       ERROR   Constraint 'pot@contact_envelope@envelope@constraint' raised the following error while attempting to solve for 'pot@contact_envelope@envelope@component'.  Consider flipping the constraint or changing the value of one of ['requiv@primary@star@component', 'q@binary@orbit@component', 'sma@binary@orbit@component', 'pot@contact_envelope@envelope@component'] until the constraint succeeds.  Original error: roche_contact_Omega_at_partial_vol::Volume is outside bounds.
Mon, 25 May 2020 13:03 BUNDLE       WARNING secondary is overflowing at L2/L3 (requiv=2.261321950354358, requiv_min=0.1, requiv_max=2.013275176537638)  If not addressed, this warning will continue to be raised and will throw an error at run_compute.
Mon, 25 May 2020 13:03 BUNDLE       WARNING constraints ['pot@contact_envelope@envelope@constraint'] failed to run.  Address errors and try again.  Call run_failed_constraints to see the tracebacks.  If not addressed, this warning will continue to be raised and will throw an error at run_compute.
Mon, 25 May 2020 13:03 BUNDLE       WARNING secondary is overflowing at L2/L3 (requiv=2.261321950354358, requiv_min=0.1, requiv_max=2.013275176537638)  If not addressed, this warning will continue to be raised and will throw an error at run_compute.
Mon, 25 May 2020 13:03 BUNDLE       WARNING constraints ['pot@contact_envelope@envelope@constraint'] failed to run.  Address errors and try again.  Call run_failed_constraints to see the tracebacks.  If not addressed, this warning will continue to be raised and will throw an error at run_compute.
Mon, 25 May 2020 13:03 BUNDLE       WARNING secondary is overflowing at L2/L3 (requiv=2.261321950354358, requiv_min=0.1, requiv_max=2.013275176537638)  If not addressed, this warning will continue to be raised and will throw an error at run_compute.
Mon, 25 May 2020 13:03 BUNDLE       WARNING constraints ['pot@contact_envelope@envelope@constraint'] failed to run.  Address errors and try again.  Call run_failed_constraints to see the tracebacks.  If not addressed, this warning will continue to be raised and will throw an error at run_compute.
Mon, 25 May 2020 13:03 BUNDLE       WARNING secondary is overflowing at L2/L3 (requiv=2.261321950354358, requiv_min=0.1, requiv_max=2.013275176537638)  If not addressed, this warning will continue to be raised and will throw an error at run_compute.
Mon, 25 May 2020 13:03 BUNDLE       WARNING constraints ['pot@contact_envelope@envelope@constraint'] failed to run.  Address errors and try again.  Call run_failed_constraints to see the tracebacks.  If not addressed, this warning will continue to be raised and will throw an error at run_compute.
Mon, 25 May 2020 13:03 BUNDLE       WARNING secondary is overflowing at L2/L3 (requiv=2.261321950354358, requiv_min=0.1, requiv_max=2.013275176537638)  If not addressed, this warning will continue to be raised and will throw an error at run_compute.
Mon, 25 May 2020 13:03 BUNDLE       WARNING constraints ['pot@contact_envelope@envelope@constraint'] failed to run.  Address errors and try again.  Call run_failed_constraints to see the tracebacks.  If not addressed, this warning will continue to be raised and will throw an error at run_compute.
Mon, 25 May 2020 13:03 BUNDLE       WARNING secondary is overflowing at L2/L3 (requiv=2.261321950354358, requiv_min=0.1, requiv_max=2.013275176537638)  If not addressed, this warning will continue to be raised and will throw an error at run_compute.
Mon, 25 May 2020 13:03 BUNDLE       WARNING constraints ['pot@contact_envelope@envelope@constraint'] failed to run.  Address errors and try again.  Call run_failed_constraints to see the tracebacks.  If not addressed, this warning will continue to be raised and will throw an error at run_compute.
Mon, 25 May 2020 13:03 BUNDLE       WARNING secondary is overflowing at L2/L3 (requiv=2.261321950354358, requiv_min=0.1, requiv_max=2.013275176537638)  If not addressed, this warning will continue to be raised and will throw an error at run_compute.
Mon, 25 May 2020 13:03 BUNDLE       WARNING constraints ['pot@contact_envelope@envelope@constraint'] failed to run.  Address errors and try again.  Call run_failed_constraints to see the tracebacks.  If not addressed, this warning will continue to be raised and will throw an error at run_compute.
Mon, 25 May 2020 13:03 BUNDLE       WARNING secondary is overflowing at L2/L3 (requiv=2.261321950354358, requiv_min=0.1, requiv_max=2.013275176537638)  If not addressed, this warning will continue to be raised and will throw an error at run_compute.
Mon, 25 May 2020 13:03 BUNDLE       WARNING constraints ['pot@contact_envelope@envelope@constraint'] failed to run.  Address errors and try again.  Call run_failed_constraints to see the tracebacks.  If not addressed, this warning will continue to be raised and will throw an error at run_compute.
Mon, 25 May 2020 13:03 BUNDLE       WARNING secondary is overflowing at L2/L3 (requiv=2.261321950354358, requiv_min=0.1, requiv_max=2.013275176537638)  If not addressed, this warning will continue to be raised and will throw an error at run_compute.
Mon, 25 May 2020 13:03 BUNDLE       WARNING constraints ['pot@contact_envelope@envelope@constraint'] failed to run.  Address errors and try again.  Call run_failed_constraints to see the tracebacks.  If not addressed, this warning will continue to be raised and will throw an error at run_compute.
Mon, 25 May 2020 13:03 BUNDLE       WARNING secondary is overflowing at L2/L3 (requiv=2.261321950354358, requiv_min=0.1, requiv_max=2.013275176537638)  If not addressed, this warning will continue to be raised and will throw an error at run_compute.
Mon, 25 May 2020 13:03 BUNDLE       WARNING constraints ['pot@contact_envelope@envelope@constraint'] failed to run.  Address errors and try again.  Call run_failed_constraints to see the tracebacks.  If not addressed, this warning will continue to be raised and will throw an error at run_compute.
Mon, 25 May 2020 13:03 BUNDLE       WARNING secondary is overflowing at L2/L3 (requiv=2.261321950354358, requiv_min=0.1, requiv_max=2.013275176537638)  If not addressed, this warning will continue to be raised and will throw an error at run_compute.
Mon, 25 May 2020 13:03 BUNDLE       WARNING constraints ['pot@contact_envelope@envelope@constraint'] failed to run.  Address errors and try again.  Call run_failed_constraints to see the tracebacks.  If not addressed, this warning will continue to be raised and will throw an error at run_compute.
Mon, 25 May 2020 13:03 BUNDLE       WARNING primary is underflowing at L1 and not a contact system (requiv=1.0, requiv_min=2.013275176537638, requiv_max=2.6459757927177145)  If not addressed, this warning will continue to be raised and will throw an error at run_compute.
Mon, 25 May 2020 13:03 BUNDLE       WARNING secondary is overflowing at L2/L3 (requiv=2.261321950354358, requiv_min=0.1, requiv_max=2.013275176537638)  If not addressed, this warning will continue to be raised and will throw an error at run_compute.
Mon, 25 May 2020 13:03 BUNDLE       WARNING constraints ['pot@contact_envelope@envelope@constraint'] failed to run.  Address errors and try again.  Call run_failed_constraints to see the tracebacks.  If not addressed, this warning will continue to be raised and will throw an error at run_compute.
Mon, 25 May 2020 13:03 BUNDLE       WARNING primary is underflowing at L1 and not a contact system (requiv=1.0, requiv_min=2.013275176537638, requiv_max=2.6459757927177145)  If not addressed, this warning will continue to be raised and will throw an error at run_compute.
Mon, 25 May 2020 13:03 BUNDLE       WARNING secondary is overflowing at L2/L3 (requiv=2.261321950354358, requiv_min=0.1, requiv_max=2.013275176537638)  If not addressed, this warning will continue to be raised and will throw an error at run_compute.
Mon, 25 May 2020 13:03 BUNDLE       WARNING constraints ['pot@contact_envelope@envelope@constraint'] failed to run.  Address errors and try again.  Call run_failed_constraints to see the tracebacks.  If not addressed, this warning will continue to be raised and will throw an error at run_compute.
Mon, 25 May 2020 13:03 BUNDLE       WARNING primary is underflowing at L1 and not a contact system (requiv=1.0, requiv_min=2.013275176537638, requiv_max=2.6459757927177145)  If not addressed, this warning will continue to be raised and will throw an error at run_compute.
Mon, 25 May 2020 13:03 BUNDLE       WARNING secondary is overflowing at L2/L3 (requiv=2.261321950354358, requiv_min=0.1, requiv_max=2.013275176537638)  If not addressed, this warning will continue to be raised and will throw an error at run_compute.
Mon, 25 May 2020 13:03 BUNDLE       WARNING constraints ['pot@contact_envelope@envelope@constraint'] failed to run.  Address errors and try again.  Call run_failed_constraints to see the tracebacks.  If not addressed, this warning will continue to be raised and will throw an error at run_compute.
Mon, 25 May 2020 13:03 BUNDLE       WARNING primary is underflowing at L1 and not a contact system (requiv=1.0, requiv_min=2.013275176537638, requiv_max=2.6459757927177145)  If not addressed, this warning will continue to be raised and will throw an error at run_compute.
Mon, 25 May 2020 13:03 BUNDLE       WARNING secondary is overflowing at L2/L3 (requiv=2.261321950354358, requiv_min=0.1, requiv_max=2.013275176537638)  If not addressed, this warning will continue to be raised and will throw an error at run_compute.
Mon, 25 May 2020 13:03 BUNDLE       WARNING constraints ['pot@contact_envelope@envelope@constraint'] failed to run.  Address errors and try again.  Call run_failed_constraints to see the tracebacks.  If not addressed, this warning will continue to be raised and will throw an error at run_compute.
Mon, 25 May 2020 13:03 BUNDLE       WARNING primary is underflowing at L1 and not a contact system (requiv=1.0, requiv_min=2.013275176537638, requiv_max=2.6459757927177145)  If not addressed, this warning will continue to be raised and will throw an error at run_compute.
Mon, 25 May 2020 13:03 BUNDLE       WARNING secondary is overflowing at L2/L3 (requiv=2.261321950354358, requiv_min=0.1, requiv_max=2.013275176537638)  If not addressed, this warning will continue to be raised and will throw an error at run_compute.
Mon, 25 May 2020 13:03 BUNDLE       WARNING constraints ['pot@contact_envelope@envelope@constraint'] failed to run.  Address errors and try again.  Call run_failed_constraints to see the tracebacks.  If not addressed, this warning will continue to be raised and will throw an error at run_compute.
Mon, 25 May 2020 13:03 BUNDLE       WARNING primary is underflowing at L1 and not a contact system (requiv=1.0, requiv_min=2.013275176537638, requiv_max=2.6459757927177145)  If not addressed, this warning will continue to be raised and will throw an error at run_compute.
Mon, 25 May 2020 13:03 BUNDLE       WARNING secondary is overflowing at L2/L3 (requiv=2.261321950354358, requiv_min=0.1, requiv_max=2.013275176537638)  If not addressed, this warning will continue to be raised and will throw an error at run_compute.
Mon, 25 May 2020 13:03 BUNDLE       WARNING constraints ['pot@contact_envelope@envelope@constraint'] failed to run.  Address errors and try again.  Call run_failed_constraints to see the tracebacks.  If not addressed, this warning will continue to be raised and will throw an error at run_compute.
Mon, 25 May 2020 13:03 BUNDLE       WARNING primary is underflowing at L1 and not a contact system (requiv=1.0, requiv_min=2.013275176537638, requiv_max=2.6459757927177145)  If not addressed, this warning will continue to be raised and will throw an error at run_compute.
Mon, 25 May 2020 13:03 BUNDLE       WARNING constraints ['pot@contact_envelope@envelope@constraint'] failed to run.  Address errors and try again.  Call run_failed_constraints to see the tracebacks.  If not addressed, this warning will continue to be raised and will throw an error at run_compute.
Mon, 25 May 2020 13:03 BUNDLE       WARNING primary is underflowing at L1 and not a contact system (requiv=1.0, requiv_min=2.013275176537638, requiv_max=2.6459757927177145)  If not addressed, this warning will continue to be raised and will throw an error at run_compute.
Mon, 25 May 2020 13:03 BUNDLE       WARNING constraints ['pot@contact_envelope@envelope@constraint'] failed to run.  Address errors and try again.  Call run_failed_constraints to see the tracebacks.  If not addressed, this warning will continue to be raised and will throw an error at run_compute.

In [18]:
print(b_detached.hierarchy)


    orbit:binary
    
        star:primary
        star:secondary
        envelope:contact_envelope
    

However, since our system was detached, the system is not overflowing, and therefore doesn't pass system checks


In [19]:
print(b_detached.run_checks())


Run Checks Report: FAIL
ERROR: primary is underflowing at L1 and not a contact system (requiv=1.0, requiv_min=2.013275176537638, requiv_max=2.6459757927177145) (3 affected parameters, affecting system,run_compute)
ERROR: constraints ['pot@contact_envelope@envelope@constraint'] failed to run.  Address errors and try again.  Call run_failed_constraints to see the tracebacks. (1 affected parameters, affecting system,run_compute)

And because of this, the potential and requiv@secondary constraints cannot be updated from the constraints.


In [20]:
b_detached['pot@component']


Out[20]:
<Parameter: pot=3.5 | keys: description, value, quantity, default_unit, limits, visible_if, copy_for, readonly, advanced>

In [21]:
b_detached['requiv@secondary@component']


Out[21]:
<Parameter: requiv=2.261321950354358 solRad | keys: description, value, quantity, default_unit, limits, visible_if, copy_for, readonly, advanced>

Likewise, we can make a contact system detached again simply by removing the envelope from the hierarchy. The parameters themselves will still exist (unless you remove them), so you can always just change the hierarchy again to change back to an overcontact system.


In [22]:
hier = phoebe.hierarchy.binaryorbit(b_detached['binary'], b_detached['primary'], b_detached['secondary'])
print(hier)


orbit:binary(star:primary, star:secondary)

In [23]:
b_detached.set_hierarchy(hier)


Mon, 25 May 2020 13:03 BUNDLE       WARNING constraints [] failed to run.  Address errors and try again.  Call run_failed_constraints to see the tracebacks.  If not addressed, this warning will continue to be raised and will throw an error at run_compute.
Mon, 25 May 2020 13:03 BUNDLE       WARNING secondary is overflowing at periastron (requiv=2.261321950354358, requiv_max=2.013275176537638).  Use contact model if overflowing is desired.  If not addressed, this warning will continue to be raised and will throw an error at run_compute.

In [24]:
print(b_detached.hierarchy)


    orbit:binary
    
        star:primary
        star:secondary
    

Although the constraints have been removed, PHOEBE has lost the original value of the secondary radius (because of the failed contact constraints), so we'll have to reset that here as well.


In [25]:
b_detached['requiv@secondary@component'] = 1.0

Adding Datasets


In [26]:
b_cb.add_dataset('mesh', compute_times=[0], dataset='mesh01')


Out[26]:
<ParameterSet: 8 parameters | contexts: dataset, compute, constraint>

In [27]:
b_cb.add_dataset('orb', compute_times=np.linspace(0,1,201), dataset='orb01')


Out[27]:
<ParameterSet: 8 parameters | contexts: dataset, figure, compute, constraint>

In [28]:
b_cb.add_dataset('lc', times=np.linspace(0,1,21), dataset='lc01')


Out[28]:
<ParameterSet: 42 parameters | contexts: dataset, figure, compute, constraint>

In [29]:
b_cb.add_dataset('rv', times=np.linspace(0,1,21), dataset='rv01')


Out[29]:
<ParameterSet: 44 parameters | contexts: dataset, figure, compute, constraint>

For comparison, we'll do the same to our detached system


In [30]:
b_detached.add_dataset('mesh', compute_times=[0], dataset='mesh01')


Out[30]:
<ParameterSet: 8 parameters | contexts: dataset, compute, constraint>

In [31]:
b_detached.add_dataset('orb', compute_times=np.linspace(0,1,201), dataset='orb01')


Out[31]:
<ParameterSet: 8 parameters | contexts: dataset, figure, compute, constraint>

In [32]:
b_detached.add_dataset('lc', times=np.linspace(0,1,21), dataset='lc01')


Out[32]:
<ParameterSet: 42 parameters | contexts: dataset, figure, compute, constraint>

In [33]:
b_detached.add_dataset('rv', times=np.linspace(0,1,21), dataset='rv01')


Out[33]:
<ParameterSet: 44 parameters | contexts: dataset, figure, compute, constraint>

Running Compute


In [34]:
b_cb.run_compute(irrad_method='none')


Out[34]:
<ParameterSet: 31 parameters | kinds: orb, rv, lc, mesh>

In [35]:
b_detached.run_compute(irrad_method='none')


Out[35]:
<ParameterSet: 31 parameters | kinds: orb, rv, lc, mesh>

Synthetics

To ensure compatibility with computing synthetics in detached and semi-detached systems in Phoebe, the synthetic meshes for our overcontact system are attached to each component separetely, instead of the contact envelope.


In [36]:
print(b_cb['mesh01@model'].components)


['primary', 'secondary']

In [37]:
print(b_detached['mesh01@model'].components)


['primary', 'secondary']

Plotting

Meshes


In [38]:
afig, mplfig = b_cb['mesh01@model'].plot(x='ws', show=True)



In [39]:
afig, mplfig = b_detached['mesh01@model'].plot(x='ws', show=True)


Orbits


In [40]:
afig, mplfig = b_cb['orb01@model'].plot(x='ws',show=True)



In [41]:
afig, mplfig = b_detached['orb01@model'].plot(x='ws',show=True)


Light Curves


In [42]:
afig, mplfig = b_cb['lc01@model'].plot(show=True)



In [43]:
afig, mplfig = b_detached['lc01@model'].plot(show=True)


RVs


In [44]:
afig, mplfig = b_cb['rv01@model'].plot(show=True)



In [45]:
afig, mplfig = b_detached['rv01@model'].plot(show=True)



In [ ]: