Modification to be able to pass new values to variational parameters via the options struct.

This commit is contained in:
Karthik 2024-11-17 13:49:53 +01:00
parent e3f9c7b352
commit 7bdfb6af51
5 changed files with 37 additions and 9 deletions

View File

@ -60,13 +60,19 @@ OptionsStruct.ScatteringLength = 98.0676; % Critical point: 102.515;
OptionsStruct.TrapFrequencies = [10, 10, 72.4];
OptionsStruct.TrapPotentialType = 'None';
OptionsStruct.NumberOfGridPoints = [128, 128];
OptionsStruct.NumberOfGridPoints = [256, 256];
OptionsStruct.Dimensions = [7.5, 7.5]; % Critical point: 6.996; Triangular phase: 7.5; Stripe phase: 6.972; Honeycomb phase: 6.239 for both for Atom Number fixed to 1E5
OptionsStruct.TimeStepSize = 200E-6; % in s
OptionsStruct.TimeCutOff = 100; % in s
OptionsStruct.EnergyTolerance = 5E-10;
OptionsStruct.ResidualTolerance = 1E-05;
OptionsStruct.MaxIterations = 20;
OptionsStruct.VariationalWidth = 4;
OptionsStruct.WidthLowerBound = 5;
OptionsStruct.WidthUpperBound = 8;
OptionsStruct.WidthCutoff = 1e-3;
OptionsStruct.JobNumber = 1;
OptionsStruct.RunOnGPU = false;
OptionsStruct.SaveData = true;

View File

@ -17,6 +17,12 @@ classdef DipolarGas < handle & matlab.mixin.Copyable
EnergyTolerance;
ResidualTolerance;
MaxIterations;
VariationalWidth;
WidthLowerBound;
WidthUpperBound;
WidthCutoff;
Calculator;
SimulationParameters;
@ -60,6 +66,16 @@ classdef DipolarGas < handle & matlab.mixin.Copyable
@(x) assert(isnumeric(x) && isscalar(x) && (x > 0)));
addParameter(p, 'ResidualTolerance', 1e-10,...
@(x) assert(isnumeric(x) && isscalar(x) && (x > 0)));
addParameter(p, 'MaxIterations', 20,...
@(x) assert(isnumeric(x) && isscalar(x) && (x > 0)));
addParameter(p, 'VariationalWidth', 4,...
@(x) assert(isnumeric(x) && isscalar(x) && (x > 0)));
addParameter(p, 'WidthLowerBound', 2,...
@(x) assert(isnumeric(x) && isscalar(x) && (x > 0)));
addParameter(p, 'WidthUpperBound', 12,...
@(x) assert(isnumeric(x) && isscalar(x) && (x > 0)));
addParameter(p, 'WidthCutoff', 1e-2,...
@(x) assert(isnumeric(x) && isscalar(x) && (x > 0)));
addParameter(p, 'JobNumber', 1,...
@(x) assert(isnumeric(x) && isscalar(x) && (x > 0)));
addParameter(p, 'RunOnGPU', false,...
@ -86,6 +102,13 @@ classdef DipolarGas < handle & matlab.mixin.Copyable
this.TimeCutOff = p.Results.TimeCutOff;
this.EnergyTolerance = p.Results.EnergyTolerance;
this.ResidualTolerance = p.Results.ResidualTolerance;
this.MaxIterations = p.Results.MaxIterations;
this.VariationalWidth = p.Results.VariationalWidth;
this.WidthLowerBound = p.Results.WidthUpperBound;
this.WidthUpperBound = p.Results.WidthUpperBound;
this.WidthCutoff = p.Results.WidthCutoff;
this.JobNumber = p.Results.JobNumber;
this.RunOnGPU = p.Results.RunOnGPU;
this.DebugMode = p.Results.DebugMode;

View File

@ -1,4 +1,4 @@
function [psi] = propagateWavefunction(this, psi, Params, VParams, Transf, VDk, V, t_idx, Observ)
function [psi, Observ] = propagateWavefunction(this, psi, Params, VParams, Transf, VDk, V, t_idx, Observ)
set(0,'defaulttextInterpreter','latex')
set(groot, 'defaultAxesTickLabelInterpreter','latex'); set(groot, 'defaultLegendInterpreter','latex');

View File

@ -23,7 +23,6 @@ function [Params, Transf, psi, V, VDk] = run(this)
mkdir(sprintf(this.SaveDirectory))
mkdir(sprintf('./Data/Run_%03i',Params.njob))
fminconoptions = optimoptions('fmincon','Display','off','StepTolerance',1e-8);
[psi,V,VDk] = this.initialize(Params,VParams,Transf);
ells(1) = VParams.ell;
@ -49,7 +48,7 @@ function [Params, Transf, psi, V, VDk] = run(this)
psi = psi + 0.25*noise;
% --- Run ---
[psi] = this.propagateWavefunction(psi, Params, VParams, Transf, VDk, V, t_idx, Observ);
[psi, Observ] = this.propagateWavefunction(psi, Params, VParams, Transf, VDk, V, t_idx, Observ);
psi = gather(psi);
% --- Constrained minimization ---

View File

@ -51,15 +51,15 @@ function [Params] = setupParameters(this)
% ================ Variational method parameters ================ %
% FMinCon Settings
Params.SelfConIter = 20; % Max number of iterations to perform self-consistent calculation
Params.ell = 4; % initial [ell], ell is the "width" - psi ~ e^(z^2/ell^2)
Params.SelfConIter = this.MaxIterations; % Max number of iterations to perform self-consistent calculation
Params.ell = this.VariationalWidth; % initial [ell], ell is the "width" - psi ~ e^(z^2/ell^2)
% Window of optimization
Params.ell_lower = 0.2;
Params.ell_upper = 12;
Params.ell_lower = this.WidthLowerBound;
Params.ell_upper = this.WidthUpperBound;
% Relative cutoffs
Params.ellcutoff = 1e-2;
Params.ellcutoff = this.WidthCutoff;
% ================ Parameters defined by those above ================ %