Page 1 of 1
Energy Dissipation in Pendulum
Posted: Sun Nov 17, 2013 11:11 am
by drm
I'm trying to use Chipmunk2D for a simple physics simulation involving pendula. I've set up a simple preliminary scenario with a mass hanging straight below a fixed point, attached by a pin joint. The mass is hit with an impulse to the left as soon as the simulation starts, and nothing else is actively done to the mass.
However, it appears that energy dissipation is occuring somewhere in Chipmunk's calculuations, as the pendulum will eventually lose velocity and the maximum angle it achieves will decrease. While this is realistic, it's not the behaviour that I want. Is there a way that I can get Chimpunk to simulate objects whithout any energy dissipation due to friction, air resistance, etc?
Re: Energy Dissipation in Pendulum
Posted: Sun Nov 17, 2013 8:26 pm
by LegoCylon
It sounds like you may have a custom damping or gravity value set on the space. Neither are set by default. Try checking for calls to cpSpaceSetDamping and cpSpaceSetGravity.
Re: Energy Dissipation in Pendulum
Posted: Sun Nov 17, 2013 9:32 pm
by drm
I have set a custom gravity value, but that's intended. I'm modelling a pendulum, and need gravity to act as a conservative force on the system. However, even removing the gravity from the system, things slow down. Any ideas? Can I provide more information that would help?
Re: Energy Dissipation in Pendulum
Posted: Mon Nov 18, 2013 10:18 am
by slembcke
While it's not specifically desired behavior, it is expected behavior even given perfect initial conditions.
Chipmunk like pretty much all other physics engines intended for games are tuned for performance and not exactness. They tend to use Euler integration because it has some very desirable behaviors for simulations. They tend to use inaccurate iterative based solvers since they allow you to pick a compromise between accuracy and performance. They use discrete time steps since analytic solutions to even simple problems with few objects tend to quickly turn into a mess.
So. If you are really looking for a super accurate simulation you probably need to integrate and simulate it yourself.
Re: Energy Dissipation in Pendulum
Posted: Mon Nov 18, 2013 11:14 am
by drm
Fair enough, that makes quite a bit of sense. I'll see what I can do simulating myself, or maybe I can arrange my constraints so that Chipmunk will satisfy. Either way, Chipmunk is certainly a useful library!