diff --git a/Dipolar Gas Simulator/+Simulator/@Calculator/calculateChemicalPotential.m b/Dipolar Gas Simulator/+Simulator/@Calculator/calculateChemicalPotential.m new file mode 100644 index 0000000..96a6a84 --- /dev/null +++ b/Dipolar Gas Simulator/+Simulator/@Calculator/calculateChemicalPotential.m @@ -0,0 +1,29 @@ +function muchem = calculateChemicalPotential(~,psi,Params,Transf,VDk,V) + + %Parameters + normfac = Params.Lx*Params.Ly*Params.Lz/numel(psi); + KEop= 0.5*(Transf.KX.^2+Transf.KY.^2+Transf.KZ.^2); + + % DDIs + frho=fftn(abs(psi).^2); + Phi=real(ifftn(frho.*VDk)); + + Eddi = (Params.gdd*Phi.*abs(psi).^2); + + %Kinetic energy + Ekin = KEop.*abs(fftn(psi)*normfac).^2; + Ekin = trapz(Ekin(:))*Transf.dkx*Transf.dky*Transf.dkz/(2*pi)^3; + + %Potential energy + Epot = V.*abs(psi).^2; + + %Contact interactions + Eint = Params.gs*abs(psi).^4; + + %Quantum fluctuations + Eqf = Params.gammaQF*abs(psi).^5; + + %Total energy + muchem = Ekin + trapz(Epot(:) + Eint(:) + Eddi(:) + Eqf(:))*Transf.dx*Transf.dy*Transf.dz; % + muchem = muchem / Params.N; +end \ No newline at end of file diff --git a/Dipolar Gas Simulator/+Simulator/@Calculator/calculateEnergyComponents.m b/Dipolar Gas Simulator/+Simulator/@Calculator/calculateEnergyComponents.m new file mode 100644 index 0000000..92dd32c --- /dev/null +++ b/Dipolar Gas Simulator/+Simulator/@Calculator/calculateEnergyComponents.m @@ -0,0 +1,35 @@ +function E = calculateEnergyComponents(~,psi,Params,Transf,VDk,V) + + %Parameters + + KEop= 0.5*(Transf.KX.^2+Transf.KY.^2+Transf.KZ.^2); + normfac = Params.Lx*Params.Ly*Params.Lz/numel(psi); + + % DDIs + frho = fftn(abs(psi).^2); + Phi = real(ifftn(frho.*VDk)); + + Eddi = 0.5*Params.gdd*Phi.*abs(psi).^2; + E.Eddi = trapz(Eddi(:))*Transf.dx*Transf.dy*Transf.dz; + + % EddiTot = trapz(Eddi(:))*Transf.dx*Transf.dy*Transf.dz; + + %Kinetic energy + % psik = ifftshift(fftn(fftshift(psi)))*normfac; + + Ekin = KEop.*abs(fftn(psi)*normfac).^2; + E.Ekin = trapz(Ekin(:))*Transf.dkx*Transf.dky*Transf.dkz/(2*pi)^3; + + % Potential energy + Epot = V.*abs(psi).^2; + E.Epot = trapz(Epot(:))*Transf.dx*Transf.dy*Transf.dz; + + %Contact interactions + Eint = 0.5*Params.gs*abs(psi).^4; + E.Eint = trapz(Eint(:))*Transf.dx*Transf.dy*Transf.dz; + + %Quantum fluctuations + Eqf = 0.4*Params.gammaQF*abs(psi).^5; + E.Eqf = trapz(Eqf(:))*Transf.dx*Transf.dy*Transf.dz; + +end diff --git a/Dipolar Gas Simulator/+Simulator/@Calculator/calculateNormalizedResiduals.m b/Dipolar Gas Simulator/+Simulator/@Calculator/calculateNormalizedResiduals.m new file mode 100644 index 0000000..134e426 --- /dev/null +++ b/Dipolar Gas Simulator/+Simulator/@Calculator/calculateNormalizedResiduals.m @@ -0,0 +1,25 @@ +function res = calculateNormalizedResiduals(~,psi,Params,Transf,VDk,V,muchem) + + KEop= 0.5*(Transf.KX.^2+Transf.KY.^2+Transf.KZ.^2); + + % DDIs + frho=fftn(abs(psi).^2); + Phi=real(ifftn(frho.*VDk)); + + Eddi = Params.gdd*Phi.*psi; + + %Kinetic energy + Ekin = ifftn(KEop.*fftn(psi)); + + %Potential energy + Epot = V.*psi; + + %Contact interactions + Eint = Params.gs*abs(psi).^2.*psi; + + %Quantum fluctuations + Eqf = Params.gammaQF*abs(psi).^3.*psi; + + %Total energy + res = trapz(abs(Ekin(:) + Epot(:) + Eint(:) + Eddi(:) + Eqf(:) - muchem*psi(:))*Transf.dx*Transf.dy*Transf.dz)/trapz(abs(muchem*psi(:))*Transf.dx*Transf.dy*Transf.dz); +end \ No newline at end of file diff --git a/Dipolar Gas Simulator/+Simulator/@Calculator/calculateNumericalHankelTransform.m b/Dipolar Gas Simulator/+Simulator/@Calculator/calculateNumericalHankelTransform.m new file mode 100644 index 0000000..b3d96c6 --- /dev/null +++ b/Dipolar Gas Simulator/+Simulator/@Calculator/calculateNumericalHankelTransform.m @@ -0,0 +1,39 @@ +function VDkSemi = calculateNumericalHankelTransform(~,kr,kz,Rmax,Zmax,Nr) + + % accuracy inputs for numerical integration + if(nargin==5) + Nr = 5e4; + end + + Nz = 64; + farRmultiple = 2000; + + % midpoint grids for the integration over 0