From 7f2dac17b84d59eac7aabfb47622f7576c9b22f5 Mon Sep 17 00:00:00 2001 From: Karthik Chandrashekara Date: Wed, 12 Feb 2025 02:14:19 +0100 Subject: [PATCH] Script to analyse the results of system size scan added. --- ...nalyzeGSWavefunction_optimal_system_size.m | 66 +++++++++++++++++++ Dipolar-Gas-Simulator/+Scripts/run_locally.m | 8 ++- ...m => run_on_cluster_optimal_system_size.m} | 0 3 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 Dipolar-Gas-Simulator/+Scripts/analyzeGSWavefunction_optimal_system_size.m rename Dipolar-Gas-Simulator/+Scripts/{run_on_cluster_determine_system_size.m => run_on_cluster_optimal_system_size.m} (100%) diff --git a/Dipolar-Gas-Simulator/+Scripts/analyzeGSWavefunction_optimal_system_size.m b/Dipolar-Gas-Simulator/+Scripts/analyzeGSWavefunction_optimal_system_size.m new file mode 100644 index 0000000..ff03213 --- /dev/null +++ b/Dipolar-Gas-Simulator/+Scripts/analyzeGSWavefunction_optimal_system_size.m @@ -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 diff --git a/Dipolar-Gas-Simulator/+Scripts/run_locally.m b/Dipolar-Gas-Simulator/+Scripts/run_locally.m index fd1980d..eb27950 100644 --- a/Dipolar-Gas-Simulator/+Scripts/run_locally.m +++ b/Dipolar-Gas-Simulator/+Scripts/run_locally.m @@ -320,4 +320,10 @@ JobNumber = 0; SaveDirectory = './Results/Data_TiltingOfDipoles/HarmonicTrap/Hz2000'; JobNumber = 0; % Plotter.visualizeGSWavefunction2D(SaveDirectory, JobNumber) -[contrast, period_X, period_Y] = Scripts.analyzeGSWavefunction_in_plane_trap(SaveDirectory, JobNumber); \ No newline at end of file +[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); \ No newline at end of file diff --git a/Dipolar-Gas-Simulator/+Scripts/run_on_cluster_determine_system_size.m b/Dipolar-Gas-Simulator/+Scripts/run_on_cluster_optimal_system_size.m similarity index 100% rename from Dipolar-Gas-Simulator/+Scripts/run_on_cluster_determine_system_size.m rename to Dipolar-Gas-Simulator/+Scripts/run_on_cluster_optimal_system_size.m