Software for "Changing Rest Frames"

Private Sub cmdParticleInKp_Click()

Const c As Double = 300000000#

Const u As Double = 0.95 * c

Const N As Long = 100000# 'epochs in either frame

Const xfinal As Double = 2000#

Const vfinal As Double = u

Const a As Double = vfinal ^ 2 / (2 * xfinal)

MsgBox ("a = " & a)

Const tfinal As Double = vfinal / a

MsgBox ("tfinal = " & tfinal)

Const dt As Double = tfinal / N

Dim gamma As Double

Dim xfp As Double

Dim tfp As Double

Dim t(N + 1) As Double

Dim x(N + 1) As Double

Dim v(N + 1) As Double

Dim tp(N + 1) As Double

Dim xp(N + 1) As Double

Dim vp(N + 1) As Double

Dim ap(N + 1) As Double

Dim i As Long

gamma = 1 / Sqr(1 - u ^ 2 / c ^ 2)

xfp = gamma * (xfinal - u * tfinal)

MsgBox ("xfp = " & xfp)

tfp = gamma * (tfinal - u * xfinal / c ^ 2)

MsgBox ("tfp = " & tfp)

For i = 0 To N

t(i) = i * dt

v(i) = a * t(i)

x(i) = (1 / 2) * a * t(i) ^ 2

xp(i) = gamma * (x(i) - u * t(i))

vp(i) = (v(i) - u) / (1 - u * v(i) / c ^ 2)

ap(i) = a / (gamma ^ 3 * (1 - u * v(i) / c ^ 2) ^ 3)

tp(i) = gamma * (t(i) - u * x(i) / c ^ 2)

Next i

Open "c:\WINMCAD\Physics\ParticleInKp.PRN" For Output As #1

For i = 0 To N Step 100

Write #1, t(i), x(i), v(i), a, tp(i), xp(i), vp(i), ap(i)

Next i

Close

MsgBox ("Ready for plotting")

Stop

End Sub