Merge branch 'main' of cau-git.rz.uni-kiel.de:nt/mitarbeiter/silas/imdd_simulation
This commit is contained in:
@@ -1,135 +1,3 @@
|
||||
|
||||
% plot_dispersion_models
|
||||
% ------------------------------------------------------------
|
||||
% Visualizes exact and linearized chromatic dispersion D(λ)
|
||||
% around the zero-dispersion wavelength (ZDW).
|
||||
%
|
||||
% Inputs:
|
||||
% lambda0_nm - ZDW in nm
|
||||
% S0 - dispersion slope at ZDW [ps/(nm^2·km)]
|
||||
% ------------------------------------------------------------
|
||||
|
||||
%% ZDW 1
|
||||
lambda0_nm = [1310];
|
||||
S0 = [0.075,0.095]';
|
||||
% wavelength axis around ZDW
|
||||
lambda_nm = linspace(1240, 1360, 400);
|
||||
|
||||
% exact dispersion model
|
||||
D_exact_1 = (S0./4) .* ( ...
|
||||
lambda_nm - (lambda0_nm^4)./(lambda_nm.^3) );
|
||||
|
||||
%% ZDW 2
|
||||
lambda0_nm = [1320];
|
||||
% exact dispersion model
|
||||
D_exact_2 = (S0./4) .* ( ...
|
||||
lambda_nm - (lambda0_nm^4)./(lambda_nm.^3) );
|
||||
|
||||
|
||||
%% plot
|
||||
figure('Color','w'); hold on;
|
||||
cols = [0.6510 0.8078 0.8902;...
|
||||
0.1216 0.4706 0.7059;...
|
||||
0.6980 0.8745 0.5412;...
|
||||
0.2000 0.6275 0.1725];
|
||||
|
||||
plot(lambda_nm, D_exact_1(1,:), 'LineWidth',2, 'DisplayName',sprintf('$S_0=\SI{0.09}{\Dslope}$'),'Color',[0,0,0]);
|
||||
plot(lambda_nm, D_exact_1(2,:), 'LineWidth',2, 'DisplayName',sprintf('$S_0=\SI{0.09}{\Dslope}$'),'Color',[0,0,0]);
|
||||
|
||||
% plot(lambda_nm, D_exact_2(1,:), 'LineWidth',2, 'HandleVisibility','on', 'DisplayName',sprintf('$S_0=\SI{0.09}{\Dslope}$'),'Color',[0,0,0]);
|
||||
% plot(lambda_nm, D_exact_2(2,:), 'LineWidth',2, 'HandleVisibility','on', 'DisplayName',sprintf('$S_0=\SI{0.09}{\Dslope}$'),'Color',[0,0,0]);
|
||||
|
||||
xlabel('Wavelength $\lambda$ [nm]','Interpreter','latex');
|
||||
ylabel('D($\lambda$) [ps/(nm km)]','Interpreter','latex');
|
||||
title('Chromatic Dispersion Around the ZDW');
|
||||
legend('Location','best');
|
||||
grid on; box on;
|
||||
xlim([min(lambda_nm) max(lambda_nm)])
|
||||
ylim([-5 5]);
|
||||
|
||||
% mat2tikz_improved('C:\Users\Silas\Documents\6971e0b65b380ca6d71c837f\02_IMDD_System\tikz\dispersion\dispersion')
|
||||
|
||||
|
||||
|
||||
%%
|
||||
|
||||
%% plot_dispersion_dual_ZDW
|
||||
% Visualizes two ZDW fiber types, each with an S0 tolerance range.
|
||||
|
||||
%% plot_dispersion_minimal_for_tikz
|
||||
% Minimal setup for clean TikZ tuning
|
||||
|
||||
% 1. Parameters
|
||||
lambda_nm = linspace(1240, 1360, 400);
|
||||
S0_range = [0.075, 0.095];
|
||||
ZDW_range = [1300, 1325];
|
||||
|
||||
% 2. Calculate Envelope and Nominal
|
||||
[S_mesh, Z_mesh] = meshgrid(S0_range, ZDW_range);
|
||||
D_all = zeros(length(lambda_nm), 4);
|
||||
for i = 1:4
|
||||
D_all(:,i) = (S_mesh(i)/4) .* (lambda_nm - (Z_mesh(i)^4)./(lambda_nm.^3));
|
||||
end
|
||||
D_env_min = min(D_all, [], 2);
|
||||
D_env_max = max(D_all, [], 2);
|
||||
D_nominal = (mean(S0_range)/4) .* (lambda_nm - (mean(ZDW_range)^4)./(lambda_nm.^3));
|
||||
|
||||
% 3. Plotting
|
||||
figure('Color','w'); hold on;
|
||||
env_col = [0.1216, 0.4706, 0.7059];
|
||||
|
||||
% Shaded area
|
||||
[hl, hp] = boundedline(lambda_nm, (D_env_min+D_env_max)/2, ...
|
||||
(D_env_max-D_env_min)/2, 'alpha', 'cmap', env_col);
|
||||
set(hl, 'YData', D_nominal, 'Color', 'k', 'LineWidth', 1.5);
|
||||
|
||||
% Generate the outline and capture the handle
|
||||
ho = outlinebounds(hl, hp);
|
||||
|
||||
% Change properties
|
||||
set(ho, 'Color', 'k', ... % Make it black
|
||||
'LineStyle', '--', ... % Make it dashed
|
||||
'LineWidth', 0.5, ... % Make it thin
|
||||
'HandleVisibility', 'off'); % Hide from legend
|
||||
|
||||
% 4. "Minimal" Measurement Lines (Tweak these in TikZ later)
|
||||
% Vertical measurement at 1290nm
|
||||
lambda_v = 1290;
|
||||
[~, idx] = min(abs(lambda_nm - lambda_v));
|
||||
y_bot = D_env_min(idx);
|
||||
y_top = D_env_max(idx);
|
||||
|
||||
% Simple line - in TikZ this will be a single \draw command
|
||||
line([lambda_v, lambda_v], [y_bot, y_top], 'Color', 'r', 'LineWidth', 1.2, 'Tag', 'VertArrow');
|
||||
text(lambda_v + 2, (y_top+y_bot)/2, '$\Delta D$', 'Color', 'r', 'Interpreter', 'latex');
|
||||
|
||||
% Horizontal measurement at D=0
|
||||
z1 = ZDW_range(1);
|
||||
z2 = ZDW_range(2);
|
||||
line([z1, z2], [0, 0], 'Color', [0.1 0.5 0.1], 'LineWidth', 1.2, 'Tag', 'HorizArrow');
|
||||
text(mean(ZDW_range), 0.5, '$\Delta \lambda_0$', 'Color', [0.1 0.5 0.1], ...
|
||||
'Interpreter', 'latex', 'HorizontalAlignment', 'center');
|
||||
|
||||
% 5. Aesthetics
|
||||
xlabel('Wavelength $\lambda$ [nm]', 'Interpreter', 'latex');
|
||||
ylabel('$D(\lambda)$ [ps/(nm km)]', 'Interpreter', 'latex');
|
||||
grid on; box on;
|
||||
xlim([1240 1360]); ylim([-5 5]);
|
||||
line(xlim, [0 0], 'Color', [0.4 0.4 0.4], 'LineStyle', '--', 'HandleVisibility', 'off');
|
||||
|
||||
% Legend using the handles we have
|
||||
legend([hp, hl], {'Worst-case Envelope', 'Nominal Realization'}, ...
|
||||
'Location', 'northwest', 'Interpreter', 'latex');
|
||||
|
||||
% To export, run:
|
||||
% matlab2tikz('dispersion.tex', 'standalone', true);
|
||||
|
||||
%% plot_dispersion_for_tikz
|
||||
% Optimized for matlab2tikz compatibility with manual arrows
|
||||
|
||||
%% plot_dispersion_statistical_envelopes
|
||||
% Visualizes hard spec limits vs. 98% statistical distribution
|
||||
|
||||
%% plot_dispersion_final_for_tikz
|
||||
lambda_nm = linspace(1240, 1360, 400);
|
||||
|
||||
@@ -181,6 +49,14 @@ for k = 1:size(scenarios, 1)
|
||||
% 'HandleVisibility', 'off'); % Hide from legend
|
||||
% Capture Wide Spec (k=1) bounds for the TikZ measurement lines
|
||||
hp.FaceAlpha = 0.5;
|
||||
% ho = outlinebounds(hl, hp);
|
||||
% % Change properties
|
||||
% set(ho, 'Color', 'k', ... % Make it black
|
||||
% 'LineStyle', '--', ... % Make it dashed
|
||||
% 'LineWidth', 1, ... % Make it thin
|
||||
% 'HandleVisibility', 'off'); % Hide from legend
|
||||
% Capture Wide Spec (k=1) bounds for the TikZ measurement lines
|
||||
hp.FaceAlpha = 0.5;
|
||||
else
|
||||
hp.FaceAlpha = 0.8;
|
||||
end
|
||||
|
||||
@@ -18,7 +18,7 @@ Dacc_surface = zeros(numel(L_values), numel(f_targets));
|
||||
for iL = 1:numel(L_values)
|
||||
L = L_values(iL);
|
||||
[lambda_vec, Dacc_vec] = lambda_for_first_null_full(f_targets, L, lambda0, S0);
|
||||
|
||||
|
||||
% Store the 1x absolute offset |lambda - lambda0|
|
||||
lambda_surface(iL, :) = abs(lambda0 - lambda_vec);
|
||||
Dacc_surface(iL, :) = Dacc_vec;
|
||||
@@ -38,7 +38,7 @@ hold on;
|
||||
lambda_levels = unique([50:-10:30, 30:-5:5]);
|
||||
|
||||
% Contour plot
|
||||
[C,h] = contour(f_GHz, L_km, lambda_surface_nm, lambda_levels, ...
|
||||
[C,h] = contourf(f_GHz, L_km, lambda_surface_nm, lambda_levels, ...
|
||||
'LineWidth', 1.2, ...
|
||||
'ShowText', 'off');
|
||||
|
||||
@@ -53,19 +53,19 @@ ylabel(cb, '$\Delta \lambda$ [nm]', 'Interpreter', 'latex');
|
||||
% Find placement along the first-null curve for each level
|
||||
for i = 1:length(lambda_levels)
|
||||
lvl = lambda_levels(i);
|
||||
|
||||
|
||||
% Re-calculate the specific (f, L) curve for this delta-lambda
|
||||
lambda_target = lambda0 - (lvl * 1e-9);
|
||||
LHS = -( (S0*1e3) / 4 ) * (lambda_target - (lambda0^4)/(lambda_target^3)) * lambda_target^2;
|
||||
const_val = (c*0.5) / LHS;
|
||||
|
||||
|
||||
f_curve_GHz = linspace(min(f_GHz), max(f_GHz), 500);
|
||||
L_curve_km = const_val ./ (f_curve_GHz * 1e9).^2 / 1000;
|
||||
|
||||
|
||||
% Filter for points within the plot axes
|
||||
in_bounds = find(L_curve_km >= min(L_km)*1.1 & L_curve_km <= max(L_km)*0.9 & ...
|
||||
f_curve_GHz >= min(f_GHz)*1.1 & f_curve_GHz <= max(f_GHz)*0.9);
|
||||
|
||||
|
||||
if ~isempty(in_bounds)
|
||||
% Specific alternating pattern for weight to minimize overlapping
|
||||
if i < 9
|
||||
@@ -74,7 +74,7 @@ for i = 1:length(lambda_levels)
|
||||
weight = 0.05 + 0.1 * mod(i, 2);
|
||||
end
|
||||
idx = in_bounds(max(1, min(length(in_bounds), round(length(in_bounds) * weight))));
|
||||
|
||||
|
||||
text(f_curve_GHz(idx), L_curve_km(idx), sprintf('%g nm', lvl), ...
|
||||
'Color', 'k', 'BackgroundColor', 'w', 'Margin', 1.5, ...
|
||||
'HorizontalAlignment', 'center', 'VerticalAlignment', 'middle', ...
|
||||
@@ -98,7 +98,7 @@ if 0
|
||||
max_D = max(Dacc_surface(:), [], 'omitnan');
|
||||
% Calculate 3 integer levels well within the data range
|
||||
D_levels = unique(round(linspace(min_D*0.8, max_D*0.8, 3)));
|
||||
|
||||
|
||||
[CS, h] = contour(f_GHz, L_km, Dacc_surface, D_levels, 'k--', 'LineWidth', 0.8);
|
||||
clabel(CS, h, 'Color','k', 'FontSize',8);
|
||||
end
|
||||
@@ -106,7 +106,7 @@ end
|
||||
|
||||
%% Export
|
||||
% Hier erzwingen wir die rote Colormap für pgfplots, damit mat2tikz es nicht blau exportiert!
|
||||
mat2tikz_improved("C:/Users/Silas/Documents/6971e0b65b380ca6d71c837f/02_IMDD_System/tikz/dispersion/dispersion_power_fading_contour2.tikz");
|
||||
% mat2tikz_improved("C:/Users/Silas/Documents/6971e0b65b380ca6d71c837f/02_IMDD_System/tikz/dispersion/dispersion_power_fading_contour2.tikz");
|
||||
|
||||
function [lambda_vec, Dacc_vec] = lambda_for_first_null_full(f_target, L, lambda0, S0)
|
||||
% lambda_for_first_null_full (stable, single-branch + validity checks)
|
||||
@@ -148,10 +148,10 @@ Dacc_vec = NaN(N,1);
|
||||
|
||||
for k = 1:N
|
||||
RHS = c * 0.5 / (f_target(k)^2 * L);
|
||||
|
||||
|
||||
% Normal-dispersion branch (λ < λ0)
|
||||
fun = @(lambda) -(S0_si/4).*(lambda - (lambda0^4)./(lambda.^3)).*lambda.^2 - RHS;
|
||||
|
||||
|
||||
% Limit the search to [λ_min, λ0)
|
||||
try
|
||||
lambda_sol = fzero(fun, [lambda_min, lambda0 * 0.999]);
|
||||
@@ -159,18 +159,18 @@ for k = 1:N
|
||||
% If the zero is not within bounds, skip this point
|
||||
lambda_sol = NaN;
|
||||
end
|
||||
|
||||
|
||||
% Validate solution
|
||||
if isnan(lambda_sol) || lambda_sol < lambda_min || lambda_sol > lambda_max
|
||||
lambda_vec(k) = NaN;
|
||||
Dacc_vec(k) = NaN;
|
||||
continue
|
||||
end
|
||||
|
||||
|
||||
% Compute D(lambda) and accumulated dispersion
|
||||
D_lambda = (S0_si/4) * (lambda_sol - (lambda0^4)/(lambda_sol^3)) / 1e-6; % ps/(nm·km)
|
||||
Dacc_val = D_lambda * (L/1000); % ps/nm
|
||||
|
||||
|
||||
% Sanity bound on dispersion (avoid unphysical > ±100 ps/nm)
|
||||
if abs(Dacc_val) > 100
|
||||
lambda_vec(k) = NaN;
|
||||
|
||||
@@ -16,6 +16,9 @@ D_lambda = (S0/4) * (lambda*1e9 - (lambda0*1e9)^4/(lambda*1e9)^3); % ps/(nm·km)
|
||||
D_si = D_lambda * 1e-6; % → s/m²
|
||||
b2 = -D_si * lambda^2 / (2*pi*c); % s²/m
|
||||
|
||||
Dacc = D_lambda * L;
|
||||
fprintf('Accumulated Dispersion: %.2f ps/nm \n', Dacc / 1e3);
|
||||
|
||||
%% Frequency grid
|
||||
f_max = 200e9;
|
||||
f = linspace(0, f_max, 5000); % [Hz]
|
||||
|
||||
Reference in New Issue
Block a user