Calculations/Dipolar-Gas-Simulator/+VariationalSolver2D/@Calculator/calculateVariationalEnergy.m

37 lines
1.4 KiB
Matlab

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)));
Ez = (0.25/ell^2) + (0.25*Params.gz*ell^2);
% Parameters
KEop = 0.5*(Transf.KX.^2+Transf.KY.^2);
normfac = Params.Lx*Params.Ly/numel(psi);
% DDIs
VDk = this.calculateVDkWithCutoff(Transf, Params, ell); % 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);%
Eddi = sum(Eddi(:))*Transf.dx*Transf.dy;
% Kinetic energy
Ekin = KEop.*abs(fftn(psi)*normfac).^2;
Ekin = trapz(Ekin(:))*Transf.dkx*Transf.dky/(2*pi)^2;
% Potential energy
Epot = V.*abs(psi).^2;
Epot = trapz(Epot(:))*Transf.dx*Transf.dy;
% Contact interactions
Eint = 0.5*g_eff*abs(psi).^4;
Eint = trapz(Eint(:))*Transf.dx*Transf.dy;
% Quantum fluctuations
Eqf = 0.4*gamma_eff*abs(psi).^5;
Eqf = trapz(Eqf(:))*Transf.dx*Transf.dy;
% Total
E = Ez*Params.N + Ekin + Epot + Eint + Eddi + Eqf;
end