Unit systems and interactions

Simple unit system: Lengths,Times,Masses

In [2]:
from units.LTM import *

SI units

In [3]:
# SI is the SI system for LTM, with the SI units as the quantites defining 1 unit
for q in SI.base_quantities(): 
    print(q)
m = 1.000000e+00 m^1 ([L]^1)
s = 1.000000e+00 s^1 ([T]^1)
kg = 1.000000e+00 kg^1 ([M]^1)
In [4]:
# We provide short-hands for practical purposes
print(m)
print(s)
print(kg)
m = 1.000000e+00 m^1 ([L]^1)
s = 1.000000e+00 s^1 ([T]^1)
kg = 1.000000e+00 kg^1 ([M]^1)
In [5]:
# We can perform operations between units as you would expect
speed_of_light = 3e8 * m/s
print(speed_of_light)
print(speed_of_light + 1e8*m/s)
3.000000e+08 m^1 s^-1 ([L]^1[T]^-1)
4.000000e+08 m^1 s^-1 ([L]^1[T]^-1)

HEP system

The HEP system measures the same quantities (generated from distances, times and masses) in terms of energies (unit GeV), velocity (unit c) and angular momentum (unit hbar)

In [6]:
print(GeV)
print(c)
print(hbar)
GeV = 1.000000e+00 GeV^1 ([E]^1)
c = 1.000000e+00 c^1 ([V]^1)
hbar = 1.000000e+00 hbar^1 ([J]^1)

We can convert between systems:

In [7]:
# Convert 1m^2 to the HEP system
print(HEP(m**2))
# We can easily check that this is correct using the underlying system
print((GeV**-2*c**2*hbar**2).underlying_quantity())
2.568190e+31 GeV^-2 c^2 hbar^2 ([E]^-2[V]^2[J]^2)
3.893794e-32 m^2 ([L]^2)

Algebraic operations work across different system, with the left operator setting the system of the result

In [8]:
print(GeV**-1*c*hbar/m)
print(GeV*m)
print(m*GeV)
1.973270e-16 ()
5.067731e+15 c^1 hbar^1 ([V]^1[J]^1)
1.602177e-10 m^3 s^-2 kg^1 ([L]^3[T]^-2[M]^1)

Building your own systems

PhysicalSystem and MeasurementSystem

There are two main classes which define the framework in which quantities are measured:

  • PhysicalSystem embodies the abstract system of possible measurements. It relies on defining a list of abstract quantities and associated units but you should think of it as the abstract structure $\text{Dim}_D=\mathbb{K}\times D$ defined in the math section.
  • MeasurementSystem is a specific choice of units within a given PhysicalSystem. It is defined by choosing a complete set of quantities which we will use as our new units. Choosing such a set corresponds to choosing a generating set of $\text{Dim}_D$ (i.e. a choice of basis for $D$ and a set of associated values in $\mathbb{K}$ as outlined in the math section).

In the example of the LTM system above, the PhysicalSystem should be thought of as the abstract set of quantities that can be built out of lengths, times and masses. We show two measurement systems: SI in which we measure these quantities as combinations of meters, seconds and kilograms, and HEP, in which we use instead GeV, c and hbar.

Building a PhysicalSystem

In [9]:
import units.physical_system as ps
In [14]:
# Defining a PhysicalSystem is done by providing a list of pairs of (quantity_name,unit_name) as:
# The choice of units has no profound importance but is required to fix a reference
# with respect to which all other units will be defined
mySystemDefinition = (("Length","yards"),("Time","(four scores and seven years)"),("Mass","stones"))
LTM_better_units = ps.PhysicalSystem(mySystemDefinition)

We can obtain some information on our physical system

In [13]:
print(LTM_better_units.quantity_definitions)
for q in LTM_better_units.base_quantities():
    print(q)
[('Length', 'yards'), ('Time', 'four scores and seven years'), ('Mass', 'stones')]
1.000000e+00 yards^1 ([Length]^1)
1.000000e+00 four scores and seven years^1 ([Time]^1)
1.000000e+00 stones^1 ([Mass]^1)

The base_quantities are PhysicalQuantity objects which can be manipulated as one would expect. However it is better to define a MeasurementSystem and get MeasurementQuantity objects as these allow seamless system changes. The PhysicalSystem is there only to provide a reference point.

We can obtain a trivial MeasurementSystem

In [15]:
import units.measurement_system as ms
In [21]:
imperial=ms.physical_measurement_system(LTM_better_units)
print(imperial.quantity_definitions)
for q in imperial.base_quantities():
    print(q)
(yards,lincolntime,stones) = imperial.base_quantities()
[('Length', 'yards'), ('Time', '(four scores and seven years)'), ('Mass', 'stones')]
yards = 1.000000e+00 yards^1 ([Length]^1)
(four scores and seven years) = 1.000000e+00 (four scores and seven years)^1 ([Time]^1)
stones = 1.000000e+00 stones^1 ([Mass]^1)

If for some reason a crazy user wanted to use a different unit system to measure the same quantities, one first defines a complete set of units

In [40]:
meter = 1.09361*yards
second = (1./(2743632000))*lincolntime
kilogram = 0.157473*stones

We must name these quantities (the dimension) and the unit. Having a MeasurementQuantity object ensures that the new system will be generated with the same underlying PhysicalSystem

In [41]:
crazy_system_def = (
("L","meter",meter),
("T","second",second),
("M","kilogram",kilogram)
)
crazy_system = ms.MeasurementSystem(crazy_system_def)
In [42]:
one_year = 31536000*second
print(lincolntime/one_year)
8.700000e+01 ()

That is indeed four scores and seven years

As illustrated by the HEP system above, we do not need to use just a change of unit by rescaling them, but we can change which elementeray physical quantities to use for our base units (say energy instead of mass). This is quite practical for physics since we often like to "set some quantities to 1", which simply means using them as a base unit. For example we can use a subset of atomic units to describe our system

In [53]:
from math import pi
me = 9.10938356e-31*kilogram
h = 6.62607015e-34*kilogram*meter**2/second
c = 299792458*meter/second
alpha = 1./137

atomic_unit_def = (
("M","me",me),
("J","hbar",h/(2.*pi)),
("v","(alpha*c)",alpha*c)
)

atomic_units = ms.MeasurementSystem(atomic_unit_def)
In [54]:
atomic_units.base_quantities()
Out[54]:
[<MeasurementQuantity 1.000000e+00 me^1>,
 <MeasurementQuantity 1.000000e+00 hbar^1>,
 <MeasurementQuantity 1.000000e+00 (alpha*c)^1>]
In [55]:
atomic_units(meter)
Out[55]:
<MeasurementQuantity 1.890223e+10 me^-1 hbar^1 (alpha*c)^-1>

And indeed $$\left[\frac{\hbar}{\alpha c m_e }\right]=[D]$$