rodluger / Limbdark.jl

Analytical transit light curves for limb darkened stars
MIT License
14 stars 4 forks source link

Difference between gradient/non-gradient fluxes #94

Open ericagol opened 2 years ago

ericagol commented 2 years ago

As @langfzac points out, there are some differences in the computation with & without the gradients:

1). t.onembmr2 has different order of operations:

https://github.com/rodluger/Limbdark.jl/blob/48df50f6a1c72ddb353c5d6f2d6fe56428a8b4a6/src/transit_poly_struct.jl#L106

https://github.com/rodluger/Limbdark.jl/blob/48df50f6a1c72ddb353c5d6f2d6fe56428a8b4a6/src/transit_poly_struct.jl#L348

2). t.k2 differs:

https://github.com/rodluger/Limbdark.jl/blob/48df50f6a1c72ddb353c5d6f2d6fe56428a8b4a6/src/transit_poly_struct.jl#L112

vs.

https://github.com/rodluger/Limbdark.jl/blob/48df50f6a1c72ddb353c5d6f2d6fe56428a8b4a6/src/transit_poly_struct.jl#L353

3). t.kc differs:

https://github.com/rodluger/Limbdark.jl/blob/48df50f6a1c72ddb353c5d6f2d6fe56428a8b4a6/src/transit_poly_struct.jl#L123

https://github.com/rodluger/Limbdark.jl/blob/48df50f6a1c72ddb353c5d6f2d6fe56428a8b4a6/src/transit_poly_struct.jl#L364

4). t.kc2 differs:

https://github.com/rodluger/Limbdark.jl/blob/48df50f6a1c72ddb353c5d6f2d6fe56428a8b4a6/src/transit_poly_struct.jl#L125-L126

https://github.com/rodluger/Limbdark.jl/blob/48df50f6a1c72ddb353c5d6f2d6fe56428a8b4a6/src/transit_poly_struct.jl#L366-L367

5). t.kc differs:

https://github.com/rodluger/Limbdark.jl/blob/48df50f6a1c72ddb353c5d6f2d6fe56428a8b4a6/src/transit_poly_struct.jl#L131

https://github.com/rodluger/Limbdark.jl/blob/48df50f6a1c72ddb353c5d6f2d6fe56428a8b4a6/src/transit_poly_struct.jl#L134

https://github.com/rodluger/Limbdark.jl/blob/48df50f6a1c72ddb353c5d6f2d6fe56428a8b4a6/src/transit_poly_struct.jl#L372

https://github.com/rodluger/Limbdark.jl/blob/48df50f6a1c72ddb353c5d6f2d6fe56428a8b4a6/src/transit_poly_struct.jl#L375

6). If uniform, non-gradient returns uniform case before moving on:

https://github.com/rodluger/Limbdark.jl/blob/48df50f6a1c72ddb353c5d6f2d6fe56428a8b4a6/src/transit_poly_struct.jl#L141-L144

7). Two different functions called for s2:

https://github.com/rodluger/Limbdark.jl/blob/48df50f6a1c72ddb353c5d6f2d6fe56428a8b4a6/src/transit_poly_struct.jl#L148

https://github.com/rodluger/Limbdark.jl/blob/48df50f6a1c72ddb353c5d6f2d6fe56428a8b4a6/src/transit_poly_struct.jl#L397

8). Non-gradient returns special case of linear limb-darkening:

https://github.com/rodluger/Limbdark.jl/blob/48df50f6a1c72ddb353c5d6f2d6fe56428a8b4a6/src/transit_poly_struct.jl#L155-L159

9). eta2 is computed differently:

https://github.com/rodluger/Limbdark.jl/blob/48df50f6a1c72ddb353c5d6f2d6fe56428a8b4a6/src/transit_poly_struct.jl#L164

https://github.com/rodluger/Limbdark.jl/blob/48df50f6a1c72ddb353c5d6f2d6fe56428a8b4a6/src/transit_poly_struct.jl#L408

10). Different choice made for t.k2 >=1

https://github.com/rodluger/Limbdark.jl/blob/48df50f6a1c72ddb353c5d6f2d6fe56428a8b4a6/src/transit_poly_struct.jl#L165

https://github.com/rodluger/Limbdark.jl/blob/48df50f6a1c72ddb353c5d6f2d6fe56428a8b4a6/src/transit_poly_struct.jl#L411

11). Non-grad case- quadratic case is returned:

https://github.com/rodluger/Limbdark.jl/blob/48df50f6a1c72ddb353c5d6f2d6fe56428a8b4a6/src/transit_poly_struct.jl#L171-L175

12). Small values of b < bcut handled differently in grad case:

https://github.com/rodluger/Limbdark.jl/blob/48df50f6a1c72ddb353c5d6f2d6fe56428a8b4a6/src/transit_poly_struct.jl#L300

https://github.com/rodluger/Limbdark.jl/blob/48df50f6a1c72ddb353c5d6f2d6fe56428a8b4a6/src/transit_poly_struct.jl#L431-L433

https://github.com/rodluger/Limbdark.jl/blob/48df50f6a1c72ddb353c5d6f2d6fe56428a8b4a6/src/transit_poly_struct.jl#L437-L439

https://github.com/rodluger/Limbdark.jl/blob/48df50f6a1c72ddb353c5d6f2d6fe56428a8b4a6/src/transit_poly_struct.jl#L460-L463

13). Denominator is multiplied once, versus term-by-term:

https://github.com/rodluger/Limbdark.jl/blob/48df50f6a1c72ddb353c5d6f2d6fe56428a8b4a6/src/transit_poly_struct.jl#L210

https://github.com/rodluger/Limbdark.jl/blob/48df50f6a1c72ddb353c5d6f2d6fe56428a8b4a6/src/transit_poly_struct.jl#L477-L479

14). Non-gradient case doesn't check for r==0:

https://github.com/rodluger/Limbdark.jl/blob/48df50f6a1c72ddb353c5d6f2d6fe56428a8b4a6/src/transit_poly_struct.jl#L85

https://github.com/rodluger/Limbdark.jl/blob/48df50f6a1c72ddb353c5d6f2d6fe56428a8b4a6/src/transit_poly_struct.jl#L315

15). Annular case handled differently:

https://github.com/rodluger/Limbdark.jl/blob/48df50f6a1c72ddb353c5d6f2d6fe56428a8b4a6/src/transit_poly_struct.jl#L97

https://github.com/rodluger/Limbdark.jl/blob/48df50f6a1c72ddb353c5d6f2d6fe56428a8b4a6/src/transit_poly_struct.jl#L103

https://github.com/rodluger/Limbdark.jl/blob/48df50f6a1c72ddb353c5d6f2d6fe56428a8b4a6/src/transit_poly_struct.jl#L331-L332

16). First three flux terms added up (without denominator), versus sequential with denominator:

https://github.com/rodluger/Limbdark.jl/blob/48df50f6a1c72ddb353c5d6f2d6fe56428a8b4a6/src/transit_poly_struct.jl#L191

https://github.com/rodluger/Limbdark.jl/blob/48df50f6a1c72ddb353c5d6f2d6fe56428a8b4a6/src/transit_poly_struct.jl#L479

ericagol commented 2 years ago

@langfzac This is still an issue which needs to be fixed. It causes a problem when b=1-r, which is encountered in some of the tests with Photodynamics.jl. The version without a gradient works fine, while the version with gradient gives the wrong flux. We will fix this by changing the gradient version to match the non-gradient version.

ericagol commented 2 years ago

@langfzac Okay, I made changes 1, 2, 4, 9 & 10, and this fixed the issue with Limbdark.jl for b=1-r (for the case I tested with r = 0.08740709353364863). Now the gradient & non-gradient formulae agree in this case, and they also agree with the BigFloat computation. This also fixed the Photodynamics.jl test. I'm not sure whether any of the other differences above are critical to change, but for now I'm happy that we can fix this (rare) case.

ericagol commented 2 years ago

@langfzac Okay, so commit https://github.com/rodluger/Limbdark.jl/commit/9524317c1c5c04705fa4864d7ad46d21fbe5b638 seems to fix this. I also had to change the tolerance in the M_n test since the test wasn't passing.

There are some other issues with the build that need to be fixed, but hopefully this version of Limbdark.jl will work fine with Photodynamics.jl