diff --git a/Dipolar-Gas-Simulator/+Plotter/visualizeSpace2D.m b/Dipolar-Gas-Simulator/+Plotter/visualizeSpace2D.m new file mode 100644 index 0000000..57734dc --- /dev/null +++ b/Dipolar-Gas-Simulator/+Plotter/visualizeSpace2D.m @@ -0,0 +1,83 @@ +function visualizeSpace2D(Transf) + + % Ensure that x and y are vectors (1D) and create a 2D mesh grid from them + [X, Y] = meshgrid(Transf.x, Transf.y); % Create 2D mesh grid from x and y vectors + + height = 20; + width = 45; + figure(1) + clf + set(gcf, 'Units', 'centimeters') + set(gcf, 'Position', [2 4 width height]) + set(gcf, 'PaperPositionMode', 'auto') + + % Plot real space grid + subplot(1,2,1) + hold on + + % Plot the grid lines + for i = 1:size(X, 1) + plot(X(i,:), Y(i,:), 'k'); % Plot horizontal grid lines in black + end + for j = 1:size(X, 2) + plot(X(:,j), Y(:,j), 'k'); % Plot vertical grid lines in black + end + + axis equal % Ensures equal scaling for both axes + + % Set axes labels + xlabel(gca, {'$x / l_o ~ (m)$'}, ... + 'Interpreter', 'latex', ... + 'FontName', 'Times New Roman', ... + 'FontSize', 14, ... + 'FontWeight', 'normal', ... + 'FontAngle', 'normal') + ylabel(gca, {'$y / l_o ~ (m)$'}, ... + 'Interpreter', 'latex', ... + 'FontName', 'Times New Roman', ... + 'FontSize', 14, ... + 'FontWeight', 'normal', ... + 'FontAngle', 'normal') + title(gca, 'Real Space', ... + 'Interpreter', 'tex', ... + 'FontName', 'Times New Roman', ... + 'FontSize', 14, ... + 'FontWeight', 'normal', ... + 'FontAngle', 'normal') + + % Plot Fourier space grid in a similar style + [KX, KY] = meshgrid(Transf.kx, Transf.ky); % Create 2D mesh grid from kx and ky + + subplot(1,2,2) + hold on + + % Plot the grid lines + for i = 1:size(KX, 1) + plot(KX(i,:), KY(i,:), 'k'); % Plot horizontal grid lines + end + for j = 1:size(KX, 2) + plot(KX(:,j), KY(:,j), 'k'); % Plot vertical grid lines + end + + axis equal % Ensure equal scaling for both axes + + % Set axes labels + xlabel(gca, {'$k_x / l_o ~ (m^{-1})$'}, ... + 'Interpreter', 'latex', ... + 'FontName', 'Times New Roman', ... + 'FontSize', 14, ... + 'FontWeight', 'normal', ... + 'FontAngle', 'normal') + ylabel(gca, {'$k_y / l_o ~ (m^{-1})$'}, ... + 'Interpreter', 'latex', ... + 'FontName', 'Times New Roman', ... + 'FontSize', 14, ... + 'FontWeight', 'normal', ... + 'FontAngle', 'normal') + title(gca, 'Fourier Space', ... + 'Interpreter', 'tex', ... + 'FontName', 'Times New Roman', ... + 'FontSize', 14, ... + 'FontWeight', 'normal', ... + 'FontAngle', 'normal') +end diff --git a/Dipolar-Gas-Simulator/+Scripts/run_locally.m b/Dipolar-Gas-Simulator/+Scripts/run_locally.m index 9b5252e..286dbe3 100644 --- a/Dipolar-Gas-Simulator/+Scripts/run_locally.m +++ b/Dipolar-Gas-Simulator/+Scripts/run_locally.m @@ -32,12 +32,12 @@ OptionsStruct.SaveDirectory = './Data'; options = Helper.convertstruct2cell(OptionsStruct); clear OptionsStruct -sim = Simulator.DipolarGas(options{:}); -pot = Simulator.Potentials(options{:}); -sim.Potential = pot.trap(); % + pot.repulsive_chopstick(); +sim = Simulator.DipolarGas(options{:}); +pot = Simulator.Potentials(options{:}); +sim.Potential = pot.trap(); % + pot.repulsive_chopstick(); %-% Run Simulation %-% -[Params, Transf, psi, V, VDk] = sim.run(); +[Params, Transf, psi, V, VDk] = sim.run(); %% - Plot numerical grid Plotter.visualizeSpace(Transf) @@ -59,12 +59,12 @@ OptionsStruct.ScatteringLength = 90; OptionsStruct.TrapFrequencies = [44.97, 10.4, 126.3]; -OptionsStruct.NumberOfGridPoints = [128, 256, 128]; -OptionsStruct.Dimensions = [50, 120, 150]; -OptionsStruct.TimeStepSize = 500E-6; % in s -OptionsStruct.NumberOfTimeSteps = 100; % in s +OptionsStruct.NumberOfGridPoints = [50, 50]; +OptionsStruct.Dimensions = [100, 100]; +OptionsStruct.TimeStepSize = 1E-3; % in s +OptionsStruct.TimeCutOff = 2E6; % in s OptionsStruct.EnergyTolerance = 5E-10; -OptionsStruct.ResidualTolerance = 1E-05; +OptionsStruct.ResidualTolerance = 1E-04; OptionsStruct.JobNumber = 1; OptionsStruct.RunOnGPU = false; @@ -73,16 +73,15 @@ OptionsStruct.SaveDirectory = './Data'; options = Helper.convertstruct2cell(OptionsStruct); clear OptionsStruct -solver = Variational2D.DipolarGas(options{:}); +solver = Variational2D.DipolarGas(options{:}); %-% Run Solver %-% [Params, Transf, psi, V, VDk] = solver.run(); %% - Plot numerical grid -Plotter.visualizeSpace(Transf) -%% - Plot trap potential -Plotter.visualizeTrapPotential(sim.Potential,Params,Transf) +Plotter.visualizeSpace2D(Transf) %% - Plot initial wavefunction -Plotter.visualizeWavefunction(psi,Params,Transf) +Plotter.visualizeWavefunction2D(psi,Params,Transf) %% - Plot GS wavefunction -Plotter.visualizeGSWavefunction(Params.njob) \ No newline at end of file +Plotter.visualizeGSWavefunction2D(Params.njob) + diff --git a/Dipolar-Gas-Simulator/+Variational2D/@DipolarGas/DipolarGas.m b/Dipolar-Gas-Simulator/+Variational2D/@DipolarGas/DipolarGas.m index 5cd658d..034c476 100644 --- a/Dipolar-Gas-Simulator/+Variational2D/@DipolarGas/DipolarGas.m +++ b/Dipolar-Gas-Simulator/+Variational2D/@DipolarGas/DipolarGas.m @@ -11,11 +11,11 @@ classdef DipolarGas < handle & matlab.mixin.Copyable SimulationMode; TimeStepSize; - NumberOfTimeSteps; + MinimumTimeStepSize; + TimeCutOff; EnergyTolerance; ResidualTolerance; - MinimumTimeStepSize; - + Calculator; SimulationParameters; @@ -51,14 +51,14 @@ classdef DipolarGas < handle & matlab.mixin.Copyable @(x) assert(isnumeric(x) && isvector(x) && all(x > 0))); addParameter(p, 'TimeStepSize', 5E-4,... @(x) assert(isnumeric(x) && isscalar(x) && (x > 0))); - addParameter(p, 'NumberOfTimeSteps', 2e6,... + addParameter(p, 'MinimumTimeStepSize', 1e-6,... + @(x) assert(isnumeric(x) && isscalar(x) && (x > 0))); + addParameter(p, 'TimeCutOff', 2e6,... @(x) assert(isnumeric(x) && isscalar(x) && (x > 0))); addParameter(p, 'EnergyTolerance', 1e-10,... @(x) assert(isnumeric(x) && isscalar(x) && (x > 0))); addParameter(p, 'ResidualTolerance', 1e-10,... @(x) assert(isnumeric(x) && isscalar(x) && (x > 0))); - addParameter(p, 'MinimumTimeStepSize', 1e-6,... - @(x) assert(isnumeric(x) && isscalar(x) && (x > 0))); addParameter(p, 'JobNumber', 1,... @(x) assert(isnumeric(x) && isscalar(x) && (x > 0))); addParameter(p, 'RunOnGPU', false,... @@ -80,11 +80,10 @@ classdef DipolarGas < handle & matlab.mixin.Copyable this.NumberOfGridPoints = p.Results.NumberOfGridPoints; this.Dimensions = p.Results.Dimensions; this.TimeStepSize = p.Results.TimeStepSize; - this.NumberOfTimeSteps = p.Results.NumberOfTimeSteps; + this.MinimumTimeStepSize = p.Results.MinimumTimeStepSize; + this.TimeCutOff = p.Results.TimeCutOff; this.EnergyTolerance = p.Results.EnergyTolerance; this.ResidualTolerance = p.Results.ResidualTolerance; - this.MinimumTimeStepSize = p.Results.MinimumTimeStepSize; - this.JobNumber = p.Results.JobNumber; this.RunOnGPU = p.Results.RunOnGPU; this.DebugMode = p.Results.DebugMode; @@ -106,12 +105,12 @@ classdef DipolarGas < handle & matlab.mixin.Copyable function ret = get.TimeStepSize(this) ret = this.TimeStepSize; end - function set.NumberOfTimeSteps(this, val) - assert(val <= 2E6, 'Not time efficient to compute for time spans longer than 2E6 seconds!'); - this.NumberOfTimeSteps = val; + function set.TimeCutOff(this, val) + assert(val <= 2E6, 'Not efficient to compute for time spans longer than 2E6 seconds!'); + this.TimeCutOff = val; end - function ret = get.NumberOfTimeSteps(this) - ret = this.NumberOfTimeSteps; + function ret = get.TimeCutOff(this) + ret = this.TimeCutOff; end function set.NumberOfAtoms(this, val) assert(val <= 1E6, '!!Not time efficient to compute for atom numbers larger than 1,000,000!!'); diff --git a/Dipolar-Gas-Simulator/+Variational2D/@DipolarGas/run.m b/Dipolar-Gas-Simulator/+Variational2D/@DipolarGas/run.m index 7876214..6de64b8 100644 --- a/Dipolar-Gas-Simulator/+Variational2D/@DipolarGas/run.m +++ b/Dipolar-Gas-Simulator/+Variational2D/@DipolarGas/run.m @@ -27,7 +27,7 @@ function [Params, Transf, psi, V, VDk] = run(this) E_vs_iter(1) = E_Var([ells(1) nus(1)]); t_idx = 1; % Start at t = 0; - + for nn = 1:Params.SelfConIter Observ.EVec = []; Observ.NormVec = []; Observ.PCVec = []; Observ.tVecPlot = []; Observ.mucVec = []; Observ.res_idx = 1; diff --git a/Dipolar-Gas-Simulator/+Variational2D/@DipolarGas/setupParameters.m b/Dipolar-Gas-Simulator/+Variational2D/@DipolarGas/setupParameters.m index 4fedd24..6e04113 100644 --- a/Dipolar-Gas-Simulator/+Variational2D/@DipolarGas/setupParameters.m +++ b/Dipolar-Gas-Simulator/+Variational2D/@DipolarGas/setupParameters.m @@ -42,11 +42,11 @@ function [Params] = setupParameters(this) % Tolerances Params.Etol = this.EnergyTolerance; Params.rtol = this.ResidualTolerance; - Params.sim_time_cut_off = this.NumberOfTimeSteps; % sometimes the imaginary time gets a little stuck - % even though the solution is good, this just stops it going on forever - Params.mindt = this.MinimumTimeStepSize; % Minimum size for a time step using adaptive dt + Params.sim_time_cut_off = this.TimeCutOff; % sometimes the imaginary time gets a little stuck + % even though the solution is good, this just stops it going on forever + Params.mindt = this.MinimumTimeStepSize; % Minimum size for a time step using adaptive dt - Params.njob = this.JobNumber; + Params.njob = this.JobNumber; % ================ Variational method parameters ================ %