Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix definition of particle age/times #3864

Merged
merged 2 commits into from
Mar 29, 2022

Conversation

cphyc
Copy link
Member

@cphyc cphyc commented Mar 28, 2022

PR Summary

This fixes #3861.

Copy link
Member

@matthewturk matthewturk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks alright to me. I am not sure I can properly 'approve' however.

@neutrinoceros
Copy link
Member

Agreed. Let's wait on the reporter's approval for this one.

@lconaboy
Copy link
Contributor

Hi @cphyc, this looks good. Just tested on my dataset and compared the results to those produced by the ramses utils. The birth times/ages match to similar accuracy as I mentioned in #3861 -- most of the ages agree to +/- 0.005 Myr, birth times are a little off, with most of them very close to -0.7 Myr compared to the ramses utils. I don't think this is due to this PR, though, instead I think it is down to the discrepancy between ds.current_time as calculated yt (I'm getting 381.03 Myr) and time_simu as calculated by the ramses utils (I'm getting 381.75 Myr). Not sure why that arises, but it's not due to this (as far as I can tell).

@cphyc
Copy link
Member Author

cphyc commented Mar 29, 2022

Hi @cphyc, this looks good. Just tested on my dataset and compared the results to those produced by the ramses utils. The birth times/ages match to similar accuracy as I mentioned in #3861 -- most of the ages agree to +/- 0.005 Myr, birth times are a little off, with most of them very close to -0.7 Myr compared to the ramses utils. I don't think this is due to this PR, though, instead I think it is down to the discrepancy between ds.current_time as calculated yt (I'm getting 381.03 Myr) and time_simu as calculated by the ramses utils (I'm getting 381.75 Myr). Not sure why that arises, but it's not due to this (as far as I can tell).

The small discrepancy come from the way we interpolate times from conformal to physical, which is probably slightly different (though I wouldn't know which one of RAMSES' and yt's is the most accurate).

@neutrinoceros
Copy link
Member

Great, thanks @iconaboy for your feedback.
@cphyc is this ready for merging ?

@cphyc
Copy link
Member Author

cphyc commented Mar 29, 2022

@neutrinoceros yes!

@lconaboy
Copy link
Contributor

lconaboy commented Mar 29, 2022

The small discrepancy come from the way we interpolate times from conformal to physical, which is probably slightly different (though I wouldn't know which one of RAMSES' and yt's is the most accurate).

Ah ok, I thought it might be something like this.

I dug a bit and just noticed that in yt/frontends/ramses/data_structures.py, the value 3.08e24 is used for cm_per_mpc, from line 974:

                self.current_time = (
                    (self.time_tot + self.time_simu)
                    / (self.hubble_constant * 1e7 / 3.08e24)
                    / self.parameters["unit_t"]
                )

I think this is a hangover from when ramses used to use 3.08e24 as the conversion from Mpc to cm, but newer versions use the more accurate 3.0856776d+24 (this is the value I used for the ramses utils comparison), which matches up with the yt value in yt/utilities/physical_ratios.py. Swapping the line

(self.hubble_constant * 1e7 / 3.08e24)

for

(self.hubble_constant * 1e7 / cm_per_mpc)

brings most of the particle_birth_time values to within +/- 0.01 Myr of the ramses utils (though there is some tail still, due to interpolation?)

This is a separate issue to the one @cphyc fixed above, though, might be better if I make a new issue/PR?

e: Might this inconsistency in cm_per_Mpc be related to #2098 @cphyc?
ee: Somewhat, though there is still some error (again, from interpolation?). Using cm_per_Mpc gives (as in #2098) tA-tB = -0.562655331151916 Myr whereas 3.08e24 gives tA-tB = -1.2650417797501063 Myr where tA is ds.current_time.to('Myr') and tB is ds.cosmology.t_from_z(ds.current_redshift).to('Myr').

@cphyc
Copy link
Member Author

cphyc commented Mar 29, 2022

@lconaboy that may indeed be related to #2098. If you want to submit a PR changing 3.08e24 to cm_per_mpc that would be a great first contribution :)

neutrinoceros added a commit that referenced this pull request Mar 29, 2022
…4-on-yt-4.0.x

Backport PR #3864 on branch yt-4.0.x (Fix definition of particle age/times)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug code frontends Things related to specific frontends
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: RAMSES star_age and particle_birth_time are swapped
4 participants