From 3a4419fe67cb3336f7a4f7a77f64212c5aeb1a73 Mon Sep 17 00:00:00 2001 From: Karthik Chandrashekara Date: Tue, 18 Jun 2024 12:49:02 +0200 Subject: [PATCH] Restored individual files for functions of Calculator class. --- .../@Calculator/calculateChemicalPotential.m | 29 +++++++++ .../@Calculator/calculateEnergyComponents.m | 35 ++++++++++ .../calculateNormalizedResiduals.m | 25 ++++++++ .../calculateNumericalHankelTransform.m | 39 +++++++++++ .../@Calculator/calculateOrderParameter.m | 58 +++++++++++++++++ .../@Calculator/calculatePhaseCoherence.m | 19 ++++++ .../@Calculator/calculateTotalEnergy.m | 32 ++++++++++ .../@Calculator/calculateVDCutoff.m | 64 +++++++++++++++++++ 8 files changed, 301 insertions(+) create mode 100644 Dipolar Gas Simulator/+Simulator/@Calculator/calculateChemicalPotential.m create mode 100644 Dipolar Gas Simulator/+Simulator/@Calculator/calculateEnergyComponents.m create mode 100644 Dipolar Gas Simulator/+Simulator/@Calculator/calculateNormalizedResiduals.m create mode 100644 Dipolar Gas Simulator/+Simulator/@Calculator/calculateNumericalHankelTransform.m create mode 100644 Dipolar Gas Simulator/+Simulator/@Calculator/calculateOrderParameter.m create mode 100644 Dipolar Gas Simulator/+Simulator/@Calculator/calculatePhaseCoherence.m create mode 100644 Dipolar Gas Simulator/+Simulator/@Calculator/calculateTotalEnergy.m create mode 100644 Dipolar Gas Simulator/+Simulator/@Calculator/calculateVDCutoff.m 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