  We develop a comprehensive approach to simulate the deformation of mirrors
and lenses due to thermal and mechanical stresses that couples efficiently to
photon-based optics simulations. This expands upon previous work where we
demonstrated a comprehensive ab initio approach to simulate astronomical images
using a photon Monte Carlo method. We apply elasticity theory and estimate
thermal effects by adapting a three-dimensional numerical method. We also
consider the effect of active optics control systems and active cooling systems
in further correcting distortions in the optics. We validate the approach by
showing convergence to analytic estimates, and then apply the methodology to
the WIYN 3.5m telescope primary mirror. We demonstrate that changes in the soak
temperature result in second order point spread function (PSF) defocusing, the
gravitational sag and positioning errors result in highly structured PSF
distortions, and large-scale thermal gradients result in an elliptical PSF
distortion patterns. All three aspects of the environment are larger than the
intrinsic optical aberrations of the design, and further exploration with a
variety of telescopes should lead to detailed PSF size and shape, astrometric
distortion, and field variation predictions. The simulation capabilities
developed in this work is publicly available with the Photon Simulation
(PhoSim) package.
