Density of states of the XY model: An energy landscape approach