phoebe-project / phoebe2

PHOEBE - Eclipsing Binary Star Modeling Software
http://phoebe-project.org
GNU General Public License v3.0
76 stars 28 forks source link

Treatment of distance using ellc #830

Closed J-Liptak closed 3 months ago

J-Liptak commented 3 months ago

Hi everybody, I was trying to do something akin to SED using ellc backend in Phoebe 2.4.11 It seems that fluxes scale as 1/d^4 instead of 1/d^2. I tried to do as an example sun with a small companion and test for a value of solar constant - code below. To obtain reasonable flux around 1360 W/m^2 I came up with b['distance@system']=np.sqrt(1.5e11/np.sqrt(3.14)) and that seems to work. Do you have an idea what is going on?

Using phoebe backend gives correct values.

Thanks a lot, Jozef Liptak

=====================================================================

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

logger = phoebe.logger()

b= phoebe.default_binary()
b.set_value('teff@primary', 5770)
b.set_value('requiv@primary', 1.0)
b.set_value('period@binary', 365)
b.set_value('teff@secondary', 3500)
b.set_value('q', 0.08)
b.set_value('requiv@secondary', 0.1)
b.set_value('sma@binary', 215)
b.set_value('incl@binary', 90)

b.add_dataset('lc', compute_times=phoebe.linspace(0,1000,10), overwrite=True, dataset='lc_K')
b['passband@lc_K']='Bolometric:900-40000'
b['pblum_mode@lc_K@dataset']='absolute'
b['distance@system']=np.sqrt(1.5e11/np.sqrt(3.14))

b.add_compute('ellc', compute='fastcompute', overwrite=True)
b.set_value_all(qualifier='ld_mode', value='lookup')
b.set_value_all('ld_coeffs_source', value='phoenix')
b.set_value_all('atm', 'phoenix')
b.run_compute(model='init0', compute='fastcompute', overwrite=True)

afig, mplfig  = b.plot( x='phases', model='init0', save='test.pdf', show=True)
kecnry commented 3 months ago

I can reproduce the same thing, thanks for noticing this! The distance scaling logic goes through the same code, so I'm guessing the scaling is being handled twice somehow, we'll investigate and try to get this out as a bugfix soon.

import phoebe
b=phoebe.default_binary()
b.add_dataset('lc', compute_phases=phoebe.linspace(0,1,101))
b.add_compute('ellc')
b.set_value_all('ld_mode', 'manual')
b.run_compute(kind='ellc', model='ellc_d1')
b.run_compute(kind='phoebe', model='phoebe_d1')
b.set_value('distance', 2)
b.run_compute(kind='phoebe', model='phoebe_d2')
b.run_compute(kind='ellc', model='ellc_d2')
b.plot(show=True, legend=True)
image
kecnry commented 3 months ago

Update: I tracked this down to the 2.4.2 bugfix release which also added distance handling in b.calculate_pblums(pbflux=True). This means that ever since then we have been (incorrectly) accounting for distance twice for compute backends other than phoebe and phoebe legacy. I'll need to think about how this plays with other scaling (dataset-coupling, dataset-scaling, third light, etc), but hopefully the code fix itself should be fairly straightforward.

kecnry commented 3 months ago

The fix for this is now in the 2.4.13 bugfix release - thanks again for reporting the bug!