An algorithm to discretize one-dimensional distributed port Hamiltonian systems