2024-11-20 00:02:17 +01:00
|
|
|
function visualizeGSWavefunction2D(folder_path, run_index)
|
2024-11-14 15:03:38 +01:00
|
|
|
|
|
|
|
set(0,'defaulttextInterpreter','latex')
|
|
|
|
set(groot, 'defaultAxesTickLabelInterpreter','latex'); set(groot, 'defaultLegendInterpreter','latex');
|
|
|
|
|
|
|
|
% Load data
|
2025-01-22 23:04:36 +01:00
|
|
|
Data = load(sprintf(horzcat(folder_path, '/Run_%03i/psi_gs.mat'),run_index),'psi','Transf','Observ','Params','VParams');
|
2024-11-14 15:03:38 +01:00
|
|
|
|
2025-01-22 23:04:36 +01:00
|
|
|
Transf = Data.Transf;
|
|
|
|
Observ = Data.Observ;
|
|
|
|
Params = Data.Params;
|
|
|
|
VParams = Data.VParams;
|
|
|
|
|
2024-11-14 15:03:38 +01:00
|
|
|
if isgpuarray(Data.psi)
|
|
|
|
psi = gather(Data.psi);
|
|
|
|
else
|
|
|
|
psi = Data.psi;
|
|
|
|
end
|
|
|
|
|
|
|
|
if isgpuarray(Data.Observ.residual)
|
|
|
|
Observ.residual = gather(Data.Observ.residual);
|
|
|
|
else
|
|
|
|
Observ.residual = Data.Observ.residual;
|
|
|
|
end
|
|
|
|
|
|
|
|
% Set long format for output
|
|
|
|
format long
|
|
|
|
|
|
|
|
% Coordinates in micrometers
|
|
|
|
x = Transf.x * Params.l0 * 1e6;
|
|
|
|
y = Transf.y * Params.l0 * 1e6;
|
|
|
|
|
|
|
|
% Plotting
|
|
|
|
figure('Position', [100, 100, 1600, 900]);
|
|
|
|
clf
|
2025-01-22 23:04:36 +01:00
|
|
|
t = tiledlayout(2, 3, 'TileSpacing', 'compact', 'Padding', 'compact'); % 2x3 grid
|
2024-11-14 15:03:38 +01:00
|
|
|
|
|
|
|
% Compute probability density |psi|^2
|
2024-11-20 09:49:39 +01:00
|
|
|
nxy = abs(psi).^2;
|
|
|
|
nxyScaled = nxy*(Params.add*10^6)^2;
|
|
|
|
|
2024-11-14 15:03:38 +01:00
|
|
|
% Plot |psi(x,y)|^2 (density in x and y plane)
|
2025-01-22 23:04:36 +01:00
|
|
|
nexttile; % Equivalent to subplot('Position', [0.05, 0.55, 0.28, 0.4]);
|
2024-11-20 09:49:39 +01:00
|
|
|
plotxy = pcolor(x,y,nxyScaled');
|
|
|
|
set(plotxy, 'EdgeColor', 'none');
|
|
|
|
cbar1 = colorbar;
|
|
|
|
cbar1.Label.Interpreter = 'latex';
|
2025-01-23 01:19:31 +01:00
|
|
|
colormap(gca, 'parula')
|
2025-01-22 23:04:36 +01:00
|
|
|
% clim(ax1,[0.00,0.3]);
|
2024-11-20 09:49:39 +01:00
|
|
|
ylabel(cbar1,'$na_{dd}^2$','FontSize',16,'Rotation',270)
|
|
|
|
xlabel('$x$ ($\mu$m)', 'Interpreter', 'latex', 'FontSize', 14)
|
|
|
|
ylabel('$y$ ($\mu$m)', 'Interpreter', 'latex', 'FontSize', 14)
|
|
|
|
title('$|\Psi(x,y)|^2$', 'Interpreter', 'latex', 'FontSize', 14)
|
2024-11-14 15:03:38 +01:00
|
|
|
|
2025-01-22 23:04:36 +01:00
|
|
|
% Plot phase psi
|
|
|
|
nexttile; % Equivalent to subplot('Position', [0.36, 0.55, 0.28, 0.4]);
|
|
|
|
plotxy = pcolor(x, y, angle(psi)');
|
|
|
|
set(plotxy, 'EdgeColor', 'none');
|
|
|
|
cbar2 = colorbar;
|
|
|
|
cbar2.Label.Interpreter = 'latex';
|
2025-01-23 01:19:31 +01:00
|
|
|
colormap(gca, 'hsv')
|
2025-01-22 23:04:36 +01:00
|
|
|
clim([-pi,pi])
|
|
|
|
ylabel(cbar2,'$\phi$','FontSize',16,'Rotation',270)
|
|
|
|
xlabel('$x$ ($\mu$m)', 'Interpreter', 'latex', 'FontSize', 14)
|
|
|
|
ylabel('$y$ ($\mu$m)', 'Interpreter', 'latex', 'FontSize', 14)
|
|
|
|
title('Phase', 'FontSize', 14);
|
2024-11-14 15:03:38 +01:00
|
|
|
|
|
|
|
% Plot residual (time steps vs -log10(residual))
|
2025-01-22 23:04:36 +01:00
|
|
|
nexttile; % Equivalent to subplot('Position', [0.67, 0.55, 0.28, 0.4])
|
2024-11-14 15:03:38 +01:00
|
|
|
plot(-log10(Observ.residual), '-b')
|
|
|
|
ylabel('$-\mathrm{log}_{10}(r)$', 'FontSize', 14); xlabel('Time steps', 'FontSize', 14);
|
|
|
|
title('Residual', 'FontSize', 14);
|
2025-01-22 23:04:36 +01:00
|
|
|
grid on
|
2024-11-14 15:03:38 +01:00
|
|
|
|
|
|
|
% Plot total energy over time
|
2025-01-22 23:04:36 +01:00
|
|
|
nexttile; % Equivalent to subplot('Position', [0.05, 0.05, 0.26, 0.4]);
|
2024-11-14 15:03:38 +01:00
|
|
|
plot(Observ.EVec, '-b')
|
|
|
|
ylabel('$E$', 'FontSize', 14); xlabel('Time steps', 'FontSize', 14);
|
|
|
|
title('Total Energy', 'FontSize', 14);
|
2025-01-22 23:04:36 +01:00
|
|
|
grid on
|
2024-11-14 15:03:38 +01:00
|
|
|
|
|
|
|
% Plot chemical potential over time
|
2025-01-22 23:04:36 +01:00
|
|
|
nexttile; % Equivalent to subplot('Position', [0.36, 0.05, 0.26, 0.4]);
|
2024-11-14 15:03:38 +01:00
|
|
|
plot(Observ.mucVec, '-b')
|
|
|
|
ylabel('$\mu$', 'FontSize', 14); xlabel('Time steps', 'FontSize', 14);
|
|
|
|
title('Chemical Potential', 'FontSize', 14);
|
2025-01-22 23:04:36 +01:00
|
|
|
grid on
|
|
|
|
|
|
|
|
% Plot variational width
|
|
|
|
nexttile; % Equivalent to subplot('Position', [0.67, 0.05, 0.26, 0.4]);
|
|
|
|
plot(VParams.ells,VParams.E_vs_iter,'LineStyle','none','Marker','o','MarkerSize',3,'Color','b','MarkerFaceColor','b')
|
|
|
|
xlabel('$\ell$', 'FontSize', 14)
|
|
|
|
ylabel('$E_{var}$', 'FontSize', 14)
|
|
|
|
title('Variational Energy', 'FontSize', 14);
|
|
|
|
grid on
|
2024-11-14 15:03:38 +01:00
|
|
|
end
|