# Three-Dimensional, Time-Dependent Analysis of High- and Low-\(Q\) Free-Electron Laser Oscillators
## 2 Numerical Formulation
### The Optical Propagation Code OPC
#### 2.4.1 Optical Elements  
To allow the modeling of FEL oscillators, the optical field needs to interact with various types of optical elements, such as lenses, mirrors or diaphragms. Diaphragms are implemented as hard edge apertures that reduce the optical field to zero outside the aperture. Various apodization functions are available that can be applied to the edge of the aperture. Lenses and mirrors are implemented as elements that apply a phase shift to the optical field. This is done by multiplying the optical field by \(e^{-iq(x,y)}\), where \(q(x,y)\) is the local phase shift in the transverse plane. For example, a thin lens is modeled as \(q(x,y)=k_{0}(x^{2}+y^{2})/2f\) with \(f\) as the focal strength of the lens. Mirrors are modeled as thin lenses using \(f=R/2\), where \(R\) is the radius of curvature of the mirror. More complicated optical elements as thick lenses or a combination of lenses can be implemented by determining the overall ABCD matrix and using the modified Fresnel diffraction integral (Equation 35). OPC also allows for more complicated phase masks that can be created using Zernike polynomials [194]. These can be used to implement not only various types of mirror and lens aberrations, but also mirror distortion resulting from thermal loading [203; 204] (see Section 2.4.2 for more detail). In the latter case, OPC can set a scaling factor for the aberrations depending on the (average) optical power loading of the mirror.  
Typically, it is assumed that the FEL gain bandwidth is sufficiently small that dispersive effects within the optical elements can be neglected. However, this is not the case when crystal Bragg mirrors are used, e.g., to model oscillator configurations at X-ray wavelengths. For such mirrors, the angle of reflection and mirror loss strongly depend on the type of crystal used, its orientation and the X-ray photon energy [205]. To properly model the reflection of Bragg mirrors, the incident optical field needs to be Fourier transformed into the frequency domain to handle the different photon energies in the optical field, and a two-dimensional spatial Fourier transform of the incident field is needed to deal with the various angles of incidence on the mirror.  
Several optical elements can be combined to form a more complex optical component, e.g., by combining a mirror with a diaphragm element, extraction of radiation from a resonator through a hole in one of the mirrors can be modeled. Another example is to use an external finite element program to simulate mirror surface distortion due to thermal loading of the mirror. This surface distortion can then be converted to a phase mask, the amplitude of which can be dynamically scaled at each roundtrip to model mirror distortion during the start-up of the oscillator.  
Finally, the collection of wavefront propagators together with the optical components and interfaces with several FEL gain codes is known as the optical propagation code (OPC). As OPC is specifically designed to work several FEL gain codes to model FEL oscillators, some of the optical components allow for the forking of the optical propagation path. For example, at the mirror used for coupling the light out of the resonator, the tracking of the light within the resonator can temporarily be suspended to propagate the light outside the resonator to some diagnostic point where several optical properties of the light can be obtained. Afterwards, the propagation of the light within the resonator can be continued. This allows simultaneous monitoring of the light properties at some external diagnostic point, as well as the build-up of the light within the resonator.