SUBROUTINE EulerRichardson(pos,vel,t,GM,dt,kick_flag,xsave,ysave) IMPLICIT NONE REAL*8 accel(2), diffx, diffy, impulse, on, posmid(2), v, v2, + velmid(2), pos(*), vel(*), t, GM, dt, xsave, ysave REAL x, y INTEGER IR_, i, Itmp1_ CHARACTER*80 kick_flag CALL GWmouse(IR_, Itmp1_, x, y) if(IR_ .NE. 0 .OR. Itmp1_ .NE. 0) THEN xsave = x ! save position where mouse clicked ysave = y kick_flag = 'on' END IF IF((kick_flag .EQ. 'on')) THEN diffx = abs(pos(1) - xsave) diffy = abs(pos(2) - ysave) * wait until orbit reaches point where mouse clicked IF((diffx .LT. 0.02D0) .AND. (diffy .LT. 0.02D0)) THEN v2 = vel(1)*vel(1) + vel(2)*vel(2) v = sqrt(v2) impulse = 0.1D0*v ! magnitude of impulse/mass vel(2) = vel(2) + impulse ! vertical kick kick_flag = 'off' END IF END IF * compute acceleration at beginning of interval CALL acceleration(pos,accel,GM) DO i = 1, 2 velmid(i) = vel(i) + 0.5D0*accel(i)*dt posmid(i) = pos(i) + 0.5D0*vel(i)*dt END DO * compute acceleration at middle of interval CALL acceleration(posmid,accel,GM) * position and velocity at end of interval DO i = 1, 2 vel(i) = vel(i) + accel(i)*dt pos(i) = pos(i) + velmid(i)*dt END DO t = t + dt END