Analytical studies of top-up safety for the Advanced Photon Source