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

Issue with mesh_radiosity_problem_nbody_convex::slow convergence #782

Open amiszuda opened 9 months ago

amiszuda commented 9 months ago

Hi,

When trying to compute a model of double-contact system (semidetached=True), the following error pops out:

 81%|████████████████████████████████████████████████████████████████████████████████████████▏                    | 89/110 [01:13<00:17,  1.21it/s]
TypeError: mesh_radiosity_problem_nbody_convex::slow convergence

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/amiszuda/miniconda3/envs/phoebe_tmp/lib/python3.8/site-packages/phoebe/parameters/parameters.py", line 424, in _send_if_client
    return fctn(self, *args, **kwargs)
  File "/home/amiszuda/miniconda3/envs/phoebe_tmp/lib/python3.8/site-packages/phoebe/frontend/bundle.py", line 11943, in run_compute
    ml_params = compute_class().run(self, computeparams.compute,
  File "/home/amiszuda/miniconda3/envs/phoebe_tmp/lib/python3.8/site-packages/phoebe/backend/backends.py", line 518, in run
    rpacketlists_per_worker = [self._run_chunk(**packet)]
  File "/home/amiszuda/miniconda3/envs/phoebe_tmp/lib/python3.8/site-packages/phoebe/backend/backends.py", line 576, in _run_chunk
    packetlist = self._run_single_time(b, i, time, infolist, **worker_setup_kwargs)
  File "/home/amiszuda/miniconda3/envs/phoebe_tmp/lib/python3.8/site-packages/phoebe/backend/backends.py", line 1152, in _run_single_time
    system.populate_observables(time, populate_kinds, populate_datasets)
  File "/home/amiszuda/miniconda3/envs/phoebe_tmp/lib/python3.8/site-packages/phoebe/backend/universe.py", line 315, in populate_observables
    self.handle_reflection()
  File "/home/amiszuda/miniconda3/envs/phoebe_tmp/lib/python3.8/site-packages/phoebe/backend/universe.py", line 368, in handle_reflection
    fluxes_intrins_and_refl_per_body = libphoebe.mesh_radiosity_problem_nbody_convex(vertices_per_body,
SystemError: <built-in function mesh_radiosity_problem_nbody_convex> returned a result with an error set

A working example reproducing this error may be:

import phoebe
from phoebe import u
import numpy as np

logger = phoebe.logger(clevel='ERROR')

b=phoebe.default_binary(semidetached=True)

times=np.linspace(0,4,110)
b.add_dataset('lc', times=times, dataset='lc1', intens_weighting='photon',passband='TESS:T')

b.set_value('period', component='binary', value=3.923923923923924) 
b.set_value('incl', component='binary', value=72)
b.set_value('t0_supconj', component='binary', value=2366.1)
b.set_value('ecc', value=0.03)
b.set_value('per0', value=50)

b.set_value('vgamma', value=-37.3)
b.set_value('q', value=0.375)
b.set_value('sma@binary', value=25)

b.set_value('teff', component='primary', value=25000)
b.set_value('teff', component='secondary', value=15000)
b.set_value('atm', component='primary', value='blackbody')
b.set_value('atm', component='secondary', value='blackbody')
b.set_value(qualifier='ld_mode', dataset='lc1', component='primary', value='manual')
b.set_value(qualifier='ld_mode', dataset='lc1', component='secondary', value='manual')

b.set_value('l3_mode', 'fraction')
b.set_value('l3_frac', 0.0)

b.set_value('Av', value=1.862) 
b.set_value('distance', value=2217.30688000*u.pc)

b.run_compute()

This error comes from phoebe 2.4.11 with python 3.8.18 installed on Ubuntu. Different versions of phoebe were tested to give the same output. Has anyone had similar issues? Reducing times to smaller number, e.g. 10 points works just fine.

kecnry commented 9 months ago

Thanks for the detailed report!

It seems that it crashes at time=3.302752293577982 specifically, even if that is the only time passed (times=[times[90]])... so is likely something to do with the geometry at that specific time/configuration.

amiszuda commented 9 months ago

Actually, it crashes at phase around 0.8. Below that phase, the model runs successfully.

kecnry commented 9 months ago

With 110 times between 0 and 4 (with a period of ~4), I think those are the same. Can you confirm though that replacing the times in your add_dataset with times=times[90] still crashes on your end?

amiszuda commented 9 months ago

Yes, it does crash.

amiszuda commented 8 months ago

any luck with this one?

kecnry commented 8 months ago

It would be helpful to be able to reproduce this with a single call to libphoebe (outside of all the bundle-logic). There is already a debugging logger output immediately before the line that crashes that should say irradiation ld_func_and_coeffs: {}".format(ld_func_and_coeffs). Can you either update that logging message to include all inputs to the libphoebe function (depending on the size of the mesh, that might be a lot of output), or maybe do a try/except and export the inputs to a separate file when it fails?