BKaperick / Fizz-2D

Bare-bones 2D physics engine for handling interactions of rigid convex polygons on a 2D plane.
1 stars 0 forks source link

Energy Gain in Wall Collisions in Perfectly Elastic Setting #3

Open BKaperick opened 5 years ago

BKaperick commented 5 years ago

Here the ELASTICITY parameter is set to 1, to indicate that collisions with walls are perfectly elastic. We appear to gain a small (relative to system) amount of total energy with each hit. This effect likely exists with other choices of ELASTICITY, but this should be the simplest case to analyze.

Figure_1 simul

BKaperick commented 5 years ago

Currently, we use a fixed time step dt. If - in between two states - a collision occurred, the step is reversed, and we advance at increment dt/2. This is repeated, incrementing at dt/2^k until no collisions exist above COLLISION_TOL or the modified time increment dt/2^k is below EPSILON. We only seem to be gaining energy when the second condition fails:

https://github.com/BKaperick/Fizz-2D/blob/5c8ac7a003bb6e99225faa5abbd4047593b23a14/src/physics.py#L91-L114

This makes perfect sense, as this is exactly the scenario in which the collision resolution "fails" and has to bail out for fear of instability with a small time step.

BKaperick commented 5 years ago

Interestingly, changing the EPSILON parameter results in only negligible improvement in the magnitude of energy error incurred. With GRAVITY=[0, 100] and input file simulations/BOX_1SQUARE.in:

EPSILON Relative Energy Gain in Collision
1e-4 1.83360663%
1e-8 1.82640794%
1e-9 1.82640756%
1e-10 1.82640751%
BKaperick commented 5 years ago

Reducing time discretization can make this energy gain arbitrarily small, at the cost of more computational time.