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

29 lines
1.1 KiB
Matlab

function res = calculateNormalizedResiduals(~,psi,Params,VParams,Transf,VDk,V,muchem)
g_eff = Params.gs*VParams.nu/(2^(1+1/VParams.nu)*VParams.ell*gamma(1/VParams.nu));
gamma_eff = Params.gammaQF*2^(1/VParams.nu-1.5)*5^(-1/VParams.nu)*VParams.ell*gamma(1+1/VParams.nu)*( VParams.nu/(VParams.ell*gamma(1/VParams.nu)) )^(5/2);
EVar = VParams.nu^2*gamma(2-1/VParams.nu)/(8*VParams.ell^2*gamma(1/VParams.nu)) + 0.5*Params.gz*VParams.ell^2*gamma(3/VParams.nu)/gamma(1/VParams.nu);
KEop = 0.5*(Transf.KX.^2+Transf.KY.^2);
% DDIs
frho = fftn(abs(psi).^2);
Phi = real(ifftn(frho.*VDk));
Eddi = Params.gdd*Phi.*psi/(sqrt(2*pi)*VParams.ell_eff);
% 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
res = trapz(abs(Ekin(:) + EVar*psi(:) + Epot(:) + Eint(:) + Eddi(:) + Eqf(:) - muchem*psi(:))*Transf.dx*Transf.dy)/trapz(abs(muchem*psi(:))*Transf.dx*Transf.dy);
end