-
Notifications
You must be signed in to change notification settings - Fork 0
/
chirpedFBG_InP.m
60 lines (51 loc) · 1.12 KB
/
chirpedFBG_InP.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
global F kappa_0_L Delta
kappa_0 = 50e2;
L = 200e-6;
n = 3.266;
lambda_0 = 1550e-9;
BW = 2e-9;
kappa_0_L = kappa_0*L;
F = (BW*4*pi*n*L)/(lambda_0^2);
xmesh = linspace(-0.5, 0.5, 500);
solinit = bvpinit(xmesh, @guess);
Delta_scan = linspace(-25, 25, 500);
r = zeros(1, length(Delta_scan));
for i=1:length(Delta_scan)
Delta = Delta_scan(i);
sol = bvp4c(@bvpfcn, @bcfcn, solinit);
r(i) = sol.y(1,1);
% plot(sol.x, abs(sol.y(1,:)).^2, '-o')
% xlim([-0.5, 0.5])
% ylim([0, 1])
end
%%
subplot(1, 2, 1)
plot(Delta_scan, abs(r).^2)
%xlim([-15, 15])
xlabel('Delta')
ylim([0, 1])
ylabel('R')
phase = unwrap(angle(r));
p = polyfit(Delta_scan, phase, 2);
subplot(1, 2, 2)
plot(Delta_scan, phase)
hold on
plot(Delta_scan, p(1)*Delta_scan.^2 + Delta_scan*p(2) + p(3))
%xlim([-15, 15])
xlabel('Delta')
ylabel('Phase [rad.]')
function dydx = bvpfcn(x, y)
global F kappa_0_L Delta
dydx = zeros(2,1);
dydx = [y(2)
1j*(2*Delta-F*x)*y(2)+((kappa_0_L)^2)*y(1)];
end
function res = bcfcn(ya, yb)
global F kappa_0_L Delta
res = [ya(2) - (kappa_0_L)*exp(1j*(-Delta-F/8))
yb(1)];
end
function g = guess(x)
g = [0.1
1];
end