Low rank ODEs for Hamiltonian matrix nearness problems