Hacker News new | past | comments | ask | show | jobs | submit login

Would it make sense to explicitly implement conservation of energy?

I.e. do a simple method but calculate the total energy at the beginning, and at each step adjust the speeds (e.g. proportionally) so that the total energy matches the initial value - you'll still always get some difference due to numerical accuracy issues, but that difference won't be growing over time.




The method you describe would be an example of what is called a "thermostat" in molecular dynamics (because the speed of molecules forms what we call temperature). Such adjustments to the speed can definitely paper over issues with your energy conservation, but you still have to be careful: if you rescale the speeds naively you get the "flying ice cube" effect where all internal motions of the system cease and it maintains its original energy simply by zooming away at high speed.

https://en.wikipedia.org/wiki/Flying_ice_cube


Thermostats ensure that the average _kinetic energy_ remains constant (on average or instantaneously depending on how they are implemented). Your parent post wants to enforce the constraint that the total energy remains constant. So its a bit different from a canonical ensemble (NVT) simulation. This is a microcanonical ensemble simulation (NVE). This means you don't know if you should correct the position (controlling the potential energy) or the velocities (controlling the kinetic energy).

Basically, there will be error in the positions and velocities due to the integrator used and you don't know how to patch it up. You have 1 constraint; the total energy should be constant. There are 2(3N-6) degrees of freedom for the positions and velocities (if more than 2 bodies). The extra constraint doesn't help much!

Edit: Also, the only reason thermostats work is because the assumption is that the system is in equilibrium with a heat bath (i.e. bunch of atoms at constant temperature). So there is an entire distribution of velocities that is statistically valid and as long as the velocities of the atoms in the system reflect that, you will on average model the kinetics of the system properly (e.g. things like reaction rates will be right). In gravitational problems there is no heat bath.




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: