Skip to content

Unexpected loss of energy in frictionless perfectly elastic setting #256

Description

@mbchang

I'm using a modified version of the beachBalls example, with no friction, no air friction, and restitution of 1. When I let it run in the demo window, the balls eventually stop bouncing and come to a stop. I would expect them to keep bouncing indefinitely.

(function() {

    var World = Matter.World,
        Bodies = Matter.Bodies,
        Composites = Matter.Composites;

    Example.frictionlessBeachBalls = function(demo) {

        var engine = demo.engine,
            world = engine.world;

        // need random initialization
        var stack = Composites.stack(0, 100, 3, 1, 20, 0, function(x, y) {
            return Bodies.circle(x, y, 75, { restitution: 1, friction: 0, frictionAir: 0, frictionStatic: 0 });
        });
        World.add(world, stack);
    };

})();

I also tried setting the restitution of the world boundaries to 1 (the code below is modified from the Demo.reset, and that did not help.

        World.add(world, [
            Bodies.rectangle(400, -offset, 800.5 + 2 * offset, 50.5, { isStatic: true, restitution: 1 }),
            Bodies.rectangle(400, 600 + offset, 800.5 + 2 * offset, 50.5, { isStatic: true, restitution: 1 }),
            Bodies.rectangle(800 + offset, 300, 50.5, 600.5 + 2 * offset, { isStatic: true, restitution: 1 }),
            Bodies.rectangle(-offset, 300, 50.5, 600.5 + 2 * offset, { isStatic: true, restitution: 1 })
        ]);

I thought this might be an approximation issue when computing the effects of collisions and set high numbers for positionIterations, velocityIterations, and constraintIterations.

        demo.engine.positionIterations = 1000
        demo.engine.velocityIterations = 1000
        demo.engine.constraintIterations = 1000

This did not help either.

Is this loss of energy due to numerical approximation errors, or can this energy loss be explicitly controlled? At the moment beyond adjusting restitution and friction I am unable to find ways to make energy conservation perfect.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions