irfpy.util.lorentztrans

Functions for Lorenz transformation

Code author: Yoshifumi Futaana

Todo

Consider importing to physics module

irfpy.util.lorentztrans.beta(v)[source]

Return β.

Return the parameter β.

β=vc

where v is the velocity of the object and c is the velocity of light.

Parameters:

v (float or np.array.) – Velocity (in meter) of the object.

>>> print('%.5f' % beta(3e7))  # About 0.1
0.10007
irfpy.util.lorentztrans.beta_u(*args)

Unitful version of beta().

irfpy.util.lorentztrans.gamma(v)[source]

Return γ.

Return the parameter γ.

γ=11(vc)2

where v is the velocity of the object and c is the velocity of light.

Parameters:

v (float or np.array.) – Velocity of the object.

>>> print('%.6f' % gamma(3e7))
1.005045
irfpy.util.lorentztrans.gamma_u(*args)

Unitful version of gamma().

irfpy.util.lorentztrans.gamma2vel(gamma)[source]

Inverse function of gamma().

Parameters:

gamma – The parameter γ.

Returns:

v in m/s.

The relation is

γ=11(vc)2

so that

v=c11γ2
>>> print('%.3e' % gamma2vel(1.01))
4.208e+07

You may use unitful version:

>>> print('%.3e' % gamma2vel_u(1.01).rescale(u.km / u.s))
4.208e+04
irfpy.util.lorentztrans.transformx(x, t, v)[source]

Lorenz transform along x.

An inertia frame, K(x, y, z), is Lorentz-transformed to K’(x’, y’, z’), another inertia frame. K’ is moving relative to K with velocity v along x axis.

The formulation is

x=γ(xvt)t=γ(tvc2x)
Parameters:
  • x – The x coordinate in K frame.

  • t – The t in K frame.

  • v – The velocity of K’ relative to K.

Returns:

A tuple, (x’, t’).

A simple example for x=3e8, t=10, v=2e8. If you consider Galileo transform, the time does not change (t=10) and the position is xvt=3e810×2e8=17e9. However, if you use the Lorentz transform, these values differ.

>>> x1, t1 = transformx(3e8, 10, 2e8)
>>> print('%.3e' % x1)
-2.282e+09
>>> print('%.3f' % t1)
12.528

Unitful version is also supported. Numpy array argument is also supported.

>>> x1u, t1u = transformx_u(np.array([3e8, 3e8]) * u.m, np.array([5, 10]) * u.s, np.array([2e8, 2e8]) * u.m/u.s)
>>> print(x1u)
[-9.39669291e+08  -2.28205399e+09] m
>>> print(t1u)
[  5.81576086  12.52768436] s

If velocity is very small, (almost) identical solution to Galilei transform can be obtained. Example is x=5, t=10, v=3. In this case time does not change (t=10). The position is 53×10=25.

>>> x2, t2 = transformx(5, 10, 3)
>>> print('{:.2f}'.format(x2))
-25.00
>>> print('{:.2f}'.format(t2))
10.00
irfpy.util.lorentztrans.transformx_u(*args)

Unitful version of transformx()

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