From 27fe40068ed213bf227c4f08c02dc84ae9461e7e Mon Sep 17 00:00:00 2001 From: Karthik Chandrashekara Date: Fri, 16 Jul 2021 16:14:11 +0200 Subject: [PATCH] Minor changes to scripting style. --- test_MOTCaptureProcessSimulation.m | 57 +++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 17 deletions(-) diff --git a/test_MOTCaptureProcessSimulation.m b/test_MOTCaptureProcessSimulation.m index 24054cf..a74b82a 100644 --- a/test_MOTCaptureProcessSimulation.m +++ b/test_MOTCaptureProcessSimulation.m @@ -6,6 +6,7 @@ % - Create MOTCaptureProcess object with specified options % - Automatically creates Beams objects OptionsStruct = struct; +OptionsStruct.ErrorEstimationMethod = 'bootstrap'; % 'jackknife' | 'bootstrap' OptionsStruct.NumberOfAtoms = 10000; OptionsStruct.TimeStep = 50e-06; % in s OptionsStruct.SimulationTime = 4e-03; % in s @@ -24,21 +25,17 @@ MOT2D = Simulator.TwoDimensionalMOT(options{:}); Beams = MOT2D.Beams; %% - Run Simulation -% poolobj = gcp('nocreate'); % Check if pool is open -% if isempty(poolobj) -% parpool; -% end -MOT2D.NumberOfAtoms = 5000; -MOT2D.Sideband = false; -CoolingBeam = Beams{cellfun(@(x) strcmpi(x.Alias, 'Blue'), Beams)}; -CoolingBeam.Power = 0.4; -CoolingBeam.Waist = 13.3e-03; -CoolingBeam.Detuning = -1.67*Helper.PhysicsConstants.BlueLinewidth; -PushBeam = Beams{cellfun(@(x) strcmpi(x.Alias, 'Push'), Beams)}; +MOT2D.NumberOfAtoms = 5000; +MOT2D.SidebandBeam = false; +CoolingBeam = Beams{cellfun(@(x) strcmpi(x.Alias, 'Blue'), Beams)}; +CoolingBeam.Power = 0.4; +CoolingBeam.Waist = 13.3e-03; +CoolingBeam.Detuning = -1.67*Helper.PhysicsConstants.BlueLinewidth; +PushBeam = Beams{cellfun(@(x) strcmpi(x.Alias, 'Push'), Beams)}; PushBeam.Power = 0.025; PushBeam.Waist = 0.81e-03; PushBeam.Detuning = 0; -[LoadingRate, ~] = MOT2D.runSimulation(Oven); +[LoadingRate, ~] = MOT2D.runSimulation(Oven); %% - Plot initial distribution % - sampling the position distribution InitialPositions = Oven.initialPositionSampling(); @@ -73,7 +70,7 @@ Plotter.plotAngularDistributionForDifferentBeta(Oven, Beta) Plotter.plotCaptureVelocityVsAngle(Oven, MOT2D); % Takes a long time to plot! %% - Plot Phase Space with Acceleration Field -MOT2D.Sideband = false; +MOT2D.SidebandBeam = false; MOT2D.NumberOfAtoms = 50; MinimumVelocity = 0; MaximumVelocity = 150; @@ -128,13 +125,13 @@ QuantityOfInterestArray = LoadingRateArray; OptionsStruct = struct; OptionsStruct.RescalingFactorForParameter = 1000; OptionsStruct.XLabelString = 'Cooling Beam Power (mW)'; -OptionsStruct.RescalingFactorForYQuantity = 1e-11; +OptionsStruct.RescalingFactorForYQuantity = 1e-10; OptionsStruct.ErrorsForYQuantity = true; OptionsStruct.ErrorsArray = StandardErrorArray; OptionsStruct.CIForYQuantity = true; OptionsStruct.CIArray = ConfidenceIntervalArray; 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); options = Helper.convertstruct2cell(OptionsStruct); @@ -143,11 +140,24 @@ Plotter.plotResultForOneParameterScan(ParameterArray, QuantityOfInterestArray, o 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 MOT2D.NumberOfAtoms = 50; MOT2D.TotalPower = 0.6; -MOT2D.Sideband = false; +MOT2D.SidebandBeam = false; SidebandBeam = Beams{cellfun(@(x) strcmpi(x.Alias, 'BlueSideband'), Beams)}; NumberOfPointsForFirstParam = 10; %iterations of the simulation @@ -196,4 +206,17 @@ options = Helper.convertstruct2cell( Plotter.plotResultForTwoParameterScan(FirstParameterArray, SecondParameterArray, QuantityOfInterestArray, options{:}) -clear OptionsStruct \ No newline at end of file +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 \ No newline at end of file