phetsims / keplers-laws

"Kepler's Laws" is an educational simulation in HTML5, by PhET Interactive Simulations.
GNU General Public License v3.0
1 stars 1 forks source link

Engine not always preserving Angular Momentum! #248

Closed AgustinVallejo closed 7 months ago

AgustinVallejo commented 7 months ago

In the current engine behavior, the orbital parameters are calculated once, set to draw the ellipse, and then the planet moves step-wise along that trajectory. However, it seems the current method for enforcing angular momentum across the orbit it not fully consistent, likely due to the stepped direction of the velocity being wrong.

As a result, in some edge cases, if you recalculate the orbit after the planet has moved, it results in a significantly different orbit. This can be either done by pausing the planet mid orbit and touching it to recalculate, or in the state wrapper by setting state mid orbit, with results such as this one: image

I'm currently looking into this as will require a careful change of the run method within the engine. Thankfully, there's explicit equations that can help us get better results.

Potential solution

AgustinVallejo commented 7 months ago

This is now fixed. And as a plus, it seems when manually calculating angular momentum, L is much more accurately conserved now. Closing

AgustinVallejo commented 7 months ago

Reopening as it should be cherry picked

KatieWoe commented 7 months ago

I was able to reproduce this in rc.2 and haven't in rc.3 so far, which is good. I think this is fixed, but I'll keep an eye out.