Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simulation breaks when the two pendulums are on opposing sides of the anchor. #2

Open
ocket8888 opened this issue Oct 21, 2021 · 5 comments
Labels
bug Something isn't working

Comments

@ocket8888
Copy link

ocket8888 commented Oct 21, 2021

  1. Lift the middle ball up and to the right, above the anchor point.
  2. When you let go, the simulation begins, so wait for the ball to come back to about the same point where you just dropped it, then pause.
  3. raise the lower pendulum up and to the left, across the anchor point from the first pendulum. Looks like its height relative to the the other pendulum is irrelevant.
  4. Let go, watch as the simulated pendulums speed up over time, seemingly violating conservation of energy/momentum, until they reach a speed the simulation can no longer handle and the pendulum becomes just a line that extends outside the screen space. This also seemed to break the rendering of the pause button, for some reason (although I could still click it to pause afterwards).

Update: actually it looks like the line was just a coincidence the first time. After reproducing, I found that the pendulum lines appeared in three separate places, two of which don't seem possible:

image

@ocket8888
Copy link
Author

oh, actually, four places. It's up behind the pause button too.

@theabbie
Copy link
Owner

Thanks for letting me know, appreciate it, I will see what's the issue

@theabbie theabbie added the bug Something isn't working label Oct 21, 2021
@gregreen
Copy link

gregreen commented Oct 21, 2021

The non-conservation of energy is probably due to the fact that you're using Euler integration.

You can get rid of this behavior by using a symplectic integrator, such as the Verlet method (look specifically at the "Velocity Verlet" section). Symplectic integrators approximately conserve energy, and are generally more stable.

@theabbie
Copy link
Owner

@gregreen oh okay, thanks, will check out

@ocket8888
Copy link
Author

Sorry, one would think that a guy with degrees in both physics and compsci should be well-equipped to diagnose this, but it turns out that I don't remember anything they taught me in Intermediate Mechanics - a class where I literally had to build a double-pendulum simulation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants