Class AppMath::Kep2D
In: kepler_2d.rb
Parent: Object

Kepler problem in 2 dimensions mass of the test particle is 1. space-fixed central mass times constant of gravity is @g

Methods

acc   ang_mom   energy   get_t   get_x   get_y   lenz   new   step!   to_s  

Public Class methods

[Source]

    # File kepler_2d.rb, line 86
86:   def initialize(x,v,g)
87:     @t = R.c0
88:     @x = x
89:     @v = v
90:     @g = g
91:   end

Public Instance methods

acceleration

[Source]

    # File kepler_2d.rb, line 94
94:   def acc
95:     r = @x.abs
96:     k = -@g * r**-3
97:     @x * k
98:   end

angular momentum

[Source]

     # File kepler_2d.rb, line 134
134:   def ang_mom
135:     @x.x * @v.y - @x.y * @v.x
136:   end

total energy

[Source]

     # File kepler_2d.rb, line 129
129:   def energy
130:     @v.abs2 * 0.5 - @g/@x.abs
131:   end

[Source]

     # File kepler_2d.rb, line 124
124:   def get_t
125:     @t
126:   end

[Source]

     # File kepler_2d.rb, line 116
116:   def get_x 
117:     @x.x
118:   end

[Source]

     # File kepler_2d.rb, line 120
120:   def get_y
121:     @x.y
122:   end

Runge-Lenz vector

[Source]

     # File kepler_2d.rb, line 139
139:   def lenz
140:     @x * @v.abs2 - @x * @v.spr(@x) - @x.uv * @g 
141:   end

time step of the direct midpoint integrator, highly symmetric !

[Source]

     # File kepler_2d.rb, line 101
101:   def step!(dt)
102:     h = dt * 0.5
103:     @t += h
104:     @x += @v * h
105:     @v += acc * dt
106:     @x += @v * h
107:     @t += h
108:   end

[Source]

     # File kepler_2d.rb, line 110
110:   def to_s
111:     res = "x = " + @x.to_s + "\n" +
112:     "v = " + @v.to_s + "\n" +
113:     "t = " + @t.to_s
114:   end

[Validate]