An answer to the question When is the Hamiltonian of a system not equal to its total energy? is:
In an ideal, holonomic and monogenic system (the usual one in classical mechanics), Hamiltonian equals total energy when and only when both the constraint and Lagrangian are time-independent and generalized potential is absent.
(from Siyuan Ren (https://physics.stackexchange.com/users/3887/siyuan-ren), URL (version: 2011-07-06): https://physics.stackexchange.com/a/11918/ )
that seems the most exact one I've found in several similar posted questions.
I'm trying to translate these conditions to equations.
- Lagrangian is time-independent could be: $L(q,\dot{q},t)=L(q,\dot{q})$.
- constraint is time-independent: ?
- generalized potential is absent: ?