Added technical milestone report and changes to 1st presentation
[4yp.git] / agrawalAppendixB.m
CommitLineData
f9a73e9e
AIL
1distance = input('Enter fiber length in L_D ');
2beta2 = input('dispersion: 1 for normal, -1 for anomalous ');
3N = input('Nonlinear parameter N = '); % Soliton order
4mshape = input('m = 0 for sech, m > 0 for super-Gaussian ');
5chirp0 = 0;
6
7% set simulation parameters
8nt = 1024; Tmax = 32; % FFT points and window size
9step_num = round(20 * distance * N^2); % No. of z steps
10deltaz = distance/step_num; % step size in z
11dtau = (2*Tmax) / nt; % step size in tau
12
13%% tau and omega arrays
14tau = (-nt/2 : nt/2-1) * dtau; % temporal grid
15omega = (pi/Tmax) * [(0:nt/2-1) (-nt/2:-1)]; % freq grid
16
17if mshape == 0
18 uu = sech(tau) .* exp(-0.5j * chirp0 * tau.^2);
19else
20 uu = exp(-0.5 * (1 + 1j * chirp0) .* tau.^(2 * mshape));
21end
22
23%% plot input pulse shape and spectrum
24temp = fftshift(ifft(uu)) .* (nt * dtau) / sqrt(2 * pi); % spectrum
25figure(1); clf; subplot(2,1,1);
26plot(tau, abs(uu).^2, '--k'); hold on;
27axis([-5 5 0 inf]);
28xlabel('Normalized Time');
29ylabel('Normalized Power');
30title('Input and Output pulse shape and spectrum');
31
32subplot(2, 1, 2);
33plot(fftshift(omega)/(2*pi), abs(temp) .^ 2, '--k'); hold on;
34axis([-.5 .5 0 inf]);
35xlabel('Normaized freq');
36ylabel('spectral power');
37
38%% store dispersive phase shifts to speed up code
39dispersion = exp(0.5j * beta2 * omega.^2 * deltaz); % [hase factor
40hhz = 1j * N^2 * deltaz;
41
42%% begin main loop
43%% N/2 -> D -> N/2 first half step nonlinear
44temp = uu .* exp(abs(uu) .^ 2 .* hhz / 2);
45for n = 1 : step_num
46 f_temp = ifft(temp) .* dispersion;
47 uu = fft(f_temp);
48 temp = uu .* exp(abs(uu) .^ 2 .* hhz);
49end
50uu = temp .* exp(-abs(uu) .^ 2 .* hhz); % final field
51temp = fftshift(ifft(uu)) .* (nt*dtau) / sqrt(2 * pi); % final spectrum
52%% end of main loop
53
54%% plot output pulse shape and spectrum
55subplot(2,1,1);
56plot(tau, abs(uu).^2, '-k');
57subplot(2,1,2);
58plot(fftshift(omega) / (2*pi), abs(temp).^2, '-k');