Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convergence failure for small planet #27

Open
bmorris3 opened this issue Nov 4, 2018 · 2 comments
Open

Convergence failure for small planet #27

bmorris3 opened this issue Nov 4, 2018 · 2 comments

Comments

@bmorris3
Copy link
Contributor

bmorris3 commented Nov 4, 2018

Hey Laura!

I'm working on simulating transits of Mars-sized planets orbiting Sun-sized stars, and it seems that I'm butting up against some convergence failures by going to small planet sizes. For example, the following code:

from batman import TransitParams, TransitModel
import numpy as np
from astropy.constants import R_earth, R_sun
import astropy.units as u

params = TransitParams()
params.per = 365
params.rp = 0.6 * float(R_earth/R_sun)
params.a = float(1*u.AU/R_sun)
params.inc = 89.9

# Sing 2009: https://arxiv.org/pdf/0912.2274.pdf
params.u = [0.6283, -0.3063, 0.8965, -0.4593] 
params.limb_dark = "nonlinear"

params.ecc = 0
params.w = np.pi/2
params.t0 = 0


times = np.linspace(-0.3, 0.3, 1000)
m = TransitModel(params, times)

m.light_curve(params)

Raises the error

---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
<ipython-input-4-5f6b6e406502> in <module>()
     20 
     21 times = np.linspace(-0.3, 0.3, 1000)
---> 22 m = TransitModel(params, times)
     23 
     24 m.light_curve(params)

/Users/bmmorris/anaconda/lib/python3.5/site-packages/batman/transitmodel.py in __init__(self, params, t, max_err, nthreads, fac, transittype, supersample_factor, exp_time)
    125 
    126                 if fac != None: self.fac = fac
--> 127                 else: self.fac = self._get_fac()
    128 
    129                 if nthreads==None or nthreads == 1: self.nthreads=1

/Users/bmmorris/anaconda/lib/python3.5/site-packages/batman/transitmodel.py in _get_fac(self)
    209                                 else: fac_lo = fac
    210                                 n += 1
--> 211                                 if n > 1e3: raise Exception("Convergence failure in calculation of scale factor for integration step size")
    212                         return fac
    213                 else: return None

Exception: Convergence failure in calculation of scale factor for integration step size

Am I doing something wrong, or should I change the hard-coded convergence limit (1e3) to a higher number?

Thanks!

@bmorris3
Copy link
Contributor Author

bmorris3 commented Nov 4, 2018

It looks like if I supply the TransitModel class with a fac value (for example, 1e-6), I get transit light curves for arbitrarily small planets – is that the parameter I should be adjusting?

@lkreidberg
Copy link
Owner

Yeah, for a quick fix I'd recommend sending fac by hand. My guess is that my automated calculation fails because the starting value is too large - I'll take a look!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants