I've been playing with a code for simulation of FBG properties. Code is using CMT and TMM implemented in matlab. Can anyone tell me why are there those sudden "drops/falls" in calculated dispersion? Am I missing something?
Have you examined how the complex amplitude of the reflected optical field varies with wavelength?
For a uniform un-chirped grating there are deep nulls in the reflected field. For a grating of moderate or weak strength, the nulls are approximately equally spaced and coincide with peaks in the group delay.
Group delay is typically calculated from the rate of change of phase of the reflected field with radian optical frequency. If the reflectance is calculated at a sequence of equally spaced wavelengths or optical frequencies, and the derivative calculated from a simple difference between adjacent frequency samples, there is potential for simplistic calculations to deliver invalid results near these reflectance nulls.
If one of the optical frequencies corresponds exactly with a reflectance null, the phase is undefined. I have not checked how Matlab behaves, but Octave returns atan2(0,0) = 0, and atan(0/0) = NaN, with a division by zero warning.
If one of the optical frequencies is close to, but not exactly at a reflectance null, the calculated phase may be subject to rounding errors from the coupled mode calculation which are sufficient to cause the spikes you see. This seems less likely, but is a possibility if the group delay spikes vary in magnitude.
Another problem around the nulls is that the reflectance changes sign. If the derivative is calculated from two optical frequencies near to but on opposite sides of the null, the rate of change of phase will be π / (radian frequency step). The real and imaginary parts of the reflectance are both continuous, but there is a π step discontinuity in the phase, which results in a group delay spike inversely proportional to the frequency step. To avoid this, ensure that the optical frequencies used for a two-point group delay calculation do not bracket a reflectance null. If accuracy is a concern, then calculate dispersion at two or more pairs of points on each side of the null and interpolate to the required optical frequency or wavelength.
Alan's explanation looks good to me. Whenever a complex number goes through the origin the phase is indeterminate, also the phase goes through 180 degrees change (in one side of the origin, out the other) in the small frequency step that takes it through the origin. The same happens with glint in radar cross-section. Don't try using phase very close to the origin!
Part of your problem is that you have chosen a sampling that probably exactly coincides with the nulls in your signal. Sometimes I add 1e-7 or some small number to everything to keep me out of exact zeros.