2024-11-13 18:36:50 +01:00
|
|
|
function res = calculateNormalizedResiduals(~,psi,Params,VParams,Transf,VDk,V,muchem)
|
|
|
|
|
2024-11-15 14:33:46 +01:00
|
|
|
g_eff = Params.gs * (1/(sqrt(2*pi)*VParams.ell));
|
|
|
|
gamma_eff = Params.gammaQF * (sqrt(2/5)/(pi^(3/4)*VParams.ell^(3/2)));
|
2024-11-18 13:25:09 +01:00
|
|
|
Ez = (0.25/VParams.ell^2) + (0.25*Params.gz*VParams.ell^2);
|
2024-11-13 18:36:50 +01:00
|
|
|
|
|
|
|
KEop = 0.5*(Transf.KX.^2+Transf.KY.^2);
|
|
|
|
|
|
|
|
% DDIs
|
|
|
|
frho = fftn(abs(psi).^2);
|
|
|
|
Phi = real(ifftn(frho.*VDk));
|
2024-11-15 14:33:46 +01:00
|
|
|
Eddi = Params.gdd*Phi.*psi/(sqrt(2*pi)*VParams.ell);
|
2024-11-13 18:36:50 +01:00
|
|
|
|
|
|
|
% Kinetic energy
|
|
|
|
Ekin = ifftn(KEop.*fftn(psi));
|
|
|
|
|
|
|
|
% Potential energy
|
|
|
|
Epot = V.*psi;
|
|
|
|
|
|
|
|
% Contact interactions
|
|
|
|
Eint = g_eff*abs(psi).^2.*psi;
|
|
|
|
|
|
|
|
% Quantum fluctuations
|
|
|
|
Eqf = gamma_eff*abs(psi).^3.*psi;
|
|
|
|
|
|
|
|
% Total energy
|
2024-11-15 14:33:46 +01:00
|
|
|
res = trapz(abs(Ekin(:) + Ez*psi(:) + Epot(:) + Eint(:) + Eddi(:) + Eqf(:) - muchem*psi(:))*Transf.dx*Transf.dy)/trapz(abs(muchem*psi(:))*Transf.dx*Transf.dy);
|
2024-11-13 18:36:50 +01:00
|
|
|
|
|
|
|
end
|