# Comparative Analysis of the Methods for Fiber Bragg Structures Spectrum Modeling
## 2 Modeling Methods
### Layer Sweep Method  
Any medium inside the optical fiber with a known variation of the refractive index can be represented as a set of thin homogeneous \"films\", in each of which the refractive index can be considered constant [18]. Thus, the entire FBG is divided by a one-dimensional coordinate grid \(\{z_{i}\}\), \(i=1\), \(N\) (Figure 2) into homogeneous layers, in which the refractive index is determined as an integral average over the layer thickness:  
\[n_{i+1}=\frac{1}{z_{i+1}-z_{i}}\int\limits_{z_{i}}^{z_{i+1}}n(z)dz\,\,\,. \tag{4}\]It must be noted that the length of the partition interval \(\Delta z=z_{i+1}-z_{i}\) may significantly affect the performance of the modeled structure, which is discussed in Section 3. Substituting (1) and (2) into (4), we obtain a function that describes the layer-by-layer dependence of the refractive index on the coordinate \(z\):  
\[n_{i+1}=\frac{1}{z_{i+1}-z_{i}}\int\limits_{z_{i}}^{z_{i+1}}\left[n_{0}+\frac{1 }{2}\cdot\Delta n\cdot\exp\left(-\frac{1}{2}\left(\frac{z-z_{\text{M}}}{\sigma }\right)^{2}\right)\cdot\left(1+\sin\left(\frac{2\pi}{\Lambda}z\right)\right) \right]dz\enspace. \tag{5}\]  
Equation (5) is not an integral-elementary function, but integration in (5) is not required in this case, since the refractive index of the medium must be constant inside each layer, and expression (5) does not take this requirement into account, since the exponential multiplier that normalizes the amplitude of the refractive index variation implies that its amplitude within the layer changes along the coordinate \(z\). The constancy of the induced refractive index within each layer implies the constancy of the exponent in (5) over the layer thickness. Therefore, the exponential multiplier in (5) must be replaced by the average value of the refractive index, which, on the interval from \([z_{i},z_{i+1}]\) can be taken as its value in the middle of the interval:  
\[\exp\left(-\frac{1}{2}\left(\frac{z-(z_{\text{M}})_{k}}{\sigma_{k}}\right)^{2 }\right)\;\simeq\;\exp\left(-\frac{1}{2}\left(\frac{\frac{z_{i+1}+z_{i}}{2}-( z_{\text{M}})_{k}}{\sigma_{k}}\right)^{2}\right)\;+\text{o}(\Delta z_{i}), \tag{6}\]  
where \(\Delta z_{i}=z_{i+1}-z_{i}\), and \(\text{o}(x)\) is the error function, which denotes that the specified function decreases faster than its argument. Substituting (6) into (5), we obtain:  
\[n_{i+1}=\frac{1}{z_{i+1}-z_{i}}\int\limits_{z_{i}}^{z_{i+1}}\left[n_{0}+\frac{ 1}{2}\Delta n\left(\exp\left(-\frac{1}{2}\left(\frac{z_{i+1}+z_{i}-2z_{\text{ M}}}{2\sigma}\right)^{2}\right)+\text{o}(\Delta z_{i})\right)\left(1+\sin \left(\frac{2\pi}{\Lambda}z\right)\right)\right]dz\enspace. \tag{7}\]  
After that, the multiplier of the amplitude becomes independent of the integration variable and the integral can be taken analytically; thus, the dependence of the refractive index over all the layers of an arbitrary layered structure can be expressed as follows:  
\[n_{i+1}=n_{0}+\frac{\Delta n}{2}\exp\left(-\frac{1}{2}\left(\frac{z_{i+1}+z_ {i}-2z_{\text{M}}}{2\sigma}\right)^{2}\right)\;\cdot\left(1-\frac{\Lambda}{ \pi(z_{i+1}-z_{i})}\sin\left(\frac{\pi(z_{i+1}+z_{i})}{\Lambda}\right)\sin \left(\frac{\pi(z_{i+1}-z_{i})}{\Lambda}\right)\right)+\text{o}(\Delta z_{i}) \enspace. \tag{8}\]  
In order to model the reflection spectrum of such a structure, it is necessary to initialize the parameters of the layers based on relations (8), with further application of the classical algorithms of backward and forward sweeps for the layered structure calculation. The electric and  
Figure 2: Scheme of a layered structure of a substance with an arbitrary dependence of the refractive index over its thickness. magnetic components of the electromagnetic field at each point of each layer are the superposition of two waves (Figure 3) moving in different directions--the direct and the reflected ones:  
\[