Generalization of Hamilton's principle to continuous dissipative systems