  For a general class of nonlinear port-Hamiltonian systems we develop a
high-order time discretization scheme with certain structure preservation
properties. The finite or infinite-dimensional system under consideration
possesses a Hamiltonian function, which represents an energy in the system and
is conserved or dissipated along solutions. For infinite-dimensional systems
this structure is preserved under suitable Galerkin discretization in space.
The numerical scheme is energy-consistent in the sense that the Hamiltonian of
the approximate solutions at time grid points behaves accordingly. This
structure preservation property is achieved by specific design of a continuous
Petrov-Galerkin (cPG) method in time. It coincides with standard cPG methods in
special cases, in which the latter are energy-consistent. Examples of
port-Hamiltonian ODEs and PDEs are presented to visualize the framework. In
numerical experiments the energy consistency is verified and the convergence
behavior is investigated.
