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

Attempt at replacing | with * for creating quantities #693

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
656 changes: 328 additions & 328 deletions src/amuse/units/constants.py

Large diffs are not rendered by default.

243 changes: 135 additions & 108 deletions src/amuse/units/core.py

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/amuse/units/derivedsi.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from amuse.units.si import *

Hz = named('hertz', 'Hz', 1/s)
MHz = named('megahertz', 'MHz', 1e6*Hz)
Hz = named('hertz', 'Hz', (1/s).as_unit())
rieder marked this conversation as resolved.
Show resolved Hide resolved
MHz = named('megahertz', 'MHz', (1e6*Hz).as_unit())
rad = named('radian','rad',m/m)
sr = named('steradian','sr',m**2/m**2)
N = named('newton', 'N', kg * m /s**2)
Expand All @@ -19,5 +19,5 @@
weber = Wb

# handy definitions
one = 1 | none
one = 1 * none
km = k(m)
16 changes: 7 additions & 9 deletions src/amuse/units/nbody_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
International System of Quantities, I.S.Q. and defines
the gravitational constant to be 1:

G = 1 | (length**3) / (mass * (time**2))
G = 1 * (length**3) / (mass * (time**2))

+-------------------+-----------------------------------+-----------------+
|Base quantity |Name in generic unit |Name in S.I. unit|
Expand Down Expand Up @@ -57,21 +57,19 @@ class nbody_unit(core.base_unit):
def __init__(self, unit_in_si, system):
core.base_unit.__init__(self, unit_in_si.quantity, unit_in_si.name, unit_in_si.symbol, system)
self.unit_in_si = unit_in_si

def __str__(self):
return 'nbody '+self.unit_in_si.quantity



def is_generic(self):
return True


nbody_system = core.system('nbody')

length = generic_unit_system.length
time = generic_unit_system.time
mass = generic_unit_system.mass
time = generic_unit_system.time
mass = generic_unit_system.mass

acceleration = length / (time ** 2)
potential = (length ** 2) / (time ** 2)
Expand All @@ -83,7 +81,7 @@ def is_generic(self):
pressure = mass / length / (time ** 2)
momentum_density = density * speed
energy_density = density * specific_energy
G = 1. | (length**3) / (mass * (time**2))
G = 1. * (length**3) / (mass * (time**2))

def is_nbody_unit(unit):
for factor, x in unit.base:
Expand Down
6 changes: 3 additions & 3 deletions src/amuse/units/nist.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
pi = numpy.pi
hbar = h / (2.0 * numpy.pi)
four_pi_stefan_boltzmann = 4.0 * numpy.pi * Stefan_hyphen_Boltzmann_constant
mu0 = 4 * numpy.pi * 1.e-7 | N/A**2
mu0 = 4 * numpy.pi * 1.e-7 * N/A**2
eps0 = mu0**-1 * c**-2
sidereal_day = 86164.100352 | s
sidereal_day = 86164.100352 * s
#machine constants
eps = numpy.finfo(numpy.double).eps
precision = int(numpy.log10(2/eps))
Expand Down Expand Up @@ -173,7 +173,7 @@ def sort_units(self):

def print_list_of_units(self, unitlist):
for name, value, unit in unitlist:
self.nistfile += ("{0} = {1} | {2}\n".format(name, value, unit or "none"))
self.nistfile += ("{0} = {1} * {2}\n".format(name, value, unit or "none"))

def generate_constants(self):
self.list_constants()
Expand Down