Is there a way to improve collision accuracy?

Hey,
I have been trying to create a 2D and 3D Gas model and have run into some issues with conservation of energy laws. The system seems to gain energy if restitution is set to 1 (More stable at 0.96 but still fluctuates around too much). I have applied a fix with a thermostat type function running every time step, as can be seen in the below code:
https://playcanvas.com/editor/code/514710?tabs=9941587
However, I was wondering whether there are any better solutions? Such as a way to edit the accuracy of the physics engine to be more accurate in its calculations.
Thanks in advance,
Chris
P.s. Here is a link to the full project in case it is useful:
https://playcanvas.com/editor/project/514710

If you need something that is scientifically accurate, you most likely need to write your own physics or find another 3rd party. The one that PlayCanvas uses is ammo.js which is a JS compiled version of Bullet used for games.