The Gärtner-Ellis Theorem, Homogenization, and Affine Processes