  In this paper we provide a unifying energy-based approach to the modeling,
analysis and control of power systems and markets, which is based on the
port-Hamiltonian framework. Using a primal-dual gradient method applied to the
social welfare problem, a distributed dynamic pricing algorithm in
port-Hamiltonian form is obtained. By interconnection with the physical model a
closed-loop port-Hamiltonian system is obtained, whose properties are exploited
to prove asymptotic stability to the optimal points. This result is extended
such that also general nodal power constraints are included into the social
welfare problem. Additionally, the cases of line congestion and power
transmission cost in (a)cyclic networks considering (non)linear power flow
models are covered as well. Finally, we provide port-Hamiltonian descriptions
and analysis of the well studied distributed averaging proportional integral
(DAPI) and certain internal-model-based controllers, which solve an optimal
frequency regulation problem.
