function plotLive2D(psi, Params, Transf, Observ, vrun) set(0,'defaulttextInterpreter','latex') set(groot, 'defaultAxesTickLabelInterpreter','latex'); set(groot, 'defaultLegendInterpreter','latex'); format long % Axes scaling and coordinates in micrometers x = Transf.x * Params.l0 * 1e6; y = Transf.y * Params.l0 * 1e6; % Compute probability density |psi|^2 nxy = abs(psi).^2; nxyScaled = nxy*(Params.add*10^6)^2; % Plotting figure(1); clf set(gcf, 'Name', ['Variational Run: ', num2str(vrun)]) set(gcf,'Position', [100, 100, 1600, 900]) t = tiledlayout(2, 3, 'TileSpacing', 'compact', 'Padding', 'compact'); % 2x3 grid % Plot |psi(x,y)|^2 (density in x and y plane) nexttile; % Equivalent to subplot('Position', [0.05, 0.55, 0.28, 0.4]); plotxy = pcolor(x,y,nxyScaled'); set(plotxy, 'EdgeColor', 'none'); cbar1 = colorbar; cbar1.Label.Interpreter = 'latex'; colormap('turbo') % clim(ax1,[0.00,0.3]); 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) % 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'; colormap('hsv') 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); % Plot residual (time steps vs -log10(residual)) nexttile; % Equivalent to subplot('Position', [0.67, 0.55, 0.28, 0.4]) plot(-log10(Observ.residual), '-b') ylabel('$-\mathrm{log}_{10}(r)$', 'FontSize', 14); xlabel('Time steps', 'FontSize', 14); title('Residual', 'FontSize', 14); grid on % Plot total energy over time nexttile; % Equivalent to subplot('Position', [0.05, 0.05, 0.26, 0.4]); plot(Observ.EVec, '-b') ylabel('$E_{tot}$', 'FontSize', 14); xlabel('Time steps', 'FontSize', 14); title('Total Energy', 'FontSize', 14); grid on % Plot chemical potential over time nexttile; % Equivalent to subplot('Position', [0.36, 0.05, 0.26, 0.4]); plot(Observ.mucVec, '-b') ylabel('$\mu$', 'FontSize', 14); xlabel('Time steps', 'FontSize', 14); title('Chemical Potential', 'FontSize', 14); grid on % Plot variational width nexttile; % Equivalent to subplot('Position', [0.67, 0.05, 0.26, 0.4]); xlabel('$\ell$', 'FontSize', 14) ylabel('$E_{var}$', 'FontSize', 14) title('Variational Energy', 'FontSize', 14); grid on end