Advanced: Alternate Backends

Setup

Let's first make sure we have the latest version of PHOEBE 2.0 installed. (You can comment out this line if you don't use pip for your installation or don't want to update to the latest release).


In [ ]:
!pip install -I "phoebe>=2.0,<2.1"

As always, let's do imports and initialize a logger and a new Bundle. See Building a System for more details.


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

logger = phoebe.logger()

b = phoebe.default_binary()


WARNING: Constant u'Gravitational constant' is already has a definition in the u'si' system [astropy.constants.constant]
WARNING: Constant u'Solar mass' is already has a definition in the u'si' system [astropy.constants.constant]
WARNING: Constant u'Solar radius' is already has a definition in the u'si' system [astropy.constants.constant]
WARNING: Constant u'Solar luminosity' is already has a definition in the u'si' system [astropy.constants.constant]
/usr/local/lib/python2.7/dist-packages/astropy/units/quantity.py:782: FutureWarning: comparison to `None` will result in an elementwise object comparison in the future.
  return super(Quantity, self).__eq__(other)

And we'll attach some dummy datasets. See Datasets for more details.


In [2]:
b.add_dataset('orb', times=np.linspace(0,10,1000), dataset='orb01', component=['primary', 'secondary'])


Out[2]:
<ParameterSet: 3 parameters | contexts: compute, dataset>

In [3]:
b.add_dataset('lc', times=np.linspace(0,10,1000), dataset='lc01')


Out[3]:
<ParameterSet: 15 parameters | contexts: compute, dataset>

Available Backends

See the Compute Tutorial for details on adding compute options and using them to create synthetic models.

PHOEBE 1.0 Legacy

For more details, see Comparing PHOEBE 2.0 vs PHOEBE Legacy


In [4]:
b.add_compute('legacy', compute='legacybackend')
print b['legacybackend']


ParameterSet: 9 parameters
  protomesh@legacybackend@com...: False
    pbmesh@legacybackend@compute: False
  refl_num@legacybackend@compute: 1
        ie@legacybackend@compute: False
  enabled@lc01@legacybackend@...: True
  atm@primary@legacybackend@c...: extern_atmx
  atm@secondary@legacybackend...: extern_atmx
  gridsize@primary@legacyback...: 60
  gridsize@secondary@legacyba...: 60

Using Alternate Backends

Adding Compute Options

Adding a set of compute options for an alternate backend is just as easy as for the PHOEBE backend. Simply provide the function or name of the function in phoebe.parameters.compute that points to the parameters for that backend.

Here we'll add the default PHOEBE backend as well as the PHOEBE 1.0 (legacy) backend. Note that in order to use an alternate backend, that backend must be installed on your machine.


In [5]:
b.add_compute('phoebe', compute='phoebebackend')


Out[5]:
<ParameterSet: 21 parameters | datasets: lc01, orb01>

In [6]:
print b['phoebebackend']


ParameterSet: 21 parameters
  dynamics_method@phoebebacke...: keplerian
      ltte@phoebebackend@compute: False
  irrad_method@phoebebackend@...: wilson
  boosting_method@phoebebacke...: none
  protomesh@phoebebackend@com...: False
    pbmesh@phoebebackend@compute: False
   horizon@phoebebackend@compute: False
  eclipse_method@phoebebacken...: native
  horizon_method@phoebebacken...: boolean
  enabled@lc01@phoebebackend@...: True
  enabled@orb01@phoebebackend...: True
  mesh_method@primary@phoebeb...: marching
  mesh_method@secondary@phoeb...: marching
  ntriangles@primary@phoebeba...: 1000
  ntriangles@secondary@phoebe...: 1000
  distortion_method@primary@p...: roche
  distortion_method@secondary...: roche
  atm@primary@phoebebackend@c...: ck2004
  atm@secondary@phoebebackend...: ck2004
  lc_method@phoebebackend@com...: numerical
  fti_method@phoebebackend@co...: none

Running Compute

Nothing changes for running compute - simply provide the compute tag for those options. Do note, however, that not all backends support all dataset types.

But, since the legacy backend doesn't support ck2004 atmospheres and interpolated limb-darkening, we do need to choose a limb-darkening law.


In [7]:
b.set_value_all('ld_func', 'logarithmic')


Fri, 10 Feb 2017 13:28 PARAMETERS   WARNING ld_func='interp' only supported by atm='ck2004'
Fri, 10 Feb 2017 13:28 PARAMETERS   WARNING ld_func='interp' only supported by atm='ck2004'

In [8]:
b.run_compute('legacybackend', model='legacyresults')


Fri, 10 Feb 2017 13:28 IO           WARNING rpole has no phoebe 1 corollary
Fri, 10 Feb 2017 13:28 IO           WARNING freq has no phoebe 1 corollary
Fri, 10 Feb 2017 13:28 IO           WARNING irrad_frac_lost_bol has no phoebe 1 corollary
Fri, 10 Feb 2017 13:28 IO           WARNING ld_func_bol has no phoebe 1 corollary
Fri, 10 Feb 2017 13:28 IO           WARNING mass has no phoebe 1 corollary
Fri, 10 Feb 2017 13:28 IO           WARNING rpole has no phoebe 1 corollary
Fri, 10 Feb 2017 13:28 IO           WARNING freq has no phoebe 1 corollary
Fri, 10 Feb 2017 13:28 IO           WARNING irrad_frac_lost_bol has no phoebe 1 corollary
Fri, 10 Feb 2017 13:28 IO           WARNING ld_func_bol has no phoebe 1 corollary
Fri, 10 Feb 2017 13:28 IO           WARNING mass has no phoebe 1 corollary
Fri, 10 Feb 2017 13:28 IO           WARNING lc_method has no phoebe 1 corollary
Fri, 10 Feb 2017 13:28 IO           WARNING pblum_ref has no phoebe 1 corollary
Fri, 10 Feb 2017 13:28 IO           WARNING lc_method has no phoebe 1 corollary
Fri, 10 Feb 2017 13:28 IO           WARNING pblum_ref has no phoebe 1 corollary
Fri, 10 Feb 2017 13:28 IO           WARNING fti_method has no phoebe 1 corollary
Fri, 10 Feb 2017 13:28 IO           WARNING Finite integration Time is not fully supported and will be turned off by legacy wrapper before computation
Fri, 10 Feb 2017 13:28 IO           WARNING intens_weighting has no phoebe 1 corollary
Fri, 10 Feb 2017 13:28 IO           WARNING fti_method has no phoebe 1 corollary
Fri, 10 Feb 2017 13:28 IO           WARNING freq has no phoebe 1 corollary
Fri, 10 Feb 2017 13:28 IO           WARNING t0_perpass has no phoebe 1 corollary
Fri, 10 Feb 2017 13:28 IO           WARNING mean_anom has no phoebe 1 corollary
Fri, 10 Feb 2017 13:28 IO           WARNING long_an has no phoebe 1 corollary
Fri, 10 Feb 2017 13:28 IO           WARNING asini has no phoebe 1 corollary
Fri, 10 Feb 2017 13:28 IO           WARNING ecosw has no phoebe 1 corollary
Fri, 10 Feb 2017 13:28 IO           WARNING esinw has no phoebe 1 corollary
Fri, 10 Feb 2017 13:28 IO           WARNING protomesh has no phoebe 1 corollary
Fri, 10 Feb 2017 13:28 IO           WARNING pbmesh has no phoebe 1 corollary
Fri, 10 Feb 2017 13:28 IO           WARNING t0 has no phoebe 1 corollary
Fri, 10 Feb 2017 13:28 IO           WARNING ra has no phoebe 1 corollary
Fri, 10 Feb 2017 13:28 IO           WARNING dec has no phoebe 1 corollary
Fri, 10 Feb 2017 13:28 IO           WARNING epoch has no phoebe 1 corollary
Fri, 10 Feb 2017 13:28 IO           WARNING distance has no phoebe 1 corollary
Fri, 10 Feb 2017 13:28 IO           WARNING hierarchy has no phoebe 1 corollary
Out[8]:
<ParameterSet: 2 parameters | qualifiers: fluxes, times>

Running Multiple Backends Simultaneously

Running multiple backends simultaneously is just as simple as running the PHOEBE backend with multiple sets of compute options (see Compute).

We just need to make sure that each dataset is only enabled for one (or none) of the backends that we want to use, and then send a list of the compute tags to run_compute. Here we'll use the PHOEBE backend to compute orbits and the legacy backend to compute light curves.


In [9]:
b.set_value_all('enabled@lc01@phoebebackend', False)
#b.set_value_all('enabled@orb01@legacybackend', False)  # don't need this since legacy NEVER computes orbits
print b['enabled']


ParameterSet: 5 parameters
  enabled@orb01@phoebe01@compute: True
   enabled@lc01@phoebe01@compute: True
  enabled@lc01@legacybackend@...: True
  enabled@lc01@phoebebackend@...: False
  enabled@orb01@phoebebackend...: True

In [10]:
b.run_compute(['phoebebackend', 'legacybackend'], model='mixedresults')


Fri, 10 Feb 2017 13:29 IO           WARNING rpole has no phoebe 1 corollary
Fri, 10 Feb 2017 13:29 IO           WARNING freq has no phoebe 1 corollary
Fri, 10 Feb 2017 13:29 IO           WARNING irrad_frac_lost_bol has no phoebe 1 corollary
Fri, 10 Feb 2017 13:29 IO           WARNING ld_func_bol has no phoebe 1 corollary
Fri, 10 Feb 2017 13:29 IO           WARNING mass has no phoebe 1 corollary
Fri, 10 Feb 2017 13:29 IO           WARNING rpole has no phoebe 1 corollary
Fri, 10 Feb 2017 13:29 IO           WARNING freq has no phoebe 1 corollary
Fri, 10 Feb 2017 13:29 IO           WARNING irrad_frac_lost_bol has no phoebe 1 corollary
Fri, 10 Feb 2017 13:29 IO           WARNING ld_func_bol has no phoebe 1 corollary
Fri, 10 Feb 2017 13:29 IO           WARNING mass has no phoebe 1 corollary
Fri, 10 Feb 2017 13:29 IO           WARNING lc_method has no phoebe 1 corollary
Fri, 10 Feb 2017 13:29 IO           WARNING pblum_ref has no phoebe 1 corollary
Fri, 10 Feb 2017 13:29 IO           WARNING lc_method has no phoebe 1 corollary
Fri, 10 Feb 2017 13:29 IO           WARNING pblum_ref has no phoebe 1 corollary
Fri, 10 Feb 2017 13:29 IO           WARNING fti_method has no phoebe 1 corollary
Fri, 10 Feb 2017 13:29 IO           WARNING Finite integration Time is not fully supported and will be turned off by legacy wrapper before computation
Fri, 10 Feb 2017 13:29 IO           WARNING intens_weighting has no phoebe 1 corollary
Fri, 10 Feb 2017 13:29 IO           WARNING fti_method has no phoebe 1 corollary
Fri, 10 Feb 2017 13:29 IO           WARNING freq has no phoebe 1 corollary
Fri, 10 Feb 2017 13:29 IO           WARNING t0_perpass has no phoebe 1 corollary
Fri, 10 Feb 2017 13:29 IO           WARNING mean_anom has no phoebe 1 corollary
Fri, 10 Feb 2017 13:29 IO           WARNING long_an has no phoebe 1 corollary
Fri, 10 Feb 2017 13:29 IO           WARNING asini has no phoebe 1 corollary
Fri, 10 Feb 2017 13:29 IO           WARNING ecosw has no phoebe 1 corollary
Fri, 10 Feb 2017 13:29 IO           WARNING esinw has no phoebe 1 corollary
Fri, 10 Feb 2017 13:29 IO           WARNING protomesh has no phoebe 1 corollary
Fri, 10 Feb 2017 13:29 IO           WARNING pbmesh has no phoebe 1 corollary
Fri, 10 Feb 2017 13:29 IO           WARNING t0 has no phoebe 1 corollary
Fri, 10 Feb 2017 13:29 IO           WARNING ra has no phoebe 1 corollary
Fri, 10 Feb 2017 13:29 IO           WARNING dec has no phoebe 1 corollary
Fri, 10 Feb 2017 13:29 IO           WARNING epoch has no phoebe 1 corollary
Fri, 10 Feb 2017 13:29 IO           WARNING distance has no phoebe 1 corollary
Fri, 10 Feb 2017 13:29 IO           WARNING hierarchy has no phoebe 1 corollary
Out[10]:
<ParameterSet: 16 parameters | kinds: orb, lc>

The parameters inside the returned model even remember which set of compute options (and therefore, in this case, which backend) were used to compute them.


In [11]:
print b['mixedresults'].computes


['legacybackend', 'phoebebackend']

In [12]:
b['mixedresults@phoebebackend'].datasets


Out[12]:
['orb01']

In [13]:
b['mixedresults@legacybackend'].datasets


Out[13]:
['lc01']

In [ ]:


In [ ]: