Major issue addressed - Vdk was not being recalculated during constrained optimization, this is has been rectified.

This commit is contained in:
Karthik 2024-11-20 11:57:33 +01:00
parent fde359df9e
commit 6672e4fca0
3 changed files with 4 additions and 4 deletions

View File

@ -1,4 +1,4 @@
function E = calculateVariationalEnergy(~, psi, Params, ell, Transf, VDk, V)
function E = calculateVariationalEnergy(~, psi, Params, ell, Transf, V)
g_eff = Params.gs * (1/(sqrt(2*pi)*ell));
gamma_eff = Params.gammaQF * (sqrt(2/5)/(pi^(3/4)*ell^(3/2)));
@ -9,6 +9,8 @@ function E = calculateVariationalEnergy(~, psi, Params, ell, Transf, VDk, V)
normfac = Params.Lx*Params.Ly/numel(psi);
% DDIs
VParams.ell = ell;
VDk = this.Calculator.calculateVDkWithCutoff(Transf, Params, VParams); % VDk depends on the variational parameters. THIS HAS TO BE RECALCULATED HERE FOR THE CONSTRAINED OPTIMIZATION TO WORK!
frho = fftn(abs(psi).^2);
Phi = real(ifftn(frho.*VDk));
Eddi = 0.5*Params.gdd*Phi.*abs(psi).^2/(sqrt(2*pi)*ell);%

View File

@ -5,8 +5,6 @@ function [psi,V,VDk] = initialize(this,Params,VParams,Transf)
% == Calculating the DDIs == %
VDk = this.Calculator.calculateVDkWithCutoff(Transf, Params, VParams);
save(sprintf(strcat(this.SaveDirectory, '/VDk_M.mat')),'VDk');
fprintf('Computed and saved DDI potential in Fourier space with cutoff.\n')
% == Setting up the initial wavefunction == %
psi = this.setupWavefunction(Params,Transf);

View File

@ -34,7 +34,7 @@ function [Params, Transf, psi, V, VDk] = run(this)
t_idx = 1; % Start at t = 0;
[psi,V,VDk] = this.initialize(Params,VParams,Transf); % Recalculate Psi, VDk with new value for the variational parameter
[~,V,VDk] = this.initialize(Params,VParams,Transf); % Recalculate VDk with new value for the variational parameter, keep new psi at the end of loop to increase likelihood of faster convergence
% --- Adding some noise ---
% Noise added in every iteration to ensure it is not stuck in some local minimum