Phase transition and thermodynamics of thorium from first-principles calculations