Calculations/Dipolar-Gas-Simulator/+Plotter/visualizeWavefunction2D.m

41 lines
1.2 KiB
Mathematica
Raw Permalink Normal View History

function visualizeWavefunction2D(psi, Params, Transf)
set(0,'defaulttextInterpreter','latex')
set(groot, 'defaultAxesTickLabelInterpreter','latex'); set(groot, 'defaultLegendInterpreter','latex');
format long
height = 10;
width = 30;
figure(1)
clf
set(gcf, 'Units', 'centimeters')
set(gcf, 'Position', [2 8 width height])
set(gcf, 'PaperPositionMode', 'auto')
% Axes scaling and coordinates in micrometers
x = Transf.x * Params.l0 * 1e6;
y = Transf.y * Params.l0 * 1e6;
% Compute probability density |psi|^2
n = abs(psi).^2;
% Plot |psi(x,y)|^2
subplot(1, 2, 1)
pcolor(x, y, n')
shading interp; % Smooth shading
colorbar; % Show color bar
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 real part of psi
subplot(1, 2, 2)
pcolor(x, y, real(psi)')
shading interp;
colorbar;
xlabel('$x$ ($\mu$m)', 'Interpreter', 'latex', 'FontSize', 14)
ylabel('$y$ ($\mu$m)', 'Interpreter', 'latex', 'FontSize', 14)
title('Re$\{\Psi(x,y)\}$', 'Interpreter', 'latex', 'FontSize', 14)
end