Allow me to give some context to this answer.
For some decades statistical mechanics was taught in an axiomatic (which can also mean dogmatic) way: in such-and-such situation you use such-and-such distribution/ensemble. I'm sure it's still taught that way in many courses. But at least since the 1950s (with Brillouin, Jaynes, and Kac too in my opinion) it became clear that its axioms were actually consequences of a logical and rational approach – nothing more than probabilistic inference. After all, this was also the starting point of Boltzmann, Maxwell, Gibbs (which I find somewhat dogmatic here and there), Einstein.
And the probabilistic inference allows us to use any combination of macroscopic and microscopic information. This understanding led to at least two kinds of development.
First, for systems in macroscopic equilibrium, additional pieces of macroscopic information are now used to construct ensemble distributions. For example, if we know not only the average total energy (under repetitions of the macroscopic preparation), but also its variance, this additional piece of information can be also used and appears as an extra parameter in the distribution. The ensemble thus obtained is called the Gaussian ensemble. Depending on the value of the additional parameter, reflecting the observed variance, the microcanonical and canonical ensembles are obtained as special cases. For a review see for example
This is just an example. You can search the literature for "angular-momentum ensemble", "pressure ensemble", "evaporative ensemble"... The possibilities are endless. These ensembles are absolutely needed for particular systems, such as small-size or non-extensive systems, or for particular situations such as phase transitions.
The probabilistic-inference rationale behind this was explained very clearly by Jaynes; see for example
Another review focusing on more recent applications is
Second, outside of equilibrium we can use time-varying macroscopic information, and also microscopic information such as the Hamiltonian, if it's known. This leads to time-dependent ensembles, where the time dependence comes from the Hamiltonian or from the ensemble parameters, which are now functions of time, say $\beta(t)$ as they reflect time-varying macroscopic quantities. Roughly speaking we're using Gibbs's approach on the space of trajectories, rather than on state space. The approach – again it's nothing else than probabilistic inference – was rationally summarized by Jaynes, see for example (these two are the main references for your question):
(other papers by Jaynes at https://bayes.wustl.edu/etj/node1.html) and also
And many applications of this development are appearing, for example (most of them should also be on arXiv):
Most interesting is that the resulting equations and results mirror those of non-equilibrium thermodynamics developed from first principles (without microscopic considerations) – for which see for example Astarita's brilliant text:
In fact it's even possible to include spatially varying macroscopic information in this approach, as explained in Jaynes's paper above. For particular cases of this kind of derivations see for example
The parameters in the resulting distributions have space- and time-dependence, for example $\beta(x,t)$ – just like the temperature field in continuum thermomechanics. Indeed also in this case there appear amazing parallels with general, non-equilibrium thermomechanics – for which see for example
Coming finally to your question, the answer is that if our system is in thermal equilibrium then by definition its total energy is macroscopically constant in time. Then the ensemble distribution you write, with $E(q,p)$, is indeed appropriate for some predictive purposes, no matter what the Hamiltonian is. About time dependence and ensembles see Jaynes's paper "Inferential scattering" above, especially sections 4–7.
But we can also construct a sharper, time-dependent distribution by using the Hamiltonian evolution (time-dependent or not). In short, we use the Hamiltonian to propagate macroscopic information from each time to all other times. See the paper Macroscopic prediction above, especially sections 4–5.
There's no "correct" ensemble distribution: it depends on what we want to use it for (microscopic predictions? prediction of other macroscopic quantities?).
Outside of equilibrium, if we have time-dependent macroscopic measurements of the energy $E(t)$, we can build a time-dependent canonical distribution with a time-dependent parameter $\beta(t)$. Again we can also obtain an even sharper time-varying distribution by using the Hamiltonian.
Finally, it may be useful to point out that macroscopic dissipation can (and usually does) occur even if microscopically we have a time-independent Hamiltonian. The ideal gas, for example, is a (macroscopically) dissipative system, for entropic reasons. See for example
This post imported from StackExchange Physics at 2025-01-22 10:54 (UTC), posted by SE-user pglpm