Modeling the degradation and recovery of perovskite solar cells