HajimeKawahara / exojax

🐈 Automatic differentiable spectrum modeling of exoplanets/brown dwarfs using JAX, compatible with NumPyro and JAXopt
http://secondearths.sakura.ne.jp/exojax/
MIT License
45 stars 14 forks source link

use searchsorted to determine cloud base pressure #485

Closed YuiKasagi closed 4 months ago

YuiKasagi commented 4 months ago

This PR fixes a bug related to cloud calculations.

The previous code used argmin to determine the intersection between the T-P profile and a condensation curve. However, this sometimes picks up the minimum value even if it is not at the intersection, as shown in the orange line in the figure.

γ‚Ήγ‚―γƒͺγƒΌγƒ³γ‚·γƒ§γƒƒγƒˆ 2024-04-23 13 50 39

Therefore, I changed it to searchsorted, which solved the problem. I confirmed that this function is differentiable. By default, the intersection was found only when the ascending array was input, which is probably physically correct.

γ‚Ήγ‚―γƒͺγƒΌγƒ³γ‚·γƒ§γƒƒγƒˆ 2024-04-23 13 51 45