Skip to content

Commit

Permalink
cleanup units, split off stellar_type unit
Browse files Browse the repository at this point in the history
  • Loading branch information
rieder committed Apr 24, 2024
1 parent f2270fe commit 45bf037
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 49 deletions.
29 changes: 29 additions & 0 deletions src/amuse/units/stellar_types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from amuse.units.si import core

stellar_type = core.enumeration_unit(
'stellar_type',
'stellar_type',
None,
[
"deeply or fully convective low mass MS star", # 0
"Main Sequence star", # 1
"Hertzsprung Gap", # 2
"First Giant Branch", # 3
"Core Helium Burning", # 4
"First Asymptotic Giant Branch", # 5
"Second Asymptotic Giant Branch", # 6
"Main Sequence Naked Helium star", # 7
"Hertzsprung Gap Naked Helium star", # 8
"Giant Branch Naked Helium star", # 9
"Helium White Dwarf", # 10
"Carbon/Oxygen White Dwarf", # 11
"Oxygen/Neon White Dwarf", # 12
"Neutron Star", # 13
"Black Hole", # 14
"Massless Supernova", # 15
"Unknown stellar type", # 16
"Pre-main-sequence Star", # 17
"Planet", # 18
"Brown Dwarf", # 19
]
)
61 changes: 12 additions & 49 deletions src/amuse/units/units.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,20 @@
"""

import numpy
from amuse.units.si import (
named,
s,
m,
kg,
none,
core,
)
from amuse.units.derivedsi import (
km,
V,
W,
J,
Pa,
rad,
)
from amuse.units.si import *
from amuse.units.derivedsi import *
from amuse.units import constants
from . import constants
from . import quantities

# The two imports below are to explicitly expose everything directly used in
# this module.
from .si import (named, s, m, kg, none, core, no_unit,)
from .derivedsi import (km, V, W, J, Pa, rad,)

# importing * from si and derivedsi since we do want all of the units in these
# modules, and we don't want to repeat everything here.
from .si import *
from .derivedsi import *
from .stellar_types import stellar_type

# misc every day
minute = named("minute", "min", 60.0 * s)
hour = named("hour", "hr", 60.0 * minute)
Expand Down Expand Up @@ -57,7 +50,6 @@
Mpc = named("mega parsec", "Mpc", 10**6 * parsec)
Gpc = named("giga parsec", "Gpc", 10**9 * parsec)
lightyear = named("light year", "ly", 9460730472580.8 * km)
# lightyear = named('light year', 'ly', c*julianyr)
LSun = named("solar luminosity", "LSun", 3.839e26 * W)
MSun = named("solar mass", "MSun", 1.98892e30 * kg)
RSun = named("solar radius", "RSun", 6.955e8 * m)
Expand Down Expand Up @@ -99,39 +91,10 @@

string = core.string_unit("string", "string")

stellar_type = core.enumeration_unit(
"stellar_type",
"stellar_type",
None,
[
"deeply or fully convective low mass MS star", # 0
"Main Sequence star", # 1
"Hertzsprung Gap", # 2
"First Giant Branch", # 3
"Core Helium Burning", # 4
"First Asymptotic Giant Branch", # 5
"Second Asymptotic Giant Branch", # 6
"Main Sequence Naked Helium star", # 7
"Hertzsprung Gap Naked Helium star", # 8
"Giant Branch Naked Helium star", # 9
"Helium White Dwarf", # 10
"Carbon/Oxygen White Dwarf", # 11
"Oxygen/Neon White Dwarf", # 12
"Neutron Star", # 13
"Black Hole", # 14
"Massless Supernova", # 15
"Unknown stellar type", # 16
"Pre-main-sequence Star", # 17
"Planet", # 18
"Brown Dwarf", # 19
],
)

# special unit for keys of particles
object_key = core.key_unit("object_key", "key")

# angles
# rad=named('radian','rad',m/m) (defined in derivedsi.py)
pi = numpy.pi | rad
rev = named("revolutions", "rev", (2 * numpy.pi) * rad)
deg = named("degree", "deg", (numpy.pi / 180) * rad)
Expand Down

0 comments on commit 45bf037

Please sign in to comment.