Cosmetic changes/additions, analysis script for variational solver, added save feature for all ells and E_vs_iter.

This commit is contained in:
Karthik 2024-11-19 18:46:47 +01:00
parent fb7c19791c
commit 37de6a6353
5 changed files with 81 additions and 57 deletions

View File

@ -1,50 +0,0 @@
set(0,'defaulttextInterpreter','latex')
set(groot, 'defaultAxesTickLabelInterpreter','latex'); set(groot, 'defaultLegendInterpreter','latex');
format long
runIdx = 6;
load(sprintf('./Data/Run_%03i/psi_gs.mat',runIdx),'psi','muchem','Observ','t_idx','Transf','Params','VDk','V');
x = Transf.x*Params.l0*1e6;
y = Transf.y*Params.l0*1e6;
z = Transf.z*Params.l0*1e6;
%percentcomplete = linspace(0,1,Params.cut_off/200);
dx = x(2)-x(1); dy = y(2)-y(1); dz = z(2)-z(1);
%Plotting
subplot(2,3,1)
n = abs(psi).^2;
nxz = squeeze(trapz(n*dy,2));
nyz = squeeze(trapz(n*dx,1));
nxy = squeeze(trapz(n*dz,3));
plotxz = pcolor(x,z,nxz');
set(plotxz, 'EdgeColor', 'none');
xlabel('$x$ [$\mu$m]'); ylabel('$z$ [$\mu$m]');
subplot(2,3,2)
plotyz = pcolor(y,z,nyz');
set(plotyz, 'EdgeColor', 'none');
xlabel('$y$ [$\mu$m]'); ylabel('$z$ [$\mu$m]');
subplot(2,3,3)
plotxy = pcolor(x,y,nxy');
set(plotxy, 'EdgeColor', 'none');
xlabel('$x$ [$\mu$m]'); ylabel('$y$ [$\mu$m]');
subplot(2,3,4)
plot(-log10(Observ.residual),'-b')
ylabel('$-\mathrm{log}_{10}(r)$'); xlabel('steps');
subplot(2,3,5)
plot(Observ.EVec,'-b')
ylabel('$E$'); xlabel('steps');
subplot(2,3,6)
plot(Observ.mucVec,'-b')
ylabel('$\mu$'); xlabel('steps');
% xlim([0,1]); ylim([0,8]);
% xlim([0,1]); ylim([0,8]);
Ecomp = energy_components(psi,Params,Transf,VDk,V);

View File

@ -0,0 +1,72 @@
function analyzeRun2D(run_index)
set(0,'defaulttextInterpreter','latex')
set(groot, 'defaultAxesTickLabelInterpreter','latex'); set(groot, 'defaultLegendInterpreter','latex');
folder_path = './Data';
% Load data
Data = load(sprintf(horzcat(folder_path, '/Run_%03i/psi_gs.mat'),run_index),'psi','Observ','Transf','Params','VParams');
Params = Data.Params;
Transf = Data.Transf;
Observ = Data.Observ;
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
% Compute probability density |psi|^2
n = abs(psi).^2;
% Plot |psi(x,y)|^2 (density in x and y plane)
subplot('Position', [0.05, 0.55, 0.28, 0.4])
pcolor(x, y, n');
shading interp;
colorbar;
xlabel('$x$ [$\mu$m]', 'FontSize', 14); ylabel('$y$ [$\mu$m]', 'FontSize', 14);
title('$|\Psi_{xy}|^2$', 'FontSize', 14);
% Plot residual (time steps vs -log10(residual))
subplot('Position', [0.36, 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);
% Plot total energy over time
subplot('Position', [0.67, 0.55, 0.28, 0.4])
plot(Observ.EVec, '-b')
ylabel('$E$', 'FontSize', 14); xlabel('Time steps', 'FontSize', 14);
title('Total Energy', 'FontSize', 14);
% Plot chemical potential over time
subplot('Position', [0.05, 0.05, 0.26, 0.4]);
subplot('Position', [0.67, 0.05, 0.26, 0.4]);
plot(Observ.mucVec, '-b')
ylabel('$\mu$', 'FontSize', 14); xlabel('Time steps', 'FontSize', 14);
title('Chemical Potential', 'FontSize', 14);
subplot('Position', [0.36, 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);
end

View File

@ -51,16 +51,15 @@ Plotter.visualizeGSWavefunction(Params.njob)
%%
% To reproduce results from the Blair Blakie paper:
% (n*add^2, as/add)
% Critical point: (0.0978, 0.784); Triangular phase: (0.0959, 0.750); Stripe phase: (0.144, 0.765); Honeycomb phase: (0.192, 0.780)
% N = ((nadd^2)/Params.add^2) * (Params.Lx *1E-6)^2
% N = ((n*add^2)/Params.add^2) * (Params.Lx *1E-6)^2
% Critical point: N = 2.0427e+07; Triangular phase: N = 2.0030e+07; Stripe phase: N = 3.0077e+07; Honeycomb phase: N = 4.0102e+07 for dimensions fixed to 100
% as = ((as/add)*Params.add)/Params.a0
% Critical point: 102.5133; Triangular phase: 98.0676; Stripe phase: 100.0289; Honeycomb phase: 101.9903
%% - Create Variational2D and Calculator object with specified options
OptionsStruct = struct;

View File

@ -1,16 +1,15 @@
%%
% To reproduce results from the Blair Blakie paper:
% (n*add^2, as/add)
% Critical point: (0.0978, 0.784); Triangular phase: (0.0959, 0.750); Stripe phase: (0.144, 0.765); Honeycomb phase: (0.192, 0.780)
% N = ((nadd^2)/Params.add^2) * (Params.Lx *1E-6)^2
% N = ((n*add^2)/Params.add^2) * (Params.Lx *1E-6)^2
% Critical point: N = 2.0427e+07; Triangular phase: N = 2.0030e+07; Stripe phase: N = 3.0077e+07; Honeycomb phase: N = 4.0102e+07 for dimensions fixed to 100
% as = ((as/add)*Params.add)/Params.a0
% Critical point: 102.5133; Triangular phase: 98.0676; Stripe phase: 100.0289; Honeycomb phase: 101.9903
%% - Create Variational2D and Calculator object with specified options
OptionsStruct = struct;

View File

@ -59,7 +59,7 @@ function [Params, Transf, psi, V, VDk] = run(this)
ells = [ells VParams.ell];
relelldiff = abs(ells(nn+1)-ells(nn))/ells(nn);
E_vs_iter = [E_vs_iter E_Var(VParams.ell)];
save(sprintf(strcat(this.SaveDirectory, '/Run_%03i/psi_gs_%i.mat'),Params.njob),'psi','Observ','Transf','Params','VDk','V','VParams');
%Plotting
@ -76,6 +76,10 @@ function [Params, Transf, psi, V, VDk] = run(this)
break
end
end
VParams.ells = ells;
VParams.E_vs_iter = E_vs_iter;
fprintf('\n')
disp('Saving data...');
save(sprintf(strcat(this.SaveDirectory, '/Run_%03i/psi_gs.mat'),Params.njob),'psi','Observ','Transf','Params','VDk','V','VParams');