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

A side effect related to opa and mdb #510

Closed HajimeKawahara closed 1 month ago

HajimeKawahara commented 1 month ago

description:

opa = OpaPremodit uses mdb, but since the temperature setting of OpaPremodit is used within mdb (specifically in change_reference_temperature). Originally, @KoHosokawa pointed that the multiple call of opa with the same mdb changes the first opa. See the sample code #515 (but before this, we needed to define the __eq__ method #509).

opacalc.py

    def apply_params(self):
        self.mdb.change_reference_temperature(self.Tref)

when invoking opa multiple times with the same mdb, the state of opa defined earlier gets altered.

potential solution:

Modify the code so that opa does not alter mdb. Specifically, provide Tref externally from opa and use it to calculate line_strength_ref and qt. This way, Tref is not stored in the internal state of mdb.

i.e. more functional programming like mdb

HajimeKawahara commented 1 month ago

509 #514

HajimeKawahara commented 1 month ago
HajimeKawahara commented 1 month ago

close with #515