# Three-Dimensional, Time-Dependent Analysis of High- and Low-\(Q\) Free-Electron Laser Oscillators
## 2 Numerical Formulation
### The MINERVA Simulation Code  
MINERVA is a time-dependent, three-dimensional simulation code that models the interaction between electrons and a co-propagating optical field through an undulator line, which may include strong-focusing quadrupoles and/or dipole chicanes [1, 190, 191, 192]. The optical fields are described using a superposition of Gauss-Hermite modes, using two independent polarization directions taken to be in the \(x\)- and \(y\)-directions with the \(z\)-direction taken along the axis of the undulator line. The Gauss-Hermite modes constitute a complete set, and together with the two independent polarizations, are able to describe the generation of arbitrary polarizations that might arise for any given undulator geometry. The vector potential representing the optical field in terms of the Gauss-Hermite modes is given by  
\[ \begin{split}\delta\mathbf{A}(\mathbf{x},t)=&\mathbf{e }_{x}\sum\limits_{\begin{subarray}{c}l,n=0\\ h=1\end{subarray}}^{\infty}e_{l,n,h}^{(x)}(\mathbf{x},t)\Big{(}\delta A_{l,n,h}^{(1,x)}(z,t)\sin(\varphi_{h}^{(x)}(\mathbf{x},t))+\delta A_{l,n,h}^{(2,x )}(z,t)\cos(\varphi_{h}^{(x)}(\mathbf{x},t))\Big{)}+\\ &\mathbf{e}_{y}\sum\limits_{\begin{subarray}{c}l,n=0\\ h=1\end{subarray}}^{\infty}e_{l,n,h}^{(y)}(\mathbf{x},t)\Big{(}\delta A_{l,n,h}^{(1,y)}(z,t)\sin(\varphi_{h}^{(y)}(\mathbf{x},t))+\delta A_{l,n,h}^{(2,y )}(z,t)\cos(\varphi_{h}^{(y)}(\mathbf{x},t))\Big{)},\end{split}  \tag{1}\]  
where \((l,n)\) are the transverse mode numbers, \(h\) is the harmonic number and \(\delta A_{l,n,h}\) are the mode amplitudes. Furthermore, \(\mathbf{\hat{e}}_{j}\) is a unit vector in the \(j\)-direction, \(j=x,y\) and  
\[e_{l,n,h}^{(j)}(\mathbf{x},t)=\frac{w_{0,h}^{(j)}}{w_{h}^{(j)}(z-z_{0},t)}e^{ -r^{2}/(w_{h}^{(j)}(z-z_{0},t))^{2}}H_{l}(\zeta_{x}^{(j)}(x,z,t))H_{n}(\zeta_{ y}^{(j)}(y,z,t)) \tag{2}\]  
are the transverse eigenfunctions for polarization direction \(j\)\(r=\sqrt{x^{2}+y^{2}}\), \(H_{l}\) and \(H_{n}\) are the Hermite polynomials of order \(l\) and \(n\), respectively, \(\zeta_{x}^{(j)}(x,z,t)=\sqrt{2}x/w_{h}^{(j)}(z-z_{0},t)\), \(\zeta_{y}^{(j)}(y,z,t)=\sqrt{2}y/w_{h}^{(j)}(z-z_{0},t)\) and \(w_{0,h}^{(j)}\) and \(w^{(j)}(z-z_{0},t)\) are the beam radii in the waist at \(z=z_{0}\) and at location \(z\) along the optical axis. Note, \(e_{l,n,h}^{(j)}\) and \(w^{(j)}\) are dependent on time through the source dependent expansion (SDE) [193], as different parts of the optical pulse will experience different gain. Finally, the optical phases \(\varphi_{h}^{(j)}(\mathbf{x},t)\) are given by  
\[\varphi_{h}^{(j)}(\mathbf{x},t)=h(k_{0}z-\omega_{0}t)+\alpha_{h}^{(j)}(z,t) \left(\frac{r}{w_{h}^{(j)}(z-z_{0},t)}\right)^{2}, \tag{3}\]  
where \(k_{0}=\omega_{0}/c\) is the vacuum wavenumber belonging to the carrier frequency \(\omega_{0}\), \(c\) is the speed of light in vacuo and \(\alpha_{h}^{(j)}(z,t)\) is the curvature of the wavefront for harmonic \(h\). In this formulation, we assume that the mode amplitudes, curvature of the phase fronts and radii of the modes are slowly varying functions of \(z\) and \(t\). The total optical power is given by  
\[P(z,t)=\sum\limits_{ \begin{subarray}{c}l,n=0\\ h=1\end{subarray} }^{\infty}P_{l,n,h}(z,t)=\frac{m_{e}^{2}c^{5}}{8e^{2}}k_{0}^ {2}\sum\limits_{ \begin{subarray}{c}l,n=0\\ h=1\end{subarray} }^{\infty}2^{l+n-1}l!n!\sum\limits_{j=x,y}(w_{0,h}^{(j)})^{2 }\Big{(}(\delta a_{l,n,h}^{(1,j)}(z,t))^{2}+(\delta a_{l,n,h}^{(2,j)}(z,t))^{2 }\Big{)}, \tag{4}\]  
where \(\delta a_{l,n,h}^{(i,j)}(z,t)=e\delta A_{l,n,h}^{(i,j)}(z,t)/m_{e}c^{2}\) are the components of the normalized mode amplitudes, \(i=1,2,j=x,y\) and \(m_{e}\) is the electron rest mass. The optical fields are driven by accelerated electrons, as they co-propagate through the magnetic fields that are placed along the transport line. Of main interest here is the amplification of the optical field by the electrons within the undulators that can be placed in arbitrary configuration along the electron beam transport line.