The acceleration of the ball is calcuated by utilizing the force equation F=qv x B, used when a point charge interacts with a magnetic field. The cross product requires the right hand rule behavior of the ball. The magnetic contribution to the acceleration in the ODE is set so that it equals q*v*B/m only when in the specific light green region. The B value is negative in the teal region, reversing the direction.
Friction is added to the acceleration calculation with simply subtracting b*v/m, where b is a friction coefficient set to .5 in this simulation. I then wrote code to prevent the ball from infinitely approaching a zero velocity. The program sets the velocity of the ball to zero when its velocity slows to less than .05. It uses this information to allow the player to putt once more.