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

single scattering albedo method in ArtReflectPure #505

Open HajimeKawahara opened 1 month ago

HajimeKawahara commented 1 month ago

I found that in some case, trans_coeff in the flux-adding reflection scheme becomes nan.

HajimeKawahara commented 1 month ago

This is because in some case $\gamma_2 > \gamma_1$, then delta = jnp.sqrt((gamma_1 - gamma_2) / (gamma_1 + gamma_2)) becomes nan.

See spec.toon.zetalambda_coeffs(gamma_1, gamma_2)

For the hemispheric mean, $\gamma_1 - \gamma_2 = 2 (1 - \omega)$. So, Unless $\omega > 1$, this error does not happen.

In fact, investigating the code, I found

single_scattering_albedo = [1.008468   1.00827063 1.00805159 ... 1.01170891 1.01171055 1.01171209]

when the error occurs.

HajimeKawahara commented 1 month ago

I found this bug because I used the wrong dtau_cld and dtau_cld_scat to compute single_scattering_albedo. But, this mistake should be avoided by defining the method to compute single_scattering_albedo in the art class because it will be likely a typical mistake.