Latest working version (after minor bugfixes).
This commit is contained in:
parent
6672e4fca0
commit
72c2b17d36
@ -1,4 +1,4 @@
|
||||
function E = calculateVariationalEnergy(~, psi, Params, ell, Transf, V)
|
||||
function E = calculateVariationalEnergy(this, 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)));
|
||||
@ -10,7 +10,7 @@ function E = calculateVariationalEnergy(~, psi, Params, ell, Transf, V)
|
||||
|
||||
% 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!
|
||||
VDk = this.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);%
|
||||
|
@ -26,7 +26,7 @@ function [Params, Transf, psi, V, VDk] = run(this)
|
||||
|
||||
[psi,V,VDk] = this.initialize(Params,VParams,Transf);
|
||||
ells(1) = VParams.ell;
|
||||
E_Var = @(x) this.Calculator.calculateVariationalEnergy(psi, Params, x, Transf, VDk, V)/Params.N;
|
||||
E_Var = @(x) this.Calculator.calculateVariationalEnergy(psi, Params, x, Transf, V)/Params.N;
|
||||
E_vs_iter(1) = E_Var(ells(1));
|
||||
|
||||
for nn = 1:Params.SelfConIter
|
||||
@ -50,7 +50,7 @@ function [Params, Transf, psi, V, VDk] = run(this)
|
||||
psi = gather(psi);
|
||||
|
||||
% --- Constrained minimization ---
|
||||
E_Var = @(x) this.Calculator.calculateVariationalEnergy(psi, Params, x, Transf, VDk, V)/Params.N;
|
||||
E_Var = @(x) this.Calculator.calculateVariationalEnergy(psi, Params, x, Transf, V)/Params.N;
|
||||
VParams.ell = fmincon(E_Var,VParams.ell,[],[],[],[],Params.ell_lower,Params.ell_upper,[],fminconoptions);
|
||||
|
||||
% --- Convergence check ---
|
||||
|
Loading…
Reference in New Issue
Block a user