Optical modeling and polarization calibration for CMB measurements with ACTPol and Advanced ACTPol