sbird / fake_spectra

A code for generating fake spectra from a cosmological simulation
MIT License
12 stars 13 forks source link

fixed point solver #33

Closed qezlou closed 4 years ago

qezlou commented 4 years ago

https://github.com/sbird/fake_spectra/blob/2ec63a35c34ada87981b5dc68cab1a0aa0aa082f/fake_spectra/rate_network.py#L143

Since rooted() returns nebynh shouln't the second argument of fixed_point() be just a unit vector ?

qezlou commented 4 years ago

https://github.com/sbird/fake_spectra/blob/2ec63a35c34ada87981b5dc68cab1a0aa0aa082f/fake_spectra/rate_network.py#L143

Since rooted() returns nebynh shouln't the second argument of fixed_point() be just a unit vector ?

Sorry, It cannot be a unit vector :)) We are looking for x0 in f(x0)=x0. But, this line seems to me is looking for nebynh = nh. Maybe I am wrong.

qezlou commented 4 years ago

I modified the rooted() to return ne instead of nebynh. like this :

        def rooted(ne, nh, ienergy):
            return self._nebynh(nh, self._get_temp(ne/nh, ienergy, helium=helium), ne/nh, helium=helium)*nh
        ne = fixed_point(rooted, nh, args=(nh, ienergy),xtol=self.converge)
        assert np.all(np.abs(rooted(ne, nh, ienergy) - ne) < self.converge)
return nebynh * nh

It did not solve my issue with TNG though :((