From 95781545d421f0f7978cf3dc8d2189f0809fc90b Mon Sep 17 00:00:00 2001 From: Karthik Chandrashekara Date: Wed, 26 Mar 2025 13:57:24 +0100 Subject: [PATCH] Latest scripts for the 2D variational solver. --- .../+Scripts/analyzeGSWavefunction.m | 48 +-- ...function_constrained_optimal_system_size.m | 2 +- Dipolar-Gas-Simulator/+Scripts/run_locally.m | 80 +++-- .../+Scripts/run_on_cluster.m | 298 ++++++++++++++---- .../run_on_cluster_adjusted_system_size.m | 128 +++++++- .../run_on_cluster_optimal_system_size.m | 74 +++++ .../@DipolarGas/setupCosineModulatedAnsatz.m | 4 +- 7 files changed, 508 insertions(+), 126 deletions(-) diff --git a/Dipolar-Gas-Simulator/+Scripts/analyzeGSWavefunction.m b/Dipolar-Gas-Simulator/+Scripts/analyzeGSWavefunction.m index 5ca1071..bc09337 100644 --- a/Dipolar-Gas-Simulator/+Scripts/analyzeGSWavefunction.m +++ b/Dipolar-Gas-Simulator/+Scripts/analyzeGSWavefunction.m @@ -1,5 +1,11 @@ -function [contrast, periodX, periodY] = analyzeGSWavefunction(folder_path, run_index) +function [contrast, periodX, periodY] = analyzeGSWavefunction(folder_path, run_index, LatticePropertyDisplayFlag) + arguments + folder_path (1,:) char + run_index (1,:) {mustBeNumeric,mustBeReal} + LatticePropertyDisplayFlag (1,:) logical = true + end + set(0,'defaulttextInterpreter','latex') set(groot, 'defaultAxesTickLabelInterpreter','latex'); set(groot, 'defaultLegendInterpreter','latex'); @@ -73,25 +79,27 @@ function [contrast, periodX, periodY] = analyzeGSWavefunction(folder_path, run_i colormap(gca, Helper.Colormaps.plasma()) % clim(ax1,[0.00,0.3]); - % Define normalized positions (relative to axis limits) - x_offset = 0.025; % 5% offset from the edges - y_offset = 0.025; % 5% offset from the edges - - % Top-left corner (normalized axis coordinates) - text(0 + x_offset, 1 - y_offset, lattice_type, ... - 'Color', 'white', 'FontWeight', 'bold', 'Interpreter', 'tex', 'FontSize', 30, 'Units', 'normalized', 'HorizontalAlignment', 'left', 'VerticalAlignment', 'top'); - - % Top-right corner (normalized axis coordinates) - text(1 - x_offset, 1 - y_offset, ['C: ', num2str(contrast, '%.3f')], ... - 'Color', 'white', 'FontWeight', 'bold', 'Interpreter', 'tex', 'FontSize', 30, 'Units', 'normalized', 'HorizontalAlignment', 'right', 'VerticalAlignment', 'top'); - - % Bottom-left corner (normalized axis coordinates) - text(0 + x_offset, 0 + y_offset, ['dx: ', num2str(periodX, '%.2f'), ' \mum'], ... - 'Color', 'white', 'FontWeight', 'bold', 'Interpreter', 'tex', 'FontSize', 30, 'Units', 'normalized', 'HorizontalAlignment', 'left', 'VerticalAlignment', 'bottom'); - - % Bottom-right corner (normalized axis coordinates) - text(1 - x_offset, 0 + y_offset, ['dy: ', num2str(periodY, '%.2f'), ' \mum'], ... - 'Color', 'white', 'FontWeight', 'bold', 'Interpreter', 'tex', 'FontSize', 30, 'Units', 'normalized', 'HorizontalAlignment', 'right', 'VerticalAlignment', 'bottom'); + if LatticePropertyDisplayFlag + % Define normalized positions (relative to axis limits) + x_offset = 0.025; % 5% offset from the edges + y_offset = 0.025; % 5% offset from the edges + + % Top-left corner (normalized axis coordinates) + text(0 + x_offset, 1 - y_offset, lattice_type, ... + 'Color', 'white', 'FontWeight', 'bold', 'Interpreter', 'tex', 'FontSize', 30, 'Units', 'normalized', 'HorizontalAlignment', 'left', 'VerticalAlignment', 'top'); + + % Top-right corner (normalized axis coordinates) + text(1 - x_offset, 1 - y_offset, ['C: ', num2str(contrast, '%.3f')], ... + 'Color', 'white', 'FontWeight', 'bold', 'Interpreter', 'tex', 'FontSize', 30, 'Units', 'normalized', 'HorizontalAlignment', 'right', 'VerticalAlignment', 'top'); + + % Bottom-left corner (normalized axis coordinates) + text(0 + x_offset, 0 + y_offset, ['dx: ', num2str(periodX, '%.2f'), ' \mum'], ... + 'Color', 'white', 'FontWeight', 'bold', 'Interpreter', 'tex', 'FontSize', 30, 'Units', 'normalized', 'HorizontalAlignment', 'left', 'VerticalAlignment', 'bottom'); + + % Bottom-right corner (normalized axis coordinates) + text(1 - x_offset, 0 + y_offset, ['dy: ', num2str(periodY, '%.2f'), ' \mum'], ... + 'Color', 'white', 'FontWeight', 'bold', 'Interpreter', 'tex', 'FontSize', 30, 'Units', 'normalized', 'HorizontalAlignment', 'right', 'VerticalAlignment', 'bottom'); + end ylabel(cbar1,'$na_{dd}^2$','FontSize',16,'Rotation',270) xlabel('$x$ ($\mu$m)', 'Interpreter', 'latex', 'FontSize', 14) diff --git a/Dipolar-Gas-Simulator/+Scripts/analyzeGSWavefunction_constrained_optimal_system_size.m b/Dipolar-Gas-Simulator/+Scripts/analyzeGSWavefunction_constrained_optimal_system_size.m index 9ac2427..abda805 100644 --- a/Dipolar-Gas-Simulator/+Scripts/analyzeGSWavefunction_constrained_optimal_system_size.m +++ b/Dipolar-Gas-Simulator/+Scripts/analyzeGSWavefunction_constrained_optimal_system_size.m @@ -70,7 +70,7 @@ function MinEnergyDataArray = analyzeGSWavefunction_constrained_optimal_system_s clf set(gcf,'Position',[50 50 950 750]) set(gca,'FontSize',16,'Box','On','Linewidth',2); - plot(LatticeSpacing, MinEnergyDataValues, Marker = "o", LineWidth=2.0); + plot(LatticeSpacing, MinEnergyDataValues, LineStyle='none', Marker = "o", MarkerFaceColor= "b", MarkerEdgeColor="none", LineWidth=2.0); xlim([min(LatticeSpacing) max(LatticeSpacing)]) xlabel('$a$','fontsize',16,'interpreter','latex'); ylabel('$E_{var}$','fontsize',16,'interpreter','latex'); diff --git a/Dipolar-Gas-Simulator/+Scripts/run_locally.m b/Dipolar-Gas-Simulator/+Scripts/run_locally.m index 444987f..c490ca7 100644 --- a/Dipolar-Gas-Simulator/+Scripts/run_locally.m +++ b/Dipolar-Gas-Simulator/+Scripts/run_locally.m @@ -251,8 +251,8 @@ Plotter.visualizeGSWavefunction2D(SaveDirectory, JobNumber) %% - Analysis SaveDirectory = './Results/Data_TiltingOfDipoles/AdjustedSystemSize/Hz500'; -JobNumber = 1; -% Plotter.visualizeGSWavefunction2D(SaveDirectory, JobNumber) +JobNumber = 2; +Plotter.visualizeGSWavefunction2D(SaveDirectory, JobNumber) [contrast, period_X, period_Y] = Scripts.analyzeGSWavefunction(SaveDirectory, JobNumber); %% - Analysis @@ -333,40 +333,64 @@ Ly_Range = 4:0.2:6; % Extend Ly from 5 to 10 MinEnergyDataArray = Scripts.analyzeGSWavefunction_optimal_system_size(SaveDirectory, Lx_Range, Ly_Range); %% -SaveDirectory = './Results/Data_TiltingOfDipoles/TransitionAngle/OptimalSystemSize/Hz500/Degree0'; +% SaveDirectory = './Results/Data_TiltingOfDipoles/TransitionAngle/OptimalSystemSize/Hz500/Degree0'; +SaveDirectory = './Results/Data_TiltingOfDipoles/TransitionAngle/OptimalSystemSizeWithBiasAnsatz/Hz500/Degree0'; % Define the desired range -LatticeSpacing = 1.0:0.05:4.0; +% LatticeSpacing = 1.0:0.05:4.0; +LatticeSpacing = linspace(1.6,2.25,61); MinEnergyDataArray = Scripts.analyzeGSWavefunction_constrained_optimal_system_size(SaveDirectory, LatticeSpacing); -% Plotter.visualizeGSWavefunction2D(SaveDirectory, 17) -% [contrast, periodX, periodY] = Scripts.analyzeGSWavefunction(SaveDirectory, 17); +[val, idx] = min(MinEnergyDataArray(:,3)); +OptimalSize = MinEnergyDataArray(idx,1:2); +Plotter.visualizeGSWavefunction2D(SaveDirectory, idx) +[contrast, periodX, periodY] = Scripts.analyzeGSWavefunction(SaveDirectory, idx, false); %% -SaveDirectory = './Results/Data_TiltingOfDipoles/TransitionAngle/OptimalSystemSize/Hz500/Degree5'; +% SaveDirectory = './Results/Data_TiltingOfDipoles/TransitionAngle/OptimalSystemSize/Hz500/Degree5'; +SaveDirectory = './Results/Data_TiltingOfDipoles/TransitionAngle/OptimalSystemSizeWithBiasAnsatz/Hz500/Degree5'; % Define the desired range -LatticeSpacing = 1.0:0.05:4.0; -% MinEnergyDataArray = Scripts.analyzeGSWavefunction_constrained_optimal_system_size(SaveDirectory, LatticeSpacing); -% Plotter.visualizeGSWavefunction2D(SaveDirectory, 17) -[contrast, periodX, periodY] = Scripts.analyzeGSWavefunction(SaveDirectory, 17); -%% -SaveDirectory = './Results/Data_TiltingOfDipoles/TransitionAngle/OptimalSystemSize/Hz500/Degree7_5'; -% Define the desired range -LatticeSpacing = 1.0:0.05:4.0; -% MinEnergyDataArray = Scripts.analyzeGSWavefunction_constrained_optimal_system_size(SaveDirectory, LatticeSpacing); -% Plotter.visualizeGSWavefunction2D(SaveDirectory, 17) -[contrast, periodX, periodY] = Scripts.analyzeGSWavefunction(SaveDirectory, 17); -%% -SaveDirectory = './Results/Data_TiltingOfDipoles/TransitionAngle/OptimalSystemSize/Hz500/Degree10'; -% Define the desired range -LatticeSpacing = 1.0:0.05:4.0; +% LatticeSpacing = 1.0:0.05:4.0; +LatticeSpacing = linspace(1.6,2.25,61); MinEnergyDataArray = Scripts.analyzeGSWavefunction_constrained_optimal_system_size(SaveDirectory, LatticeSpacing); -% Plotter.visualizeGSWavefunction2D(SaveDirectory, 17) -[contrast, periodX, periodY] = Scripts.analyzeGSWavefunction(SaveDirectory, 22); +[val, idx] = min(MinEnergyDataArray(:,3)); +OptimalSize = MinEnergyDataArray(idx,1:2); +Plotter.visualizeGSWavefunction2D(SaveDirectory, idx) +[contrast, periodX, periodY] = Scripts.analyzeGSWavefunction(SaveDirectory, idx, false); + %% -SaveDirectory = './Results/Data_TiltingOfDipoles/TransitionAngle/OptimalSystemSize/Hz500/Degree15'; +% SaveDirectory = './Results/Data_TiltingOfDipoles/TransitionAngle/OptimalSystemSize/Hz500/Degree7_5'; +SaveDirectory = './Results/Data_TiltingOfDipoles/TransitionAngle/OptimalSystemSizeWithBiasAnsatz/Hz500/Degree7_5'; % Define the desired range -LatticeSpacing = 1.0:0.05:4.0; +% LatticeSpacing = 1.0:0.05:4.0; +LatticeSpacing = linspace(1.6,2.25,61); MinEnergyDataArray = Scripts.analyzeGSWavefunction_constrained_optimal_system_size(SaveDirectory, LatticeSpacing); -% Plotter.visualizeGSWavefunction2D(SaveDirectory, 17) -% [contrast, periodX, periodY] = Scripts.analyzeGSWavefunction(SaveDirectory, 22); +[val, idx] = min(MinEnergyDataArray(:,3)); +OptimalSize = MinEnergyDataArray(idx,1:2); +Plotter.visualizeGSWavefunction2D(SaveDirectory, idx) +[contrast, periodX, periodY] = Scripts.analyzeGSWavefunction(SaveDirectory, idx, false); + +%% +% SaveDirectory = './Results/Data_TiltingOfDipoles/TransitionAngle/OptimalSystemSize/Hz500/Degree10'; +SaveDirectory = './Results/Data_TiltingOfDipoles/TransitionAngle/OptimalSystemSizeWithBiasAnsatz/Hz500/Degree10'; +% Define the desired range +% LatticeSpacing = 1.0:0.05:4.0; +LatticeSpacing = linspace(1.6,2.25,61); +MinEnergyDataArray = Scripts.analyzeGSWavefunction_constrained_optimal_system_size(SaveDirectory, LatticeSpacing); +[val, idx] = min(MinEnergyDataArray(:,3)); +OptimalSize = MinEnergyDataArray(idx,1:2); +Plotter.visualizeGSWavefunction2D(SaveDirectory, idx) +[contrast, periodX, periodY] = Scripts.analyzeGSWavefunction(SaveDirectory, idx, false); + +%% +% SaveDirectory = './Results/Data_TiltingOfDipoles/TransitionAngle/OptimalSystemSize/Hz500/Degree15'; +SaveDirectory = './Results/Data_TiltingOfDipoles/TransitionAngle/OptimalSystemSizeWithBiasAnsatz/Hz500/Degree15'; +% Define the desired range +% LatticeSpacing = 1.0:0.05:4.0; +LatticeSpacing = linspace(1.6,2.25,61); +MinEnergyDataArray = Scripts.analyzeGSWavefunction_constrained_optimal_system_size(SaveDirectory, LatticeSpacing); +[val, idx] = min(MinEnergyDataArray(:,3)); +OptimalSize = MinEnergyDataArray(idx,1:2); +Plotter.visualizeGSWavefunction2D(SaveDirectory, idx) +[contrast, periodX, periodY] = Scripts.analyzeGSWavefunction(SaveDirectory, idx, false); + %% - Analysis SaveDirectory = './Results/Data_TiltingOfDipoles/HarmonicTrap/AspectRatio/AR2_8'; JobNumber = 0; % 79 diff --git a/Dipolar-Gas-Simulator/+Scripts/run_on_cluster.m b/Dipolar-Gas-Simulator/+Scripts/run_on_cluster.m index 1cb045f..1cde2e6 100644 --- a/Dipolar-Gas-Simulator/+Scripts/run_on_cluster.m +++ b/Dipolar-Gas-Simulator/+Scripts/run_on_cluster.m @@ -1,76 +1,254 @@ %% Tilting of the dipoles +% Atom Number = 1250 ppum +% System size = [sf * unitcell_x, sf * unitcell_x] ppum = 1250; % Atom Number Density in per micrometers -%% theta = 0 +%% v_z = 500, theta = 0: a_s = 75.00 -LatticeSpacing = 1.0:0.05:4.0; -totalIterations = numel(LatticeSpacing); +a = 1.8058; +scalingfactor = 5; +lx = scalingfactor*a; +ly = scalingfactor*sqrt(3)*a; -% create a local cluster object -cluster = parcluster('local'); +% Initialize OptionsStruct +OptionsStruct = struct; -% get the number of dedicated cores from environment -nprocs = str2num(getenv('SLURM_NPROCS')); +% Assign values to OptionsStruct +OptionsStruct.NumberOfAtoms = ppum * (lx*ly); +OptionsStruct.DipolarPolarAngle = deg2rad(0); +OptionsStruct.DipolarAzimuthAngle = 0; +OptionsStruct.ScatteringLength = 75.00; -% you may explicitly set the JobStorageLocation to the tmp directory that is unique to each cluster job (and is on local, fast scratch) -parpool_tmpdir = [getenv('TMP'),'/.matlab/local_cluster_jobs/slurm_jobID_',getenv('SLURM_JOB_ID')]; -mkdir(parpool_tmpdir); -cluster.JobStorageLocation = parpool_tmpdir; +OptionsStruct.TrapFrequencies = [0, 0, 500]; +OptionsStruct.TrapPotentialType = 'None'; -% start the parallel pool -parpool(cluster, nprocs) +OptionsStruct.NumberOfGridPoints = [128, 128]; +OptionsStruct.Dimensions = [lx, ly]; +OptionsStruct.TimeStepSize = 1E-3; % in s +OptionsStruct.MinimumTimeStepSize = 1E-5; % in s +OptionsStruct.TimeCutOff = 2E6; % in s +OptionsStruct.EnergyTolerance = 5E-10; +OptionsStruct.ResidualTolerance = 1E-05; +OptionsStruct.NoiseScaleFactor = 0.05; +OptionsStruct.IncludeDDICutOff = false; -% Parallel loop over all combinations of i, j -parfor (k = 1:totalIterations, cluster) - - a = LatticeSpacing(k); - lx = a; - ly = sqrt(3)*a; - - % Initialize OptionsStruct - OptionsStruct = struct; +OptionsStruct.MaxIterations = 10; +OptionsStruct.VariationalWidth = 1.15; +OptionsStruct.WidthLowerBound = 0.01; +OptionsStruct.WidthUpperBound = 12; +OptionsStruct.WidthCutoff = 1e-2; - % Assign values to OptionsStruct - OptionsStruct.NumberOfAtoms = ppum * (lx*ly); - OptionsStruct.DipolarPolarAngle = deg2rad(0); - OptionsStruct.DipolarAzimuthAngle = 0; - OptionsStruct.ScatteringLength = 75.00; +OptionsStruct.PlotLive = false; +OptionsStruct.JobNumber = 0; +OptionsStruct.RunOnGPU = true; +OptionsStruct.SaveData = true; +OptionsStruct.SaveDirectory = './Results/Data_TiltingOfDipoles/AdjustedSystemSize/Hz500'; +options = Helper.convertstruct2cell(OptionsStruct); +clear OptionsStruct - OptionsStruct.TrapFrequencies = [0, 0, 500]; - OptionsStruct.TrapPotentialType = 'None'; +solver = VariationalSolver2D.DipolarGas(options{:}); +pot = VariationalSolver2D.Potentials(options{:}); +solver.Potential = pot.trap(); - OptionsStruct.NumberOfGridPoints = [128, 128]; - OptionsStruct.Dimensions = [lx, ly]; - OptionsStruct.TimeStepSize = 5E-4; % in s - OptionsStruct.MinimumTimeStepSize = 1E-5; % in s - OptionsStruct.TimeCutOff = 2E6; % in s - OptionsStruct.EnergyTolerance = 5E-10; - OptionsStruct.ResidualTolerance = 1E-05; - OptionsStruct.NoiseScaleFactor = 0.05; - OptionsStruct.BiasWithAnsatz = true; - OptionsStruct.Ansatz = 'triangular'; - OptionsStruct.IncludeDDICutOff = false; - - OptionsStruct.MaxIterations = 10; - OptionsStruct.VariationalWidth = 1.10; - OptionsStruct.WidthLowerBound = 0.01; - OptionsStruct.WidthUpperBound = 12; - OptionsStruct.WidthCutoff = 1e-2; +%-% Run Solver %-% +[Params, Transf, psi, V, VDk] = solver.run(); - OptionsStruct.PlotLive = false; - OptionsStruct.JobNumber = k; - OptionsStruct.RunOnGPU = true; - OptionsStruct.SaveData = true; - OptionsStruct.SaveDirectory = sprintf('./Results/Data_TiltingOfDipoles/TransitionAngle/OptimalSystemSize/Hz500/Degree%i', round(rad2deg(OptionsStruct.DipolarPolarAngle))); +%% v_z = 500, theta = 5: a_s = 75.00 - options = Helper.convertstruct2cell(OptionsStruct); - - solver = VariationalSolver2D.DipolarGas(options{:}); - pot = VariationalSolver2D.Potentials(options{:}); - solver.Potential = pot.trap(); +a = 1.795; +scalingfactor = 5; +lx = scalingfactor*a; +ly = scalingfactor*sqrt(3)*a; - % Run Solver - [Params, Transf, psi, V, VDk] = solver.run(); - -end +% Initialize OptionsStruct +OptionsStruct = struct; + +% Assign values to OptionsStruct +OptionsStruct.NumberOfAtoms = ppum * (lx*ly); +OptionsStruct.DipolarPolarAngle = deg2rad(5); +OptionsStruct.DipolarAzimuthAngle = 0; +OptionsStruct.ScatteringLength = 75.00; + +OptionsStruct.TrapFrequencies = [0, 0, 500]; +OptionsStruct.TrapPotentialType = 'None'; + +OptionsStruct.NumberOfGridPoints = [128, 128]; +OptionsStruct.Dimensions = [lx, ly]; +OptionsStruct.TimeStepSize = 1E-3; % in s +OptionsStruct.MinimumTimeStepSize = 1E-5; % in s +OptionsStruct.TimeCutOff = 2E6; % in s +OptionsStruct.EnergyTolerance = 5E-10; +OptionsStruct.ResidualTolerance = 1E-05; +OptionsStruct.NoiseScaleFactor = 0.05; +OptionsStruct.IncludeDDICutOff = false; + +OptionsStruct.MaxIterations = 10; +OptionsStruct.VariationalWidth = 1.15; +OptionsStruct.WidthLowerBound = 0.01; +OptionsStruct.WidthUpperBound = 12; +OptionsStruct.WidthCutoff = 1e-2; + +OptionsStruct.PlotLive = false; +OptionsStruct.JobNumber = 1; +OptionsStruct.RunOnGPU = true; +OptionsStruct.SaveData = true; +OptionsStruct.SaveDirectory = './Results/Data_TiltingOfDipoles/AdjustedSystemSize/Hz500'; +options = Helper.convertstruct2cell(OptionsStruct); +clear OptionsStruct + +solver = VariationalSolver2D.DipolarGas(options{:}); +pot = VariationalSolver2D.Potentials(options{:}); +solver.Potential = pot.trap(); + +%-% Run Solver %-% +[Params, Transf, psi, V, VDk] = solver.run(); + +%% v_z = 500, theta = 7.5: a_s = 75.00 + +a = 2.055; +scalingfactor = 5; +lx = scalingfactor*a; +ly = scalingfactor*sqrt(3)*a; + +% Initialize OptionsStruct +OptionsStruct = struct; + +% Assign values to OptionsStruct +OptionsStruct.NumberOfAtoms = ppum * (lx*ly); +OptionsStruct.DipolarPolarAngle = deg2rad(7.5); +OptionsStruct.DipolarAzimuthAngle = 0; +OptionsStruct.ScatteringLength = 75.00; + +OptionsStruct.TrapFrequencies = [0, 0, 500]; +OptionsStruct.TrapPotentialType = 'None'; + +OptionsStruct.NumberOfGridPoints = [128, 128]; +OptionsStruct.Dimensions = [lx, ly]; +OptionsStruct.TimeStepSize = 1E-3; % in s +OptionsStruct.MinimumTimeStepSize = 1E-5; % in s +OptionsStruct.TimeCutOff = 2E6; % in s +OptionsStruct.EnergyTolerance = 5E-10; +OptionsStruct.ResidualTolerance = 1E-05; +OptionsStruct.NoiseScaleFactor = 0.05; +OptionsStruct.IncludeDDICutOff = false; + +OptionsStruct.MaxIterations = 10; +OptionsStruct.VariationalWidth = 1.15; +OptionsStruct.WidthLowerBound = 0.01; +OptionsStruct.WidthUpperBound = 12; +OptionsStruct.WidthCutoff = 1e-2; + +OptionsStruct.PlotLive = false; +OptionsStruct.JobNumber = 2; +OptionsStruct.RunOnGPU = true; +OptionsStruct.SaveData = true; +OptionsStruct.SaveDirectory = './Results/Data_TiltingOfDipoles/AdjustedSystemSize/Hz500'; +options = Helper.convertstruct2cell(OptionsStruct); +clear OptionsStruct + +solver = VariationalSolver2D.DipolarGas(options{:}); +pot = VariationalSolver2D.Potentials(options{:}); +solver.Potential = pot.trap(); + +%-% Run Solver %-% +[Params, Transf, psi, V, VDk] = solver.run(); +%% v_z = 500, theta = 10: a_s = 75.00 + +a = 2.055; +scalingfactor = 5; +lx = scalingfactor*a; +ly = scalingfactor*sqrt(3)*a; + +% Initialize OptionsStruct +OptionsStruct = struct; + +% Assign values to OptionsStruct +OptionsStruct.NumberOfAtoms = ppum * (lx*ly); +OptionsStruct.DipolarPolarAngle = deg2rad(10); +OptionsStruct.DipolarAzimuthAngle = 0; +OptionsStruct.ScatteringLength = 75.00; + +OptionsStruct.TrapFrequencies = [0, 0, 500]; +OptionsStruct.TrapPotentialType = 'None'; + +OptionsStruct.NumberOfGridPoints = [128, 128]; +OptionsStruct.Dimensions = [lx, ly]; +OptionsStruct.TimeStepSize = 1E-3; % in s +OptionsStruct.MinimumTimeStepSize = 1E-5; % in s +OptionsStruct.TimeCutOff = 2E6; % in s +OptionsStruct.EnergyTolerance = 5E-10; +OptionsStruct.ResidualTolerance = 1E-05; +OptionsStruct.NoiseScaleFactor = 0.05; +OptionsStruct.IncludeDDICutOff = false; + +OptionsStruct.MaxIterations = 10; +OptionsStruct.VariationalWidth = 1.15; +OptionsStruct.WidthLowerBound = 0.01; +OptionsStruct.WidthUpperBound = 12; +OptionsStruct.WidthCutoff = 1e-2; + +OptionsStruct.PlotLive = false; +OptionsStruct.JobNumber = 3; +OptionsStruct.RunOnGPU = true; +OptionsStruct.SaveData = true; +OptionsStruct.SaveDirectory = './Results/Data_TiltingOfDipoles/AdjustedSystemSize/Hz500'; +options = Helper.convertstruct2cell(OptionsStruct); +clear OptionsStruct + +solver = VariationalSolver2D.DipolarGas(options{:}); +pot = VariationalSolver2D.Potentials(options{:}); +solver.Potential = pot.trap(); + +%-% Run Solver %-% +[Params, Transf, psi, V, VDk] = solver.run(); + +%% v_z = 500, theta = 15: a_s = 75.00 + +a = 2.0875; +scalingfactor = 5; +lx = scalingfactor*a; +ly = scalingfactor*sqrt(3)*a; + +% Initialize OptionsStruct +OptionsStruct = struct; + +% Assign values to OptionsStruct +OptionsStruct.NumberOfAtoms = ppum * (lx*ly); +OptionsStruct.DipolarPolarAngle = deg2rad(15); +OptionsStruct.DipolarAzimuthAngle = 0; +OptionsStruct.ScatteringLength = 75.00; + +OptionsStruct.TrapFrequencies = [0, 0, 500]; +OptionsStruct.TrapPotentialType = 'None'; + +OptionsStruct.NumberOfGridPoints = [128, 128]; +OptionsStruct.Dimensions = [lx, ly]; +OptionsStruct.TimeStepSize = 1E-3; % in s +OptionsStruct.MinimumTimeStepSize = 1E-5; % in s +OptionsStruct.TimeCutOff = 2E6; % in s +OptionsStruct.EnergyTolerance = 5E-10; +OptionsStruct.ResidualTolerance = 1E-05; +OptionsStruct.NoiseScaleFactor = 0.05; +OptionsStruct.IncludeDDICutOff = false; + +OptionsStruct.MaxIterations = 10; +OptionsStruct.VariationalWidth = 1.15; +OptionsStruct.WidthLowerBound = 0.01; +OptionsStruct.WidthUpperBound = 12; +OptionsStruct.WidthCutoff = 1e-2; + +OptionsStruct.PlotLive = false; +OptionsStruct.JobNumber = 4; +OptionsStruct.RunOnGPU = true; +OptionsStruct.SaveData = true; +OptionsStruct.SaveDirectory = './Results/Data_TiltingOfDipoles/AdjustedSystemSize/Hz500'; +options = Helper.convertstruct2cell(OptionsStruct); +clear OptionsStruct + +solver = VariationalSolver2D.DipolarGas(options{:}); +pot = VariationalSolver2D.Potentials(options{:}); +solver.Potential = pot.trap(); + +%-% Run Solver %-% +[Params, Transf, psi, V, VDk] = solver.run(); \ No newline at end of file diff --git a/Dipolar-Gas-Simulator/+Scripts/run_on_cluster_adjusted_system_size.m b/Dipolar-Gas-Simulator/+Scripts/run_on_cluster_adjusted_system_size.m index c1ce511..1cde2e6 100644 --- a/Dipolar-Gas-Simulator/+Scripts/run_on_cluster_adjusted_system_size.m +++ b/Dipolar-Gas-Simulator/+Scripts/run_on_cluster_adjusted_system_size.m @@ -4,9 +4,9 @@ ppum = 1250; % Atom Number Density in per micrometers -%% v_z = 500, theta = 0: a_s = 76.00 +%% v_z = 500, theta = 0: a_s = 75.00 -a = 1.8; +a = 1.8058; scalingfactor = 5; lx = scalingfactor*a; ly = scalingfactor*sqrt(3)*a; @@ -18,7 +18,7 @@ OptionsStruct = struct; OptionsStruct.NumberOfAtoms = ppum * (lx*ly); OptionsStruct.DipolarPolarAngle = deg2rad(0); OptionsStruct.DipolarAzimuthAngle = 0; -OptionsStruct.ScatteringLength = 76.00; +OptionsStruct.ScatteringLength = 75.00; OptionsStruct.TrapFrequencies = [0, 0, 500]; OptionsStruct.TrapPotentialType = 'None'; @@ -43,7 +43,7 @@ OptionsStruct.PlotLive = false; OptionsStruct.JobNumber = 0; OptionsStruct.RunOnGPU = true; OptionsStruct.SaveData = true; -OptionsStruct.SaveDirectory = './Results/Data_TiltingOfDipoles/SystemSize100squm/Hz500'; +OptionsStruct.SaveDirectory = './Results/Data_TiltingOfDipoles/AdjustedSystemSize/Hz500'; options = Helper.convertstruct2cell(OptionsStruct); clear OptionsStruct @@ -54,9 +54,59 @@ solver.Potential = pot.trap(); %-% Run Solver %-% [Params, Transf, psi, V, VDk] = solver.run(); -%% v_z = 500, theta = 7.5: a_s = 76.00 +%% v_z = 500, theta = 5: a_s = 75.00 -a = 1.5; +a = 1.795; +scalingfactor = 5; +lx = scalingfactor*a; +ly = scalingfactor*sqrt(3)*a; + +% Initialize OptionsStruct +OptionsStruct = struct; + +% Assign values to OptionsStruct +OptionsStruct.NumberOfAtoms = ppum * (lx*ly); +OptionsStruct.DipolarPolarAngle = deg2rad(5); +OptionsStruct.DipolarAzimuthAngle = 0; +OptionsStruct.ScatteringLength = 75.00; + +OptionsStruct.TrapFrequencies = [0, 0, 500]; +OptionsStruct.TrapPotentialType = 'None'; + +OptionsStruct.NumberOfGridPoints = [128, 128]; +OptionsStruct.Dimensions = [lx, ly]; +OptionsStruct.TimeStepSize = 1E-3; % in s +OptionsStruct.MinimumTimeStepSize = 1E-5; % in s +OptionsStruct.TimeCutOff = 2E6; % in s +OptionsStruct.EnergyTolerance = 5E-10; +OptionsStruct.ResidualTolerance = 1E-05; +OptionsStruct.NoiseScaleFactor = 0.05; +OptionsStruct.IncludeDDICutOff = false; + +OptionsStruct.MaxIterations = 10; +OptionsStruct.VariationalWidth = 1.15; +OptionsStruct.WidthLowerBound = 0.01; +OptionsStruct.WidthUpperBound = 12; +OptionsStruct.WidthCutoff = 1e-2; + +OptionsStruct.PlotLive = false; +OptionsStruct.JobNumber = 1; +OptionsStruct.RunOnGPU = true; +OptionsStruct.SaveData = true; +OptionsStruct.SaveDirectory = './Results/Data_TiltingOfDipoles/AdjustedSystemSize/Hz500'; +options = Helper.convertstruct2cell(OptionsStruct); +clear OptionsStruct + +solver = VariationalSolver2D.DipolarGas(options{:}); +pot = VariationalSolver2D.Potentials(options{:}); +solver.Potential = pot.trap(); + +%-% Run Solver %-% +[Params, Transf, psi, V, VDk] = solver.run(); + +%% v_z = 500, theta = 7.5: a_s = 75.00 + +a = 2.055; scalingfactor = 5; lx = scalingfactor*a; ly = scalingfactor*sqrt(3)*a; @@ -68,7 +118,7 @@ OptionsStruct = struct; OptionsStruct.NumberOfAtoms = ppum * (lx*ly); OptionsStruct.DipolarPolarAngle = deg2rad(7.5); OptionsStruct.DipolarAzimuthAngle = 0; -OptionsStruct.ScatteringLength = 76.00; +OptionsStruct.ScatteringLength = 75.00; OptionsStruct.TrapFrequencies = [0, 0, 500]; OptionsStruct.TrapPotentialType = 'None'; @@ -93,7 +143,56 @@ OptionsStruct.PlotLive = false; OptionsStruct.JobNumber = 2; OptionsStruct.RunOnGPU = true; OptionsStruct.SaveData = true; -OptionsStruct.SaveDirectory = './Results/Data_TiltingOfDipoles/SystemSize100squm/Hz500'; +OptionsStruct.SaveDirectory = './Results/Data_TiltingOfDipoles/AdjustedSystemSize/Hz500'; +options = Helper.convertstruct2cell(OptionsStruct); +clear OptionsStruct + +solver = VariationalSolver2D.DipolarGas(options{:}); +pot = VariationalSolver2D.Potentials(options{:}); +solver.Potential = pot.trap(); + +%-% Run Solver %-% +[Params, Transf, psi, V, VDk] = solver.run(); +%% v_z = 500, theta = 10: a_s = 75.00 + +a = 2.055; +scalingfactor = 5; +lx = scalingfactor*a; +ly = scalingfactor*sqrt(3)*a; + +% Initialize OptionsStruct +OptionsStruct = struct; + +% Assign values to OptionsStruct +OptionsStruct.NumberOfAtoms = ppum * (lx*ly); +OptionsStruct.DipolarPolarAngle = deg2rad(10); +OptionsStruct.DipolarAzimuthAngle = 0; +OptionsStruct.ScatteringLength = 75.00; + +OptionsStruct.TrapFrequencies = [0, 0, 500]; +OptionsStruct.TrapPotentialType = 'None'; + +OptionsStruct.NumberOfGridPoints = [128, 128]; +OptionsStruct.Dimensions = [lx, ly]; +OptionsStruct.TimeStepSize = 1E-3; % in s +OptionsStruct.MinimumTimeStepSize = 1E-5; % in s +OptionsStruct.TimeCutOff = 2E6; % in s +OptionsStruct.EnergyTolerance = 5E-10; +OptionsStruct.ResidualTolerance = 1E-05; +OptionsStruct.NoiseScaleFactor = 0.05; +OptionsStruct.IncludeDDICutOff = false; + +OptionsStruct.MaxIterations = 10; +OptionsStruct.VariationalWidth = 1.15; +OptionsStruct.WidthLowerBound = 0.01; +OptionsStruct.WidthUpperBound = 12; +OptionsStruct.WidthCutoff = 1e-2; + +OptionsStruct.PlotLive = false; +OptionsStruct.JobNumber = 3; +OptionsStruct.RunOnGPU = true; +OptionsStruct.SaveData = true; +OptionsStruct.SaveDirectory = './Results/Data_TiltingOfDipoles/AdjustedSystemSize/Hz500'; options = Helper.convertstruct2cell(OptionsStruct); clear OptionsStruct @@ -104,9 +203,9 @@ solver.Potential = pot.trap(); %-% Run Solver %-% [Params, Transf, psi, V, VDk] = solver.run(); -%% v_z = 500, theta = 15: a_s = 76.00 +%% v_z = 500, theta = 15: a_s = 75.00 -a = 1.05; +a = 2.0875; scalingfactor = 5; lx = scalingfactor*a; ly = scalingfactor*sqrt(3)*a; @@ -118,7 +217,7 @@ OptionsStruct = struct; OptionsStruct.NumberOfAtoms = ppum * (lx*ly); OptionsStruct.DipolarPolarAngle = deg2rad(15); OptionsStruct.DipolarAzimuthAngle = 0; -OptionsStruct.ScatteringLength = 76.00; +OptionsStruct.ScatteringLength = 75.00; OptionsStruct.TrapFrequencies = [0, 0, 500]; OptionsStruct.TrapPotentialType = 'None'; @@ -140,10 +239,10 @@ OptionsStruct.WidthUpperBound = 12; OptionsStruct.WidthCutoff = 1e-2; OptionsStruct.PlotLive = false; -OptionsStruct.JobNumber = 2; +OptionsStruct.JobNumber = 4; OptionsStruct.RunOnGPU = true; OptionsStruct.SaveData = true; -OptionsStruct.SaveDirectory = './Results/Data_TiltingOfDipoles/SystemSize100squm/Hz500'; +OptionsStruct.SaveDirectory = './Results/Data_TiltingOfDipoles/AdjustedSystemSize/Hz500'; options = Helper.convertstruct2cell(OptionsStruct); clear OptionsStruct @@ -152,5 +251,4 @@ pot = VariationalSolver2D.Potentials(options{: solver.Potential = pot.trap(); %-% Run Solver %-% -[Params, Transf, psi, V, VDk] = solver.run(); - +[Params, Transf, psi, V, VDk] = solver.run(); \ No newline at end of file diff --git a/Dipolar-Gas-Simulator/+Scripts/run_on_cluster_optimal_system_size.m b/Dipolar-Gas-Simulator/+Scripts/run_on_cluster_optimal_system_size.m index 998b317..5c3b0e0 100644 --- a/Dipolar-Gas-Simulator/+Scripts/run_on_cluster_optimal_system_size.m +++ b/Dipolar-Gas-Simulator/+Scripts/run_on_cluster_optimal_system_size.m @@ -2,6 +2,80 @@ ppum = 1250; % Atom Number Density in per micrometers +%% theta = 0 + +LatticeSpacing = linspace(1.6, 2.25, 61); +totalIterations = numel(LatticeSpacing); + +% create a local cluster object +cluster = parcluster('local'); + +% get the number of dedicated cores from environment +nprocs = str2num(getenv('SLURM_NPROCS')); + +% you may explicitly set the JobStorageLocation to the tmp directory that is unique to each cluster job (and is on local, fast scratch) +parpool_tmpdir = [getenv('TMP'),'/.matlab/local_cluster_jobs/slurm_jobID_',getenv('SLURM_JOB_ID')]; +mkdir(parpool_tmpdir); +cluster.JobStorageLocation = parpool_tmpdir; + +% start the parallel pool +parpool(cluster, nprocs) + +% Parallel loop over all combinations of i, j +parfor (k = 1:totalIterations, cluster) + + a = LatticeSpacing(k); + lx = a; + ly = sqrt(3)*a; + + % Initialize OptionsStruct + OptionsStruct = struct; + + % Assign values to OptionsStruct + OptionsStruct.NumberOfAtoms = ppum * (lx*ly); + OptionsStruct.DipolarPolarAngle = deg2rad(0); + OptionsStruct.DipolarAzimuthAngle = 0; + OptionsStruct.ScatteringLength = 75.00; + + OptionsStruct.TrapFrequencies = [0, 0, 500]; + OptionsStruct.TrapPotentialType = 'None'; + + OptionsStruct.NumberOfGridPoints = [128, 128]; + OptionsStruct.Dimensions = [lx, ly]; + OptionsStruct.TimeStepSize = 1E-3; % in s + OptionsStruct.MinimumTimeStepSize = 1E-5; % in s + OptionsStruct.TimeCutOff = 2E6; % in s + OptionsStruct.EnergyTolerance = 5E-10; + OptionsStruct.ResidualTolerance = 1E-05; + OptionsStruct.NoiseScaleFactor = 0.05; + OptionsStruct.BiasWithAnsatz = true; + OptionsStruct.Ansatz = 'triangular'; + OptionsStruct.IncludeDDICutOff = false; + + OptionsStruct.MaxIterations = 10; + OptionsStruct.VariationalWidth = 1.10; + OptionsStruct.WidthLowerBound = 0.01; + OptionsStruct.WidthUpperBound = 12; + OptionsStruct.WidthCutoff = 1e-2; + + OptionsStruct.PlotLive = false; + OptionsStruct.JobNumber = k; + OptionsStruct.RunOnGPU = true; + OptionsStruct.SaveData = true; + OptionsStruct.SaveDirectory = sprintf('./Results/Data_TiltingOfDipoles/TransitionAngle/OptimalSystemSizeWithBiasAnsatz/Hz500/Degree%i', round(rad2deg(OptionsStruct.DipolarPolarAngle))); + + options = Helper.convertstruct2cell(OptionsStruct); + + solver = VariationalSolver2D.DipolarGas(options{:}); + pot = VariationalSolver2D.Potentials(options{:}); + solver.Potential = pot.trap(); + + % Run Solver + [Params, Transf, psi, V, VDk] = solver.run(); + +end + + %% theta = 0 Lx = 4:0.4:11; diff --git a/Dipolar-Gas-Simulator/+VariationalSolver2D/@DipolarGas/setupCosineModulatedAnsatz.m b/Dipolar-Gas-Simulator/+VariationalSolver2D/@DipolarGas/setupCosineModulatedAnsatz.m index 3a13cd1..3430454 100644 --- a/Dipolar-Gas-Simulator/+VariationalSolver2D/@DipolarGas/setupCosineModulatedAnsatz.m +++ b/Dipolar-Gas-Simulator/+VariationalSolver2D/@DipolarGas/setupCosineModulatedAnsatz.m @@ -10,9 +10,9 @@ function [psi] = setupCosineModulatedAnsatz(this, Params, Transf) if strcmp(this.Ansatz, 'stripe') % STRIPES 2-D % Parameters - c = 1; % Fourier coefficient + c = 0.2; % Fourier coefficient k = 2 * pi / Params.Lx; % Wavenumber - n = 2; % Order + n = 1; % Order % Define the 2D function for stripes psi = (1 + (c * cos(n * k * Y))) / (1 + (0.5 * c^2));