Merge branch 'main' of cau-git.rz.uni-kiel.de:nt/mitarbeiter/silas/imdd_simulation
This commit is contained in:
@@ -7,7 +7,7 @@ alpha = 10^(-SIR_dB/20); % Interference attenuation [linear]
|
||||
n_fiber = 1.467; % Refractive index
|
||||
c = physconst('lightspeed'); % [m/s]
|
||||
|
||||
L = linspace(0,250,50); % Interference delay [m]
|
||||
L = linspace(0,250,50); % Interference delay [m]
|
||||
tau = n_fiber./c.*L; % Interference time (= tau) [s]
|
||||
|
||||
tau_c = 1/(pi*df); % laser coherence time [s]
|
||||
@@ -25,21 +25,21 @@ phase_noise_std = sqrt(2*pi*df/fs); % standard dev. phase noise
|
||||
num_realizations = 50; % number of parallel runs
|
||||
monte_carlo_variance = zeros(num_realizations, length(L));
|
||||
parfor r = 1:num_realizations
|
||||
|
||||
|
||||
% generate a realization of phase noise random walk
|
||||
dphi = phase_noise_std * randn(1, N + max_delay_samples); % matlab randn process has std = 1
|
||||
phi = cumsum(dphi);
|
||||
phi_direct = phi(max_delay_samples+1 : max_delay_samples+N);
|
||||
var_k = zeros(1, length(L));
|
||||
for t = 1:length(tau)
|
||||
|
||||
|
||||
nd = round( tau(t)*fs ); % delay in samples for current interference time
|
||||
phi_delayed = phi(max_delay_samples+1-nd : max_delay_samples+N-nd); %cut out interfering signal part (was earlier)
|
||||
|
||||
|
||||
E = exp(1j*phi_direct) + alpha*exp(1j*phi_delayed); % E-fields combined
|
||||
I = abs(E).^2; % photo current as magnitude square of E-field
|
||||
var_k(t) = var(I);
|
||||
|
||||
|
||||
end
|
||||
monte_carlo_variance(r, :) = var_k;
|
||||
end
|
||||
@@ -48,21 +48,23 @@ avg_of_mc_variances = mean(monte_carlo_variance, 1);
|
||||
std_of_mc_variances = std(monte_carlo_variance, 0, 1);
|
||||
|
||||
%% Analytic variance
|
||||
L_ = linspace(0,250,500); % Interference delay [m]
|
||||
L_ = linspace(0,250,500); % Interference delay [m]
|
||||
tau_ = n_fiber./c.*L_;
|
||||
analytic_variance = 2*alpha^2 * (1 - exp(-2*pi*df.*tau_)).^2;
|
||||
|
||||
%% Plot
|
||||
%% Plot
|
||||
cols = [0.3467 0.5360 0.6907
|
||||
0.9153 0.2816 0.2878
|
||||
0.4416 0.7490 0.4322];
|
||||
0.9153 0.2816 0.2878
|
||||
0.4416 0.7490 0.4322];
|
||||
|
||||
coherence_length_multiples = 0.5:0.5:ceil(L(end)/L_c);
|
||||
|
||||
figure();
|
||||
hold on;
|
||||
plot(L, avg_of_mc_variances, 'LineWidth',2, 'DisplayName','Simulation','Color',cols(1,:),'LineStyle','-');
|
||||
errorbar(L, avg_of_mc_variances,std_of_mc_variances, 'LineWidth',0.7,'LineStyle','none', 'DisplayName','Simulation','Color',cols(1,:),'HandleVisibility','off');
|
||||
[hl, hp] = boundedline(L, avg_of_mc_variances, std_of_mc_variances, 'alpha', 'cmap', cols(1,:));
|
||||
set(hl, 'LineWidth', 2, 'DisplayName', 'Simulation');
|
||||
set(hp, 'HandleVisibility', 'off', 'FaceAlpha', 0.8); % Hide patch from legend to match original behavior
|
||||
|
||||
|
||||
plot(L_, analytic_variance, 'LineWidth',2, 'DisplayName','Analytic','Color',cols(2,:),'LineStyle','-');
|
||||
xticks(coherence_length_multiples.*L_c);
|
||||
@@ -76,10 +78,12 @@ else
|
||||
xlabel('Interference Delay [m]', 'FontSize',12);
|
||||
end
|
||||
|
||||
xline(L_c.*coherence_length_multiples, 'LineWidth',1.5, 'DisplayName','Coh. Length','HandleVisibility','off','Color',[0.7,0.7,0.7],'LineStyle','-');
|
||||
%xline(L_c.*coherence_length_multiples, 'LineWidth',1.5,'HandleVisibility','off','Color',[0.7,0.7,0.7],'LineStyle','-');
|
||||
xlim([0,L(end)]);
|
||||
yline(var_sat, '-.k','LineWidth',1.5, 'DisplayName','Saturation: 2$\alpha ^2$');
|
||||
grid on;
|
||||
ylabel('Intensity Variance', 'FontSize',12);
|
||||
title(sprintf('MPI Variance; %d MHz; SIR: %d dB',df.*1e-6,SIR_dB), 'FontSize',14);
|
||||
legend('Location','southeast');
|
||||
|
||||
% mat2tikz_improved("C:\Users\Silas\Documents\6971e0b65b380ca6d71c837f\02_IMDD_System\tikz\mpi\analytical_mpi_variance2.tikz");
|
||||
@@ -18,6 +18,7 @@ xlabel('Laser linewidth [MHz]','FontSize',12,'Interpreter','latex');
|
||||
ylabel('Coherence length [m]','FontSize',12,'Interpreter','latex');
|
||||
title('Coherence Length vs. Laser Linewidth','FontSize',14,'Interpreter','latex');
|
||||
|
||||
mat2tikz_improved("C:\Users\Silas\Documents\6971e0b65b380ca6d71c837f\02_IMDD_System\tikz\mpi\laser_linewidth_vs_coherence.tikz");
|
||||
%% Annotate some key points
|
||||
% hold on;
|
||||
% freqs = [150e3, 1e6, 10e6, 50e6]; % [Hz]
|
||||
|
||||
Reference in New Issue
Block a user