irfpy.util.sprel

Formulae of special relativity.

Code author: Yoshifumi Futaana

time_dilation(t0, v)

Calculate the time dilation

length_contraction(l0, v)

Calculate the length contraction (Lorentz contraction)

energy(m)

Return the total energy

irfpy.util.sprel.time_dilation(t0, v)[source]

Calculate the time dilation

Parameters:
  • t0 – Time in the rest frame (moving with the object) in s.

  • v – Velocity of the object in m/s.

Returns:

t1, time observed by an observer moving with relative to the object (s).

\[t_1 = \gamma t_0\]
>>> print('%.3f' % time_dilation(1, 42300000.))
1.010

Unitful version, too.

>>> u.pprint(time_dilation_u(1 * u.s, 42300000. * u.m / u.s), fmt='%.8f')
1.01010541 s
irfpy.util.sprel.time_dilation_u(*args)

Unitful version of time_dilation()

irfpy.util.sprel.length_contraction(l0, v)[source]

Calculate the length contraction (Lorentz contraction)

Parameters:
  • l0 – The proper length (length of the object in the rest frame) in m.

  • v – Velocity of the object relative to the observer (m/s).

Returns:

l1, length observed by an observer moving relative to the object (m).

\[l_1 = \frac{l_0}{\gamma}\]
>>> print('%.4f' % length_contraction(1, 13400000.))
0.9990
>>> print('%.4f' % length_contraction(1, 42300000.))
0.9900

Unitful version, too.

>>> u.pprint(length_contraction_u(1 * u.km, 42300 * u.km / u.s).rescale(u.km), fmt='%.9f')
0.989995689 km
irfpy.util.sprel.length_contraction_u(*args)

Unitful version of length_contraction().

irfpy.util.sprel.energy(m)[source]

Return the total energy

Parameters:

m – Mass of the object in kg.

Returns:

The rest energy, E, in J.

\[E = m c^2\]
>>> me = 9.11e-31     # Electron mass
>>> print('%.3e' % energy(me))
8.188e-14
>>> ene_u = energy_u(me * u.kg)
>>> print('%.3f keV' % ene_u.r(u.keV))
511.034 keV
>>> print('%.3f MeV' % energy_u(u.k.proton_mass).r(u.MeV))
938.272 MeV
irfpy.util.sprel.energy_u(*args)

Unitful version of energy().

irfpy.util.sprel.doctests()[source]