Script to analyse the results of system size scan added.

This commit is contained in:
Karthik 2025-02-12 02:14:19 +01:00
parent a3b42649a8
commit 7f2dac17b8
3 changed files with 73 additions and 1 deletions

View File

@ -0,0 +1,66 @@
function MinEnergyDataArray = analyzeGSWavefunction_optimal_system_size(folder_path, Lx_Range, Ly_Range)
% Initialize matrix to store [Lx, Ly, minEnergy]
MinEnergyDataArray = [];
% Get a list of all subfolders in the parent folder
subfolders = dir(fullfile(folder_path, 'Run_*'));
% Loop through each subfolder
for i = 1:length(subfolders)
% Get the full path of the current subfolder
subfolder_path = fullfile(subfolders(i).folder, subfolders(i).name);
% Check if the current item is a folder
if subfolders(i).isdir
% Load the data file from the current folder
data_file = fullfile(subfolder_path, 'psi_gs.mat');
if isfile(data_file)
% Load required variables from the .mat file
Data = load(data_file, 'Params', 'VParams');
% Extract Lx and Ly from Params.Dimensions
Lx = Data.Params.Lx;
Ly = Data.Params.Ly;
% Extract the minimum energy from VParams.E_vs_iter
minEnergy = min(gather(Data.VParams.E_vs_iter));
% Append [Lx, Ly, minEnergy] to the results array
MinEnergyDataArray(end + 1, :) = [Lx, Ly, minEnergy];
else
fprintf('Warning: File psi_gs.mat not found in %s\n', subfolder_path);
end
end
end
% Initialize a padded matrix with zeros
paddedMatrix = zeros(length(Lx_Range), length(Ly_Range));
% Map Lx and Ly values from minEnergyData into paddedMatrix
for i = 1:size(MinEnergyDataArray, 1)
Lx = MinEnergyDataArray(i, 1);
Ly = MinEnergyDataArray(i, 2);
energy = MinEnergyDataArray(i, 3);
% Find indices in the padded matrix corresponding to Lx and Ly
Lx_idx = find(Lx_Range == Lx);
Ly_idx = find(Ly_Range == Ly);
% Assign the energy value to the appropriate position in the matrix
paddedMatrix(Lx_idx, Ly_idx) = energy;
end
figure
clf
set(gcf,'Position',[50 50 950 750])
imagesc(Lx_Range, Ly_Range, paddedMatrix');
hold on
set(gca, 'YDir', 'normal'); % Correct the y-axis direction
cbar1 = colorbar;
cbar1.Label.Interpreter = 'latex';
ylabel(cbar1,'$E_{var}$','FontSize',16,'Rotation',270)
xlabel('$L_x$','fontsize',16,'interpreter','latex');
ylabel('$L_y$','fontsize',16,'interpreter','latex');
title('Variational energy for different system sizes', 'FontSize', 16);
end

View File

@ -320,4 +320,10 @@ JobNumber = 0;
SaveDirectory = './Results/Data_TiltingOfDipoles/HarmonicTrap/Hz2000'; SaveDirectory = './Results/Data_TiltingOfDipoles/HarmonicTrap/Hz2000';
JobNumber = 0; JobNumber = 0;
% Plotter.visualizeGSWavefunction2D(SaveDirectory, JobNumber) % Plotter.visualizeGSWavefunction2D(SaveDirectory, JobNumber)
[contrast, period_X, period_Y] = Scripts.analyzeGSWavefunction_in_plane_trap(SaveDirectory, JobNumber); [contrast, period_X, period_Y] = Scripts.analyzeGSWavefunction_in_plane_trap(SaveDirectory, JobNumber);
%%
SaveDirectory = './Results/Data_TiltingOfDipoles/TransitionAngle/OptimalSystemSize/Hz500/Degree5';
% Define the desired range for Lx and Ly
Lx_Range = 5:10; % Extend Lx from 5 to 10
Ly_Range = 5:10; % Extend Ly from 5 to 10
MinEnergyDataArray = Scripts.analyzeGSWavefunction_optimal_system_size(SaveDirectory, Lx_Range, Ly_Range);