Minor changes to scripting style.

This commit is contained in:
Karthik 2021-07-16 16:14:11 +02:00
parent c19a514027
commit 27fe40068e

View File

@ -6,6 +6,7 @@
% - Create MOTCaptureProcess object with specified options % - Create MOTCaptureProcess object with specified options
% - Automatically creates Beams objects % - Automatically creates Beams objects
OptionsStruct = struct; OptionsStruct = struct;
OptionsStruct.ErrorEstimationMethod = 'bootstrap'; % 'jackknife' | 'bootstrap'
OptionsStruct.NumberOfAtoms = 10000; OptionsStruct.NumberOfAtoms = 10000;
OptionsStruct.TimeStep = 50e-06; % in s OptionsStruct.TimeStep = 50e-06; % in s
OptionsStruct.SimulationTime = 4e-03; % in s OptionsStruct.SimulationTime = 4e-03; % in s
@ -24,12 +25,8 @@ MOT2D = Simulator.TwoDimensionalMOT(options{:});
Beams = MOT2D.Beams; Beams = MOT2D.Beams;
%% - Run Simulation %% - Run Simulation
% poolobj = gcp('nocreate'); % Check if pool is open
% if isempty(poolobj)
% parpool;
% end
MOT2D.NumberOfAtoms = 5000; MOT2D.NumberOfAtoms = 5000;
MOT2D.Sideband = false; MOT2D.SidebandBeam = false;
CoolingBeam = Beams{cellfun(@(x) strcmpi(x.Alias, 'Blue'), Beams)}; CoolingBeam = Beams{cellfun(@(x) strcmpi(x.Alias, 'Blue'), Beams)};
CoolingBeam.Power = 0.4; CoolingBeam.Power = 0.4;
CoolingBeam.Waist = 13.3e-03; CoolingBeam.Waist = 13.3e-03;
@ -73,7 +70,7 @@ Plotter.plotAngularDistributionForDifferentBeta(Oven, Beta)
Plotter.plotCaptureVelocityVsAngle(Oven, MOT2D); % Takes a long time to plot! Plotter.plotCaptureVelocityVsAngle(Oven, MOT2D); % Takes a long time to plot!
%% - Plot Phase Space with Acceleration Field %% - Plot Phase Space with Acceleration Field
MOT2D.Sideband = false; MOT2D.SidebandBeam = false;
MOT2D.NumberOfAtoms = 50; MOT2D.NumberOfAtoms = 50;
MinimumVelocity = 0; MinimumVelocity = 0;
MaximumVelocity = 150; MaximumVelocity = 150;
@ -128,13 +125,13 @@ QuantityOfInterestArray = LoadingRateArray;
OptionsStruct = struct; OptionsStruct = struct;
OptionsStruct.RescalingFactorForParameter = 1000; OptionsStruct.RescalingFactorForParameter = 1000;
OptionsStruct.XLabelString = 'Cooling Beam Power (mW)'; OptionsStruct.XLabelString = 'Cooling Beam Power (mW)';
OptionsStruct.RescalingFactorForYQuantity = 1e-11; OptionsStruct.RescalingFactorForYQuantity = 1e-10;
OptionsStruct.ErrorsForYQuantity = true; OptionsStruct.ErrorsForYQuantity = true;
OptionsStruct.ErrorsArray = StandardErrorArray; OptionsStruct.ErrorsArray = StandardErrorArray;
OptionsStruct.CIForYQuantity = true; OptionsStruct.CIForYQuantity = true;
OptionsStruct.CIArray = ConfidenceIntervalArray; OptionsStruct.CIArray = ConfidenceIntervalArray;
OptionsStruct.RemoveOutliers = true; OptionsStruct.RemoveOutliers = true;
OptionsStruct.YLabelString = 'Loading rate (x 10^{11} atoms/s)'; OptionsStruct.YLabelString = 'Loading rate (x 10^{10} atoms/s)';
OptionsStruct.TitleString = sprintf('Magnetic Gradient = %.0f (G/cm)', MOT2D.MagneticGradient * 100); OptionsStruct.TitleString = sprintf('Magnetic Gradient = %.0f (G/cm)', MOT2D.MagneticGradient * 100);
options = Helper.convertstruct2cell(OptionsStruct); options = Helper.convertstruct2cell(OptionsStruct);
@ -143,11 +140,24 @@ Plotter.plotResultForOneParameterScan(ParameterArray, QuantityOfInterestArray, o
clear OptionsStruct clear OptionsStruct
if MOT2D.DoSave
LoadingRate = struct;
LoadingRate.Values = LoadingRateArray;
LoadingRate.Errors = StandardErrorArray;
LoadingRate.CI = ConfidenceIntervalArray;
MOT2D.Results = LoadingRate;
SaveFolder = [MOT2D.SaveDirectory filesep 'Results'];
Filename = ['OneParameterScan_' datestr(now,'yyyymmdd_HHMM')];
eval([sprintf('%s_Object', Filename) ' = MOT2D;']);
mkdir(SaveFolder);
save([SaveFolder filesep Filename], sprintf('%s_Object', Filename));
end
%% - Scan parameters: Two-Parameter Scan %% - Scan parameters: Two-Parameter Scan
MOT2D.NumberOfAtoms = 50; MOT2D.NumberOfAtoms = 50;
MOT2D.TotalPower = 0.6; MOT2D.TotalPower = 0.6;
MOT2D.Sideband = false; MOT2D.SidebandBeam = false;
SidebandBeam = Beams{cellfun(@(x) strcmpi(x.Alias, 'BlueSideband'), Beams)}; SidebandBeam = Beams{cellfun(@(x) strcmpi(x.Alias, 'BlueSideband'), Beams)};
NumberOfPointsForFirstParam = 10; %iterations of the simulation NumberOfPointsForFirstParam = 10; %iterations of the simulation
@ -197,3 +207,16 @@ options = Helper.convertstruct2cell(
Plotter.plotResultForTwoParameterScan(FirstParameterArray, SecondParameterArray, QuantityOfInterestArray, options{:}) Plotter.plotResultForTwoParameterScan(FirstParameterArray, SecondParameterArray, QuantityOfInterestArray, options{:})
clear OptionsStruct clear OptionsStruct
if MOT2D.DoSave
LoadingRate = struct;
LoadingRate.Values = LoadingRateArray;
LoadingRate.Errors = StandardErrorArray;
LoadingRate.CI = ConfidenceIntervalArray;
MOT2D.Results = LoadingRate;
SaveFolder = [MOT2D.SaveDirectory filesep 'Results'];
Filename = ['TwoParameterScan_' datestr(now,'yyyymmdd_HHMM')];
eval([sprintf('%s_Object', Filename) ' = MOT2D;']);
mkdir(SaveFolder);
save([SaveFolder filesep Filename], sprintf('%s_Object', Filename));
end