From 9d187540ad9a22de67139fb6a5f631cefeb05de5 Mon Sep 17 00:00:00 2001 From: Karthik Chandrashekara Date: Wed, 12 Jun 2024 20:45:08 +0200 Subject: [PATCH] Latest commit --- .../+Helper/convertstruct2cell.m | 6 ++++ Dipolar Gas Simulator/+Scripts/test.m | 29 +++++++++++++---- .../+Simulator/@Calculator/Calculator.m | 31 +++++++++++++++---- .../+Simulator/@Potentials/Potentials.m | 23 ++++++++++---- 4 files changed, 71 insertions(+), 18 deletions(-) create mode 100644 Dipolar Gas Simulator/+Helper/convertstruct2cell.m diff --git a/Dipolar Gas Simulator/+Helper/convertstruct2cell.m b/Dipolar Gas Simulator/+Helper/convertstruct2cell.m new file mode 100644 index 0000000..90fdf2c --- /dev/null +++ b/Dipolar Gas Simulator/+Helper/convertstruct2cell.m @@ -0,0 +1,6 @@ +function CellOut = convertstruct2cell(StructIn) + % CellOut = Convertstruct2cell(StructIn) + % converts a struct into a cell-matrix where the first column contains + % the fieldnames and the second the contents + CellOut = [fieldnames(StructIn) struct2cell(StructIn)]'; +end \ No newline at end of file diff --git a/Dipolar Gas Simulator/+Scripts/test.m b/Dipolar Gas Simulator/+Scripts/test.m index ba15e8e..0ff3407 100644 --- a/Dipolar Gas Simulator/+Scripts/test.m +++ b/Dipolar Gas Simulator/+Scripts/test.m @@ -1,9 +1,26 @@ -%-% Run Simulation %-% -clearvars +%% This script is testing the functionalities of the Dipolar Gas Simulator +% +% Important: Run only sectionwise!! -sim = DipolarGas(); -calc = Calculator(); +%% - Create Simulator, Potential and Calculator object with specified options + +OptionsStruct = struct; +OptionsStruct.SimulationMode = 'ImaginaryTimeEvolution'; % 'ImaginaryTimeEvolution' | 'RealTimeEvolution' +OptionsStruct.ErrorEstimationMethod = 'bootstrap'; % 'jackknife' | 'bootstrap' +OptionsStruct.NumberOfAtoms = 5000; +OptionsStruct.TimeStep = 50e-06; % in s +OptionsStruct.SimulationTime = 4e-03; % in s +OptionsStruct.CutoffType = true; +OptionsStruct.SaveData = true; +OptionsStruct.SaveDirectory = './Data'; +options = Helper.convertstruct2cell(OptionsStruct); +clear OptionsStruct + +sim = Simulator.DipolarGas(options{:}); +calc = Simulator.Calculator(options{:}); + +%-% Run Simulation %-% [Params, Transf, psi, V, VDk] = sim.runSimulation(calc); -%-% Plot %-% -Plotter.visualizeSpace(Transf) +%% - Plot results +Plotter.visualizeSpace(Transf) \ No newline at end of file diff --git a/Dipolar Gas Simulator/+Simulator/@Calculator/Calculator.m b/Dipolar Gas Simulator/+Simulator/@Calculator/Calculator.m index 53c2eda..2195bb8 100644 --- a/Dipolar Gas Simulator/+Simulator/@Calculator/Calculator.m +++ b/Dipolar Gas Simulator/+Simulator/@Calculator/Calculator.m @@ -1,7 +1,17 @@ classdef Calculator < handle & matlab.mixin.Copyable - properties (Access = public) + properties (Access = private) + CalculatorDefaults = struct('OrderParameter', 1, ... + 'PhaseCoherence', 1, ... + 'CutoffType', 'Cylindrical'); + + end + + properties (Access = public) + OrderParameter; + PhaseCoherence; + CutoffType; end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -9,13 +19,22 @@ classdef Calculator < handle & matlab.mixin.Copyable methods function this = Calculator(varargin) - + this.OrderParameter = this.CalculatorDefaults.OrderParameter; + this.PhaseCoherence = this.CalculatorDefaults.PhaseCoherence; + this.CutoffType = this.CalculatorDefaults.CutoffType; end - end - - methods - end % - setters and getters + function restoreDefaults(this) + this.OrderParameter = this.PotentialDefaults.OrderParameter; + this.PhaseCoherence = this.CalculatorDefaults.PhaseCoherence; + this.CutoffType = this.CalculatorDefaults.CutoffType; + end + + end % - lifecycle + + % methods + + % end % - setters and getters %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %- Methods diff --git a/Dipolar Gas Simulator/+Simulator/@Potentials/Potentials.m b/Dipolar Gas Simulator/+Simulator/@Potentials/Potentials.m index 0df5607..8421484 100644 --- a/Dipolar Gas Simulator/+Simulator/@Potentials/Potentials.m +++ b/Dipolar Gas Simulator/+Simulator/@Potentials/Potentials.m @@ -1,7 +1,13 @@ classdef Potentials < handle & matlab.mixin.Copyable - properties (Access = public) + properties (Access = private) + PotentialDefaults = struct('TrapFrequency', 100e3); + + end + + properties (Access = public) + TrapFrequency; end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -9,13 +15,18 @@ classdef Potentials < handle & matlab.mixin.Copyable methods function this = Potentials(varargin) - + this.TrapFrequency = this.PotentialDefaults.TrapFrequency; end - end - - methods - end % - setters and getters + function restoreDefaults(this) + this.TrapFrequency = this.PotentialDefaults.TrapFrequency; + end + + end % - lifecycle + + % methods + + % end % - setters and getters %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %- Methods