## 2 Methods  
Figure 1 shows a schematic diagram of a Q-switched fiber laser cavity, which is the subject of the numerical investigation. The action of the Q-switch is approximated by a mirror with a time dependent reflectivity positioned at \(z=L\). The pump light is delivered to the fiber at \(z=0\) using a beam splitter, which also allows extraction of the infrared signal at the same end of the fiber. The fiber used is made of fluoride glass doped with trivalent erbium ions. The energy level diagram for trivalent erbium ion is shown in Figure 2. The pumping wavelength is 976 nm, whilst the infrared signal is at a wavelength of 2800 nm. Levels \({}^{4}\)F\({}_{7/2}\), \({}^{4}\)H\({}_{11/2}\) and \({}^{4}\)S\({}_{3/2}\) are thermally coupled, and represented in the model as one level N\({}_{4}\). Similarly, thermal coupling occurs for \(N_{2}\), which represents coupled levels \({}^{4}\)I\({}_{9/2}\) and \({}^{4}\)I\({}_{11/2}\). The higher lying levels, i.e., \(N_{3}\) and \(N_{4}\), are populated by an up-conversion processes. The temporal dependence of energy level populations for the energy level system shown in Figure 2 can be calculated by solving a set of differential equations, which can be derived using a rate equations approach [17]:  
\[ \begin{split}\frac{\partial N_{4}}{\partial t}&=W_{2 2}N_{2}^{2}-\frac{N_{4}}{\tau_{4}}+R_{ESA}\\ \frac{\partial N_{3}}{\partial t}&=\frac{\beta_{43} N_{4}}{\tau_{4}}-\frac{N_{3}}{\tau_{3}}\\ \frac{\partial N_{2}}{\partial t}&=R_{\text{GSA}}-R_ {SE}+\sum\limits_{i=3}^{4}\frac{\beta_{i2}N_{i}}{\tau_{i}}-\frac{N_{2}}{\tau_ {2}}-2W_{22}N_{2}^{2}+W_{11}N_{1}^{2}\\ \frac{\partial N_{1}}{\partial t}&=R_{SE}+\sum \limits_{i=2}^{4}\frac{\beta_{11}N_{i}}{\tau_{i}}-\frac{N_{1}}{\tau_{1}}-2W_{1 1}N_{1}^{2}\\ \frac{\partial N_{0}}{\partial t}&=-R_{\text{GSA}}+ \sum\limits_{i=1}^{4}\frac{\beta_{i0}N_{i}}{\tau_{i}}+W_{22}N_{2}^{2}+W_{11}N _{1}^{2}\end{split}  \tag{1}\]  
The energy level populations fulfill the condition \(N_{0}+N_{1}+N_{2}+N_{3}+N_{4}=N\). The ground state absorption rate \(R_{\text{GSA}}\) and the stimulated emission rate R\({}_{\text{SE}}\) are given by [21]:  
\[ \begin{split} R_{\text{GSA}}&=\frac{\lambda_{p} \Gamma_{p}\sigma_{\text{GSA}}}{hcA_{eff}}N_{0}\Big{(}P_{p}^{+}+P_{p}^{-}\Big{)} \\ R_{SE}&=\frac{\lambda_{s}\Gamma_{s}\sigma_{\text{se} }}{hcA_{eff}}\Big{(}b_{2}N_{2}-\frac{g_{2}}{g_{1}}b_{1}N_{1}\Big{)}(P_{s}^{+}+P_ {s}^{-})\end{split}  \tag{2}\]  
The power distributions for forward (denoted with upper index '+') and backward (denoted with upper index '-') propagating pump and signal waves, denoted in (2) respectively as \(P_{p}\) and \(P_{s}\), are obtained by solving a set of partial differential equations:\[\left(\frac{\partial}{\partial z}+\frac{1}{v_{g}}\frac{\partial}{ \partial t}\right)P_{p}^{+}=\big{(}g_{p}-\alpha_{p}\big{)}P_{p}^{+} \tag{3}\] \[\left(-\frac{\partial}{\partial z}+\frac{1}{v_{g}}\frac{\partial} {\partial t}\right)P_{p}^{-}=\big{(}g_{p}-\alpha_{p}\big{)}P_{p}^{-}\] \[\left(\frac{\partial}{\partial z}+\frac{1}{v_{g}}\frac{\partial} {\partial t}\right)P_{s}^{+}=\big{(}g_{s}-\alpha_{s}\big{)}P_{s}^{+}+\gamma_{ sp}N_{2}\] \[\left(-\frac{\partial}{\partial z}+\frac{1}{v_{g}}\frac{\partial} {\partial t}\right)P_{s}^{-}=\big{(}g_{s}-\alpha_{s}\big{)}P_{s}^{-}+\gamma_{ sp}N_{2}\]  
The partial differential Equations (1) and (3) are coupled together, and hence have to be solved simultaneously. Additionally, for the laser cavity configuration shown in Figure 1, the following boundary conditions apply at \(z=0\) and \(z=L\):  
\[ \begin{array}{l}P_{p}^{+}(z=0)=R_{p}(z=0)P_{p}^{-}(z=0)+\big{(}1-R_{p}(z=0) \big{)}P_{pump}\\ P_{p}^{-}(z=L)=R_{p}(z=L)P_{p}^{+}(z=L)\\ P_{s}^{+}(z=0)=R_{s}(z=0)P_{s}^{-}(z=0)\\ P_{s}^{-}(z=L)=R_{s}(z=L)P_{s}^{+}(z=L)\end{array}  \tag{4}\]  
At a set of sampling points, \(z=z_{i}\) selected along the z axis (Figure 3) partial differential Equations (1) and (3) can be reduced to a set of ordinary differential Equations (5) and (6):  
\[