  In a first part the scope of classical thermodynamics and statistical
mechanics is discussed in the broader context of formal dynamical systems,
including computer programmes. In this context classical thermodynamics appears
as a particular theory suited to a subset of all dynamical systems. A
statistical mechanics similar to the one derived with the microcanonical
ensemble emerges from dynamical systems provided it contains, 1) a finite
non-integrable part of its phase space which is, 2) ergodic at a satisfactory
degree after a finite time. The integrable part of phase space provides the
constraints that shape the particular system macroscopical properties, and the
chaotic part provides well behaved statistical properties over a relevant
finite time. More generic semi-ergodic systems lead to intermittent behaviour,
thus may be unsuited for a statistical description of steady states. Following
these lines of thought, in a second part non-extensive hierarchical systems
with statistical scale-invariance and power law interactions are explored. Only
the virial constraint, consistent with their microdynamics, is included. No
assumptions of classical thermodynamics are used, in particular extensivity and
local homogeneity. In the limit of a large hierarchical range new constraints
emerge in some conditions that depend on the interaction law range. In
particular for the gravitational case, a velocity-site scaling relation is
derived which is consistant with the ones empirically observed in the fractal
interstellar medium.
