Dear @nimrodg

After discussing your case further with my colleagues, I think we finally found the source of the problem.

In your simulation file, from the *advanced options* tab of *Edit FDTD* windows you had “always use complex fields” box checked. **This option should be unchecked for all nonlinear simulations**:

Quoted from our internal discussions:

It will definitely create problems when using complex fields and nonlinear simulation. Complex fields in the time domain are not physical, but in linear systems it is irrelevant. In nonlinear systems it is a bit unclear what to do: does E(t)^2 mean |E(t)|^2 or something else?

**I was also wrong to say that** *Kerr nonlinearity is meant to affect only the optical refractive index*. In fact, you expect to create all the harmonics at (2m+1)*w-source with Kerr material. However, using complex fields suppresses half of the harmonics, while working with the real fields will return all the harmonics.

Quoted from our internal discussions:

The plugins will be called twice with complex fields – once for the real part of E and again for the imaginary part of E. It is interesting that this suppresses half the harmonics – I will have to think that through at some point.

If *always use complex fields* box is unchecked, your simulations will include only the real part of time domain electric field (i.e. E*cos(wt)), and thus you expect the time field to oscillate in time. If you are interested to obtain the envelope, you can use the script below which basically filters higher order frequencies beyond Nyquist limit:

```
mname = "monitor";
t = getdata(mname,"t");
Ey = getdata(mname,"Ey");
Ey = pinch(Ey);
# fourier transform
Eyf = fft(Ey);
w = fftw(t);
# apply filters in frequency domain
w1 = 2*pi*c/500e-9;
#w2 = 2*pi*c/1500e-9;
filter_complex = 2*((1:length(w)) <= length(w)/2);
filter1 = 2*exp(-(w-w1)^2/(150e12)^2);
#filter2 = 2*exp(-(w-w2)^2/(150e12)^2);
# plot the spectrum and filters
plot(w/(2*pi)*1e-12,abs(Eyf)/max(abs(Eyf)),filter1,filter_complex,"f (THz)","spectrum and filters");
legend("spectrum","filter1","filter2","filter complex");
# calculate the pump and lasing field in the time domain
Ey_complex = invfft(Eyf*filter_complex);
Ey_w0 = invfft(Eyf*filter1);
#Ey_2w0 = invfft(Eyf*filter2);
# get new time vector, different due to zero padding
t2 = fftw(w);
# plot the pump and lasing output
plot(t2*1e12,abs(Ey_w0),"t (ps)", "|E|");
legend("|E_w0(t)|","|E_2w0(t)|");
plotxy(t*1e12,abs(Ey),t2*1e12,abs(Ey_complex),"t (ps)", "|E|");
legend("|E(t) original|","envelope");
```

While this should fix the problem for you, below I have tried to answer your questions:

I used a time domain signal with a slow increase in amplitude. For pulses that are truncated or have a sudden start, you might create some other frequencies when you Fourier transform them. This is something to bare in mind if you saw some other non-sense frequencies.

You can use finer mesh now. If you go to a really small mesh, you can get more reflections from the pml, maybe increase the number of layers to 24 or 32 so you don’t have to worry about it. I don’t think this is the problem here, but it is a good idea.

We invite our developers to respond directly to some posts, but I think it will be faster if I stay in charge at the moment as our developers might be quite busy before big releases. But please let me know if you had further questions and I will discuss it further with our team.

I hope this answered your questions.