-
Notifications
You must be signed in to change notification settings - Fork 102
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
split off astronomical constants from units #1059
base: main
Are you sure you want to change the base?
Changes from all commits
54e26e9
3f661af
e8563b8
3465180
a95b3e5
9d20f4f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# constants as originally defined/used in AMUSE |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
""" | ||
Series of astronomical constants, which are in turn used by the units of the | ||
same names. | ||
""" | ||
|
||
import numpy as np | ||
from amuse.units.si import m, kg | ||
from amuse.units.derivedsi import W, km | ||
|
||
|
||
au = 149597870691.0 | m | ||
parsec = au / np.tan(np.pi / (180 * 60 * 60)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that both 'au' and 'parsec' are also defined as units... Be careful, this may clash! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wow, that's a really subtle problem actually. Having a unit and a constant with almost the same name but different capitalisation seems like asking for trouble, because how do you remember which is which? Perhaps the best solution is to have a single object that can be used in both ways? But that would probably require some major redesign.... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. normally it wouldn't be a problem, since units would be used as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are constants that can also be units actually ever used as anything else than units? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably not. Except for making the units. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So... We could in principle make the names here (way) more descriptive, e.g.:
That would solve this issue. It's very verbose but since you're always using the unit form that should not be a problem. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, they could still have the same names actually, as long as no one directly uses the Then in the modules where the units are defined, we could |
||
Lsun = 3.839e26 | W | ||
Msun = 1.98892e30 | kg | ||
Rsun = 6.955e8 | m | ||
Mjupiter = 1.8987e27 | kg | ||
Rjupiter = 71492.0 | km | ||
Mearth = 5.9722e24 | kg | ||
Rearth = 6371.0088 | km # IUGG mean radius |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
""" | ||
Series of astronomical constants, which are in turn used by the units of the | ||
same names. | ||
""" | ||
|
||
# Until we have a way to select a system of constants, use the originally | ||
# defined values. Later, we should have a way to select between different | ||
# constants definitions. | ||
|
||
from amuse.units.amuse_2010.astronomical_constants import * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renaming it here since 'km' is already defined... could probably just as easily use the pre-defined 'km' unit, but maybe there was a reason not to?