Latest commit
This commit is contained in:
parent
623e9dcb7d
commit
1d524f1f0b
9
Dipolar Gas Simulator/+Scripts/test.m
Normal file
9
Dipolar Gas Simulator/+Scripts/test.m
Normal file
@ -0,0 +1,9 @@
|
||||
%-% Run Simulation %-%
|
||||
clearvars
|
||||
|
||||
sim = DipolarGas();
|
||||
calc = Calculator();
|
||||
[Params, Transf, psi, V, VDk] = sim.runSimulation(calc);
|
||||
|
||||
%-% Plot %-%
|
||||
Plotter.visualizeSpace(Transf)
|
54
Dipolar Gas Simulator/+Simulator/@Calculator/Calculator.m
Normal file
54
Dipolar Gas Simulator/+Simulator/@Calculator/Calculator.m
Normal file
@ -0,0 +1,54 @@
|
||||
classdef Calculator < handle & matlab.mixin.Copyable
|
||||
|
||||
properties (Access = public)
|
||||
|
||||
end
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%- Methods
|
||||
|
||||
methods
|
||||
function this = Calculator(varargin)
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
methods
|
||||
|
||||
end % - setters and getters
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%- Methods
|
||||
|
||||
methods(Access = protected)
|
||||
function cp = copyElement(this)
|
||||
% Shallow copy object
|
||||
cp = copyElement@matlab.mixin.Copyable(this);
|
||||
|
||||
% Forces the setter to redefine the function handles to the new copied object
|
||||
|
||||
pl = properties(this);
|
||||
for k = 1:length(pl)
|
||||
sc = superclasses(this.(pl{k}));
|
||||
if any(contains(sc,{'matlab.mixin.Copyable'}))
|
||||
cp.(pl{k}) = this.(pl{k}).copy();
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
methods (Static)
|
||||
|
||||
% Creates an Instance of Class, ensures singleton behaviour (that there
|
||||
% can only be one Instance of this class
|
||||
function singleObj = getInstance(varargin)
|
||||
% Creates an Instance of Class, ensures singleton behaviour
|
||||
persistent localObj;
|
||||
if isempty(localObj) || ~isvalid(localObj)
|
||||
localObj = Simulator.Calculator(varargin{:});
|
||||
end
|
||||
singleObj = localObj;
|
||||
end
|
||||
end
|
||||
|
||||
end
|
@ -1,4 +1,4 @@
|
||||
function VDk = calculateVDCutoff(Params, Transf)
|
||||
function VDk = calculateVDCutoff(this, Params, Transf)
|
||||
% makes the dipolar interaction matrix, size numel(Params.kr) * numel(Params.kz)
|
||||
% Rmax and Zmax are the interaction cutoffs
|
||||
% VDk needs to be multiplied by Cdd
|
||||
@ -19,7 +19,7 @@ VDk = VDk + exp(-Zcutoff*sqrt(Transf.KX.^2+Transf.KY.^2)).*( sinsq .* cos(Zcut
|
||||
Params.Lr = 0.5*min(Params.Lx,Params.Ly);
|
||||
Params.Nr = max(Params.Nx,Params.Ny);
|
||||
[TransfRad] = SetupSpaceRadial(Params);
|
||||
VDkNon = NumericalHankelTransform(TransfRad.kr, TransfRad.kz, TransfRad.Rmax, Zcutoff);
|
||||
VDkNon = this.calculateNumericalHankelTransform(TransfRad.kr, TransfRad.kz, TransfRad.Rmax, Zcutoff);
|
||||
|
||||
% Interpolating the nonanalytic part onto 3D grid
|
||||
fullkr = [-flip(TransfRad.kr)',TransfRad.kr'];
|
||||
|
143
Dipolar Gas Simulator/+Simulator/@DipolarGas/DipolarGas.m
Normal file
143
Dipolar Gas Simulator/+Simulator/@DipolarGas/DipolarGas.m
Normal file
@ -0,0 +1,143 @@
|
||||
classdef DipolarGas < handle & matlab.mixin.Copyable
|
||||
|
||||
properties (Access = public)
|
||||
SimulationMode;
|
||||
TimeStep;
|
||||
SimulationTime;
|
||||
NumberOfAtoms;
|
||||
ErrorEstimationMethod;
|
||||
|
||||
%Flags
|
||||
|
||||
|
||||
DebugMode;
|
||||
DoSave;
|
||||
SaveDirectory;
|
||||
end
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%- Methods
|
||||
|
||||
methods
|
||||
function this = DipolarGas(varargin)
|
||||
|
||||
p = inputParser;
|
||||
p.KeepUnmatched = true;
|
||||
addParameter(p, 'SimulationMode', 'ImaginaryTimeEvolution',...
|
||||
@(x) any(strcmpi(x,{'ImaginaryTimeEvolution','RealTimeEvolution'})));
|
||||
addParameter(p, 'ErrorEstimationMethod', 'bootstrap',...
|
||||
@(x) any(strcmpi(x,{'jackknife','bootstrap'})));
|
||||
addParameter(p, 'NumberOfAtoms', 5000,...
|
||||
@(x) assert(isnumeric(x) && isscalar(x) && (x > 0)));
|
||||
addParameter(p, 'TimeStep', 10e-06,...
|
||||
@(x) assert(isnumeric(x) && isscalar(x) && (x > 0)));
|
||||
addParameter(p, 'SimulationTime', 3e-03,...
|
||||
@(x) assert(isnumeric(x) && isscalar(x) && (x > 0)));
|
||||
addParameter(p, 'DebugMode', false,...
|
||||
@islogical);
|
||||
addParameter(p, 'SaveData', false,...
|
||||
@islogical);
|
||||
addParameter(p, 'SaveDirectory', './Data',...
|
||||
@ischar);
|
||||
|
||||
p.parse(varargin{:});
|
||||
|
||||
this.SimulationMode = p.Results.SimulationMode;
|
||||
this.ErrorEstimationMethod= p.Results.ErrorEstimationMethod;
|
||||
|
||||
this.NumberOfAtoms = p.Results.NumberOfAtoms;
|
||||
this.TimeStep = p.Results.TimeStep;
|
||||
this.SimulationTime = p.Results.SimulationTime;
|
||||
|
||||
this.DebugMode = p.Results.DebugMode;
|
||||
this.DoSave = p.Results.SaveData;
|
||||
this.SaveDirectory = p.Results.SaveDirectory;
|
||||
|
||||
switch this.SimulationMode
|
||||
case "ImaginaryTimeEvolution"
|
||||
% Development In progress
|
||||
case "RealTimeEvolution"
|
||||
% Development In progress
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
methods
|
||||
function set.TimeStep(this, val)
|
||||
assert(val > 1e-06, 'Not time efficient to compute for time steps smaller than 1 microsecond!');
|
||||
this.TimeStep = val;
|
||||
end
|
||||
function ret = get.TimeStep(this)
|
||||
ret = this.TimeStep;
|
||||
end
|
||||
function set.SimulationTime(this, val)
|
||||
% assert(val <= 5e-03, 'Not time efficient to compute for time spans longer than 5 milliseconds!');
|
||||
this.SimulationTime = val;
|
||||
end
|
||||
function ret = get.SimulationTime(this)
|
||||
ret = this.SimulationTime;
|
||||
end
|
||||
function set.NumberOfAtoms(this, val)
|
||||
assert(val <= 50000, '!!Not time efficient to compute for atom numbers larger than 50,000!!');
|
||||
this.NumberOfAtoms = val;
|
||||
end
|
||||
function ret = get.NumberOfAtoms(this)
|
||||
ret = this.NumberOfAtoms;
|
||||
end
|
||||
|
||||
function set.DebugMode(this, val)
|
||||
this.DebugMode = val;
|
||||
end
|
||||
function ret = get.DebugMode(this)
|
||||
ret = this.DebugMode;
|
||||
end
|
||||
function set.DoSave(this, val)
|
||||
this.DoSave = val;
|
||||
end
|
||||
function ret = get.DoSave(this)
|
||||
ret = this.DoSave;
|
||||
end
|
||||
function set.SaveDirectory(this, val)
|
||||
this.SaveDirectory = val;
|
||||
end
|
||||
function ret = get.SaveDirectory(this)
|
||||
ret = this.SaveDirectory;
|
||||
end
|
||||
|
||||
end % - setters and getters
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%- Methods
|
||||
|
||||
methods(Access = protected)
|
||||
function cp = copyElement(this)
|
||||
% Shallow copy object
|
||||
cp = copyElement@matlab.mixin.Copyable(this);
|
||||
|
||||
% Forces the setter to redefine the function handles to the new copied object
|
||||
|
||||
pl = properties(this);
|
||||
for k = 1:length(pl)
|
||||
sc = superclasses(this.(pl{k}));
|
||||
if any(contains(sc,{'matlab.mixin.Copyable'}))
|
||||
cp.(pl{k}) = this.(pl{k}).copy();
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
methods (Static)
|
||||
|
||||
% Creates an Instance of Class, ensures singleton behaviour (that there
|
||||
% can only be one Instance of this class
|
||||
function singleObj = getInstance(varargin)
|
||||
% Creates an Instance of Class, ensures singleton behaviour
|
||||
persistent localObj;
|
||||
if isempty(localObj) || ~isvalid(localObj)
|
||||
localObj = Simulator.DipolarGas(varargin{:});
|
||||
end
|
||||
singleObj = localObj;
|
||||
end
|
||||
end
|
||||
|
||||
end
|
@ -1,4 +1,4 @@
|
||||
function [psi,V,VDk] = initialize(Params,Transf)
|
||||
function [psi,V,VDk] = initialize(this,calcObj,Params,Transf)
|
||||
|
||||
format long
|
||||
X = Transf.X; Y = Transf.Y; Z = Transf.Z;
|
||||
@ -7,16 +7,16 @@ X = Transf.X; Y = Transf.Y; Z = Transf.Z;
|
||||
V = 0.5*(Params.gx.*X.^2+Params.gy.*Y.^2+Params.gz*Z.^2);
|
||||
|
||||
% == Calculating the DDIs == %
|
||||
if isfile('./Data/VDk_M.mat')
|
||||
VDk = load(sprintf('./Data/VDk_M.mat'));
|
||||
if isfile(strcat(this.SaveDirectory, '/VDk_M.mat'))
|
||||
VDk = load(sprintf(strcat(this.SaveDirectory, '/VDk_M.mat')));
|
||||
VDk = VDk.VDk;
|
||||
else
|
||||
VDk = VDCutoff(Params, Transf);
|
||||
save(sprintf('./Data/VDk_M.mat'),'VDk');
|
||||
VDk = calcObj.calculateVDCutoff(Params, Transf);
|
||||
save(sprintf(strcat(this.SaveDirectory, '/VDk_M.mat')),'VDk');
|
||||
end
|
||||
disp('Finished DDI')
|
||||
|
||||
% == Setting up the initial wavefunction == %
|
||||
psi = SetupWavefunction();
|
||||
psi = this.SetupWavefunction();
|
||||
|
||||
end
|
@ -1,34 +1,23 @@
|
||||
%-% Run Simulation %-%
|
||||
clearvars
|
||||
|
||||
function [Params, Transf, psi,V,VDk] = runSimulation(this,calcObj)
|
||||
% --- Obtain simulation parameters ---
|
||||
[Params] = setupParameters();
|
||||
[Params] = this.setupParameters();
|
||||
|
||||
% --- Set up spatial grids and transforms ---
|
||||
[Transf] = setupSpace(Params);
|
||||
[Transf] = this.setupSpace(Params);
|
||||
|
||||
% Plotter.visualizeSpace(Transf)
|
||||
|
||||
|
||||
%%
|
||||
% --- Initialize ---
|
||||
mkdir(sprintf(this.SaveDirectory))
|
||||
|
||||
mkdir(sprintf('./Data'))
|
||||
|
||||
[psi,V,VDk] = initialize(Params,Transf);
|
||||
[psi,V,VDk] = this.initialize(calcObj,Params,Transf);
|
||||
|
||||
Observ.EVec = []; Observ.NormVec = []; Observ.PCVec = []; Observ.tVecPlot = []; Observ.mucVec = [];
|
||||
t_idx = 1; %Start at t = 0;
|
||||
Observ.res_idx = 1;
|
||||
|
||||
%%
|
||||
% --- Job Settings ---
|
||||
|
||||
njob = 6;
|
||||
|
||||
mkdir(sprintf('./Data/Run_%03i',njob))
|
||||
% njob = 6;
|
||||
% mkdir(sprintf('./Data/Run_%03i',njob))
|
||||
|
||||
% --- Run Simulation ---
|
||||
|
||||
% Imaginary Time Evolution
|
||||
[psi] = SplitStepFourierImaginaryTime(psi,Params,Transf,VDk,V,njob,t_idx,Observ);
|
||||
% [psi] = this.solver(psi,Params,Transf,VDk,V,njob,t_idx,Observ);
|
||||
end
|
||||
|
@ -1,4 +1,4 @@
|
||||
function [Params] = setupParameters()
|
||||
function [Params] = setupParameters(this)
|
||||
|
||||
%%--%% Parameters %%--%%
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
function [Transf] = setupSpace(Params)
|
||||
function [Transf] = setupSpace(this,Params)
|
||||
Transf.Xmax = 0.5*Params.Lx;
|
||||
Transf.Ymax = 0.5*Params.Ly;
|
||||
Transf.Zmax = 0.5*Params.Lz;
|
||||
|
@ -1,4 +1,4 @@
|
||||
function [Transf] = setupSpaceRadial(Params,morder)
|
||||
function [Transf] = setupSpaceRadial(this,Params,morder)
|
||||
Zmax = 0.5*Params.Lz;
|
||||
Rmax = Params.Lr;
|
||||
Nz = Params.Nz;
|
||||
|
@ -1,4 +1,4 @@
|
||||
function [psi] = setupWavefunction()
|
||||
function [psi] = setupWavefunction(this)
|
||||
|
||||
ellx = sqrt(Params.hbar/(Params.m*Params.wx))/Params.l0;
|
||||
elly = sqrt(Params.hbar/(Params.m*Params.wy))/Params.l0;
|
||||
|
@ -1,4 +1,4 @@
|
||||
function [psi] = splitStepFourier(psi,Params,Transf,VDk,V,njob,t_idx,Observ)
|
||||
function [psi] = solver(this,psi,Params,Transf,VDk,V,njob,t_idx,Observ)
|
||||
|
||||
set(0,'defaulttextInterpreter','latex')
|
||||
set(groot, 'defaultAxesTickLabelInterpreter','latex'); set(groot, 'defaultLegendInterpreter','latex');
|
54
Dipolar Gas Simulator/+Simulator/@Potentials/Potentials.m
Normal file
54
Dipolar Gas Simulator/+Simulator/@Potentials/Potentials.m
Normal file
@ -0,0 +1,54 @@
|
||||
classdef Potentials < handle & matlab.mixin.Copyable
|
||||
|
||||
properties (Access = public)
|
||||
|
||||
end
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%- Methods
|
||||
|
||||
methods
|
||||
function this = Potentials(varargin)
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
methods
|
||||
|
||||
end % - setters and getters
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%- Methods
|
||||
|
||||
methods(Access = protected)
|
||||
function cp = copyElement(this)
|
||||
% Shallow copy object
|
||||
cp = copyElement@matlab.mixin.Copyable(this);
|
||||
|
||||
% Forces the setter to redefine the function handles to the new copied object
|
||||
|
||||
pl = properties(this);
|
||||
for k = 1:length(pl)
|
||||
sc = superclasses(this.(pl{k}));
|
||||
if any(contains(sc,{'matlab.mixin.Copyable'}))
|
||||
cp.(pl{k}) = this.(pl{k}).copy();
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
methods (Static)
|
||||
|
||||
% Creates an Instance of Class, ensures singleton behaviour (that there
|
||||
% can only be one Instance of this class
|
||||
function singleObj = getInstance(varargin)
|
||||
% Creates an Instance of Class, ensures singleton behaviour
|
||||
persistent localObj;
|
||||
if isempty(localObj) || ~isvalid(localObj)
|
||||
localObj = Simulator.Potentials(varargin{:});
|
||||
end
|
||||
singleObj = localObj;
|
||||
end
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue
Block a user