A Hamiltonian theory for an elastic earth: Elastic energy of deformation