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

BUG: Use cm_per_mpc instead of 3.08e24 #3867 #3868

Merged
merged 3 commits into from
Mar 31, 2022

Conversation

lconaboy
Copy link
Contributor

Fix for #3867.

PR Summary

Use cm_per_mpc instead of 3.08e24 for conversion from Mpc to cm. Also partly addresses #2098:

ds = yt.load('output_00080/info_00080.txt')
tA = ds.current_time.to('Myr')
tB = ds.cosmology.t_from_z(ds.current_redshift).to('Myr')

print(tA-tB)

where tA-tB is now -0.5628994599301222 Myr where it was -22.47323433951169 Myr.

@welcome
Copy link

welcome bot commented Mar 29, 2022

Hi! Welcome, and thanks for opening this pull request. We have some guidelines for new pull requests, and soon you'll hear back about the results of our tests and continuous integration checks. Thank you for your contribution!

@lconaboy lconaboy changed the title Use cm_per_mpc instead of 3.08e24 #3867 BUG: Use cm_per_mpc instead of 3.08e24 #3867 Mar 29, 2022
@neutrinoceros neutrinoceros linked an issue Mar 29, 2022 that may be closed by this pull request
@neutrinoceros neutrinoceros added bug code frontends Things related to specific frontends labels Mar 29, 2022
@neutrinoceros
Copy link
Member

I'll leave triage to @cphyc: don't hesitate to put this in the 4.0.3 milestone if it makes sense to you

@cphyc cphyc added this to the 4.0.3 milestone Mar 29, 2022
cphyc
cphyc previously approved these changes Mar 29, 2022
Copy link
Member

@cphyc cphyc left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution!

@cphyc cphyc enabled auto-merge March 29, 2022 12:55
@lconaboy
Copy link
Contributor Author

Looks like a test uses the old value of 3.08e24 to calculate the compared simulation time

 Age simu (yt old const)=   1.1192112175127416     
 Age simu (yt new const)=   1.1212743045965676    

and hence this commit fails. One option is to update the test values, but since this test is on an old output (probably made before the introduction of the more accurate Mpc2cm constant into RAMSES via amr/constants.f90) maybe that isn't appropriate (at least not without warning people).

@neutrinoceros
Copy link
Member

Good catch. Is it possible to parse (or deduce) which version of RAMSES produced a given output file ? If not, I'd err on the side of embracing the newest version rather than the oldest, but I guess we'd need to expose some parameter to make it possible to reproduce the old behaviour.

@cphyc
Copy link
Member

cphyc commented Mar 29, 2022

Unfortunately, I don't think there is any easy way of telling the RAMSES version where this change was introduced, so I'd be in favour of accepting this PR as is (and update the failing test accordingly).

@lconaboy
Copy link
Contributor Author

lconaboy commented Mar 29, 2022

I agree about there being no way to tell which version. Do you think this needs some kind of warning?

@neutrinoceros
Copy link
Member

If we're going to support only one convention I agree that it's best to go with the newest. Do you guys have an idea when it was switched in RAMSES ?

@lconaboy
Copy link
Contributor Author

As far as I can tell, it was introduced to master around November 2018, and is in the stable_19_09 and stable_19_10 branches.

@neutrinoceros
Copy link
Member

Ok. Sounds old enough that I'd side with Corentin: let's just update the existing test result.

auto-merge was automatically disabled March 29, 2022 14:55

Head branch was pushed to by a user without write access

@neutrinoceros
Copy link
Member

pre-commit.ci autofix

Copy link
Member

@neutrinoceros neutrinoceros left a comment

Choose a reason for hiding this comment

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

LGTM, but I'll let @cphyc push the button :)

@cphyc cphyc merged commit a6b3b8b into yt-project:main Mar 31, 2022
@welcome
Copy link

welcome bot commented Mar 31, 2022

Hooray! Congratulations on your first merged pull request! We hope we keep seeing you around! 🎆

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

Backport PR #3868 on branch yt-4.0.x (BUG: Use cm_per_mpc instead of 3.08e24 #3867)
@lconaboy lconaboy deleted the update-ramses-mpc branch April 5, 2022 12:15
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.

RAMSES inaccurate Mpc to cm conversion value
3 participants