Hamiltonian theory of a symmetric multiport