#!/usr/bin/env python # -*- coding: utf-8 -*- # (c) G. Beyerle 2016-2017 # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # This script requires python 2; for python3 the call to # raw_input() needs to be replaced by input() # Disclaimer: I'm a SymPy newbie, please bear with me. # # Changes # # Notes & Comments # # Consider three boosts, # instead of Cos() and sqrt(1-Cos()**2) # use half-angle parameterization # S = sin( alpha) # C = cos( alpha) # with # T = tan( alpha/2) # we get # S = 2 * T / (1 + T**2); # C = (1 - T**2) / (1 + T**2); # # Boosts # t = c/g * (sinh(g*tau/c)) # x = c^2/g * (cosh(g*tau/c)-1) # v = c * tanh(g*tau/c) # # with c = 1 and g = 1 we obtain # # t = (sinh(tau)) = beta*gamma # x = (cosh(tau)-1) = (gamma-1) # v = beta # # t_half = sinh(tau/2) # = sqrt((cosh(tau) - 1)/2) # = sqrt((gamma - 1)/2) # x_half = (cosh(tau/2) - 1) # = sqrt((cosh(tau) + 1)/2) - 1 # = sqrt((gamma + 1)/2) - 1 # v_half = tanh(tau/2) # = sqrt((gamma-1)/(gamma+1)) # # Simplifications / assumptions : # => 2-d geometry, i.e. all boosts are in one plane # => first boost is in [C1, S1] direction # C1 = C12; # S1 = -S12; # => second boost is in x direction [1,0] # => 3rd boost in +x direction # i.e. e1 = [C1,S1] # e2 = [1,0] # e3 = [C1,-S1] # and C1/S1 are expressed in terms of C12/S12 # C1 = C12; # S1 = S12; # => all angles are arbitrary # => time reversal symmetry, # i.e. symmetry with respect to 2nd boost, # Imports import sys from sympy import * from sympy import sin,cos,tan from sympy import sinh,cosh,tanh from sympy import symbols from sympy import MatrixSymbol, Matrix # # helper functions # def press_enter() : raw_input(" ... press ENTER to continue ...") # print("*** debug *** Press ENTER to continue ...") # In python3 use function input() instead # w = g * tau / c # g : acceleration # tau : proper time # c : velocity of light # T12 = tan(zeta12/2) # gamma : Lorentz factor # ga = 1 / sqrt(1- v**2/c**2) # with speed of light c and speed v ga = Symbol('ga') # normalized speed # be = v/c be = sqrt(ga**2 - 1) / ga; T12 = symbols( 'T12') # employ half-angle parameterization S1 = 2 * T12 / (1 + T12**2); C1 = (1 - T12**2) / (1 + T12**2); # boost direction vectors e1 = Matrix([C1,S1]) e2 = Matrix([1,0]) e3 = Matrix([C1,-S1]) # 2nd boost in frame [2] is taken to be along x-axis # e2 = [1,0] # thus, 1st boost in frame [1] is along # e1 = [cos(theta1),sin(theta1)] # = [C1,S1] # and, similarly, # e3 = [cos(theta1),-sin(theta1)] # = [C1,-S1] # # i.e. e1 = [C1,S1] # e2 = [1,0] # e3 = [C1,-S1] print ' ' print 'Warning: Script execution time may last from minutes to hours' print ' ' print 'We simplify the problem to be solved and consider' print 'a 1+2, instead of 1+3 dimensionalspace-time.' print 'This is possible since the spatial motion is assumed ' print 'to be restricted to the xy-plane.' print ' ' print 'First we define the three boost directions; e1, e2, e3' print ' ' print '2nd boost is assumed to be along x-axis, i.e.:' print ' e2 = ', e2 print ' ' print 'For symmetry reasons the first and third boost' print 'are written as' print ' e1 = [C1, S1] = [cos(zeta1), sin(zeta1)] ' print ' e3 = [C1,-S1] = [cos(zeta1),-sin(zeta1)] ' print 'where zeta1 denotes the angle between boost ' print 'directions e1 and e2. ' print ' ' print 'With the half-angle parametrization' print ' sin(zeta1) = S1 = ', S1 print ' cos(zeta1) = C1 = ', C1 print 'the boost directions are' print ' e1 = ', e1 print ' e2 = ', e2 print ' e3 = ', e3 print ' ' press_enter() print ' ' # 1st boost in [C1, S1] direction LT2To1 = Matrix([ [ ga, ga*(+be)*C1, ga*(+be)*S1 ], [ ga*(+be)*C1, 1+(ga-1)*C1**2, (ga-1)*S1*C1 ], [ ga*(+be)*S1, (ga-1)*S1*C1, 1+(ga-1)*S1**2 ] ]); # inverse 1st boost in [C1, S1] direction LT1To2 = Matrix([ [ ga, ga*(-be)*C1, ga*(-be)*S1 ], [ ga*(-be)*C1, 1+(ga-1)*C1**2, (ga-1)*S1*C1 ], [ ga*(-be)*S1, (ga-1)*S1*C1, 1+(ga-1)*S1**2 ] ]); # 3rd boost in [1, 0] direction LT3To2 = Matrix([ [ ga, ga*(+be), 0 ], [ ga*(+be), ga, 0 ], [ 0, 0, 1 ] ]); # boost in [1, 0] direction LT2To3 = Matrix([ [ ga, ga*(-be), 0 ], [ ga*(-be), ga, 0 ], [ 0, 0, 1 ] ]); # boost in [C1, -S1] direction LT4To3 = Matrix([ [ ga, ga*(+be)*C1, ga*(+be)*(-S1) ], [ ga*(+be)*C1, 1+(ga-1)*C1**2, (ga-1)*(-S1)*C1 ], [ ga*(+be)*(-S1), (ga-1)*(-S1)*C1, 1+(ga-1)*S1**2 ] ]); # boost in [C1, -S1] direction LT3To4 = Matrix([ [ ga, ga*(-be)*C1, ga*(-be)*(-S1) ], [ ga*(-be)*C1, 1+(ga-1)*C1**2, (ga-1)*(-S1)*C1 ], [ ga*(-be)*(-S1), (ga-1)*(-S1)*C1, 1+(ga-1)*S1**2 ] ]); print 'In 1+2 dimensional space-time the Lorentz ' print 'transformation matrices reduce to 3x3 matrices.' print ' ' print 'Transformation from frame [2] to [1] ... ' print ' ' print ' LT2To1 = ', LT2To1 print ' ' #print 'LT1To2 = ', LT1To2 #pprint( LT1To2) print ' ' press_enter() print ' ' print 'Transformation from frame [3] to [2] ... ' print ' ' print ' LT3To2 = ', LT3To2 #print ' ' #pprint( LT2To3) print ' ' press_enter() print ' ' print 'Transformation from frame [4] to [3] ... ' print ' ' print ' LT4To3 = ', LT4To3 #print ' ' #pprint( LT3To4) print ' ' press_enter() print ' ' print 'To transform the four-velocity at event D from' print 'frame [4] to frame[1], i.e. ' print ' vlD_Fr1 = LT4To1 * vlF_Fr4' print 'we need to know the corresponding Lorentz transformations.' # eq = LT3To4 * LT2To3 * LT1To2; vlD_Fr4 = Matrix([ [1], [0], [0] ]); print ' vlD_Fr3 = LT4To3 * vlD_Fr4 ... ' vlD_Fr3 = factor( expand( LT4To3 * vlD_Fr4)); print ' vlD_Fr2 = LT3To2 * vlD_Fr3 ... ' vlD_Fr2 = factor( expand( LT3To2 * vlD_Fr3)); print ' vlD_Fr1 = LT2To1 * vlD_Fr2 ... ' vlD_Fr1 = factor( expand( LT2To1 * vlD_Fr2)); print ' ' print 'now evaluate' print ' vlD_Fr1[0] = 1' print 'or' print ' vlD_Fr1[0] - 1 = 0' print ' ' print 'the result is' print ' vlD_Fr1[0] - 1 = ', factor( expand( vlD_Fr1[0] - 1)), ' = 0' print ' ' press_enter() print ' ' print 'Solve ' print ' (T12**2 - 2*ga - 1) = 0' print 'for T12 and obtain two solutions ' T12a = sqrt(2*ga - 1) T12b = -sqrt(2*ga - 1) print ' T12a = ', T12a print 'and ' print ' T12b = ', T12b print ' ' press_enter() print ' ' # # calculate four-position of event F in frame [1] # evA_Fr1 = Matrix([ [0], [0], [0] ]); # new position := old position + boost distance evB_Fr1 = ( evA_Fr1 + Matrix([ [ga*be], [(ga-1)*(+C1)], [(ga-1)*(+S1)] ]) ); print 'Determine sequentially evB_Fr2, evC_Fr3, evD_Fr4 ' print ' evB_Fr2 = factor( expand( LT1To2 * evB_Fr1 )) ... ' evB_Fr2 = factor( expand( LT1To2 * evB_Fr1 )) evC_Fr2 = ( evB_Fr2 + Matrix([ [ga*be], [(ga-1)], [0] ]) ); print ' evC_Fr3 = factor( expand( LT2To3 * evC_Fr2 )) ... ' evC_Fr3 = factor( expand( LT2To3 * evC_Fr2 )) evD_Fr3 = ( evC_Fr3 + Matrix([ [ga*be], [(ga-1)*(+C1)], [(ga-1)*(-S1)] ]) ); print ' evD_Fr4 = factor( expand( LT3To4 * evD_Fr3 )) ... ' evD_Fr4 = factor( expand( LT3To4 * evD_Fr3 )) print ' ' print 'The result is' print ' evD_Fr4 = ', evD_Fr4 print ' ' press_enter() print ' ' #tmpX = evD_Fr4[1] print 'Insert first solution T12a in x- and y-components of vector equation ' print ' evD_Fr4 = 0 ' print 'and obtain' print ' evD_Fr4[1] = ', factor( expand( evD_Fr4[1].subs(T12,sqrt(2*ga+1)))), ' = 0' print ' evD_Fr4[2] = ', factor( expand( evD_Fr4[2].subs(T12,sqrt(2*ga+1)))), ' = 0' print 'which has no solution for ga > 1.' print ' ' press_enter() print ' ' print 'Insert second solution T12b in x- and y-components of vector equation ' print ' evD_Fr4 = 0 ' print 'and obtain' print ' evD_Fr4[1] = ', factor( expand( evD_Fr4[1].subs(T12,-sqrt(2*ga+1)))), ' = 0' print ' evD_Fr4[2] = ', factor( expand( evD_Fr4[2].subs(T12,-sqrt(2*ga+1)))), ' = 0' print 'which has no solution for ga > 1 either.' sys.exit(); # # end of file #