From 684f419cdd19a037c538add03cff9c313e712242 Mon Sep 17 00:00:00 2001 From: Karthik Chandrashekara Date: Thu, 20 Mar 2025 16:09:37 +0100 Subject: [PATCH] Latest version of solver with additions to initialize with modulated states to bias the solver. --- .../@DipolarGas/DipolarGas.m | 12 +++++- .../@DipolarGas/setupWavefunction.m | 39 ++++++++++--------- 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/Dipolar-Gas-Simulator/+VariationalSolver2D/@DipolarGas/DipolarGas.m b/Dipolar-Gas-Simulator/+VariationalSolver2D/@DipolarGas/DipolarGas.m index 9bccb66..12f46a0 100644 --- a/Dipolar-Gas-Simulator/+VariationalSolver2D/@DipolarGas/DipolarGas.m +++ b/Dipolar-Gas-Simulator/+VariationalSolver2D/@DipolarGas/DipolarGas.m @@ -9,7 +9,7 @@ classdef DipolarGas < handle & matlab.mixin.Copyable NumberOfGridPoints; Dimensions; Potential; - + SimulationMode; TimeStepSize; MinimumTimeStepSize; @@ -18,6 +18,9 @@ classdef DipolarGas < handle & matlab.mixin.Copyable ResidualTolerance; NoiseScaleFactor; + BiasWithAnsatz; + Ansatz; + MaxIterations; VariationalWidth; WidthLowerBound; @@ -85,6 +88,10 @@ classdef DipolarGas < handle & matlab.mixin.Copyable @(x) assert(isnumeric(x) && isscalar(x) && (x > 0))); addParameter(p, 'JobNumber', 0,... @(x) assert(isnumeric(x) && isscalar(x) && (x >= 0))); + addParameter(p, 'BiasWithAnsatz', false,... + @islogical); + addParameter(p, 'Ansatz', 'None',... + @ischar); addParameter(p, 'IncludeDDICutOff', true,... @islogical); addParameter(p, 'PlotLive', false,... @@ -114,6 +121,9 @@ classdef DipolarGas < handle & matlab.mixin.Copyable this.EnergyTolerance = p.Results.EnergyTolerance; this.ResidualTolerance = p.Results.ResidualTolerance; this.NoiseScaleFactor = p.Results.NoiseScaleFactor; + + this.BiasWithAnsatz = p.Results.BiasWithAnsatz; + this.Ansatz = p.Results.Ansatz; this.MaxIterations = p.Results.MaxIterations; this.VariationalWidth = p.Results.VariationalWidth; diff --git a/Dipolar-Gas-Simulator/+VariationalSolver2D/@DipolarGas/setupWavefunction.m b/Dipolar-Gas-Simulator/+VariationalSolver2D/@DipolarGas/setupWavefunction.m index f01321f..2fffd4e 100644 --- a/Dipolar-Gas-Simulator/+VariationalSolver2D/@DipolarGas/setupWavefunction.m +++ b/Dipolar-Gas-Simulator/+VariationalSolver2D/@DipolarGas/setupWavefunction.m @@ -1,20 +1,23 @@ -function [psi] = setupWavefunction(~,Params,Transf) - - format long - - X = Transf.X; - Y = Transf.Y; - - ellx = sqrt(Params.hbar/(Params.m*Params.wx))/Params.l0; - elly = sqrt(Params.hbar/(Params.m*Params.wy))/Params.l0; - - Rx = 8*sqrt(2)*ellx; - Ry = 8*sqrt(2)*elly; - X0 = 0.0*Transf.Xmax; - Y0 = 0.0*Transf.Ymax; - - psi = exp(-(X-X0).^2/Rx^2-(Y-Y0).^2/Ry^2); - Norm = sum(abs(psi(:)).^2)*Transf.dx*Transf.dy; - psi = sqrt(Params.N)*psi/sqrt(Norm); +function [psi] = setupWavefunction(this, Params, Transf) + if this.BiasWithAnsatz + psi = this.setupCosineModulatedAnsatz(Params, Transf); + else + format long + + X = Transf.X; + Y = Transf.Y; + + ellx = sqrt(Params.hbar/(Params.m*Params.wx))/Params.l0; + elly = sqrt(Params.hbar/(Params.m*Params.wy))/Params.l0; + + Rx = 8*sqrt(2)*ellx; + Ry = 8*sqrt(2)*elly; + X0 = 0.0*Transf.Xmax; + Y0 = 0.0*Transf.Ymax; + + psi = exp(-(X-X0).^2/Rx^2-(Y-Y0).^2/Ry^2); + Norm = sum(abs(psi(:)).^2)*Transf.dx*Transf.dy; + psi = sqrt(Params.N)*psi/sqrt(Norm); + end end \ No newline at end of file