## 6 Numerical Experiments
### Double-Frequency Tuning for Gain Factor Optimization
where \(A_{1}=2\times 10^{14},\ \ A_{2}=1.5\times 10^{14},\ \ \psi_{1}=0,\ \ \psi_{2}=0,\ \ \Delta T_{1}=0.5 ns,\ \ \Delta T_{2}=1 ns\)  
\[E_{st}(x=0\mu m,t)=1\times\frac{\sin\!\left(2\pi\!\left(2.5\times 10^{14} \right)\!t\right)\ V}{m},\ \ \ for\ \ 0\leq t\leq 10 ps\]  
\[E_{hp}(x=15\mu m,t)=E_{st}(x=15\mu m,t)=0\ \ \ \ \ \ for\ 0<t<10 ps\]  
**Absorbing boundary condition (perfectly matched layer):**  
\[\sigma(x)=\left\{(x-(L-\Delta))\sigma_{0}\,\ \ \ (L-\Delta)\leq\ x<L\ \ \ \ \right\},\ \ for\ L=15\mu m,\ \ \ \Delta=2.5\mu m,\ \ \sigma_{0}=4.5\times 10^{8}S/m\]  
**Optical isolator condition:** full reflection at \(\mathrm{x}=0\upmu\)m  
\[\Gamma(x=0\upmu m,t)=1\ \ \ (Reflection\ coef\)\(\,\)_ficient is equal to \(1)\]  
**Optical bandpass filter condition:** frequency dependent reflection at \(\mathrm{x}=10\upmu\)m  
\[\left|\Gamma(f^{\prime})\right|=1-e^{-\left(\frac{(f^{\prime}-250\gamma Hz)}{ \sqrt{2}7 Hz}\right)^{2}}\]  
**Cost function to be maximized:**  
\[Q\!\left(f_{p1},f_{p2}\right)=\left|E_{st}(\ f_{st}=250 THz)\right|-\delta_{1} \!\left(f_{p1}-f_{max}\right)^{2}-\delta_{2}\!\left(f_{min}-f_{p1}\right)^{2} -\delta_{3}\!\left(f_{p2}-f_{max}\right)^{2}-\delta_{4}\!\left(f_{min}-f_{p2} \right)^{2}\]  
where  
\[\delta_{1}=\left\{ \begin{array}{ccc}0&if\ \ f_{p1}\leq f_{max}\\ \frac{\left|E_{st}(\ f_{st}=250 THz)\right|}{10^{27}}&if\ \ f_{p1}>f_{max}\end{array}  \right\},\ \delta_{2}=\left\{ \begin{array}{ccc}0&if\ \ f_{p1}\geq f_{min}\\ \frac{\left|E_{st}(\ f_{st}=250 THz)\right|}{10^{27}}&if\ \ f_{p1}<f_{min}\end{array} \right\}\]  
\[\delta_{3}=\left\{ \begin{array}{ccc}0&if\ \ f_{p2}\leq f_{max}\\ \frac{\left|E_{st}(\ f_{st}=250 THz)\right|}{10^{27}}&if\ \ f_{p2}>f_{max}\end{array}  \right\},\ \delta_{4}=\left\{ \begin{array}{ccc}0&if\ \ f_{p2}\geq f_{min}\\ \frac{\left|E_{st}(\ f_{st}=250 THz)\right|}{10^{27}}&if\ \ f_{p2}<f_{min}\end{array}  \right\}\]  
**Optimization algorithm (BFGS):**  
\[Set\ \mathbf{H_{1}}=\left[ \begin{array}{cc}1&0\\ 0&1\end{array} \right],\ f_{p1,0}=100 THz,\ \ f_{p1,1}=102 THz,\]  
\[f_{p2,0}=100 THz,\ \  
\[\rho_{k}=\frac{1}{\mathbf{y}_{k}^{T}\mathbf{s}_{k}}\] \[\mathbf{H}_{k+1}=\left(\mathbf{I}-\rho_{k}\mathbf{s}_{k}\mathbf{y}_{k}{}^{T}\right) \mathbf{H}_{k}\mathbf{\left(}\mathbf{I}-\rho_{k}\mathbf{y}_{k}\mathbf{s}_{k}{}^{T}\right)+\rho_{k} \mathbf{s}_{k}\mathbf{s}_{k}{}^{T}\left(\text{BFGS}\right)\] \[\mathbf{I}:\text{Identity matrix}\]  
In order to satisfy the [PERSON] conditions, the step size at each iteration is chosen as:  
\[\alpha_{k}=C^{\left(\log\left|\frac{Q\langle f_{\mathbf{p},k}\rangle}{Q\langle f_ {\mathbf{p},k}\rangle-Q\langle f_{\mathbf{p},k}-1\rangle}\right|\right)\ /\ (\left|\frac{Q\langle f_{\mathbf{p},k}\rangle}{Q\langle f_{\mathbf{p},k} \rangle-Q\langle f_{\mathbf{p},k}-1\rangle}\right|)} \tag{19}\]  
where \(C\) is just a constant (\(1<C<1.5\)) and \(\alpha_{k}\) is the step size at iteration k. This formula (Equation (19)) was determined by trial and error and was found to satisfy [PERSON]'s conditions automatically at each iteration. This saves us from the huge computational cost of running another iteration loop to determine the step size at each iteration of the optimization process. In this simulation C = 1.445. Based on the above formulations, the maximum stimulus wave amplitude that has been reached in the cavity (for 0 \(<\) t \(<\) 10 ps) is determined as \(Gain_{max}=\left|E_{st}\left(\ f_{st}=250 THz\right)\right|_{max}=4.67\times 1 0^{8}V/m\), which corresponds to the frequencies \(f_{p1}=387.2\ THz,f_{p2}=319.4\ THz\) (see Table 1), or to the free space wavelengths \(\lambda_{p1}=0.939\ \upmu\text{m},\lambda_{p2}=0.775\ \mu m\) as the ultrashort pulses can be practically generated outside the resonator.